+++ /dev/null
-26c26,30
-< "github.com/containernetworking/plugins/plugins/ipam/host-local/backend"
----
-> "github.com/containernetworking/plugins/plugins/ipam/vz-local/backend"
->
-> //"github.com/vishvananda/netlink"
-> //"os"
-> //"syscall"
-69a74,75
-> log.Println("AdvRoute: BGP Advertises /32", requestedIP)
->
-113a120,159
->
-> /*
-> comment test
-> var uplink types.UnmarshallableString
-> if a.conf.Args != nil {
-> uplink = a.conf.Args.UPLINK
-> log.Println("AdvRoute: BGP Advertises /32", requestedIP, uplink)
->
-> dst := &net.IPNet{
-> IP: requestedIP,
-> Mask: net.CIDRMask(32, 32),
-> }
->
-> link, err := netlink.LinkByName(string(uplink))
-> if err != nil {
-> log.Println("Can't obtain link index for: ", uplink)
-> return nil, nil, err
-> }
->
-> viaIP := a.conf.Args.VIAIP
-> route := netlink.Route{
-> Dst: dst,
-> LinkIndex: link.Attrs().Index,
-> Gw: viaIP,
-> }
->
-> if err := netlink.RouteAdd(&route); err != nil {
-> fmt.Fprintln(os.Stderr, "There was an error adding netlink route: ", err)
-> if (err == syscall.EAGAIN) {
-> log.Println("ERRNO: eagain")
-> } else if (err == syscall.EEXIST) {
-> log.Println("ERRNO: route already exists")
-> } else {
-> log.Println("ERRNO: value is: ", (int(err.(syscall.Errno))))
-> }
-> return nil, nil, err
-> }
-> }
->
-> */
-129a176,221
->
-> /*
-> var requestedIP net.IP
-> if a.conf.Args != nil {
-> requestedIP = a.conf.Args.IP
-> }
->
-> if requestedIP != nil {
-> //var uplink string
-> var uplink types.UnmarshallableString
-> if a.conf.Args != nil {
-> uplink = a.conf.Args.UPLINK
-> log.Println("AdvRoute: BGP Advertises /32", requestedIP, uplink)
-> dst := &net.IPNet{
-> // IP: net.IPv4(99, 44, 69, 3),
-> IP: requestedIP,
-> Mask: net.CIDRMask(32, 32),
-> }
->
-> link, err := netlink.LinkByName(string(uplink))
-> if err != nil {
-> log.Println("Can't obtain link index for: ", uplink)
-> return err1
-> }
->
-> viaIP := a.conf.Args.VIAIP
-> route := netlink.Route{
-> Dst: dst,
-> LinkIndex: link.Attrs().Index,
-> Gw: viaIP,
-> }
->
-> if err := netlink.RouteDel(&route); err != nil {
-> fmt.Fprintln(os.Stderr, "There was an error removing netlink route: ", err)
-> if (err == syscall.EAGAIN) {
-> log.Println("ERRNO: eagain")
-> } else if (err == syscall.ESRCH) {
-> log.Println("ERRNO: route doesn't exists")
-> } else {
-> log.Println("ERRNO: value is: ", (int(err.(syscall.Errno))))
-> }
-> // os.Exit(1)
-> return err
-> }
-> }
-> */
+++ /dev/null
-21a22,24
-> "log"
-> "os"
->
-42a46,47
-> VIAIP net.IP `json:"viaip,omitempty"`
-> UPLINK types.UnmarshallableString `json:"uplink,omitempty"`
-46a52,64
-> VIAIP net.IP `json:"viaip,omitempty"`
-> UPLINK types.UnmarshallableString `json:"uplink,omitempty"`
-> }
->
-> /*
-> * Add structs needed to parse labels
-> */
-> //type Args struct {
-> // Mesos Mesos `json:"org.apache.mesos,omitempty"`
-> //}
->
-> type Mesos struct {
-> NetworkInfo NetworkInfo `json:"network_info"`
-48a67,86
-> type NetworkInfo struct {
-> Name string `json:"name"`
-> Labels struct {
-> Labels []struct {
-> Key string `json:"key"`
-> Value string `json:"value"`
-> } `json:"labels,omitempty"`
-> } `json:"labels,omitempty"`
-> }
->
-> // NetConf describes a network.
-> //type NetConf struct {
-> // CNIVersion string `json:"cniVersion,omitempty"`
-> // Name string `json:"name,omitempty"`
-> // Type string `json:"type,omitempty"`
-> // IPAM *IPAMConfig `json:"ipam"`
-> // DNS types.DNS `json:"dns"`
-> // ARGS *Args `json:"args,omitempty"`
-> //}
->
-55a94
-> Mesos Mesos `json:"org.apache.mesos,omitempty"`
-67a107
-> //n := NetConf{}
-145a186,271
->
-> /*
-> * 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
-> */
-> labels := map[string]string{}
->
-> if n.Args != nil {
->
-> for k, label := range n.Args.Mesos.NetworkInfo.Labels.Labels {
-> labels[label.Key] = label.Value
-> println("Map k (for)", k)
-> println("Map k (for)", k, label.Key, label.Value)
-> }
->
-> println("CNI Args NetworkInfo: Net Name: ", n.Args.Mesos.NetworkInfo.Name)
-> }
->
-> for key, value := range labels {
-> println("Key:", key, "Value:", value)
-> }
->
-> 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 via_ip net.IP
-> if n.IPAM.Args.VIAIP != nil {
-> via_ip = n.IPAM.Args.VIAIP
-> log.Println("IPAM args: n.IPAM.VIAIP is:", via_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"]
-> if found {
-> println("StaticIP is: ", staticIP)
-> log.Println("StaticIP is: ", staticIP)
-> n.IPAM.Args.IP = net.ParseIP(staticIP)
-> log.Println("IPAM args: n.IPAM.IP is:", n.IPAM.Args.IP)
-> } else {
-> println("StaticIP label NOT set")
-> }
->
-> viaIP, found := labels["viaIP"]
-> if found {
-> println("viaIP is: ", viaIP)
-> log.Println("viaIP is: ", viaIP)
-> n.IPAM.Args.VIAIP = net.ParseIP(viaIP)
-> log.Println("IPAM args: n.IPAM.VIAIP is:", n.IPAM.Args.VIAIP)
-> } else {
-> println("viaIP label NOT set")
-> }
->
-> Uplink, found := labels["Uplink"]
-> if found {
-> println("Uplink is: ", Uplink)
-> log.Println("Uplink is: ", Uplink)
-> n.IPAM.Args.UPLINK= types.UnmarshallableString(Uplink)
-> log.Println("IPAM args: n.IPAM.UPLINK is:", n.IPAM.Args.UPLINK)
-> } else {
-> println("Uplink label NOT set")
-> }
->
-> bull, found := labels["bull"]
-> if !found {
-> println("Hard to believe, but bull not found")
-> } else {
-> println("Found: ", bull)
-> }
+++ /dev/null
-21a22,24
-> "log"
-> "os"
->
-42a46,47
-> VIAIP net.IP `json:"viaip,omitempty"`
-> UPLINK types.UnmarshallableString `json:"uplink,omitempty"`
-46a52,84
-> VIAIP net.IP `json:"viaip,omitempty"`
-> UPLINK types.UnmarshallableString `json:"uplink,omitempty"`
-> }
->
-> /*
-> * Add structs needed to parse labels
-> */
-> type Args struct {
-> Mesos Mesos `json:"org.apache.mesos,omitempty"`
-> }
->
-> type Mesos struct {
-> NetworkInfo NetworkInfo `json:"network_info"`
-> }
->
-> type NetworkInfo struct {
-> Name string `json:"name"`
-> Labels struct {
-> Labels []struct {
-> Key string `json:"key"`
-> Value string `json:"value"`
-> } `json:"labels,omitempty"`
-> } `json:"labels,omitempty"`
-> }
->
-> // NetConf describes a network.
-> type NetConf struct {
-> CNIVersion string `json:"cniVersion,omitempty"`
-> Name string `json:"name,omitempty"`
-> Type string `json:"type,omitempty"`
-> IPAM *IPAMConfig `json:"ipam"`
-> DNS types.DNS `json:"dns"`
-> ARGS *Args `json:"args,omitempty"`
-68c106,107
-< n := Net{}
----
-> //n := Net{}
-> n := NetConf{}
-145a185,270
->
-> /*
-> * 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
-> */
-> labels := map[string]string{}
->
-> if n.ARGS != nil {
->
-> for k, label := range n.ARGS.Mesos.NetworkInfo.Labels.Labels {
-> labels[label.Key] = label.Value
-> println("Map k (for)", k)
-> println("Map k (for)", k, label.Key, label.Value)
-> }
->
-> println("CNI Args NetworkInfo: Net Name: ", n.ARGS.Mesos.NetworkInfo.Name)
-> }
->
-> for key, value := range labels {
-> println("Key:", key, "Value:", value)
-> }
->
-> 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 via_ip net.IP
-> if n.IPAM.Args.VIAIP != nil {
-> via_ip = n.IPAM.Args.VIAIP
-> log.Println("IPAM args: n.IPAM.VIAIP is:", via_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"]
-> if found {
-> println("StaticIP is: ", staticIP)
-> log.Println("StaticIP is: ", staticIP)
-> n.IPAM.Args.IP = net.ParseIP(staticIP)
-> log.Println("IPAM args: n.IPAM.IP is:", n.IPAM.Args.IP)
-> } else {
-> println("StaticIP label NOT set")
-> }
->
-> viaIP, found := labels["viaIP"]
-> if found {
-> println("viaIP is: ", viaIP)
-> log.Println("viaIP is: ", viaIP)
-> n.IPAM.Args.VIAIP = net.ParseIP(viaIP)
-> log.Println("IPAM args: n.IPAM.VIAIP is:", n.IPAM.Args.VIAIP)
-> } else {
-> println("viaIP label NOT set")
-> }
->
-> Uplink, found := labels["Uplink"]
-> if found {
-> println("Uplink is: ", Uplink)
-> log.Println("Uplink is: ", Uplink)
-> n.IPAM.Args.UPLINK= types.UnmarshallableString(Uplink)
-> log.Println("IPAM args: n.IPAM.UPLINK is:", n.IPAM.Args.UPLINK)
-> } else {
-> println("Uplink label NOT set")
-> }
->
-> bull, found := labels["bull"]
-> if !found {
-> println("Hard to believe, but bull not found")
-> } else {
-> println("Found: ", bull)
-> }