def test_ryu_driver(self): from ryu.app import client as client_mod from ryu.app import rest_nw_id as rest_nw_id_mod self.mox.StubOutClassWithMocks(client_mod, 'OFPClient') client_mock = client_mod.OFPClient(utils.FAKE_REST_ADDR) self.mox.StubOutWithMock(client_mock, 'update_network') self.mox.StubOutWithMock(client_mock, 'create_network') self.mox.StubOutWithMock(client_mock, 'delete_network') client_mock.update_network(rest_nw_id_mod.NW_ID_EXTERNAL) uuid0 = '01234567-89ab-cdef-0123-456789abcdef' def fake_uuid4(): return uuid0 self.stubs.Set(uuid, 'uuid4', fake_uuid4) uuid1 = '12345678-9abc-def0-1234-56789abcdef0' net1 = utils.Net(uuid1) client_mock.update_network(uuid0) client_mock.create_network(uuid1) client_mock.delete_network(uuid1) self.mox.ReplayAll() db.network_create('test', uuid0) from quantum.plugins.ryu import ryu_quantum_plugin ryu_driver = ryu_quantum_plugin.OFPRyuDriver(self.config) ryu_driver.create_network(net1) ryu_driver.delete_network(net1) self.mox.VerifyAll() db.network_destroy(uuid0)
def test_delete_network(self): try: db.network_create(self.tenant_id, self.network_name_1) network_id = db.network_list(self.tenant_id)[0]['uuid'] cli.delete_net(self.client, self.tenant_id, network_id) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_delete_network failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_delete_network(network_id)
def test_list_networks(self): try: # Pre-populate data for testing using db api db.network_create(self.tenant_id, self.network_name_1) db.network_create(self.tenant_id, self.network_name_2) cli.list_nets(self.client, self.tenant_id) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_list_networks failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_list_networks()
def create_network(self, tenant_id, net_name, **kwargs): net = db.network_create(tenant_id, net_name, op_status=OperationalStatus.UP) LOG.debug("Created network: %s" % net) self.driver.create_network(net) return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
def create_network(self, tenant_id, net_name, **kwargs): net = db.network_create(tenant_id, net_name, op_status=OperationalStatus.UP) LOG.debug("Created network: %s" % net) vlan_id = self.vmap.acquire(str(net.uuid)) ovs_db.add_vlan_binding(vlan_id, str(net.uuid)) return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
def _create_target(self): tenant_id = "tenant1" net_name = "network1" self.vif_id = "vif1" net = db.network_create(tenant_id, net_name) self.port = db.port_create(net.uuid) db.port_set_attachment(self.port.uuid, net.uuid, self.vif_id)
def create_network(self, tenant_id, net_name, **kwargs): net = db.network_create(tenant_id, net_name, op_status=OperationalStatus.UP) LOG.debug("Created network: %s", net) self.driver.create_network(net) return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
def create_network(self, tenant_id, net_name, **kwargs): """ Creates a new Virtual Network, and assigns it a symbolic name. """ LOG.debug("FakePlugin.create_network() called") new_net = db.network_create(tenant_id, net_name) # Return uuid for newly created network as net-id. return {'net-id': new_net['uuid']}
def test_list_networks_details_v11_name_filter(self): try: # Pre-populate data for testing using db api db.network_create(self.tenant_id, self.network_name_1) db.network_create(self.tenant_id, self.network_name_2) #TODO: test filters cli.list_nets_detail_v11(self.client, self.tenant_id, self.version, {'name': self.network_name_1, }) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_list_networks_details_v11 failed due to " + "an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_list_networks_details_name_filter(self.network_name_1)
def test_show_network(self): try: # Load some data into the datbase net = db.network_create(self.tenant_id, self.network_name_1) cli.show_net(self.client, self.tenant_id, net['uuid']) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_detail_network failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_show_network()
def create_network(self, tenant_id, net_name): """Create a network.""" net_dict = {} try: res = db.network_create(tenant_id, net_name) LOG.debug("Created network: %s", res.uuid) net_dict["tenant_id"] = res.tenant_id net_dict["id"] = str(res.uuid) net_dict["name"] = res.name return net_dict except Exception as exc: LOG.error("Failed to create network: %s", str(exc))
def create_network(self, tenant_id, net_name): """Create a network""" net_dict = {} try: res = db.network_create(tenant_id, net_name) LOG.debug("Created network: %s", res.uuid) net_dict["tenant_id"] = res.tenant_id net_dict["id"] = str(res.uuid) net_dict["name"] = res.name return net_dict except Exception, exc: LOG.error("Failed to create network: %s", str(exc))
def create_network(self, tenant_id, net_name, **kwargs): """ Creates a new Virtual Network, and assigns it a symbolic name. """ LOG.debug("FakePlugin.create_network() called") new_net = db.network_create(tenant_id, net_name) # Put operational status UP db.network_update(new_net.uuid, net_name, op_status=OperationalStatus.UP) # Return uuid for newly created network as net-id. return {'net-id': new_net.uuid}
def create_network(self, tenant_id, net_name): """Create a network""" net_dict = {} try: res = db.network_create(tenant_id, net_name, op_status="UP") LOG.debug("Created network: %s" % res.uuid) net_dict["tenant-id"] = res.tenant_id net_dict["net-id"] = str(res.uuid) net_dict["net-name"] = res.name return net_dict except Exception, exc: LOG.error("Failed to create network: %s" % str(exc))
def test_create_port(self): network_id = None try: # Pre-populate data for testing using db api net = db.network_create(self.tenant_id, self.network_name_1) network_id = net['uuid'] cli.create_port(self.client, self.tenant_id, network_id) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_create_port failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_create_port(network_id)
def test_update_port(self): try: net = db.network_create(self.tenant_id, self.network_name_1) network_id = net['uuid'] port = db.port_create(network_id) port_id = port['uuid'] # Default state is DOWN - change to ACTIVE. cli.update_port(self.client, self.tenant_id, network_id, port_id, 'state=ACTIVE') except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_update_port failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_update_port(network_id, port_id)
def test_update_network(self): try: net = db.network_create(self.tenant_id, self.network_name_1) network_id = net['uuid'] cli.update_net(self.client, self.tenant_id, network_id, 'name=%s' % self.network_name_2, self.version) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_update_network failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_update_network()
def create_network(self, tenant_id, net_name, **kwargs): """ Creates a new Virtual Network, and assigns it a symbolic name. """ LOG.debug("LinuxBridgePlugin.create_network() called") new_network = db.network_create(tenant_id, net_name, op_status=OperationalStatus.UP) new_net_id = new_network[const.UUID] vlan_id = self._get_vlan_for_tenant(tenant_id) cdb.add_vlan_binding(vlan_id, new_net_id) new_net_dict = {const.NET_ID: new_net_id, const.NET_NAME: net_name, const.NET_PORTS: [], const.NET_OP_STATUS: new_network[const.OPSTATUS]} return new_net_dict
def create_network(self, tenant_id, net_name, **kwargs): """ Creates a new Virtual Network, and assigns it a symbolic name. :returns: a sequence of mappings with the following signature: {'net-id': uuid that uniquely identifies the particular quantum network, 'net-name': a human-readable name associated with network referenced by net-id } :raises: """ LOG.debug("QuantumRestProxy: create_network() called") # create in DB new_net = db.network_create(tenant_id, net_name) db.network_update(new_net.uuid, net_name, op_status=OperationalStatus.UP) net_id = str(new_net.uuid) # create on networl ctrl try: resource = '/tenants/%s/networks' % tenant_id data = { "network": { "id": net_id, "name": net_name, "gateway": self.nova.get_gateway(net_id), } } ret = self.servers.post(resource, data) if not self.servers.action_success(ret): raise RemoteRestError(ret[2]) except RemoteRestError as e: LOG.error( 'QuantumRestProxy: Unable to create remote network: %s' % e.message) db.network_destroy(net_id) raise # return created network return { 'net-id': net_id, 'net-name': net_name, }
def TestRuijieVlanUnsetting(): db.clear_db() net = db.network_create("miaosf", "net1") port = db.port_create(net.uuid) db.port_set_attachment(port.uuid, net.uuid, "intf_id") ruijie_db.add_ruijie_switch_eth_binding("192.168.21.35", "0050.56bc.0003", "GigabitEthernet 3/0/20"); ruijie_db.add_ruijie_vm_eth_binding("intf_id", "0050.56bc.0003"); ovs_db.add_vlan_binding(200, net.uuid) ruijie_vlan.set_ruijie_vlan("intf_id", net.uuid) binding = ruijie_db.get_ruijie_vlan_binding("192.168.21.35", "GigabitEthernet 3/0/20", 200) if binding == []: assert 0 ruijie_vlan.unset_ruijie_vlan(net.uuid, port.uuid) binding = ruijie_db.get_ruijie_vlan_binding("192.168.21.35", "GigabitEthernet 3/0/20", 200) if binding != []: assert 0
def test_unplug_iface(self): network_id = None port_id = None try: # Load some data into the datbase net = db.network_create(self.tenant_id, self.network_name_1) network_id = net['uuid'] port = db.port_create(net['uuid']) port_id = port['uuid'] db.port_set_attachment(port_id, network_id, "test_iface_id") cli.unplug_iface(self.client, self.tenant_id, network_id, port_id) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_plug_iface failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_unplug_iface(network_id, port_id)
def test_show_port_with_attach(self): network_id = None port_id = None iface_id = "flavor crystals" try: # Pre-populate data for testing using db api net = db.network_create(self.tenant_id, self.network_name_1) network_id = net['uuid'] port = db.port_create(network_id) port_id = port['uuid'] db.port_set_attachment(port_id, network_id, iface_id) cli.show_port(self.client, self.tenant_id, network_id, port_id) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_show_port_with_attach failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_show_port(network_id, port_id)
def create_network(self, tenant_id, net_name, **kwargs): """ Creates a new Virtual Network, and assigns it a symbolic name. """ LOG.debug("LinuxBridgePlugin.create_network() called") new_network = db.network_create(tenant_id, net_name, op_status=OperationalStatus.UP) new_net_id = new_network[const.UUID] vlan_id = self._get_vlan_for_tenant(tenant_id) cdb.add_vlan_binding(vlan_id, new_net_id) new_net_dict = { const.NET_ID: new_net_id, const.NET_NAME: net_name, const.NET_PORTS: [], const.NET_OP_STATUS: new_network[const.OPSTATUS], } return new_net_dict
def test_list_ports_v11(self): try: # Pre-populate data for testing using db api net = db.network_create(self.tenant_id, self.network_name_1) network_id = net['uuid'] db.port_create(network_id) db.port_create(network_id) #TODO: test filters cli.list_ports_v11(self.client, self.tenant_id, network_id, self.version) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_list_ports_v11 failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_list_ports(network_id)
def test_show_network_details(self): iface_id = "flavor crystals" try: # Load some data into the datbase net = db.network_create(self.tenant_id, self.network_name_1) network_id = net['uuid'] port = db.port_create(network_id) port_id = port['uuid'] db.port_set_attachment(port_id, network_id, iface_id) port = db.port_create(network_id) cli.show_net_detail(self.client, self.tenant_id, network_id, self.version) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_show_network_details failed due to an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_show_network_details()
def test_show_iface_no_attach(self): network_id = None port_id = None try: # Pre-populate data for testing using db api net = db.network_create(self.tenant_id, self.network_name_1) network_id = net['uuid'] port = db.port_create(network_id) port_id = port['uuid'] cli.show_iface(self.client, self.tenant_id, network_id, port_id, self.version) except: LOG.exception("Exception caught: %s", sys.exc_info()) self.fail("test_show_iface_no_attach failed due to" + " an exception") LOG.debug("Operation completed. Verifying result") LOG.debug(self.fake_stdout.content) self._verify_show_iface(network_id, port_id)
def create_network(self, tenant_id, net_name, **kwargs): net = db.network_create(tenant_id, net_name, op_status=OperationalStatus.UP) LOG.debug("Created network: %s" % net) LOG.debug("PRUTH: Created network: %s %s" % (net, net_name)) properties = net_name.split(':') LOG.debug("PRUTH: len(properties) = %d" % (len(properties))) if len(properties) >= 3 and tenant_id == self.config.get("NEUCA", "neuca_tenant_id"): # network_type:switch_name:vlan_tag[:max_ingress_rate][:max_ingress_burst] network_type = properties[0] switch_name = properties[1] vlan_tag = properties[2] if len(properties) >= 4: max_ingress_rate = properties[3] else: max_ingress_rate = 0 if len(properties) >= 5: max_ingress_burst = properties[4] else: max_ingress_burst = 0 else: LOG.debug("PRUTH: not enough properties or not neuca: len(properties) = %d, %s" % (len(properties),net_name)) network_type = 'management' switch_name = 'management' vlan_tag = 0 #should be managment vlan from conf file max_ingress_rate = 0 max_ingress_burst = 0 neuca_db.add_network_properties(str(net.uuid), network_type, switch_name, vlan_tag, max_ingress_rate, max_ingress_burst) return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
def create_network(self, tenant_id, network_name): """ Creates a new Virtual Network, and assigns it a symbolic name. """ LOG.debug("create_network() called") ofn_tenant_id = self._create_ofn_tenant(tenant_id) new_network = db.network_create(tenant_id, network_name) if self.conf.auto_id_network: """Auto ID is ture. id include response.""" res = self.ofn.ofn_create_network(ofn_tenant_id, network_name) ofn_network_id = res['id'] else: """Auto ID is false. use uuid for ofn_network.""" ofn_network_id = new_network.uuid res = self.ofn.ofn_create_network(ofn_tenant_id, network_name, ofn_network_id) LOG.debug("create_network(): ofn_create_network() return '%s'" % res) LOG.debug("create_network(): ofn_network_id = %s" % ofn_network_id) ndb.add_ofn_network(ofn_network_id, new_network.uuid) return {'net-id': new_network.uuid, 'net-name': new_network.name}
def create_network(self, tenant_id, net_name): net = db.network_create(tenant_id, net_name) LOG.debug("Created network: %s" % net) vlan_id = self.vmap.acquire(str(net.uuid)) ovs_db.add_vlan_binding(vlan_id, str(net.uuid)) return self._make_net_dict(str(net.uuid), net.name, [])