More cleanup, sample cni config
authorVZ Cambria <vzcambria@gmail.com>
Tue, 27 Dec 2016 20:58:31 +0000 (15:58 -0500)
committerVZ Cambria <vzcambria@gmail.com>
Tue, 27 Dec 2016 20:58:31 +0000 (15:58 -0500)
20-macvlan0.conf [new file with mode: 0644]
plugins/ipam/vz-local/config.go

diff --git a/20-macvlan0.conf b/20-macvlan0.conf
new file mode 100644 (file)
index 0000000..cee25bd
--- /dev/null
@@ -0,0 +1,33 @@
+{
+    "cniVersion": "0.2.0",
+    "name": "macvlan0",
+    "type": "macvlan",
+    "master": "eth0",
+    "args" : {
+      "org.apache.mesos" : {
+        "network_info" : {
+          "name" : "mynet",
+          "labels" : {
+            "labels" : [
+              { "key" : "app", "value" : "myapp" },
+              { "key" : "mccKey1", "value" : "mccVal1" },
+              { "key" : "bs", "value" : "bsVal" },
+              { "key" : "StaticIP", "value" : "172.19.0.209" },
+              { "key" : "mccKey2", "value" : "mccVal2" },
+              { "key" : "env", "value" : "prod" }
+            ]
+          }
+        }
+      }
+    },
+    "ipam": {
+        "type": "vz-local",
+        "subnet": "172.19.0.0/16",
+        "gateway": "172.19.0.1",
+        "routes": [
+            { "dst": "0.0.0.0/0" },
+            { "dst": "10.6.7.0/24", "gw": "172.19.0.199" }
+        ]
+    }
+}
+
index 61ceab3..355b340 100644 (file)
@@ -99,16 +99,16 @@ func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, error) {
        // Copy net name into IPAM so not to drag Net struct around
        n.IPAM.Name = n.Name
 
-/*
- * Example of getting an environment variable supplied to the IPAM plugin
- */
+       /*
       * Example of getting an environment variable supplied to the IPAM plugin
       */
        mccval := os.Getenv("MCCVAL")
        println("mccval is: ", mccval)
 
-/*
- * Get values for supplied labels
- * Ensure that IPAM args (e.g. CNI_ARGS) isn't confused with args passed to CNI itself 
- */
+       /*
       * Get values for supplied labels
       * Ensure that IPAM args (e.g. CNI_ARGS) isn't confused with args passed to CNI itself 
       */
        labels := map[string]string{}
 
        if args != "" {
@@ -119,6 +119,8 @@ func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, error) {
                    println("Map k (for)", k)
                    println("Map k (for)", k, label.Key, label.Value)
                }
+
+               println("CNI Args: Net Name: ", n.ARGS.Mesos.NetworkInfo.Name)
          }
        }
 
@@ -126,13 +128,20 @@ func LoadIPAMConfig(bytes []byte, args string) (*IPAMConfig, error) {
            println("Key:", key, "Value:", value)
        }
 
-       if n.ARGS != nil {
-          println("CNI Args: Net Name: ", n.ARGS.Mesos.NetworkInfo.Name)
-          println("CNI Args: IPAM Name: ", n.IPAM.Name)
-          args_ip := n.IPAM.Args.IP
-          uplink := n.IPAM.Args.UPLINK
-          log.Println("IPAM args: n.IPAM.IP is:", args_ip)
-          log.Println("IPAM args: n.IPAM.UPLINK is:", uplink)
+       println("CNI IPAM Name: ", n.IPAM.Name)
+
+       if n.IPAM.Args != nil { 
+               var args_ip net.IP
+               if n.IPAM.Args.IP != nil {
+                  args_ip = n.IPAM.Args.IP
+                  log.Println("IPAM args: n.IPAM.IP is:", args_ip)
+               }
+
+               var uplink types.UnmarshallableString
+               if n.IPAM.Args.UPLINK != "" {
+                  uplink = n.IPAM.Args.UPLINK
+                  log.Println("IPAM args: n.IPAM.UPLINK is:", uplink)
+               }
        }
 
        staticIP, found := labels["StaticIP"]