fix bug where management network was being associated with vlan_id and VSG WAN addrs
add network_name to port APIs

Change-Id: I1b4d851019d5be3e61aee86bf0fc50219c8908ca
diff --git a/xos/vtnnetport.py b/xos/vtnnetport.py
index 89d751d..3cbbf52 100644
--- a/xos/vtnnetport.py
+++ b/xos/vtnnetport.py
@@ -141,6 +141,10 @@
     def vlan_id(self):

         if not self.xos_port.instance:

             return None

+        # Only some kinds of networks can have s-tags associated with them.

+        # Currently, only VSG access networks qualify.

+        if not self.xos_port.network.template.vtn_kind in ["VSG",]:

+            return None

         tags = Tag.select_by_content_object(self.xos_port.instance).filter(name="s_tag")

         if not tags:

             return None

@@ -148,16 +152,22 @@
 

     @property

     def floating_address_pairs(self):

-        address_pairs = []

-        vsg = self.get_vsg_tenant()

-        if vsg:

-            if vsg.wan_container_ip and vsg.wan_container_mac:

-                address_pairs.append({"ip_address": vsg.wan_container_ip,

-                                      "mac_address": vsg.wan_container_mac})

+        # Floating_address_pairs is the set of WAN addresses that should be

+        # applied to this port.

 

-            if vsg.wan_vm_ip and vsg.wan_vm_mac:

-                address_pairs.append({"ip_address": vsg.wan_vm_ip,

-                                      "mac_address": vsg.wan_vm_mac})

+        address_pairs = []

+

+        # only look apply the VSG addresses if the Network is of the VSG vtn_kind

+        if self.xos_port.network.template.vtn_kind in ["VSG", ]:

+            vsg = self.get_vsg_tenant()

+            if vsg:

+                if vsg.wan_container_ip and vsg.wan_container_mac:

+                    address_pairs.append({"ip_address": vsg.wan_container_ip,

+                                          "mac_address": vsg.wan_container_mac})

+

+                if vsg.wan_vm_ip and vsg.wan_vm_mac:

+                    address_pairs.append({"ip_address": vsg.wan_vm_ip,

+                                          "mac_address": vsg.wan_vm_mac})

 

         return address_pairs

 

@@ -177,6 +187,10 @@
         return cn.net_id

 

     @property

+    def network_name(self):

+        return self.xos_port.network.name

+

+    @property

     def mac_address(self):

         return self.xos_port.mac