コード例 #1
0
 def _validate_connection(self, context, gw_connection):
     seg_id = gw_connection.get('segmentation_id', None)
     l2_gw_id = gw_connection.get('l2_gateway_id')
     self._check_port_fault_status_and_switch_fault_status(context,
                                                           l2_gw_id)
     check_vlan = self._is_vlan_configured_on_any_interface_for_l2gw(
         context, l2_gw_id)
     nw_map = {}
     network_id = gw_connection.get(constants.NETWORK_ID)
     nw_map[constants.NETWORK_ID] = network_id
     nw_map['l2_gateway_id'] = l2_gw_id
     if seg_id:
         nw_map[constants.SEG_ID] = gw_connection.get(constants.SEG_ID)
     net_segments_list = self._get_network_segments(context, network_id)
     if len(net_segments_list) > 1:
         raise l2gw_exc.MultipleSegmentsFound(network_id=network_id)
     if not self._get_network(context, network_id):
         raise exceptions.NetworkNotFound(net_id=network_id)
     if self._retrieve_gateway_connections(context, l2_gw_id,
                                           nw_map):
         raise l2gw_exc.L2GatewayConnectionExists(mapping=nw_map,
                                                  gateway_id=l2_gw_id)
     l2gw_validators.validate_network_mapping_list(nw_map, check_vlan)
     gw_db = self._get_l2_gateway(context, l2_gw_id)
     tenant_id = self._get_tenant_id_for_create(context, gw_db)
     l2gw_connection = self.get_l2_gateway_connections(
         context, filters={'network_id': [network_id],
                           'tenant_id': [tenant_id],
                           'l2_gateway_id': [l2_gw_id]})
     if l2gw_connection:
         raise l2gw_exc.L2GatewayConnectionExists(mapping=nw_map,
                                                  gateway_id=l2_gw_id)
コード例 #2
0
 def create_l2_gateway_connection(self, context, l2_gateway_connection):
     """Create l2 gateway connection."""
     self._admin_check(context, "CREATE")
     gw_connection = l2_gateway_connection[self.connection_resource]
     l2_gw_id = gw_connection.get("l2_gateway_id")
     network_id = gw_connection.get("network_id")
     nw_map = {}
     nw_map["network_id"] = network_id
     nw_map["l2_gateway_id"] = l2_gw_id
     segmentation_id = ""
     if constants.SEG_ID in gw_connection:
         segmentation_id = gw_connection.get(constants.SEG_ID)
         nw_map[constants.SEG_ID] = segmentation_id
     is_vlan = self._is_vlan_configured_on_any_interface_for_l2gw(context, l2_gw_id)
     network_id = l2gw_validators.validate_network_mapping_list(nw_map, is_vlan)
     with context.session.begin(subtransactions=True):
         gw_db = self._get_l2_gateway(context, l2_gw_id)
         tenant_id = self._get_tenant_id_for_create(context, gw_db)
         if self._retrieve_gateway_connections(context, l2_gw_id, nw_map):
             raise l2gw_exc.L2GatewayConnectionExists(mapping=nw_map, gateway_id=l2_gw_id)
         nw_map["tenant_id"] = tenant_id
         connection_id = uuidutils.generate_uuid()
         nw_map["id"] = connection_id
         if not segmentation_id:
             nw_map["segmentation_id"] = "0"
         gw_db.network_connections.append(models.L2GatewayConnection(**nw_map))
         gw_db = models.L2GatewayConnection(
             id=connection_id,
             tenant_id=tenant_id,
             network_id=network_id,
             l2_gateway_id=l2_gw_id,
             segmentation_id=segmentation_id,
         )
     return self._make_l2gw_connections_dict(gw_db)
コード例 #3
0
 def validate_l2_gateway_connection_for_create(self, context,
                                               l2_gateway_connection):
     self._admin_check(context, 'CREATE')
     gw_connection = l2_gateway_connection[self.connection_resource]
     l2_gw_id = gw_connection.get('l2_gateway_id')
     network_id = gw_connection.get('network_id')
     plugin = directory.get_plugin()
     plugin.get_network(context, network_id)
     nw_map = {}
     nw_map['network_id'] = network_id
     nw_map['l2_gateway_id'] = l2_gw_id
     segmentation_id = ""
     if constants.SEG_ID in gw_connection:
         segmentation_id = gw_connection.get(constants.SEG_ID)
         nw_map[constants.SEG_ID] = segmentation_id
     is_vlan = self._is_vlan_configured_on_any_interface_for_l2gw(context,
                                                                  l2_gw_id)
     network_id = l2gw_validators.validate_network_mapping_list(nw_map,
                                                                is_vlan)
     with context.session.begin(subtransactions=True):
         if self._retrieve_gateway_connections(context,
                                               l2_gw_id,
                                               nw_map):
             raise l2gw_exc.L2GatewayConnectionExists(mapping=nw_map,
                                                      gateway_id=l2_gw_id)
コード例 #4
0
 def validate_l2_gateway_connection_for_create(self, context,
                                               l2_gateway_connection):
     self._admin_check(context, 'CREATE')
     gw_connection = l2_gateway_connection[self.connection_resource]
     l2_gw_id = gw_connection.get('l2_gateway_id')
     network_id = gw_connection.get('network_id')
     plugin = directory.get_plugin()
     plugin.get_network(context, network_id)
     nw_map = {}
     nw_map['network_id'] = network_id
     nw_map['l2_gateway_id'] = l2_gw_id
     segmentation_id = ""
     if constants.SEG_ID in gw_connection:
         segmentation_id = gw_connection.get(constants.SEG_ID)
         nw_map[constants.SEG_ID] = segmentation_id
     is_vlan = self._is_vlan_configured_on_any_interface_for_l2gw(context,
                                                                  l2_gw_id)
     network_id = l2gw_validators.validate_network_mapping_list(nw_map,
                                                                is_vlan)
     with context.session.begin(subtransactions=True):
         if self._retrieve_gateway_connections(context,
                                               l2_gw_id,
                                               nw_map):
             raise l2gw_exc.L2GatewayConnectionExists(mapping=nw_map,
                                                      gateway_id=l2_gw_id)
コード例 #5
0
 def create_l2_gateway_connection(self, context, l2_gateway_connection):
     """Create l2 gateway connection."""
     self._admin_check(context, 'CREATE')
     gw_connection = l2_gateway_connection[self.connection_resource]
     l2_gw_id = gw_connection.get('l2_gateway_id')
     network_id = gw_connection.get('network_id')
     nw_map = {}
     nw_map['network_id'] = network_id
     nw_map['l2_gateway_id'] = l2_gw_id
     segmentation_id = ""
     if constants.SEG_ID in gw_connection:
         segmentation_id = gw_connection.get(constants.SEG_ID)
         nw_map[constants.SEG_ID] = segmentation_id
     is_vlan = self._is_vlan_configured_on_any_interface_for_l2gw(
         context, l2_gw_id)
     network_id = l2gw_validators.validate_network_mapping_list(
         nw_map, is_vlan)
     with context.session.begin(subtransactions=True):
         gw_db = self._get_l2_gateway(context, l2_gw_id)
         tenant_id = self._get_tenant_id_for_create(context, gw_db)
         if self._retrieve_gateway_connections(context, l2_gw_id, nw_map):
             raise l2gw_exc.L2GatewayConnectionExists(mapping=nw_map,
                                                      gateway_id=l2_gw_id)
         nw_map['tenant_id'] = tenant_id
         connection_id = uuidutils.generate_uuid()
         nw_map['id'] = connection_id
         if not segmentation_id:
             nw_map['segmentation_id'] = "0"
         gw_db.network_connections.append(
             models.L2GatewayConnection(**nw_map))
         gw_db = models.L2GatewayConnection(id=connection_id,
                                            tenant_id=tenant_id,
                                            network_id=network_id,
                                            l2_gateway_id=l2_gw_id,
                                            segmentation_id=segmentation_id)
     return self._make_l2gw_connections_dict(gw_db)