def setUp(self):
        """Setup our tests"""
        # Initialize cdb and credentials
        db.configure_db({'sql_connection': 'sqlite:///:memory:'})
        cdb.initialize()
        creds.Store.initialize()

        # Create a place a store net and port ids for the druation of the test
        self.net_id = 0
        self.port_id = 0

        # Create the multiblade object
        self._l2network_multiblade = l2network_multi_blade. \
                     L2NetworkMultiBlade()
        self.plugin_key = "quantum.plugins.cisco.ucs.cisco_ucs_plugin" + \
                            ".UCSVICPlugin"

        # Get UCS inventory to make sure all UCSs are affected by tests
        for key in conf.PLUGINS[const.PLUGINS].keys():
            if key in conf.PLUGINS[const.INVENTORY].keys():
                self._inventory[key] = utils.import_object(
                    conf.PLUGINS[const.INVENTORY][key])

        self.ucs_count = self._inventory['ucs_plugin'].\
                             _inventory.__len__()
示例#2
0
 def setUp(self):
     super(NexusDBTest, self).setUp()
     """Setup for nexus db tests."""
     l2network_db.initialize()
     self.addCleanup(db.clear_db)
     self.dbtest = NexusDB()
     LOG.debug("Setup")
    def setUp(self):
        """Setup our tests"""
        # Initialize cdb and credentials
        db.configure_db({'sql_connection': 'sqlite:///:memory:'})
        cdb.initialize()
        creds.Store.initialize()

        # Create a place a store net and port ids for the druation of the test
        self.net_id = 0
        self.port_id = 0

        # Create the multiblade object
        self._l2network_multiblade = l2network_multi_blade. \
                     L2NetworkMultiBlade()
        self.plugin_key = "quantum.plugins.cisco.ucs.cisco_ucs_plugin" + \
                            ".UCSVICPlugin"

        # Get UCS inventory to make sure all UCSs are affected by tests
        for key in conf.PLUGINS[const.PLUGINS].keys():
            if key in conf.PLUGINS[const.INVENTORY].keys():
                self._inventory[key] = utils.import_object(
                    conf.PLUGINS[const.INVENTORY][key])

        self.ucs_count = self._inventory['ucs_plugin'].\
                             _inventory.__len__()
示例#4
0
 def setUp(self):
     super(NexusDBTest, self).setUp()
     """Setup for nexus db tests."""
     l2network_db.initialize()
     self.addCleanup(db.clear_db)
     self.dbtest = NexusDB()
     LOG.debug("Setup")
示例#5
0
 def setUp(self):
     """Setup for tests."""
     super(QuantumDBTest, self).setUp()
     l2network_db.initialize()
     self.addCleanup(db.clear_db)
     self.dbtest = QuantumDB()
     self.tenant_id = "t1"
     LOG.debug("Setup")
示例#6
0
 def setUp(self):
     """Setup for tests."""
     super(QuantumDBTest, self).setUp()
     l2network_db.initialize()
     self.addCleanup(db.clear_db)
     self.dbtest = QuantumDB()
     self.tenant_id = "t1"
     LOG.debug("Setup")
示例#7
0
 def setUp(self):
     """Setup for tests."""
     super(L2networkDBTest, self).setUp()
     l2network_db.initialize()
     self.dbtest = L2networkDB()
     self.quantum = QuantumDB()
     self.addCleanup(db.clear_db)
     LOG.debug("Setup")
示例#8
0
 def setUp(self):
     """Setup for tests."""
     super(L2networkDBTest, self).setUp()
     l2network_db.initialize()
     self.dbtest = L2networkDB()
     self.quantum = QuantumDB()
     self.addCleanup(db.clear_db)
     LOG.debug("Setup")
示例#9
0
 def setUp(self):
     db.configure_db({'sql_connection': 'sqlite:///:memory:'})
     cdb.initialize()
     creds.Store.initialize()
     self.tenant_id = "network_admin"
     self.net_name = "TestNetwork1"
     self.vlan_name = "TestVlan1"
     self.vlan_id = 300
     self.net_id = 100
     self.vlan_mgr = L2NetworkVLANMgr()
     self.plugin_key = (
         "quantum.plugins.cisco.ucs.cisco_ucs_plugin.UCSVICPlugin")
示例#10
0
    def setUp(self):
        """
        Set up function
        """

        self.tenant_id = "test_tenant_cisco1"
        self.net_name = "test_network_cisco1"
        self.net_id = 000007
        self.vlan_name = "q-" + str(self.net_id) + "vlan"
        self.vlan_id = 267
        self.port_id = "9"
        cdb.initialize()
        self._cisco_nexus_plugin = cisco_nexus_plugin.NexusPlugin()
示例#11
0
    def setUp(self):
        """Setup our tests"""
        # Initialize cdb and credentials
        db.configure_db({'sql_connection': 'sqlite:///:memory:'})
        cdb.initialize()
        creds.Store.initialize()

        # Create the ucs inventory  object
        self._ucs_inventory = UCSInventory()
        self.inventory = self._ucs_inventory._inventory

        # Create a plugin instance to create networks/ports
        self._l2network = L2Network()
示例#12
0
def disconnect_vm(vm_instance_id, *args):
    """
    Deletes VMs and Port connection
    """
    l2db.initialize()
    print ("Terminating Service VM")
    service_logic = servlogcs.ServicesLogistics()
    vms_list = []
    vms_list.append(servconts.DELETE_VM_CMD)
    vms_list.append(vm_instance_id)
    result = subprocess.call(vms_list)
    service_logic.image_shutdown_verification(vm_instance_id)
    print ("VM Server Off")
示例#13
0
    def setUp(self):
        """Setup our tests"""
        # Initialize cdb and credentials
        db.configure_db({'sql_connection': 'sqlite:///:memory:'})
        cdb.initialize()
        creds.Store.initialize()

        # Create the ucs inventory  object
        self._ucs_inventory = UCSInventory()
        self.inventory = self._ucs_inventory._inventory

        # Create a plugin instance to create networks/ports
        self._l2network = L2Network()
示例#14
0
def disconnect_vm(vm_instance_id, *args):
    """
    Deletes VMs and Port connection
    """
    l2db.initialize()
    print("Terminating Service VM")
    service_logic = servlogcs.ServicesLogistics()
    vms_list = []
    vms_list.append(servconts.DELETE_VM_CMD)
    vms_list.append(vm_instance_id)
    result = subprocess.call(vms_list)
    service_logic.image_shutdown_verification(vm_instance_id)
    print("VM Server Off")
    def __init__(self):
        cdb.initialize()
        cred.Store.initialize()
        self._model = importutils.import_object(conf.MODEL_CLASS)
        self._vlan_mgr = importutils.import_object(conf.MANAGER_CLASS)
        """
        Changes for configure_db accordingly will be done later
        """

        sql_connection = "mysql://%s:%s@%s/%s" % (conf.DB_USER,
                          conf.DB_PASS, conf.DB_HOST, conf.DB_NAME)
        db.configure_db({'sql_connection': sql_connection,
                         'base': models_v2.model_base.BASEV2})
        LOG.debug("L2Network plugin initialization done successfully\n")
示例#16
0
 def setUp(self):
     """
     Set up function
     """
     self.tenant_id = "test_tenant_cisco1"
     self.net_name = "test_network_cisco1"
     self.net_id = 000007
     self.vlan_name = "q-" + str(self.net_id) + "vlan"
     self.vlan_id = 267
     self.port_id = "9"
     db.configure_db({'sql_connection': 'sqlite:///:memory:'})
     cdb.initialize()
     cred.Store.initialize()
     self._cisco_nexus_plugin = cisco_nexus_plugin.NexusPlugin()
示例#17
0
 def setUp(self):
     """
     Set up function
     """
     self.tenant_id = "test_tenant_cisco1"
     self.net_name = "test_network_cisco1"
     self.net_id = 000007
     self.vlan_name = "q-" + str(self.net_id) + "vlan"
     self.vlan_id = 267
     self.port_id = "9"
     db.configure_db({'sql_connection': 'sqlite:///:memory:'})
     cdb.initialize()
     cred.Store.initialize()
     self._cisco_nexus_plugin = cisco_nexus_plugin.NexusPlugin()
示例#18
0
    def setUp(self):

        self.tenant_id = "test_tenant_cisco12"
        self.net_name = "test_network_cisco12"
        self.net_id = 000011
        self.vlan_name = conf.DEFAULT_VLAN_NAME
        self.vlan_id = conf.DEFAULT_VLAN_ID
        self.port_id = "4"
        cdb.initialize()
        cred.Store.initialize()
        self._cisco_ucs_plugin = cisco_ucs_plugin.UCSVICPlugin()
        self.device_ip = conf.UCSM_IP_ADDRESS
        self._ucs_inventory = ucsinv.UCSInventory()
        self.chassis_id = '1'
        self.blade_id = '5'
        self.blade_intf_distinguished_name = 'sys/chassis-1/blade-5/'\
                                             'adaptor-1/host-eth-6'
示例#19
0
def connect_vm(tenant_id, vm_image_id, service_instance_id, *args):
    """
    Starts a VMs and is connected to southbound network
    """
    l2db.initialize()
    client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id)
    print (_("Connecting %(vm_image_id)s to Service "
             "%(service_instance_id)s") % locals())
    service_logic = servlogcs.ServicesLogistics()
    service_nets = sdb.get_service_bindings(service_instance_id)
    client.create_port(service_nets.mngnet_id)
    client.create_port(service_nets.nbnet_id)
    sb_port_id = client.create_port(service_nets.sbnet_id)
    LOG.debug(_("Operation 'create_port' executed."))
    new_port_id = sb_port_id[servconts.PORT][servconts.ID]
    try:
        create_vm_args = []
        create_vm_args.append(servconts.CREATE_VM_CMD)
        create_vm_args.append(vm_image_id)
        print _("Creating VM with image: %s") % (vm_image_id)
        process = utils.subprocess_popen(create_vm_args,
                                         stdout=subprocess.PIPE)
        result = process.stdout.readlines()
        tokens = re.search("i-[a-f0-9]*", str(result[1]))
        vm_name = tokens.group(0)
        print _("Image: %s instantiated successfully") % (vm_name)
    except Exception as exc:
        print exc

    service_logic.image_status(vm_name)
    print _("Completed")
    print _("Attaching Ports To VM Service interfaces")
    south_net = service_nets.sbnet_id
    attachment = client.show_port_attachment(south_net, new_port_id)
    attachment = attachment[servconts.ATTACHMENT][servconts.ID][:36]
    LOG.debug(_("Plugging virtual interface: %(attachment)s of VM "
                "%(vm_name)s into port: %(new_port_id)s on network: "
                "%(sbnet_id)s"), {'attachment': attachment,
                                  'vm_name': vm_name,
                                  'new_port_id': new_port_id,
                                  'sbnet_id': service_nets.sbnet_id})
    attach_data = {servconts.ATTACHMENT: {servconts.ID: '%s' % attachment}}
    client.attach_resource(service_nets.sbnet_id, new_port_id, attach_data)
    print _("Connect VM Ended")
示例#20
0
    def setUp(self):

        self.tenant_id = "test_tenant_cisco12"
        self.net_name = "test_network_cisco12"
        self.net_id = 000011
        self.vlan_name = conf.DEFAULT_VLAN_NAME
        self.vlan_id = conf.DEFAULT_VLAN_ID
        self.port_id = "4"
        cdb.initialize()
        cred.Store.initialize()
        self._cisco_ucs_plugin = cisco_ucs_plugin.UCSVICPlugin()
        self.device_ip = conf.UCSM_IP_ADDRESS
        self._ucs_inventory = ucsinv.UCSInventory()
        self._ucs_inventory._load_inventory()
        self.chassis_id_list = (
            self._ucs_inventory._inventory[self.device_ip].keys())
        self.chassis_id = self.chassis_id_list[0]
        self.blade_id_list = (
            self._ucs_inventory._inventory[self.device_ip][self.chassis_id])
        self.blade_id = (
            self._ucs_inventory._inventory[self.device_ip][self.chassis_id][0])
示例#21
0
    def setUp(self):

        self.tenant_id = "test_tenant_cisco12"
        self.net_name = "test_network_cisco12"
        self.net_id = 000011
        self.vlan_name = conf.DEFAULT_VLAN_NAME
        self.vlan_id = conf.DEFAULT_VLAN_ID
        self.port_id = "4"
        cdb.initialize()
        cred.Store.initialize()
        self._cisco_ucs_plugin = cisco_ucs_plugin.UCSVICPlugin()
        self.device_ip = conf.UCSM_IP_ADDRESS
        self._ucs_inventory = ucsinv.UCSInventory()
        self._ucs_inventory._load_inventory()
        self.chassis_id_list = (
            self._ucs_inventory._inventory[self.device_ip].keys())
        self.chassis_id = self.chassis_id_list[0]
        self.blade_id_list = (
            self._ucs_inventory._inventory[self.device_ip][self.chassis_id])
        self.blade_id = (
            self._ucs_inventory._inventory[self.device_ip][self.chassis_id][0])
示例#22
0
def connect_vm(tenant_id, vm_image_id, service_instance_id, *args):
    """
    Starts a VMs and is connected to southbound network
    """
    l2db.initialize()
    client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id)
    print("Connecting %s to Service %s " % (vm_image_id, service_instance_id))
    service_logic = servlogcs.ServicesLogistics()
    service_nets = sdb.get_service_bindings(service_instance_id)
    client.create_port(service_nets.mngnet_id)
    client.create_port(service_nets.nbnet_id)
    sb_port_id = client.create_port(service_nets.sbnet_id)
    LOG.debug("Operation 'create_port' executed.")
    new_port_id = sb_port_id[servconts.PORT][servconts.ID]
    try:
        create_vm_args = []
        create_vm_args.append(servconts.CREATE_VM_CMD)
        create_vm_args.append(vm_image_id)
        print("Creating VM with image: %s" % (vm_image_id))
        process = utils.subprocess_popen(create_vm_args,
                                         stdout=subprocess.PIPE)
        result = process.stdout.readlines()
        tokens = re.search("i-[a-f0-9]*", str(result[1]))
        vm_name = tokens.group(0)
        print("Image: %s instantiated successfully" % (vm_name))
    except Exception as exc:
        print exc

    service_logic.image_status(vm_name)
    print "Completed"
    print "Attaching Ports To VM Service interfaces"
    south_net = service_nets.sbnet_id
    attachment = client.show_port_attachment(south_net, new_port_id)
    attachment = attachment[servconts.ATTACHMENT][servconts.ID][:36]
    LOG.debug(("Plugging virtual interface: %s of VM %s "
               "into port: %s on network: %s") %
              (attachment, vm_name, new_port_id, service_nets.sbnet_id))
    attach_data = {servconts.ATTACHMENT: {servconts.ID: '%s' % attachment}}
    client.attach_resource(service_nets.sbnet_id, new_port_id, attach_data)
    print("Connect VM Ended")
示例#23
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")
示例#24
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")
示例#25
0
def insert_inpath_service(tenant_id, service_image_id, management_net_name,
                          northbound_net_name, southbound_net_name, *args):
    """Inserting a network service between two networks"""
    print("Creating Network for Services and Servers")
    service_logic = servlogcs.ServicesLogistics()
    net_list = {}
    multiport_net_list = []
    networks_name_list = [
        management_net_name, northbound_net_name, southbound_net_name
    ]
    client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id)
    for net in networks_name_list:
        data = {servconts.NETWORK: {servconts.NAME: net}}
        net_list[net] = client.create_network(data)
        net_list[net][servconts.PORTS] = []
        LOG.debug("Network %s Created with ID: %s " %
                  (net, net_list[net][servconts.NETWORK][servconts.ID]))
    print "Completed"
    print("Creating Ports on Services and Server Networks")
    LOG.debug("Operation 'create_port' executed.")
    if not service_logic.verify_plugin(const.UCS_PLUGIN):
        for net in networks_name_list:
            net_list[net][servconts.PORTS].append
            (client.create_port(
                net_list[net][servconts.NETWORK][servconts.ID]))
        LOG.debug("Operation 'create_port' executed.")
    else:
        for net in networks_name_list:
            nets = net_list[net][servconts.NETWORK][servconts.ID]
            multiport_net_list.append(nets)
        data = create_multiport(tenant_id, multiport_net_list)
        net_idx = 0
        for net in networks_name_list:
            port_id = data[servconts.PORTS][net_idx][servconts.ID]
            net_list[net][servconts.PORTS].append(port_id)
            LOG.debug("Port UUID: %s on network: %s" %
                      (data[servconts.PORTS][net_idx][servconts.ID], net))
            net_idx = net_idx + 1
    print "Completed"
    try:
        create_vm_args = []
        create_vm_args.append(servconts.CREATE_VM_CMD)
        create_vm_args.append(service_image_id)
        print("Creating VM with image: %s" % (service_image_id))
        process = subprocess.Popen(create_vm_args, stdout=subprocess.PIPE)
        result = process.stdout.readlines()
        tokens = re.search("i-[a-f0-9]*", str(result[1]))
        service_vm_name = tokens.group(0)
        print("Image: %s instantiated successfully" % (service_vm_name))

    except Exception as exc:
        print exc

    service_logic.image_status(service_vm_name)
    print "Completed"
    print "Attaching Ports To VM Service interfaces"
    try:
        idx = 0
        for net in networks_name_list:
            network_id = net_list[net][servconts.NETWORK][servconts.ID]
            port_id = net_list[net][servconts.PORTS][idx]
            attachment = client.show_port_attachment(network_id, port_id)
            attachment = attachment[servconts.ATTACHMENT][servconts.ID][:36]
            LOG.debug(("Plugging virtual interface: %s of VM %s"
                       "into port: %s on network: %s") %
                      (attachment, service_vm_name, port_id, net))
            attach_data = {
                servconts.ATTACHMENT: {
                    servconts.ID: '%s' % attachment
                }
            }
            client.attach_resource(network_id, port_id, attach_data)
    except Exception as exc:
        print exc
    print "Completed"
    try:
        LOG.debug("Registering Service in DB")
        l2db.initialize()
        for uuid_net in db.network_id(networks_name_list[0]):
            mngnet_id = str(uuid_net.uuid)
        for uuid_net in db.network_id(networks_name_list[1]):
            nbnet_id = str(uuid_net.uuid)
        for uuid_net in db.network_id(networks_name_list[2]):
            sbnet_id = str(uuid_net.uuid)
        sdb.add_services_binding(service_vm_name, mngnet_id, nbnet_id,
                                 sbnet_id)
    except Exception as exc:
        print exc
示例#26
0
 def setUp(self):
     """Setup for tests"""
     l2network_db.initialize()
     self.dbtest = QuantumDB()
     self.tenant_id = "t1"
     LOG.debug("Setup")
示例#27
0
 def setUp(self):
     """Setup for tests"""
     l2network_db.initialize()
     self.dbtest = L2networkDB()
     self.quantum = QuantumDB()
     LOG.debug("Setup")
示例#28
0
 def setUp(self):
     """Setup for nexus db tests"""
     l2network_db.initialize()
     self.dbtest = NexusDB()
     LOG.debug("Setup")
示例#29
0
 def __init__(self):
     cdb.initialize()
     cred.Store.initialize()
     self._model = utils.import_object(conf.MODEL_CLASS)
     self._vlan_mgr = utils.import_object(conf.MANAGER_CLASS)
     LOG.debug("L2Network plugin initialization done successfully\n")
示例#30
0
 def __init__(self):
     cdb.initialize()
     cred.Store.initialize()
     self._model = utils.import_object(conf.MODEL_CLASS)
     self._vlan_mgr = utils.import_object(conf.MANAGER_CLASS)
     LOG.debug("L2Network plugin initialization done successfully\n")
示例#31
0
def insert_inpath_service(tenant_id, service_image_id,
                          management_net_name, northbound_net_name,
                          southbound_net_name, *args):
    """Inserting a network service between two networks"""
    print ("Creating Network for Services and Servers")
    service_logic = servlogcs.ServicesLogistics()
    net_list = {}
    multiport_net_list = []
    networks_name_list = [management_net_name, northbound_net_name,
                          southbound_net_name]
    client = Client(HOST, PORT, USE_SSL, format='json', tenant=tenant_id)
    for net in networks_name_list:
        data = {servconts.NETWORK: {servconts.NAME: net}}
        net_list[net] = client.create_network(data)
        net_list[net][servconts.PORTS] = []
        LOG.debug("Network %s Created with ID: %s " % (
            net, net_list[net][servconts.NETWORK][servconts.ID]))
    print "Completed"
    print ("Creating Ports on Services and Server Networks")
    LOG.debug("Operation 'create_port' executed.")
    if not service_logic.verify_plugin(const.UCS_PLUGIN):
        for net in networks_name_list:
            net_list[net][servconts.PORTS].append
            (client.create_port
            (net_list[net][servconts.NETWORK][servconts.ID]))
        LOG.debug("Operation 'create_port' executed.")
    else:
        for net in networks_name_list:
            nets = net_list[net][servconts.NETWORK][servconts.ID]
            multiport_net_list.append(nets)
        data = create_multiport(tenant_id, multiport_net_list)
        net_idx = 0
        for net in networks_name_list:
            port_id = data[servconts.PORTS][net_idx][servconts.ID]
            net_list[net][servconts.PORTS].append(port_id)
            LOG.debug("Port UUID: %s on network: %s" %
                      (data[servconts.PORTS][net_idx][servconts.ID], net))
            net_idx = net_idx + 1
    print "Completed"
    try:
        create_vm_args = []
        create_vm_args.append(servconts.CREATE_VM_CMD)
        create_vm_args.append(service_image_id)
        print ("Creating VM with image: %s" % (service_image_id))
        process = utils.subprocess_popen(create_vm_args,
                                         stdout=subprocess.PIPE)
        result = process.stdout.readlines()
        tokens = re.search("i-[a-f0-9]*", str(result[1]))
        service_vm_name = tokens.group(0)
        print ("Image: %s instantiated successfully" % (service_vm_name))

    except Exception as exc:
        print exc

    service_logic.image_status(service_vm_name)
    print "Completed"
    print "Attaching Ports To VM Service interfaces"
    try:
        idx = 0
        for net in networks_name_list:
            network_id = net_list[net][servconts.NETWORK][servconts.ID]
            port_id = net_list[net][servconts.PORTS][idx]
            attachment = client.show_port_attachment(network_id, port_id)
            attachment = attachment[servconts.ATTACHMENT][servconts.ID][:36]
            LOG.debug(("Plugging virtual interface: %s of VM %s"
                       "into port: %s on network: %s") %
                      (attachment, service_vm_name, port_id, net))
            attach_data = {servconts.ATTACHMENT: {servconts.ID: '%s' %
                                                  attachment}}
            client.attach_resource(network_id, port_id, attach_data)
    except Exception as exc:
        print exc
    print "Completed"
    try:
        LOG.debug("Registering Service in DB")
        l2db.initialize()
        for uuid_net in db.network_id(networks_name_list[0]):
            mngnet_id = str(uuid_net.uuid)
        for uuid_net in db.network_id(networks_name_list[1]):
            nbnet_id = str(uuid_net.uuid)
        for uuid_net in db.network_id(networks_name_list[2]):
            sbnet_id = str(uuid_net.uuid)
        sdb.add_services_binding(service_vm_name, mngnet_id, nbnet_id,
                                 sbnet_id)
    except Exception as exc:
        print exc