本文整理汇总了Python中quantum.plugins.cisco.db.api.network_create函数的典型用法代码示例。如果您正苦于以下问题:Python network_create函数的具体用法?Python network_create怎么用?Python network_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了network_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_all_networks
def test_get_all_networks(self):
"""
Tests whether dictionary is returned containing all
<network_uuid, network_name> for
the specified tenant.
"""
LOG.debug("UCSVICTestPlugin:test_get_all_networks() called\n")
new_network1 = db.network_create(self.tenant_id, self.net_name)
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
new_network1[const.UUID])
new_net_dict1 = self._cisco_ucs_plugin.create_network(
self.tenant_id, new_network1[const.NETWORKNAME],
new_network1[const.UUID], self.vlan_name, self.vlan_id,
device_ip=self.device_ip)
new_network2 = db.network_create(self.tenant_id, "test_network2")
cdb.add_vlan_binding("6", "q-000006vlan", new_network2[const.UUID])
new_net_dict2 = self._cisco_ucs_plugin.create_network(
self.tenant_id, new_network2[const.NETWORKNAME],
new_network2[const.UUID], "q-000006vlan", "6",
device_ip=self.device_ip)
net_list = self._cisco_ucs_plugin.get_all_networks(
self.tenant_id, device_ip=self.device_ip)
net_id_list = [new_net_dict1, new_net_dict2]
self.assertTrue(net_list[0] in net_id_list)
self.assertTrue(net_list[1] in net_id_list)
self.tear_down_network(self.tenant_id, new_network1[const.UUID])
self.tear_down_network(self.tenant_id, new_network2[const.UUID])
示例2: test_reserve_segmentation_id
def test_reserve_segmentation_id(self):
LOG.debug("test_reserve_segmentation_id - START")
db.network_create(self.tenant_id, self.net_name)
vlan_id = self.vlan_mgr.reserve_segmentation_id(self.tenant_id,
self.net_name)
self.assertEqual(vlan_id, int(conf.VLAN_START))
LOG.debug("test_reserve_segmentation_id - END")
示例3: test_release_segmentation_id_idDNE
def test_release_segmentation_id_idDNE(self):
LOG.debug("test_release_segmentation_idDNE - START")
db.network_create(self.tenant_id, self.net_name)
self.assertRaises(exc.NetworkNotFound,
self.vlan_mgr.release_segmentation_id,
self.tenant_id,
self.net_id)
LOG.debug("test_release_segmentation_idDNE - END")
示例4: test_release_segmentation_id
def test_release_segmentation_id(self):
LOG.debug("test_release_segmentation_id - START")
db.network_create(self.tenant_id, self.net_name)
vlan_id = self.vlan_mgr.reserve_segmentation_id(self.tenant_id,
self.net_name)
cdb.add_vlan_binding(vlan_id, self.vlan_name, self.net_id)
release_return = self.vlan_mgr.release_segmentation_id(self.tenant_id,
self.net_id)
self.assertEqual(release_return, False)
LOG.debug("test_release_segmentation_id - END")
示例5: test_update_network
def test_update_network(self):
"""Support for the Quantum core API call"""
LOG.debug("test_update_network - START")
self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
self._l2network_multiblade.create_network([tenant_id,
net_name,
self.net_id,
vlan_name(self.net_id),
vlan_id])
cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)
net_details = db.network_update(self.net_id, tenant_id,
name=new_net_name)
networks = self._l2network_multiblade.update_network([
tenant_id,
self.net_id,
{'name': new_net_name},
])
for network in networks:
self.assertEqual(network[const.NET_ID], self.net_id)
self.assertEqual(network[const.NET_NAME], new_net_name)
LOG.debug("test_update_network - END")
示例6: test_create_port
def test_create_port(self):
"""
Tests creation of a port on the specified Virtual Network.
"""
LOG.debug("UCSVICTestPlugin:_test_create_port() called\n")
new_network = db.network_create(self.tenant_id, self.net_name)
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
new_network[const.UUID])
new_net_dict = self._cisco_ucs_plugin.create_network(
self.tenant_id, new_network[const.NETWORKNAME],
new_network[const.UUID], self.vlan_name, self.vlan_id,
device_ip=self.device_ip)
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
port_dict = self._cisco_ucs_plugin.create_port(
self.tenant_id, self.net_id, const.PORT_UP,
new_port[const.UUID], device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
least_rsvd_blade_dict=(
self._ucs_inventory._get_least_reserved_blade()))
self.assertEqual(port_dict[const.PORTID], new_port[const.UUID])
profile_name = (
self._cisco_ucs_plugin._get_profile_name(port_dict[const.PORTID]))
self.assertTrue(profile_name is not None)
self.tear_down_network_port(
self.tenant_id, new_net_dict[const.NET_ID],
port_dict[const.PORTID])
示例7: test_delete_port
def test_delete_port(self):
"""Support for the Quantum core API call"""
LOG.debug("test_delete_port - START")
self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
self._l2network_multiblade.create_network([tenant_id,
net_name,
self.net_id,
vlan_name(self.net_id),
vlan_id])
cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)
self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
self._l2network_multiblade.create_port([tenant_id,
self.net_id,
port_state, self.port_id])
port = self._l2network_multiblade.delete_port([tenant_id,
self.net_id,
self.port_id])
self.assertEqual(self.port_id, port[0][const.PORTID])
# Recreating port so tear down doesn't cause an error
self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
self._l2network_multiblade.create_port([tenant_id,
self.net_id,
port_state, self.port_id])
LOG.debug("test_delete_port - END")
示例8: test_unplug_interface
def test_unplug_interface(self):
"""Support for the Quantum core API call"""
LOG.debug("test_unplug_interface - START")
self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
self._l2network_multiblade.create_network([tenant_id,
net_name,
self.net_id,
vlan_name(self.net_id),
vlan_id])
cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)
self.port_id = db.port_create(self.net_id, port_state)[const.UUID]
self._l2network_multiblade.create_port([tenant_id,
self.net_id,
port_state, self.port_id])
self._l2network_multiblade.plug_interface([tenant_id, self.net_id,
self.port_id, interface_id])
db.port_set_attachment(self.net_id, self.port_id, interface_id)
interface = self._l2network_multiblade.unplug_interface([tenant_id,
self.net_id,
self.port_id])
self.assertEqual(self.port_id, interface[0][const.PORTID])
LOG.debug("test_unplug_interface - END")
示例9: test_delete_port
def test_delete_port(self):
"""
Tests Deletion of a port on a specified Virtual Network,
if the port contains a remote interface attachment,
the remote interface should first be un-plugged and
then the port can be deleted.
"""
LOG.debug("UCSVICTestPlugin:_test_delete_port() called\n")
new_network = db.network_create(self.tenant_id, self.net_name)
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
new_network[const.UUID])
new_net_dict = self._cisco_ucs_plugin.create_network(
self.tenant_id, new_network[const.NETWORKNAME],
new_network[const.UUID], self.vlan_name, self.vlan_id,
device_ip=self.device_ip)
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
port_dict = self._cisco_ucs_plugin.create_port(
self.tenant_id, self.net_id, const.PORT_UP,
new_port[const.UUID], device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
least_rsvd_blade_dict=self._ucs_inventory.\
_get_least_reserved_blade())
port_bind = self._cisco_ucs_plugin.delete_port(
self.tenant_id, new_net_dict[const.NET_ID],
port_dict[const.PORTID], device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
chassis_id=self.chassis_id, blade_id=self.blade_id,
blade_intf_distinguished_name=self.\
blade_intf_distinguished_name,
least_rsvd_blade_dict=self._ucs_inventory.\
_get_least_reserved_blade())
self.assertEqual(port_bind[const.PORTID], new_port[const.UUID])
self.tearDownNetwork(self.tenant_id, new_net_dict[const.NET_ID])
示例10: test_plug_interface
def test_plug_interface(self, remote_interface_id=None,
new_vlanid=10, new_vlan_name='new_vlan'):
"""
Attaches a remote interface to the specified port on the
specified Virtual Network.
"""
LOG.debug("UCSVICTestPlugin:_test_plug_interface() called\n")
new_network = db.network_create(self.tenant_id, self.net_name)
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
new_network[const.UUID])
new_net_dict = self._cisco_ucs_plugin.create_network(
self.tenant_id, new_network[const.NETWORKNAME],
new_network[const.UUID], self.vlan_name, self.vlan_id,
device_ip=self.device_ip)
new_port = db.port_create(new_network[const.UUID], const.PORT_UP)
port_dict = self._cisco_ucs_plugin.create_port(
self.tenant_id, new_net_dict[const.NET_ID],
const.PORT_UP, new_port[const.UUID],
device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
least_rsvd_blade_dict=(
self._ucs_inventory._get_least_reserved_blade()))
cdb.update_vlan_binding(new_network[const.UUID],
str(new_vlanid), new_vlan_name)
port_bind = self._cisco_ucs_plugin.plug_interface(
self.tenant_id, new_net_dict[const.NET_ID],
port_dict[const.PORTID], remote_interface_id,
device_ip=self.device_ip)
self.assertEqual(port_bind[const.VLANNAME], new_vlan_name)
self.assertEqual(port_bind[const.VLANID], new_vlanid)
self.tear_down_network_port_interface(
self.tenant_id, new_net_dict[const.NET_ID],
new_port[const.UUID])
示例11: _test_get_port_details
def _test_get_port_details(self, port_state):
"""
Tests whether user is able to retrieve a remote interface
that is attached to this particular port when port state is Up.
"""
LOG.debug("UCSVICTestPlugin:_test_get_port_details() called\n")
new_network = db.network_create(self.tenant_id, self.net_name)
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
new_network[const.UUID])
new_net_dict = self._cisco_ucs_plugin.create_network(
self.tenant_id, new_network[const.NETWORKNAME],
new_network[const.UUID], self.vlan_name, self.vlan_id,
device_ip=self.device_ip)
new_port = db.port_create(new_network[const.UUID], port_state)
port_dict = self._cisco_ucs_plugin.create_port(
self.tenant_id, self.net_id, port_state,
new_port[const.UUID], device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
least_rsvd_blade_dict=(
self._ucs_inventory._get_least_reserved_blade()))
port_detail = self._cisco_ucs_plugin.get_port_details(
self.tenant_id, new_net_dict[const.NET_ID],
port_dict[const.PORTID], device_ip=self.device_ip)
self.assertEqual(str(port_dict), str(port_detail))
self.tear_down_network_port(
self.tenant_id, new_net_dict[const.NET_ID],
port_dict[const.PORTID])
示例12: test_get_vlan_id_for_network
def test_get_vlan_id_for_network(self):
LOG.debug("UCSVICTestPlugin:test_get_vlan_id_for_network() called\n")
new_network = db.network_create(self.tenant_id, self.net_name)
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
new_network[const.UUID])
vlan_bind_id = self._cisco_ucs_plugin._get_vlan_id_for_network(
self.tenant_id, new_network[const.UUID])
self.assertEqual(str(vlan_bind_id), self.vlan_id)
示例13: test_plug_interface_portDNE
def test_plug_interface_portDNE(self):
"""Support for the Quantum core API call"""
LOG.debug("test_plug_interface_portDNE - START")
self.net_id = db.network_create(tenant_id, net_name)[const.UUID]
self._l2network_multiblade.create_network([tenant_id, net_name, self.net_id, vlan_name(self.net_id), vlan_id])
cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id)
self.assertRaises(
exc.PortNotFound, self._l2network_multiblade.plug_interface, [tenant_id, self.net_id, port_id, interface_id]
)
LOG.debug("test_plug_interface_portDNE - START")
示例14: test_get_all_ports
def test_get_all_ports(self):
"""
Retrieves all port identifiers belonging to the
specified Virtual Network.
"""
LOG.debug("UCSVICPlugin:get_all_ports() called\n")
new_network = db.network_create(self.tenant_id, self.net_name)
cdb.add_vlan_binding(str(self.vlan_id), self.vlan_name,
new_network[const.UUID])
new_net_dict = self._cisco_ucs_plugin.create_network(
self.tenant_id, new_network[const.NETWORKNAME],
new_network[const.UUID], self.vlan_name, self.vlan_id,
device_ip=self.device_ip)
new_port1 = db.port_create(new_network[const.UUID], const.PORT_UP)
port_dict1 = self._cisco_ucs_plugin.create_port(
self.tenant_id, self.net_id, const.PORT_UP,
new_port1[const.UUID], device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
least_rsvd_blade_dict=(
self._ucs_inventory._get_least_reserved_blade()))
new_port2 = db.port_create(new_network[const.UUID], const.PORT_UP)
port_dict2 = self._cisco_ucs_plugin.create_port(
self.tenant_id, self.net_id, const.PORT_UP,
new_port2[const.UUID], device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
least_rsvd_blade_dict=(
self._ucs_inventory._get_least_reserved_blade()))
ports_on_net = self._cisco_ucs_plugin.get_all_ports(
self.tenant_id, new_net_dict[const.NET_ID],
device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
least_rsvd_blade_dict=(
self._ucs_inventory._get_least_reserved_blade()))
port_list = [port_dict1, port_dict2]
self.assertTrue(str(ports_on_net[1]) == str(port_list[1]) or
str(ports_on_net[1]) == str(port_list[0]))
self.assertTrue(str(ports_on_net[0]) == str(port_list[1]) or
str(ports_on_net[0]) == str(port_list[0]))
blade_intf_details = self._ucs_inventory._get_rsvd_blade_intf_by_port(
self.tenant_id, port_dict1[const.PORTID])
self._cisco_ucs_plugin.delete_port(
self.tenant_id, new_net_dict[const.NET_ID],
port_dict1[const.PORTID], device_ip=self.device_ip,
ucs_inventory=self._ucs_inventory,
chassis_id=self.chassis_id, blade_id=self.blade_id,
blade_intf_distinguished_name=blade_intf_details[
const.BLADE_INTF_DN],
least_rsvd_blade_dict=(
self._ucs_inventory._get_least_reserved_blade()))
self.tear_down_network_port(
self.tenant_id, new_net_dict[const.NET_ID],
port_dict2[const.PORTID])
示例15: create_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["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))