コード例 #1
0
    def delete_network(self, tenant_id, net_id):
        """
        Deletes the network with the specified network identifier
        belonging to the specified tenant.
        """
        LOG.debug("delete_network() called\n")
        net = db.network_get(net_id)
        if net:
            if len(net[const.NETWORKPORTS]) > 0:
                ports_on_net = db.port_list(net_id)
                for port in ports_on_net:
                    if port[const.INTERFACEID]:
                        raise exc.NetworkInUse(net_id=net_id)
                for port in ports_on_net:
                    self.delete_port(tenant_id, net_id, port[const.UUID])

            self._invoke_device_plugins(self._func_name(), [tenant_id, net_id])
            net_dict = cutil.make_net_dict(net[const.UUID],
                                           net[const.NETWORKNAME],
                                           [])
            self._release_vlan_for_tenant(tenant_id, net_id)
            cdb.remove_vlan_binding(net_id)
            db.network_destroy(net_id)
            return net_dict
        # Network not found
        raise exc.NetworkNotFound(net_id=net_id)
コード例 #2
0
    def delete_network(self, tenant_id, net_id):
        """
        Deletes the network with the specified network identifier
        belonging to the specified tenant.
        """
        LOG.debug("delete_network() called\n")
        net = db.network_get(net_id)
        if net:
            if len(net[const.NETWORKPORTS]) > 0:
                ports_on_net = db.port_list(net_id)
                for port in ports_on_net:
                    if port[const.INTERFACEID]:
                        raise exc.NetworkInUse(net_id=net_id)
                for port in ports_on_net:
                    self.delete_port(tenant_id, net_id, port[const.UUID])

            self._invoke_device_plugins(self._func_name(), [tenant_id, net_id])
            net_dict = cutil.make_net_dict(net[const.UUID],
                                           net[const.NETWORKNAME],
                                           [])
            self._release_vlan_for_tenant(tenant_id, net_id)
            cdb.remove_vlan_binding(net_id)
            db.network_destroy(net_id)
            return net_dict
        # Network not found
        raise exc.NetworkNotFound(net_id=net_id)
コード例 #3
0
def delete_service(tenant_id, service_instance_id, *args):
    """
    Removes a service and all the network configuration
    """
    l2db.initialize()
    print("Terminating Service VM")
    service_logic = servlogcs.ServicesLogistics()
    vms_list = []
    vms_list.append(servconts.DELETE_VM_CMD)
    vms_list.append(service_instance_id)

    if not service_logic.image_exist(service_instance_id):
        print("Service VM does not exist")
        sys.exit()

    result = subprocess.call(vms_list)
    service_logic.image_shutdown_verification(service_instance_id)

    client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id)
    service_nets = sdb.get_service_bindings(service_instance_id)
    print("Terminating Ports and Networks")
    network_name = db.network_get(service_nets.mngnet_id)
    port_id_net = db.port_list(service_nets.mngnet_id)
    for ports_uuid in port_id_net:
        client.delete_port(service_nets.mngnet_id, ports_uuid.uuid)
    client.delete_network(service_nets.mngnet_id)
    network_name = db.network_get(service_nets.nbnet_id)
    port_id_net = db.port_list(service_nets.nbnet_id)
    for ports_uuid in port_id_net:
        client.delete_port(service_nets.nbnet_id, ports_uuid.uuid)
    client.delete_network(service_nets.nbnet_id)
    network_name = db.network_get(service_nets.sbnet_id)
    port_id_net = db.port_list(service_nets.sbnet_id)
    for ports_uuid in port_id_net:
        client.delete_port(service_nets.sbnet_id, ports_uuid.uuid)
    client.delete_network(service_nets.sbnet_id)
    service_list = sdb.remove_services_binding(service_instance_id)
    print("Configuration Removed Successfully")
コード例 #4
0
def delete_service(tenant_id, service_instance_id, *args):
    """
    Removes a service and all the network configuration
    """
    l2db.initialize()
    print ("Terminating Service VM")
    service_logic = servlogcs.ServicesLogistics()
    vms_list = []
    vms_list.append(servconts.DELETE_VM_CMD)
    vms_list.append(service_instance_id)

    if not service_logic.image_exist(service_instance_id):
        print ("Service VM does not exist")
        sys.exit()

    result = subprocess.call(vms_list)
    service_logic.image_shutdown_verification(service_instance_id)

    client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id)
    service_nets = sdb.get_service_bindings(service_instance_id)
    print ("Terminating Ports and Networks")
    network_name = db.network_get(service_nets.mngnet_id)
    port_id_net = db.port_list(service_nets.mngnet_id)
    for ports_uuid in port_id_net:
        client.delete_port(service_nets.mngnet_id, ports_uuid.uuid)
    client.delete_network(service_nets.mngnet_id)
    network_name = db.network_get(service_nets.nbnet_id)
    port_id_net = db.port_list(service_nets.nbnet_id)
    for ports_uuid in port_id_net:
        client.delete_port(service_nets.nbnet_id, ports_uuid.uuid)
    client.delete_network(service_nets.nbnet_id)
    network_name = db.network_get(service_nets.sbnet_id)
    port_id_net = db.port_list(service_nets.sbnet_id)
    for ports_uuid in port_id_net:
        client.delete_port(service_nets.sbnet_id, ports_uuid.uuid)
    client.delete_network(service_nets.sbnet_id)
    service_list = sdb.remove_services_binding(service_instance_id)
    print ("Configuration Removed Successfully")
コード例 #5
0
ファイル: test_database.py プロジェクト: BillTheBest/quantum
 def get_all_ports(self, net_id):
     """Get all ports"""
     ports = []
     try:
         for port in db.port_list(net_id):
             LOG.debug("Getting port: %s" % port.uuid)
             port_dict = {}
             port_dict["port-id"] = str(port.uuid)
             port_dict["net-id"] = str(port.network_id)
             port_dict["int-id"] = port.interface_id
             port_dict["state"] = port.state
             port_dict["net"] = port.network
             ports.append(port_dict)
         return ports
     except Exception, exc:
         LOG.error("Failed to get all ports: %s" % str(exc))
コード例 #6
0
ファイル: test_database.py プロジェクト: schatt/quantum
 def get_all_ports(self, net_id):
     """Get all ports."""
     ports = []
     try:
         for port in db.port_list(net_id):
             LOG.debug("Getting port: %s" % port.uuid)
             port_dict = {}
             port_dict["port-id"] = str(port.uuid)
             port_dict["net-id"] = str(port.network_id)
             port_dict["int-id"] = port.interface_id
             port_dict["state"] = port.state
             port_dict["net"] = port.network
             ports.append(port_dict)
         return ports
     except Exception as exc:
         LOG.error("Failed to get all ports: %s" % str(exc))