예제 #1
0
 def _get_l2_gateway_connections(self, context):
     """Get l2 gateway connections."""
     try:
         con = context.session.query(models.L2GatewayConnection).all()
     except sa_orm_exc.NoResultFound:
         raise l2gw_exc.L2GatewayConnectionNotFound(id="")
     return con
예제 #2
0
 def validate_l2_gateway_connection_for_delete(self, context,
                                               l2_gateway_conn_id):
     self._admin_check(context, 'DELETE')
     gw_db = self._get_l2_gateway_connection(context, l2_gateway_conn_id)
     if gw_db is None:
         raise l2gw_exc.L2GatewayConnectionNotFound(
             gateway_id=l2_gateway_conn_id)
예제 #3
0
    def delete_l2_gateway_connection(self, context, l2_gateway_connection):
        """Process the call from the CLI and trigger the RPC,

        to update the connection from the gateway.
        """
        locator_list = []
        ls_dict = {}
        mac_dict = {}
        self.service_plugin._admin_check(context, 'DELETE')
        gw_connection = self.service_plugin.get_l2_gateway_connection(
            context, l2_gateway_connection)
        if not gw_connection:
            raise l2gw_exc.L2GatewayConnectionNotFound(l2_gateway_connection)
        gw_connection_ovsdb_set = self._get_identifer_list(
            context, gw_connection)
        network_id = gw_connection.get('network_id')
        # get list of ovsdb_ids
        ovsdb_id_set = self._get_set_of_ovsdb_ids(context, gw_connection,
                                                  gw_connection_ovsdb_set)
        # call delete connection RPC to gw_connection_ovsdb_set
        l2gateway_devices = (
            self.service_plugin.get_l2gateway_devices_by_gateway_id(
                context, gw_connection.get('l2_gateway_id')))
        for device in l2gateway_devices:
            port_dict = {}
            (ovsdb_identifier, logical_switch,
             port_dict) = (self._process_port_list(context, device,
                                                   gw_connection, "DELETE",
                                                   gw_connection_ovsdb_set))
            self.agent_rpc.update_connection_to_gateway(
                context, ovsdb_identifier, ls_dict, locator_list, mac_dict,
                port_dict)
        # call delete vif_from_gateway for ovsdb_id_set
        self._remove_vm_macs(context, network_id, ovsdb_id_set)
예제 #4
0
 def _get_l2_gateway_connection_by_l2gw_id(self, context, l2gw_id):
     """Get the l2 gateway connection by l2gw id."""
     try:
         con = context.session.query(models.L2GatewayConnection).filter_by(
             l2_gateway_id=l2gw_id).all()
     except sa_orm_exc.NoResultFound:
         raise l2gw_exc.L2GatewayConnectionNotFound(id=l2gw_id)
     return con
예제 #5
0
 def delete_l2_gateway_connection(self, context, l2_gateway_connection):
     """Delete a L2 gateway connection."""
     self._admin_check(context, 'DELETE')
     gw_connection = self.get_l2_gateway_connection(context,
                                                    l2_gateway_connection)
     if not gw_connection:
         raise l2gw_exc.L2GatewayConnectionNotFound(l2_gateway_connection)
     l2gw_id = gw_connection.get(l2gw_const.L2GATEWAY_ID)
     device = self._get_device(context, l2gw_id)
     device_name = device.get('device_name')
     self._nsxv.delete_bridge(device_name)
예제 #6
0
 def _make_l2gw_connections_dict(self, gw_conn, fields=None):
     if gw_conn is None:
         raise l2gw_exc.L2GatewayConnectionNotFound(id="")
     segmentation_id = gw_conn['segmentation_id']
     if segmentation_id == 0:
         segmentation_id = ""
     res = {'id': gw_conn['id'],
            'network_id': gw_conn['network_id'],
            'l2_gateway_id': gw_conn['l2_gateway_id'],
            'tenant_id': gw_conn['tenant_id'],
            'segmentation_id': segmentation_id
            }
     return self._fields(res, fields)
예제 #7
0
 def _get_l2_gateway_connection(self, context, cn_id):
     try:
         con = context.session.query(models.L2GatewayConnection).get(cn_id)
     except sa_orm_exc.NoResultFound:
         raise l2gw_exc.L2GatewayConnectionNotFound(id=cn_id)
     return con