logger.info(
'Creating neutron network %s...' % self.network_settings.name)
net_inst = neutron_utils.get_network(
- self.__neutron, self.network_settings.name,
- self.network_settings.get_project_id(self.__os_creds))
+ self.__neutron, network_settings=self.network_settings,
+ project_id=self.network_settings.get_project_id(self.__os_creds))
if net_inst:
self.__network = net_inst
else:
logger.debug('Creating Subnets....')
for subnet_setting in self.network_settings.subnet_settings:
- sub_inst = neutron_utils.get_subnet_by_name(
- self.__neutron, subnet_setting.name)
+ sub_inst = neutron_utils.get_subnet(
+ self.__neutron, subnet_settings=subnet_setting)
if sub_inst:
self.__subnets.append(sub_inst)
logger.debug(
:param network_type: the type of network (i.e. vlan|flat).
:param physical_network: the name of the physical network
(this is required when network_type is 'flat')
+ :param segmentation_id: the id of the segmentation
+ (this is required when network_type is 'vlan')
:param subnets or subnet_settings: List of SubnetSettings objects.
:return:
"""
self.network_type = kwargs.get('network_type')
self.physical_network = kwargs.get('physical_network')
+ self.segmentation_id = kwargs.get('segmentation_id')
self.subnet_settings = list()
subnet_settings = kwargs.get('subnets')
out['provider:network_type'] = self.network_type
if self.physical_network:
out['provider:physical_network'] = self.physical_network
+ if self.segmentation_id:
+ out['provider:segmentation_id'] = self.segmentation_id
if self.external:
out['router:external'] = self.external
return {'network': out}
def __init__(self, **kwargs):
"""
- Constructor - all parameters are optional
- :param name: A symbolic name for the port.
+ Constructor
+ :param name: A symbolic name for the port (optional).
:param network_name: The name of the network on which to create the
- port.
+ port (required).
:param admin_state_up: A boolean value denoting the administrative
status of the port. True = up / False = down
:param project_name: The name of the project who owns the network.
self.device_owner = kwargs.get('device_owner')
self.device_id = kwargs.get('device_id')
- if not self.name or not self.network_name:
+ if not self.network_name:
raise PortSettingsError(
- 'The attributes neutron, name, and network_name are required '
- 'for PortSettings')
+ 'The attribute network_name is required')
def __set_fixed_ips(self, neutron):
"""
self.fixed_ips = list()
for ip_addr_dict in self.ip_addrs:
- subnet = neutron_utils.get_subnet_by_name(neutron,
- ip_addr_dict[
- 'subnet_name'])
- if subnet:
+ subnet = neutron_utils.get_subnet(
+ neutron, subnet_name=ip_addr_dict['subnet_name'])
+ if subnet and 'ip' in ip_addr_dict:
self.fixed_ips.append({'ip_address': ip_addr_dict['ip'],
'subnet_id': subnet.id})
else:
project_id = project.id
if not self.network:
- self.network = neutron_utils.get_network(neutron,
- self.network_name,
- project_id)
+ self.network = neutron_utils.get_network(
+ neutron, network_name=self.network_name, project_id=project_id)
if not self.network:
raise PortSettingsError(
'Cannot locate network with name - ' + self.network_name)