def _assure_device_network_vlan(self, network, bigip, network_folder): # Ensure bigip has configured tagged vlan # VLAN names are limited to 64 characters including # the folder name, so we name them foolish things. vlan_name = "" interface = self.interface_mapping['default'] tagged = self.tagging_mapping['default'] # Do we have host specific mappings? net_key = network['provider:physical_network'] if net_key + ':' + bigip.hostname in \ self.interface_mapping: interface = self.interface_mapping[ net_key + ':' + bigip.hostname] tagged = self.tagging_mapping[ net_key + ':' + bigip.hostname] # Do we have a mapping for this network elif net_key in self.interface_mapping: interface = self.interface_mapping[net_key] tagged = self.tagging_mapping[net_key] if tagged: vlanid = network['provider:segmentation_id'] else: vlanid = 0 vlan_name = self.get_vlan_name(network, bigip.hostname) self._assure_vcmp_device_network(bigip, vlan={'name': vlan_name, 'folder': network_folder, 'id': vlanid, 'interface': interface, 'network': network}) if self.vcmp_manager and self.vcmp_manager.get_vcmp_host(bigip): interface = None try: model = {'name': vlan_name, 'interface': interface, 'tag': vlanid, 'partition': network_folder, 'description': network['id'], 'route_domain_id': network['route_domain_id']} self.network_helper.create_vlan(bigip, model) except Exception as err: LOG.exception("%s", err.message) raise f5_ex.VLANCreationException( "Failed to create vlan: %s" % vlan_name ) if self.vlan_binding: self.vlan_binding.allow_vlan( device_name=bigip.device_name, interface=interface, vlanid=vlanid ) return vlan_name
def _assure_device_network_flat(self, network, bigip, network_folder): # Ensure bigip has configured flat vlan (untagged) vlan_name = "" interface = self.interface_mapping['default'] vlanid = 0 # Do we have host specific mappings? net_key = network['provider:physical_network'] if net_key and net_key + ':' + bigip.hostname in \ self.interface_mapping: interface = self.interface_mapping[net_key + ':' + bigip.hostname] # Do we have a mapping for this network elif net_key and net_key in self.interface_mapping: interface = self.interface_mapping[net_key] vlan_name = self.get_vlan_name(network, bigip.hostname) self._assure_vcmp_device_network(bigip, vlan={ 'name': vlan_name, 'folder': network_folder, 'id': vlanid, 'interface': interface, 'network': network }) if self.vcmp_manager and self.vcmp_manager.get_vcmp_host(bigip): interface = None try: model = { 'name': vlan_name, 'interface': interface, 'partition': network_folder, 'description': network['id'], 'route_domain_id': network['route_domain_id'] } self.network_helper.create_vlan(bigip, model) except Exception as err: LOG.exception("%s", err.message) raise f5_ex.VLANCreationException("Failed to create flat network") return vlan_name