本文整理汇总了Python中quark.plugin_modules.ip_addresses.create_ip_address函数的典型用法代码示例。如果您正苦于以下问题:Python create_ip_address函数的具体用法?Python create_ip_address怎么用?Python create_ip_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_ip_address函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_lots_of_shared_ips_same_tenant_raises
def test_create_lots_of_shared_ips_same_tenant_raises(self):
with self._stubs(self.network, self.subnet, self.ports_info4) as (
net, sub, ports):
port_ids = [ports[0]['id'], ports[1]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
self.assertEqual(ip_types.SHARED, ip['type'])
port_ids = [ports[1]['id'], ports[2]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
self.assertEqual(ip_types.SHARED, ip['type'])
port_ids = [ports[2]['id'], ports[3]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
self.assertEqual(ip_types.SHARED, ip['type'])
port_ids = [ports[0]['id'], ports[3]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
with self.assertRaises(q_exc.CannotCreateMoreSharedIPs):
ip_api.create_ip_address(self.context, shared_ip)
开发者ID:roaet,项目名称:quark,代码行数:31,代码来源:test_shared_ips.py
示例2: test_create_shared_ips_fails_with_garbage_body
def test_create_shared_ips_fails_with_garbage_body(self):
with self._stubs(self.network, self.subnet, self.ports_info2) as (net, sub, ports):
port_ids = [ports[0]["id"], ports[1]["id"]]
shared_ip = {"derpie_derp": dict(port_ids=port_ids, network_id=net["id"], version=4)}
with self.assertRaises(n_exc.BadRequest):
ip_api.create_ip_address(self.context, shared_ip)
开发者ID:kshortwindham,项目名称:quark,代码行数:8,代码来源:test_shared_ips.py
示例3: test_create_shared_ips_fails_with_plural_body
def test_create_shared_ips_fails_with_plural_body(self):
with self._stubs(self.network, self.subnet, self.ports_info2) as (
net, sub, ports):
port_ids = [ports[0]['id'], ports[1]['id']]
shared_ip = {'ip_addresses': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
with self.assertRaises(exceptions.BadRequest):
ip_api.create_ip_address(self.context, shared_ip)
开发者ID:Cerberus98,项目名称:quark,代码行数:11,代码来源:test_shared_ips.py
示例4: test_create_shared_ip_over_isolated_total_ip_on_port_quota
def test_create_shared_ip_over_isolated_total_ip_on_port_quota(self):
with self._stubs(self.network, self.subnet, self.ports_info2) as (net, sub, ports):
port_ids = [ports[0]["id"], ports[1]["id"]]
shared_ip = {"ip_address": dict(port_ids=port_ids, network_id=net["id"], version=4)}
# NOTE(roaet): this is hardcoded to 5 should fail after 4
# since a port comes with 1 IP already
for i in xrange(4):
ip_api.create_ip_address(self.context, shared_ip)
with self.assertRaises(n_exc.OverQuota):
ip_api.create_ip_address(self.context, shared_ip)
开发者ID:kshortwindham,项目名称:quark,代码行数:12,代码来源:test_shared_ips.py
示例5: test_create_shared_ip_over_service_total_ip_on_port_quota
def test_create_shared_ip_over_service_total_ip_on_port_quota(self):
network = dict(
name="service", tenant_id="fake", network_plugin="BASE", id="11111111-1111-1111-1111-111111111111"
)
network = {"network": network}
with self._stubs(network, self.subnet, self.ports_info2) as (net, sub, ports):
port_ids = [ports[0]["id"], ports[1]["id"]]
shared_ip = {"ip_address": dict(port_ids=port_ids, network_id=net["id"], version=4)}
# NOTE(roaet): this is hardcoded to 1 so should fail immediately
with self.assertRaises(n_exc.OverQuota):
ip_api.create_ip_address(self.context, shared_ip)
开发者ID:kshortwindham,项目名称:quark,代码行数:13,代码来源:test_shared_ips.py
示例6: test_create_shared_ips_with_port_ids
def test_create_shared_ips_with_port_ids(self):
def _make_body(ip):
fix_ip = dict(ip_address=ip, subnet_id=sub['id'])
port_info = {"port": dict(fixed_ips=[fix_ip])}
return port_info
with self._stubs(self.network, self.subnet, self.ports_info2) as (
net, sub, ports):
for p in ports:
port_db = db_api.port_find(self.context, id=p['id'],
scope=db_api.ONE)
assocs = db_api.ip_port_association_find(self.context,
scope=db_api.ALL,
port_id=p['id'])
self.assertEqual(1, len(p.get('fixed_ips')))
self.assertEqual(1, len(port_db.ip_addresses))
ip_db = port_db.ip_addresses[0]
self.assertEqual('none', ip_db.get_service_for_port(port_db))
self.assertEqual(1, len(assocs))
port_ids = [ports[0]['id'], ports[1]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
self.assertEqual(ip_types.SHARED, ip['type'])
ports_ip = ip_api.get_ports_for_ip_address(self.context, ip['id'])
self.assertEqual(2, len(ports_ip))
开发者ID:Anonymike,项目名称:quark,代码行数:30,代码来源:test_ip_addresses.py
示例7: test_shared_ip_in_fixed_ip_list
def test_shared_ip_in_fixed_ip_list(self):
with self._stubs(self.network, self.subnet, self.ports_info2) as (
net, sub, ports):
for port in ports:
self.assertEqual(1, len(port['fixed_ips']))
port_ids = [ports[0]['id'], ports[1]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
p_id = ports[0]['id']
ip = ip_api.create_ip_address(self.context, shared_ip)
self.assertEqual(ip_types.SHARED, ip['type'])
ports_ip = ip_api.get_ports_for_ip_address(self.context, ip['id'])
self.assertEqual(2, len(ports_ip))
port_ip_update = ip_api.update_port_for_ip_address
updated_port = port_ip_update(self.context, ip['id'],
p_id, self._make_port_body('derp'))
self.assertEqual('derp', updated_port.get('service'))
port = port_api.get_port(self.context, p_id)
self.assertEqual(2, len(port['fixed_ips']))
开发者ID:Cerberus98,项目名称:quark,代码行数:27,代码来源:test_shared_ips.py
示例8: test_ip_port_list_has_services
def test_ip_port_list_has_services(self):
with self._stubs(self.network, self.subnet, self.ports_info2) as (
net, sub, ports):
for port in ports:
self.assertEqual(1, len(port['fixed_ips']))
device_ids = [ports[0]['device_id'], ports[1]['device_id']]
shared_ip = {'ip_address': dict(device_ids=device_ids,
network_id=net['id'],
version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
port_ip_update = ip_api.update_port_for_ip_address
port_ip_update(self.context, ip['id'],
ports[0]['id'], self._make_port_body('derp'))
ports_ip = ip_api.get_ports_for_ip_address(self.context, ip['id'])
self.assertEqual(2, len(ports_ip))
for port in ports_ip:
self.assertTrue('service' in port)
self.assertTrue('device_id' in port)
self.assertTrue('id' in port)
self.assertTrue(port['service'] in ('derp', 'none'),
'Service is: %s' % str(port['service']))
开发者ID:Cerberus98,项目名称:quark,代码行数:26,代码来源:test_shared_ips.py
示例9: test_create_shared_ip_over_service_network_quota
def test_create_shared_ip_over_service_network_quota(self):
network = dict(name="service", tenant_id="fake", network_plugin="BASE",
id='11111111-1111-1111-1111-111111111111')
network = {"network": network}
with self._stubs(network, self.subnet, self.ports_info4) as (
net, sub, ports):
port_ids = [ports[0]['id'], ports[1]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
# NOTE(roaet): this is hardcoded to 0 so should fail instantly
with self.assertRaises(q_exceptions.CannotCreateMoreSharedIPs):
ip_api.create_ip_address(self.context, shared_ip)
开发者ID:Cerberus98,项目名称:quark,代码行数:16,代码来源:test_shared_ips.py
示例10: test_get_ports_filter_with_ip_and_device
def test_get_ports_filter_with_ip_and_device(self):
with self._stubs(self.network, self.subnet, self.ports_info4) as (
net, sub, ports):
network = dict(name="xx", tenant_id="fake", network_plugin="BASE")
xx_network = {"network": network}
xx_net = network_api.create_network(self.context, xx_network)
subnet = dict(id=2, ip_version=4, next_auto_assign_ip=2,
cidr=self.cidr, first_ip=self.ip_network.first,
last_ip=self.ip_network.last, ip_policy=None,
tenant_id="fake")
xx_subnet = {"subnet": subnet}
xx_subnet['subnet']['network_id'] = xx_net['id']
subnet_api.create_subnet(self.context, xx_subnet)
port_info = {'port': dict(device_id='a')}
port_info['port']['network_id'] = xx_net['id']
port_api.create_port(self.context, port_info)
port_ids1 = [ports[0]['id'], ports[1]['id']]
shared_ip1 = {'ip_address': dict(port_ids=port_ids1,
network_id=net['id'],
version=4)}
ip1 = ip_api.create_ip_address(self.context, shared_ip1)
filters = dict(device_id='a')
ports = ip_api.get_ports_for_ip_address(self.context, ip1['id'],
filters=filters)
self.assertEqual(1, len(ports))
filters = dict(device_id='a')
ports = port_api.get_ports(self.context, filters=filters)
self.assertEqual(2, len(ports))
开发者ID:Anonymike,项目名称:quark,代码行数:35,代码来源:test_ip_addresses.py
示例11: test_create_ip_over_isolated_network_quota
def test_create_ip_over_isolated_network_quota(self):
with self._stubs(self.network, self.subnet, self.ports) as (
net, sub, ports):
port_ids = [ports[0]['id']]
ip_address = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
# NOTE: This is hardcoded to 5. Port comes with an IP
# Can create 4 more before it fails
for i in xrange(4):
ip_api.create_ip_address(self.context, ip_address)
# NOTE: This should raise an exception
with self.assertRaises(q_exc.CannotAddMoreIPsToPort):
ip_api.create_ip_address(self.context, ip_address)
开发者ID:openstack,项目名称:quark,代码行数:16,代码来源:test_total_ips_per_port.py
示例12: test_create_ip_over_service_network_quota
def test_create_ip_over_service_network_quota(self):
network = dict(name="service", network_plugin="BASE",
id='11111111-1111-1111-1111-111111111111')
network = {"network": network}
with self._stubs(network, self.subnet, self.ports) as (
net, sub, ports):
port_ids = [ports[0]['id']]
ip_address = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
# NOTE : This is hardcoded to 1 and should raise an exception
# as ports come with 1 IP
with self.assertRaises(q_exc.CannotAddMoreIPsToPort):
ip_api.create_ip_address(self.context, ip_address)
开发者ID:openstack,项目名称:quark,代码行数:16,代码来源:test_total_ips_per_port.py
示例13: test_create_shared_ip_over_public_total_ip_on_port_quota
def test_create_shared_ip_over_public_total_ip_on_port_quota(self):
network = dict(
name="public", tenant_id="fake", network_plugin="BASE", id="00000000-0000-0000-0000-000000000000"
)
network = {"network": network}
with self._stubs(network, self.subnet, self.ports_info2) as (net, sub, ports):
port_ids = [ports[0]["id"], ports[1]["id"]]
shared_ip = {"ip_address": dict(port_ids=port_ids, network_id=net["id"], version=4)}
# NOTE(roaet): this is hardcoded to 6 so should fail after 5
# since a port comes with 1 IP already
for i in xrange(5):
ip_api.create_ip_address(self.context, shared_ip)
with self.assertRaises(n_exc.OverQuota):
ip_api.create_ip_address(self.context, shared_ip)
开发者ID:kshortwindham,项目名称:quark,代码行数:17,代码来源:test_shared_ips.py
示例14: test_can_delete_ip_without_active_port
def test_can_delete_ip_without_active_port(self):
with self._stubs(self.network, self.subnet, self.ports_info2) as (net, sub, ports):
device_ids = [ports[0]["device_id"], ports[1]["device_id"]]
shared_ip = {"ip_address": dict(device_ids=device_ids, network_id=net["id"], version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
ip_api.delete_ip_address(self.context, ip["id"])
with self.assertRaises(q_exc.IpAddressNotFound):
ip_api.get_ip_address(self.context, ip["id"])
开发者ID:kshortwindham,项目名称:quark,代码行数:9,代码来源:test_shared_ips.py
示例15: test_cannot_delete_ip_with_active_port
def test_cannot_delete_ip_with_active_port(self):
with self._stubs(self.network, self.subnet, self.ports_info2) as (net, sub, ports):
device_ids = [ports[0]["device_id"], ports[1]["device_id"]]
shared_ip = {"ip_address": dict(device_ids=device_ids, network_id=net["id"], version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
port_ip_update = ip_api.update_port_for_ip_address
port_ip_update(self.context, ip["id"], ports[0]["id"], self._make_port_body("derp"))
with self.assertRaises(self.disassociate_exception):
ip_api.delete_ip_address(self.context, ip["id"])
开发者ID:kshortwindham,项目名称:quark,代码行数:11,代码来源:test_shared_ips.py
示例16: test_create_ip_over_public_network_quota
def test_create_ip_over_public_network_quota(self):
network = dict(name="public", tenant_id="fake", network_plugin="BASE",
id='00000000-0000-0000-0000-000000000000')
network = {"network": network}
with self._stubs(network, self.subnet, self.ports) as (
net, sub, ports):
port_ids = [ports[0]['id']]
ip_address = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
# NOTE: This is hardcoded to 6. Port comes with an IP
# Can create 5 more before it fails
for i in xrange(5):
ip_api.create_ip_address(self.context, ip_address)
# NOTE: This should raise an exception
with self.assertRaises(q_exc.CannotAddMoreIPsToPort):
ip_api.create_ip_address(self.context, ip_address)
开发者ID:openstack,项目名称:quark,代码行数:20,代码来源:test_total_ips_per_port.py
示例17: test_create_shared_ips_with_port_ids
def test_create_shared_ips_with_port_ids(self):
with self._stubs(self.network, self.subnet, self.ports_info2) as (net, sub, ports):
port_ids = [ports[0]["id"], ports[1]["id"]]
shared_ip = {"ip_address": dict(port_ids=port_ids, network_id=net["id"], version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
self.assertEqual(ip_types.SHARED, ip["type"])
ports_ip = ip_api.get_ports_for_ip_address(self.context, ip["id"])
self.assertEqual(2, len(ports_ip))
开发者ID:kshortwindham,项目名称:quark,代码行数:11,代码来源:test_shared_ips.py
示例18: test_create_shared_ip_over_public_network_quota
def test_create_shared_ip_over_public_network_quota(self):
network = dict(name="public", tenant_id="fake", network_plugin="BASE",
id='00000000-0000-0000-0000-000000000000')
network = {"network": network}
with self._stubs(network, self.subnet, self.ports_info4) as (
net, sub, ports):
port_ids = [ports[0]['id'], ports[1]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
port_ids = [ports[2]['id'], ports[3]['id']]
shared_ip2 = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
# NOTE(roaet): this is hardcoded to 5 and will fail after 5
for i in xrange(5):
# NOTE(roaet): need to do this modulo stuff to not hit IP quota
if i % 2 == 0:
ip_api.create_ip_address(self.context, shared_ip)
else:
ip_api.create_ip_address(self.context, shared_ip2)
with self.assertRaises(q_exceptions.CannotCreateMoreSharedIPs):
ip_api.create_ip_address(self.context, shared_ip)
开发者ID:Cerberus98,项目名称:quark,代码行数:27,代码来源:test_shared_ips.py
示例19: test_update_shared_ip_with_garbage_will_error
def test_update_shared_ip_with_garbage_will_error(self):
with self._stubs(self.network, self.subnet, self.ports_info4) as (net, sub, ports):
port_ids = [ports[0]["id"], ports[1]["id"]]
shared_ip = {"ip_address": dict(port_ids=port_ids, network_id=net["id"], version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
self.assertEqual(ip_types.SHARED, ip["type"])
port_ids = [ports[0]["id"], ports[3]["id"]]
shared_ip = {"delasdfkj": dict(port_ids=port_ids)}
with self.assertRaises(n_exc.BadRequest):
ip_api.update_ip_address(self.context, ip["id"], shared_ip)
开发者ID:kshortwindham,项目名称:quark,代码行数:13,代码来源:test_shared_ips.py
示例20: test_update_shared_ip_with_empty_port_id_list_will_error
def test_update_shared_ip_with_empty_port_id_list_will_error(self):
with self._stubs(self.network, self.subnet, self.ports_info4) as (
net, sub, ports):
port_ids = [ports[0]['id'], ports[1]['id']]
shared_ip = {'ip_address': dict(port_ids=port_ids,
network_id=net['id'],
version=4)}
ip = ip_api.create_ip_address(self.context, shared_ip)
self.assertEqual(ip_types.SHARED, ip['type'])
port_ids = []
shared_ip = {'ip_addresses': dict(port_ids=port_ids)}
with self.assertRaises(exceptions.BadRequest):
ip_api.update_ip_address(self.context, ip['id'], shared_ip)
开发者ID:Cerberus98,项目名称:quark,代码行数:16,代码来源:test_shared_ips.py
注:本文中的quark.plugin_modules.ip_addresses.create_ip_address函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论