Added MTU network config and updated flavor_metadata test support
[snaps.git] / snaps / config / network.py
index 85a9fae..620640f 100644 (file)
@@ -46,6 +46,7 @@ class NetworkConfig(object):
         :param segmentation_id: the id of the segmentation
                                  (this is required when network_type is 'vlan')
         :param subnets or subnet_settings: List of SubnetConfig objects.
+        :param mtu: MTU setting (optional)
         :return:
         """
 
@@ -88,6 +89,8 @@ class NetworkConfig(object):
         if not self.name or len(self.name) < 1:
             raise NetworkConfigError('Name required for networks')
 
+        self.mtu = kwargs.get('mtu')
+
     def get_project_id(self, os_creds):
         """
         Returns the project ID for a given project_name or None
@@ -144,6 +147,8 @@ class NetworkConfig(object):
             out['provider:segmentation_id'] = self.segmentation_id
         if self.external:
             out['router:external'] = self.external
+        if self.mtu:
+            out['mtu'] = self.mtu
         return {'network': out}
 
 
@@ -458,6 +463,10 @@ class PortConfig(object):
         try:
             network = neutron_utils.get_network(
                 neutron, keystone, network_name=self.network_name)
+            if network and not network.shared:
+                network = neutron_utils.get_network(
+                    neutron, keystone, network_name=self.network_name,
+                    project_name=project_name)
         finally:
             if session:
                 keystone_utils.close_session(session)