Browse Source

Move SG and FIP API wrapper to api.neutron

We no longer need to have SG and FIP API wrapper in api.network
as we only supports a single network back-end.

Completes blueprint drop-nova-network

Change-Id: I4e59d897508b497a3cd2ae2fda93b30b786610dc
tags/12.0.0.0b2
Akihiro Motoki 2 years ago
parent
commit
9067ae8b0f
33 changed files with 906 additions and 1035 deletions
  1. +0
    -122
      openstack_dashboard/api/network.py
  2. +95
    -0
      openstack_dashboard/api/neutron.py
  3. +6
    -6
      openstack_dashboard/api/rest/network.py
  4. +1
    -1
      openstack_dashboard/api/rest/nova.py
  5. +4
    -4
      openstack_dashboard/dashboards/admin/aggregates/tests.py
  6. +1
    -1
      openstack_dashboard/dashboards/admin/floating_ips/forms.py
  7. +1
    -1
      openstack_dashboard/dashboards/admin/floating_ips/tables.py
  8. +30
    -30
      openstack_dashboard/dashboards/admin/floating_ips/tests.py
  9. +2
    -2
      openstack_dashboard/dashboards/admin/floating_ips/views.py
  10. +9
    -9
      openstack_dashboard/dashboards/admin/overview/tests.py
  11. +6
    -6
      openstack_dashboard/dashboards/identity/projects/tests.py
  12. +1
    -1
      openstack_dashboard/dashboards/project/floating_ips/forms.py
  13. +2
    -2
      openstack_dashboard/dashboards/project/floating_ips/tables.py
  14. +51
    -52
      openstack_dashboard/dashboards/project/floating_ips/tests.py
  15. +3
    -3
      openstack_dashboard/dashboards/project/floating_ips/views.py
  16. +4
    -4
      openstack_dashboard/dashboards/project/floating_ips/workflows.py
  17. +6
    -6
      openstack_dashboard/dashboards/project/instances/tables.py
  18. +118
    -120
      openstack_dashboard/dashboards/project/instances/tests.py
  19. +1
    -1
      openstack_dashboard/dashboards/project/instances/views.py
  20. +1
    -1
      openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
  21. +3
    -3
      openstack_dashboard/dashboards/project/instances/workflows/update_instance.py
  22. +10
    -10
      openstack_dashboard/dashboards/project/overview/tests.py
  23. +3
    -3
      openstack_dashboard/dashboards/project/security_groups/forms.py
  24. +2
    -2
      openstack_dashboard/dashboards/project/security_groups/tables.py
  25. +76
    -76
      openstack_dashboard/dashboards/project/security_groups/tests.py
  26. +4
    -4
      openstack_dashboard/dashboards/project/security_groups/views.py
  27. +6
    -6
      openstack_dashboard/test/api_tests/network_rest_tests.py
  28. +0
    -533
      openstack_dashboard/test/api_tests/network_tests.py
  29. +439
    -4
      openstack_dashboard/test/api_tests/neutron_tests.py
  30. +1
    -1
      openstack_dashboard/test/api_tests/nova_rest_tests.py
  31. +14
    -14
      openstack_dashboard/test/tests/quotas.py
  32. +3
    -3
      openstack_dashboard/usage/base.py
  33. +3
    -4
      openstack_dashboard/usage/quotas.py

+ 0
- 122
openstack_dashboard/api/network.py View File

@@ -19,132 +19,10 @@ introduced to abstract the differences between them for seamless consumption by
different dashboard implementations.
"""

from horizon.utils.memoized import memoized
from openstack_dashboard.api import base
from openstack_dashboard.api import neutron


class NetworkClient(object):
def __init__(self, request):
# TODO(amotoki): neutron check needs to be dropped.
# The network API wrapper can depend on neutron.
neutron_enabled = base.is_service_enabled(request, 'network')

if neutron_enabled:
self.floating_ips = neutron.FloatingIpManager(request)
else:
self.floating_ips = None

if (neutron_enabled and
neutron.is_extension_supported(request, 'security-group')):
self.secgroups = neutron.SecurityGroupManager(request)
else:
self.secgroups = None

@property
def enabled(self):
return self.floating_ips is not None


def floating_ip_pools_list(request):
return NetworkClient(request).floating_ips.list_pools()


@memoized
def tenant_floating_ip_list(request, all_tenants=False):
return NetworkClient(request).floating_ips.list(all_tenants=all_tenants)


def tenant_floating_ip_get(request, floating_ip_id):
return NetworkClient(request).floating_ips.get(floating_ip_id)


def tenant_floating_ip_allocate(request, pool=None, tenant_id=None, **params):
return NetworkClient(request).floating_ips.allocate(pool,
tenant_id,
**params)


def tenant_floating_ip_release(request, floating_ip_id):
return NetworkClient(request).floating_ips.release(floating_ip_id)


def floating_ip_associate(request, floating_ip_id, port_id):
return NetworkClient(request).floating_ips.associate(floating_ip_id,
port_id)


def floating_ip_disassociate(request, floating_ip_id):
return NetworkClient(request).floating_ips.disassociate(floating_ip_id)


def floating_ip_target_list(request):
return NetworkClient(request).floating_ips.list_targets()


def floating_ip_target_get_by_instance(request, instance_id, cache=None):
return NetworkClient(request).floating_ips.get_target_id_by_instance(
instance_id, cache)


def floating_ip_target_list_by_instance(request, instance_id, cache=None):
floating_ips = NetworkClient(request).floating_ips
return floating_ips.list_target_id_by_instance(instance_id, cache)


def floating_ip_simple_associate_supported(request):
return NetworkClient(request).floating_ips.is_simple_associate_supported()


def floating_ip_supported(request):
nwc = NetworkClient(request)
return nwc.enabled and nwc.floating_ips.is_supported()


@memoized
def security_group_list(request):
return NetworkClient(request).secgroups.list()


def security_group_get(request, sg_id):
return NetworkClient(request).secgroups.get(sg_id)


def security_group_create(request, name, desc):
return NetworkClient(request).secgroups.create(name, desc)


def security_group_delete(request, sg_id):
return NetworkClient(request).secgroups.delete(sg_id)


def security_group_update(request, sg_id, name, desc):
return NetworkClient(request).secgroups.update(sg_id, name, desc)


def security_group_rule_create(request, parent_group_id,
direction, ethertype,
ip_protocol, from_port, to_port,
cidr, group_id):
return NetworkClient(request).secgroups.rule_create(
parent_group_id, direction, ethertype, ip_protocol,
from_port, to_port, cidr, group_id)


def security_group_rule_delete(request, sgr_id):
return NetworkClient(request).secgroups.rule_delete(sgr_id)


def server_security_groups(request, instance_id):
return NetworkClient(request).secgroups.list_by_instance(instance_id)


def server_update_security_groups(request, instance_id,
new_security_group_ids):
return NetworkClient(request).secgroups.update_instance_security_group(
instance_id, new_security_group_ids)


def servers_update_addresses(request, servers, all_tenants=False):
"""Retrieve servers networking information from Neutron if enabled.


+ 95
- 0
openstack_dashboard/api/neutron.py View File

@@ -1246,6 +1246,101 @@ def provider_list(request):
return providers['service_providers']


def floating_ip_pools_list(request):
return FloatingIpManager(request).list_pools()


@memoized
def tenant_floating_ip_list(request, all_tenants=False):
return FloatingIpManager(request).list(all_tenants=all_tenants)


def tenant_floating_ip_get(request, floating_ip_id):
return FloatingIpManager(request).get(floating_ip_id)


def tenant_floating_ip_allocate(request, pool=None, tenant_id=None, **params):
return FloatingIpManager(request).allocate(pool, tenant_id, **params)


def tenant_floating_ip_release(request, floating_ip_id):
return FloatingIpManager(request).release(floating_ip_id)


def floating_ip_associate(request, floating_ip_id, port_id):
return FloatingIpManager(request).associate(floating_ip_id, port_id)


def floating_ip_disassociate(request, floating_ip_id):
return FloatingIpManager(request).disassociate(floating_ip_id)


def floating_ip_target_list(request):
return FloatingIpManager(request).list_targets()


def floating_ip_target_get_by_instance(request, instance_id, cache=None):
return FloatingIpManager(request).get_target_id_by_instance(
instance_id, cache)


def floating_ip_target_list_by_instance(request, instance_id, cache=None):
return FloatingIpManager(request).list_target_id_by_instance(
instance_id, cache)


def floating_ip_simple_associate_supported(request):
return FloatingIpManager(request).is_simple_associate_supported()


def floating_ip_supported(request):
return FloatingIpManager(request).is_supported()


@memoized
def security_group_list(request):
return SecurityGroupManager(request).list()


def security_group_get(request, sg_id):
return SecurityGroupManager(request).get(sg_id)


def security_group_create(request, name, desc):
return SecurityGroupManager(request).create(name, desc)


def security_group_delete(request, sg_id):
return SecurityGroupManager(request).delete(sg_id)


def security_group_update(request, sg_id, name, desc):
return SecurityGroupManager(request).update(sg_id, name, desc)


def security_group_rule_create(request, parent_group_id,
direction, ethertype,
ip_protocol, from_port, to_port,
cidr, group_id):
return SecurityGroupManager(request).rule_create(
parent_group_id, direction, ethertype, ip_protocol,
from_port, to_port, cidr, group_id)


def security_group_rule_delete(request, sgr_id):
return SecurityGroupManager(request).rule_delete(sgr_id)


def server_security_groups(request, instance_id):
return SecurityGroupManager(request).list_by_instance(instance_id)


def server_update_security_groups(request, instance_id,
new_security_group_ids):
return SecurityGroupManager(request).update_instance_security_group(
instance_id, new_security_group_ids)


# TODO(pkarikh) need to uncomment when osprofiler will have no
# issues with unicode in:
# openstack_dashboard/test/test_data/nova_data.py#L470 data

+ 6
- 6
openstack_dashboard/api/rest/network.py View File

@@ -42,7 +42,7 @@ class SecurityGroups(generic.View):
http://localhost/api/network/securitygroups
"""

security_groups = api.network.security_group_list(request)
security_groups = api.neutron.security_group_list(request)

return {'items': [sg.to_dict() for sg in security_groups]}

@@ -63,7 +63,7 @@ class FloatingIP(generic.View):
:return: JSON representation of the new floating IP address
"""
pool = request.DATA['pool_id']
result = api.network.tenant_floating_ip_allocate(request, pool)
result = api.neutron.tenant_floating_ip_allocate(request, pool)
return result.to_dict()

@rest_utils.ajax(data_required=True)
@@ -77,9 +77,9 @@ class FloatingIP(generic.View):
address = request.DATA['address_id']
port = request.DATA.get('port_id')
if port is None:
api.network.floating_ip_disassociate(request, address)
api.neutron.floating_ip_disassociate(request, address)
else:
api.network.floating_ip_associate(request, address, port)
api.neutron.floating_ip_associate(request, address, port)


@urls.register
@@ -98,7 +98,7 @@ class FloatingIPs(generic.View):
Example:
http://localhost/api/network/floatingips
"""
result = api.network.tenant_floating_ip_list(request)
result = api.neutron.tenant_floating_ip_list(request)
return {'items': [ip.to_dict() for ip in result]}


@@ -118,5 +118,5 @@ class FloatingIPPools(generic.View):
Example:
http://localhost/api/network/floatingippools
"""
result = api.network.floating_ip_pools_list(request)
result = api.neutron.floating_ip_pools_list(request)
return {'items': [p.to_dict() for p in result]}

+ 1
- 1
openstack_dashboard/api/rest/nova.py View File

@@ -233,7 +233,7 @@ class SecurityGroups(generic.View):
Example GET:
http://localhost/api/nova/servers/abcd/security-groups/
"""
groups = api.network.server_security_groups(request, server_id)
groups = api.neutron.server_security_groups(request, server_id)
return {'items': [s.to_dict() for s in groups]}



+ 4
- 4
openstack_dashboard/dashboards/admin/aggregates/tests.py View File

@@ -208,8 +208,8 @@ class AggregatesViewTests(test.BaseAdminViewTests):
'availability_zone_list',
'tenant_absolute_limits',),
api.cinder: ('tenant_absolute_limits',),
api.neutron: ('is_extension_supported',),
api.network: ('tenant_floating_ip_list',
api.neutron: ('is_extension_supported',
'tenant_floating_ip_list',
'security_group_list'),
api.keystone: ('tenant_list',)})
def test_panel_not_available(self):
@@ -220,9 +220,9 @@ class AggregatesViewTests(test.BaseAdminViewTests):
api.neutron.\
is_extension_supported(IsA(http.HttpRequest), 'security-group'). \
MultipleTimes().AndReturn(True)
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.keystone.tenant_list(IsA(http.HttpRequest)) \
.AndReturn(self.tenants.list())

+ 1
- 1
openstack_dashboard/dashboards/admin/floating_ips/forms.py View File

@@ -50,7 +50,7 @@ class AdminFloatingIpAllocate(forms.SelfHandlingForm):
param['floating_ip_address'] = data['floating_ip_address']
subnet = api.neutron.subnet_get(request, data['pool'])
param['subnet_id'] = subnet.id
fip = api.network.tenant_floating_ip_allocate(
fip = api.neutron.tenant_floating_ip_allocate(
request,
pool=subnet.network_id,
tenant_id=data['tenant'],

+ 1
- 1
openstack_dashboard/dashboards/admin/floating_ips/tables.py View File

@@ -61,7 +61,7 @@ class AdminSimpleDisassociateIP(project_tables.DisassociateIP):
def single(self, table, request, obj_id):
try:
fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id))
api.network.floating_ip_disassociate(request, fip.id)
api.neutron.floating_ip_disassociate(request, fip.id)
LOG.info('Disassociating Floating IP "%s".', obj_id)
messages.success(request,
_('Successfully disassociated Floating IP: %s')

+ 30
- 30
openstack_dashboard/dashboards/admin/floating_ips/tests.py View File

@@ -25,16 +25,16 @@ INDEX_TEMPLATE = 'horizon/common/_data_table_view.html'


class AdminFloatingIpViewTest(test.BaseAdminViewTests):
@test.create_stubs({api.network: ('tenant_floating_ip_list', ),
api.nova: ('server_list', ),
@test.create_stubs({api.nova: ('server_list', ),
api.keystone: ('tenant_list', ),
api.neutron: ('network_list', )})
api.neutron: ('network_list',
'tenant_floating_ip_list',)})
def test_index(self):
# Use neutron test data
fips = self.floating_ips.list()
servers = self.servers.list()
tenants = self.tenants.list()
api.network.tenant_floating_ip_list(IsA(http.HttpRequest),
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest),
all_tenants=True).AndReturn(fips)
api.nova.server_list(IsA(http.HttpRequest), all_tenants=True) \
.AndReturn([servers, False])
@@ -58,12 +58,12 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
row_actions = floating_ips_table.get_row_actions(floating_ips[1])
self.assertEqual(len(row_actions), 2)

@test.create_stubs({api.network: ('tenant_floating_ip_get', ),
api.neutron: ('network_get', )})
@test.create_stubs({api.neutron: ('tenant_floating_ip_get',
'network_get', )})
def test_floating_ip_detail_get(self):
fip = self.floating_ips.first()
network = self.networks.first()
api.network.tenant_floating_ip_get(
api.neutron.tenant_floating_ip_get(
IsA(http.HttpRequest), fip.id).AndReturn(fip)
api.neutron.network_get(
IsA(http.HttpRequest), fip.pool).AndReturn(network)
@@ -75,11 +75,11 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
'admin/floating_ips/detail.html')
self.assertEqual(res.context['floating_ip'].ip, fip.ip)

@test.create_stubs({api.network: ('tenant_floating_ip_get',)})
@test.create_stubs({api.neutron: ('tenant_floating_ip_get',)})
def test_floating_ip_detail_exception(self):
fip = self.floating_ips.first()
# Only supported by neutron, so raise a neutron exception
api.network.tenant_floating_ip_get(
api.neutron.tenant_floating_ip_get(
IsA(http.HttpRequest),
fip.id).AndRaise(self.exceptions.neutron)

@@ -90,18 +90,18 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):

self.assertRedirectsNoFollow(res, INDEX_URL)

@test.create_stubs({api.network: ('tenant_floating_ip_list', )})
@test.create_stubs({api.neutron: ('tenant_floating_ip_list', )})
def test_index_no_floating_ips(self):
api.network.tenant_floating_ip_list(IsA(http.HttpRequest),
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest),
all_tenants=True).AndReturn([])
self.mox.ReplayAll()

res = self.client.get(INDEX_URL)
self.assertTemplateUsed(res, INDEX_TEMPLATE)

@test.create_stubs({api.network: ('tenant_floating_ip_list', )})
@test.create_stubs({api.neutron: ('tenant_floating_ip_list', )})
def test_index_error(self):
api.network.tenant_floating_ip_list(IsA(http.HttpRequest),
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest),
all_tenants=True) \
.AndRaise(self.exceptions.neutron)
self.mox.ReplayAll()
@@ -154,8 +154,8 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
res = self.client.post(url, form_data)
self.assertContains(res, "Invalid version for IP address")

@test.create_stubs({api.network: ('tenant_floating_ip_allocate',),
api.neutron: ('network_list', 'subnet_get'),
@test.create_stubs({api.neutron: ('tenant_floating_ip_allocate',
'network_list', 'subnet_get'),
api.keystone: ('tenant_list',)})
def test_admin_allocate_post(self):
tenant = self.tenants.first()
@@ -171,7 +171,7 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
search_opts = {'router:external': True}
api.neutron.network_list(IsA(http.HttpRequest), **search_opts) \
.AndReturn([pool])
api.network.tenant_floating_ip_allocate(
api.neutron.tenant_floating_ip_allocate(
IsA(http.HttpRequest),
pool=pool.id,
tenant_id=tenant.id).AndReturn(floating_ip)
@@ -183,18 +183,18 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
res = self.client.post(url, form_data)
self.assertRedirectsNoFollow(res, INDEX_URL)

@test.create_stubs({api.network: ('tenant_floating_ip_list',
'floating_ip_disassociate'),
@test.create_stubs({api.neutron: ('tenant_floating_ip_list',
'floating_ip_disassociate',
'network_list'),
api.nova: ('server_list', ),
api.keystone: ('tenant_list', ),
api.neutron: ('network_list', )})
api.keystone: ('tenant_list', )})
def test_admin_disassociate_floatingip(self):
# Use neutron test data
fips = self.floating_ips.list()
floating_ip = self.floating_ips.list()[1]
servers = self.servers.list()
tenants = self.tenants.list()
api.network.tenant_floating_ip_list(IsA(http.HttpRequest),
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest),
all_tenants=True).AndReturn(fips)
api.nova.server_list(IsA(http.HttpRequest), all_tenants=True) \
.AndReturn([servers, False])
@@ -203,7 +203,7 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):
params = {"router:external": True}
api.neutron.network_list(IsA(http.HttpRequest), **params) \
.AndReturn(self.networks.list())
api.network.floating_ip_disassociate(IsA(http.HttpRequest),
api.neutron.floating_ip_disassociate(IsA(http.HttpRequest),
floating_ip.id)
self.mox.ReplayAll()

@@ -214,17 +214,17 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):

self.assertNoFormErrors(res)

@test.create_stubs({api.network: ('tenant_floating_ip_list', ),
@test.create_stubs({api.neutron: ('tenant_floating_ip_list',
'network_list'),
api.nova: ('server_list', ),
api.keystone: ('tenant_list', ),
api.neutron: ('network_list', )})
api.keystone: ('tenant_list', )})
def test_admin_delete_floatingip(self):
# Use neutron test data
fips = self.floating_ips.list()
floating_ip = self.floating_ips.list()[1]
servers = self.servers.list()
tenants = self.tenants.list()
api.network.tenant_floating_ip_list(IsA(http.HttpRequest),
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest),
all_tenants=True).AndReturn(fips)
api.nova.server_list(IsA(http.HttpRequest), all_tenants=True) \
.AndReturn([servers, False])
@@ -243,16 +243,16 @@ class AdminFloatingIpViewTest(test.BaseAdminViewTests):

self.assertNoFormErrors(res)

@test.create_stubs({api.network: ('tenant_floating_ip_list', ),
@test.create_stubs({api.neutron: ('tenant_floating_ip_list',
'network_list'),
api.nova: ('server_list', ),
api.keystone: ('tenant_list', ),
api.neutron: ('network_list', )})
api.keystone: ('tenant_list', )})
def test_floating_ip_table_actions(self):
# Use neutron test data
fips = self.floating_ips.list()
servers = self.servers.list()
tenants = self.tenants.list()
api.network.tenant_floating_ip_list(IsA(http.HttpRequest),
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest),
all_tenants=True).AndReturn(fips)
api.nova.server_list(IsA(http.HttpRequest), all_tenants=True) \
.AndReturn([servers, False])

+ 2
- 2
openstack_dashboard/dashboards/admin/floating_ips/views.py View File

@@ -65,7 +65,7 @@ class IndexView(tables.DataTableView):
def get_data(self):
floating_ips = []
try:
floating_ips = api.network.tenant_floating_ip_list(
floating_ips = api.neutron.tenant_floating_ip_list(
self.request,
all_tenants=True)
except Exception:
@@ -104,7 +104,7 @@ class DetailView(views.HorizonTemplateView):
page_title = _("Floating IP Details")

def _get_corresponding_data(self, resource, resource_id):
function_dict = {"floating IP": api.network.tenant_floating_ip_get,
function_dict = {"floating IP": api.neutron.tenant_floating_ip_get,
"instance": api.nova.server_get,
"network": api.neutron.network_get,
"router": api.neutron.router_get}

+ 9
- 9
openstack_dashboard/dashboards/admin/overview/tests.py View File

@@ -44,9 +44,9 @@ class UsageViewTests(test.BaseAdminViewTests):
self.mox.StubOutWithMock(api.nova, 'extension_supported')
self.mox.StubOutWithMock(api.keystone, 'tenant_list')
self.mox.StubOutWithMock(api.neutron, 'is_extension_supported')
self.mox.StubOutWithMock(api.network, 'floating_ip_supported')
self.mox.StubOutWithMock(api.network, 'tenant_floating_ip_list')
self.mox.StubOutWithMock(api.network, 'security_group_list')
self.mox.StubOutWithMock(api.neutron, 'floating_ip_supported')
self.mox.StubOutWithMock(api.neutron, 'tenant_floating_ip_list')
self.mox.StubOutWithMock(api.neutron, 'security_group_list')
self.mox.StubOutWithMock(api.cinder, 'tenant_absolute_limits')

api.nova.extension_supported(
@@ -103,11 +103,11 @@ class UsageViewTests(test.BaseAdminViewTests):
.AndReturn(self.limits['absolute'])
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'security-group').AndReturn(True)
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.AndReturn(True)
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.cinder.tenant_absolute_limits(IsA(http.HttpRequest)) \
.AndReturn(self.cinder_limits['absolute'])
@@ -199,11 +199,11 @@ class UsageViewTests(test.BaseAdminViewTests):
.AndReturn(self.limits['absolute'])
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'security-group').AndReturn(True)
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.AndReturn(True)
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.cinder.tenant_absolute_limits(IsA(http.HttpRequest)) \
.AndReturn(self.cinder_limits['absolute'])

+ 6
- 6
openstack_dashboard/dashboards/identity/projects/tests.py View File

@@ -1566,19 +1566,19 @@ class UsageViewTests(test.BaseAdminViewTests):

def _stub_neutron_api_calls(self, neutron_sg_enabled=True):
self.mox.StubOutWithMock(api.neutron, 'is_extension_supported')
self.mox.StubOutWithMock(api.network, 'floating_ip_supported')
self.mox.StubOutWithMock(api.network, 'tenant_floating_ip_list')
self.mox.StubOutWithMock(api.neutron, 'floating_ip_supported')
self.mox.StubOutWithMock(api.neutron, 'tenant_floating_ip_list')
if neutron_sg_enabled:
self.mox.StubOutWithMock(api.network, 'security_group_list')
self.mox.StubOutWithMock(api.neutron, 'security_group_list')
api.neutron.is_extension_supported(
IsA(http.HttpRequest),
'security-group').AndReturn(neutron_sg_enabled)
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.AndReturn(True)
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
if neutron_sg_enabled:
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())

def test_usage_csv(self):

+ 1
- 1
openstack_dashboard/dashboards/project/floating_ips/forms.py View File

@@ -45,7 +45,7 @@ class FloatingIpAllocate(forms.SelfHandlingForm):
self.api_error(error_message)
return False

fip = api.network.tenant_floating_ip_allocate(request,
fip = api.neutron.tenant_floating_ip_allocate(request,
pool=data['pool'])
messages.success(request,
_('Allocated Floating IP %(ip)s.')

+ 2
- 2
openstack_dashboard/dashboards/project/floating_ips/tables.py View File

@@ -90,7 +90,7 @@ class ReleaseIPs(tables.BatchAction):
return policy.check(policy_rules, request)

def action(self, request, obj_id):
api.network.tenant_floating_ip_release(request, obj_id)
api.neutron.tenant_floating_ip_release(request, obj_id)


class AssociateIP(tables.LinkAction):
@@ -124,7 +124,7 @@ class DisassociateIP(tables.Action):
def single(self, table, request, obj_id):
try:
fip = table.get_object_by_id(filters.get_int_or_uuid(obj_id))
api.network.floating_ip_disassociate(request, fip.id)
api.neutron.floating_ip_disassociate(request, fip.id)
LOG.info('Disassociating Floating IP "%s".', obj_id)
messages.success(request,
_('Successfully disassociated Floating IP: %s')

+ 51
- 52
openstack_dashboard/dashboards/project/floating_ips/tests.py View File

@@ -37,12 +37,12 @@ NAMESPACE = "horizon:project:floating_ips"

class FloatingIpViewTests(test.TestCase):

@test.create_stubs({api.network: ('floating_ip_target_list',
@test.create_stubs({api.neutron: ('floating_ip_target_list',
'tenant_floating_ip_list',)})
def test_associate(self):
api.network.floating_ip_target_list(IsA(http.HttpRequest)) \
api.neutron.floating_ip_target_list(IsA(http.HttpRequest)) \
.AndReturn(self._get_fip_targets())
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
self.mox.ReplayAll()

@@ -54,18 +54,18 @@ class FloatingIpViewTests(test.TestCase):
# Verify that our "associated" floating IP isn't in the choices list.
self.assertNotIn(self.floating_ips.first(), choices)

@test.create_stubs({api.network: ('floating_ip_target_list',
@test.create_stubs({api.neutron: ('floating_ip_target_list',
'floating_ip_target_get_by_instance',
'tenant_floating_ip_list',)})
def test_associate_with_instance_id(self):
targets = self._get_fip_targets()
target = targets[0]
api.network.floating_ip_target_list(IsA(http.HttpRequest)) \
api.neutron.floating_ip_target_list(IsA(http.HttpRequest)) \
.AndReturn(targets)
api.network.floating_ip_target_get_by_instance(
api.neutron.floating_ip_target_get_by_instance(
IsA(http.HttpRequest), target.instance_id, targets) \
.AndReturn(target.id)
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
self.mox.ReplayAll()

@@ -100,16 +100,16 @@ class FloatingIpViewTests(test.TestCase):
def _get_target_id(port):
return '%s_%s' % (port.id, port.fixed_ips[0]['ip_address'])

@test.create_stubs({api.network: ('floating_ip_target_list',
@test.create_stubs({api.neutron: ('floating_ip_target_list',
'tenant_floating_ip_list',)})
def test_associate_with_port_id(self):
compute_port = self._get_compute_ports()[0]
associated_fips = [fip.id for fip in self.floating_ips.list()
if fip.port_id]

api.network.floating_ip_target_list(IsA(http.HttpRequest)) \
api.neutron.floating_ip_target_list(IsA(http.HttpRequest)) \
.AndReturn(self._get_fip_targets())
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
self.mox.ReplayAll()

@@ -123,7 +123,7 @@ class FloatingIpViewTests(test.TestCase):
# Verify that our "associated" floating IP isn't in the choices list.
self.assertFalse(set(associated_fips) & set(choices.keys()))

@test.create_stubs({api.network: ('floating_ip_associate',
@test.create_stubs({api.neutron: ('floating_ip_associate',
'floating_ip_target_list',
'tenant_floating_ip_list',)})
def test_associate_post(self):
@@ -132,11 +132,11 @@ class FloatingIpViewTests(test.TestCase):
compute_port = self._get_compute_ports()[0]
port_target_id = self._get_target_id(compute_port)

api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
api.network.floating_ip_target_list(IsA(http.HttpRequest)) \
api.neutron.floating_ip_target_list(IsA(http.HttpRequest)) \
.AndReturn(self._get_fip_targets())
api.network.floating_ip_associate(IsA(http.HttpRequest),
api.neutron.floating_ip_associate(IsA(http.HttpRequest),
floating_ip.id,
port_target_id)
self.mox.ReplayAll()
@@ -147,7 +147,7 @@ class FloatingIpViewTests(test.TestCase):
res = self.client.post(url, form_data)
self.assertRedirectsNoFollow(res, INDEX_URL)

@test.create_stubs({api.network: ('floating_ip_associate',
@test.create_stubs({api.neutron: ('floating_ip_associate',
'floating_ip_target_list',
'tenant_floating_ip_list',)})
def test_associate_post_with_redirect(self):
@@ -156,11 +156,11 @@ class FloatingIpViewTests(test.TestCase):
compute_port = self._get_compute_ports()[0]
port_target_id = self._get_target_id(compute_port)

api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
api.network.floating_ip_target_list(IsA(http.HttpRequest)) \
api.neutron.floating_ip_target_list(IsA(http.HttpRequest)) \
.AndReturn(self._get_fip_targets())
api.network.floating_ip_associate(IsA(http.HttpRequest),
api.neutron.floating_ip_associate(IsA(http.HttpRequest),
floating_ip.id,
port_target_id)
self.mox.ReplayAll()
@@ -172,7 +172,7 @@ class FloatingIpViewTests(test.TestCase):
res = self.client.post(url, form_data)
self.assertRedirectsNoFollow(res, next)

@test.create_stubs({api.network: ('floating_ip_associate',
@test.create_stubs({api.neutron: ('floating_ip_associate',
'floating_ip_target_list',
'tenant_floating_ip_list',)})
def test_associate_post_with_exception(self):
@@ -181,11 +181,11 @@ class FloatingIpViewTests(test.TestCase):
compute_port = self._get_compute_ports()[0]
port_target_id = self._get_target_id(compute_port)

api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
api.network.floating_ip_target_list(IsA(http.HttpRequest)) \
api.neutron.floating_ip_target_list(IsA(http.HttpRequest)) \
.AndReturn(self._get_fip_targets())
api.network.floating_ip_associate(IsA(http.HttpRequest),
api.neutron.floating_ip_associate(IsA(http.HttpRequest),
floating_ip.id,
port_target_id) \
.AndRaise(self.exceptions.nova)
@@ -198,21 +198,21 @@ class FloatingIpViewTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)

@test.create_stubs({api.nova: ('server_list',),
api.network: ('floating_ip_disassociate',
api.neutron: ('floating_ip_disassociate',
'floating_ip_pools_list',
'tenant_floating_ip_get',
'tenant_floating_ip_list',),
api.neutron: ('is_extension_supported',)})
'tenant_floating_ip_list',
'is_extension_supported',)})
def test_disassociate_post(self):
floating_ip = self.floating_ips.first()

api.nova.server_list(IsA(http.HttpRequest), detailed=False) \
.AndReturn([self.servers.list(), False])
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation')\
.AndReturn(True)
api.network.floating_ip_disassociate(IsA(http.HttpRequest),
api.neutron.floating_ip_pools_list(IsA(http.HttpRequest)) \
.AndReturn(self.pools.list())
api.neutron.floating_ip_disassociate(IsA(http.HttpRequest),
floating_ip.id)
self.mox.ReplayAll()

@@ -222,22 +222,21 @@ class FloatingIpViewTests(test.TestCase):
self.assertRedirectsNoFollow(res, INDEX_URL)

@test.create_stubs({api.nova: ('server_list',),
api.network: ('floating_ip_disassociate',
api.neutron: ('floating_ip_disassociate',
'floating_ip_pools_list',
'tenant_floating_ip_get',
'tenant_floating_ip_list',),
api.neutron: ('is_extension_supported',)})
'tenant_floating_ip_list',
'is_extension_supported',)})
def test_disassociate_post_with_exception(self):
floating_ip = self.floating_ips.first()

api.nova.server_list(IsA(http.HttpRequest), detailed=False) \
.AndReturn([self.servers.list(), False])
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'subnet_allocation')\
.AndReturn(True)

api.network.floating_ip_disassociate(IsA(http.HttpRequest),
api.neutron.floating_ip_pools_list(IsA(http.HttpRequest)) \
.AndReturn(self.pools.list())
api.neutron.floating_ip_disassociate(IsA(http.HttpRequest),
floating_ip.id) \
.AndRaise(self.exceptions.nova)
self.mox.ReplayAll()
@@ -246,7 +245,7 @@ class FloatingIpViewTests(test.TestCase):
res = self.client.post(INDEX_URL, {"action": action})
self.assertRedirectsNoFollow(res, INDEX_URL)

@test.create_stubs({api.network: ('tenant_floating_ip_list',
@test.create_stubs({api.neutron: ('tenant_floating_ip_list',
'floating_ip_pools_list',),
api.nova: ('server_list',),
quotas: ('tenant_quota_usages',),
@@ -257,10 +256,10 @@ class FloatingIpViewTests(test.TestCase):
quota_data = self.quota_usages.first()
quota_data['floating_ips']['available'] = 10

api.network.tenant_floating_ip_list(
api.neutron.tenant_floating_ip_list(
IsA(http.HttpRequest)) \
.AndReturn(floating_ips)
api.network.floating_ip_pools_list(
api.neutron.floating_ip_pools_list(
IsA(http.HttpRequest)) \
.AndReturn(floating_pools)
api.nova.server_list(
@@ -284,7 +283,7 @@ class FloatingIpViewTests(test.TestCase):
url = 'horizon:project:floating_ips:allocate'
self.assertEqual(url, allocate_action.url)

@test.create_stubs({api.network: ('tenant_floating_ip_list',
@test.create_stubs({api.neutron: ('tenant_floating_ip_list',
'floating_ip_pools_list',),
api.nova: ('server_list',),
quotas: ('tenant_quota_usages',),
@@ -295,10 +294,10 @@ class FloatingIpViewTests(test.TestCase):
quota_data = self.quota_usages.first()
quota_data['floating_ips']['available'] = 0

api.network.tenant_floating_ip_list(
api.neutron.tenant_floating_ip_list(
IsA(http.HttpRequest)) \
.AndReturn(floating_ips)
api.network.floating_ip_pools_list(
api.neutron.floating_ip_pools_list(
IsA(http.HttpRequest)) \
.AndReturn(floating_pools)
api.nova.server_list(
@@ -321,11 +320,11 @@ class FloatingIpViewTests(test.TestCase):

@test.create_stubs({api.nova: ('tenant_quota_get', 'flavor_list',
'server_list'),
api.network: ('floating_ip_pools_list',
api.neutron: ('floating_ip_pools_list',
'floating_ip_supported',
'security_group_list',
'tenant_floating_ip_list'),
api.neutron: ('is_extension_supported',
'tenant_floating_ip_list',
'is_extension_supported',
'is_router_enabled',
'tenant_quota_get',
'network_list',
@@ -368,13 +367,13 @@ class FloatingIpViewTests(test.TestCase):
api.neutron.network_list(IsA(http.HttpRequest),
tenant_id=self.tenant.id) \
.AndReturn(self.networks.list())
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.AndReturn(True)
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(self.floating_ips.list())
api.network.floating_ip_pools_list(IsA(http.HttpRequest)) \
api.neutron.floating_ip_pools_list(IsA(http.HttpRequest)) \
.AndReturn(self.pools.list())
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
self.mox.ReplayAll()


+ 3
- 3
openstack_dashboard/dashboards/project/floating_ips/views.py View File

@@ -68,7 +68,7 @@ class AllocateView(forms.ModalFormView):

def get_initial(self):
try:
pools = api.network.floating_ip_pools_list(self.request)
pools = api.neutron.floating_ip_pools_list(self.request)
except neutron_exc.ConnectionFailed:
pools = []
exceptions.handle(self.request)
@@ -88,7 +88,7 @@ class IndexView(tables.DataTableView):

def get_data(self):
try:
floating_ips = api.network.tenant_floating_ip_list(self.request)
floating_ips = api.neutron.tenant_floating_ip_list(self.request)
except neutron_exc.ConnectionFailed:
floating_ips = []
exceptions.handle(self.request)
@@ -99,7 +99,7 @@ class IndexView(tables.DataTableView):

try:
floating_ip_pools = \
api.network.floating_ip_pools_list(self.request)
api.neutron.floating_ip_pools_list(self.request)
except neutron_exc.ConnectionFailed:
floating_ip_pools = []
exceptions.handle(self.request)

+ 4
- 4
openstack_dashboard/dashboards/project/floating_ips/workflows.py View File

@@ -54,7 +54,7 @@ class AssociateIPAction(workflows.Action):
q_port_id = self.request.GET.get('port_id')
if q_instance_id:
targets = self._get_target_list()
target_id = api.network.floating_ip_target_get_by_instance(
target_id = api.neutron.floating_ip_target_get_by_instance(
self.request, q_instance_id, targets)
self.initial['instance_id'] = target_id
elif q_port_id:
@@ -69,7 +69,7 @@ class AssociateIPAction(workflows.Action):
ips = []
redirect = reverse('horizon:project:floating_ips:index')
try:
ips = api.network.tenant_floating_ip_list(self.request)
ips = api.neutron.tenant_floating_ip_list(self.request)
except neutron_exc.ConnectionFailed:
exceptions.handle(self.request, redirect=redirect)
except Exception:
@@ -88,7 +88,7 @@ class AssociateIPAction(workflows.Action):
def _get_target_list(self):
targets = []
try:
targets = api.network.floating_ip_target_list(self.request)
targets = api.neutron.floating_ip_target_list(self.request)
except Exception:
redirect = reverse('horizon:project:floating_ips:index')
exceptions.handle(self.request,
@@ -145,7 +145,7 @@ class IPAssociationWorkflow(workflows.Workflow):

def handle(self, request, data):
try:
api.network.floating_ip_associate(request,
api.neutron.floating_ip_associate(request,
data['ip_id'],
data['instance_id'])
except neutron_exc.Conflict:

+ 6
- 6
openstack_dashboard/dashboards/project/instances/tables.py View File

@@ -633,9 +633,9 @@ class AssociateIP(policy.PolicyTargetMixin, tables.LinkAction):
def allowed(self, request, instance):
if not api.base.is_service_enabled(request, 'network'):
return False
if not api.network.floating_ip_supported(request):
if not api.neutron.floating_ip_supported(request):
return False
if api.network.floating_ip_simple_associate_supported(request):
if api.neutron.floating_ip_simple_associate_supported(request):
return False
if instance.status == "ERROR":
return False
@@ -669,7 +669,7 @@ class SimpleDisassociateIP(policy.PolicyTargetMixin, tables.Action):
def allowed(self, request, instance):
if not api.base.is_service_enabled(request, 'network'):
return False
if not api.network.floating_ip_supported(request):
if not api.neutron.floating_ip_supported(request):
return False
if not conf.HORIZON_CONFIG["simple_ip_management"]:
return False
@@ -683,18 +683,18 @@ class SimpleDisassociateIP(policy.PolicyTargetMixin, tables.Action):
try:
# target_id is port_id for Neutron and instance_id for Nova Network
# (Neutron API wrapper returns a 'portid_fixedip' string)
targets = api.network.floating_ip_target_list_by_instance(
targets = api.neutron.floating_ip_target_list_by_instance(
request, instance_id)

target_ids = [t.split('_')[0] for t in targets]

fips = [fip for fip in api.network.tenant_floating_ip_list(request)
fips = [fip for fip in api.neutron.tenant_floating_ip_list(request)
if fip.port_id in target_ids]
# Removing multiple floating IPs at once doesn't work, so this pops
# off the first one.
if fips:
fip = fips.pop()
api.network.floating_ip_disassociate(request, fip.id)
api.neutron.floating_ip_disassociate(request, fip.id)
messages.success(request,
_("Successfully disassociated "
"floating IP: %s") % fip.ip)

+ 118
- 120
openstack_dashboard/dashboards/project/instances/tests.py View File

@@ -100,7 +100,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
.AndReturn(self.flavors.list())
api.nova.keypair_list(IsA(http.HttpRequest)) \
.AndReturn(self.keypairs.list())
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.nova.availability_zone_list(IsA(http.HttpRequest)) \
.AndReturn(self.availability_zones.list())
@@ -123,9 +123,11 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'is_feature_available',
),
api.glance: ('image_list_detailed',),
api.network: (
api.neutron: (
'floating_ip_simple_associate_supported',
'floating_ip_supported',
),
api.network: (
'servers_update_addresses',
),
})
@@ -148,9 +150,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(self.limits['absolute'])
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()
@@ -197,9 +199,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'tenant_absolute_limits', 'extension_supported',
'is_feature_available',),
api.glance: ('image_list_detailed',),
api.network: ('floating_ip_simple_associate_supported',
'floating_ip_supported',
'servers_update_addresses',),
api.neutron: ('floating_ip_simple_associate_supported',
'floating_ip_supported',),
api.network: ('servers_update_addresses',),
})
def test_index_flavor_list_exception(self):
servers = self.servers.list()
@@ -225,9 +227,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
AndReturn(full_flavors[server.flavor["id"]])
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(self.limits['absolute'])
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()
@@ -243,9 +245,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
'extension_supported', 'is_feature_available',),
api.glance: ('image_list_detailed',),
api.network: ('floating_ip_simple_associate_supported',
'floating_ip_supported',
'servers_update_addresses',),
api.neutron: ('floating_ip_simple_associate_supported',
'floating_ip_supported',),
api.network: ('servers_update_addresses',),
})
def test_index_with_instance_booted_from_volume(self):
volume_server = self.servers.first()
@@ -271,9 +273,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(self.limits['absolute'])
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()
@@ -988,12 +990,12 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
"extension_supported",
'is_feature_available',
),
api.network: (
api.neutron: (
"server_security_groups",
"servers_update_addresses",
"floating_ip_simple_associate_supported",
"floating_ip_supported"
)
),
api.network: ('servers_update_addresses',),
})
def _get_instance_details(self, server, qs=None,
flavor_return=None, volumes_return=None,
@@ -1024,11 +1026,11 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
else:
api.nova.flavor_get(IsA(http.HttpRequest), server.flavor['id']) \
.AndReturn(flavor_return)
api.network.server_security_groups(IsA(http.HttpRequest), server.id) \
api.neutron.server_security_groups(IsA(http.HttpRequest), server.id) \
.AndReturn(security_groups_return)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.nova.extension_supported('AdminActions', IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
@@ -1400,9 +1402,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
'extension_supported', 'is_feature_available',),
api.glance: ('image_list_detailed',),
api.network: ('floating_ip_simple_associate_supported',
'floating_ip_supported',
'servers_update_addresses',),
api.neutron: ('floating_ip_simple_associate_supported',
'floating_ip_supported',),
api.network: ('servers_update_addresses',),
})
def _test_instances_index_retrieve_password_action(self):
servers = self.servers.list()
@@ -1423,9 +1425,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(self.limits['absolute'])
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()
@@ -1470,7 +1472,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

instance_update_get_stubs = {
api.nova: ('server_get',),
api.network: ('security_group_list',
api.neutron: ('security_group_list',
'server_security_groups',)}

@helpers.create_stubs(instance_update_get_stubs)
@@ -1478,9 +1480,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
server = self.servers.first()

api.nova.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn([])
api.network.server_security_groups(IsA(http.HttpRequest),
api.neutron.server_security_groups(IsA(http.HttpRequest),
server.id).AndReturn([])

self.mox.ReplayAll()
@@ -1517,7 +1519,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

instance_update_post_stubs = {
api.nova: ('server_get', 'server_update'),
api.network: ('security_group_list',
api.neutron: ('security_group_list',
'server_security_groups',
'server_update_security_groups')}

@@ -1530,15 +1532,15 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
wanted_groups = [secgroups[1].id, secgroups[2].id]

api.nova.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(secgroups)
api.network.server_security_groups(IsA(http.HttpRequest),
api.neutron.server_security_groups(IsA(http.HttpRequest),
server.id).AndReturn(server_groups)

api.nova.server_update(IsA(http.HttpRequest),
server.id,
server.name).AndReturn(server)
api.network.server_update_security_groups(IsA(http.HttpRequest),
api.neutron.server_update_security_groups(IsA(http.HttpRequest),
server.id,
wanted_groups)

@@ -1553,14 +1555,14 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
server = self.servers.first()

api.nova.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn([])
api.network.server_security_groups(IsA(http.HttpRequest),
api.neutron.server_security_groups(IsA(http.HttpRequest),
server.id).AndReturn([])

api.nova.server_update(IsA(http.HttpRequest), server.id, server.name) \
.AndRaise(self.exceptions.nova)
api.network.server_update_security_groups(
api.neutron.server_update_security_groups(
IsA(http.HttpRequest), server.id, [])

self.mox.ReplayAll()
@@ -1573,15 +1575,15 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
server = self.servers.first()

api.nova.server_get(IsA(http.HttpRequest), server.id).AndReturn(server)
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn([])
api.network.server_security_groups(IsA(http.HttpRequest),
api.neutron.server_security_groups(IsA(http.HttpRequest),
server.id).AndReturn([])

api.nova.server_update(IsA(http.HttpRequest),
server.id,
server.name).AndReturn(server)
api.network.server_update_security_groups(
api.neutron.server_update_security_groups(
IsA(http.HttpRequest),
server.id, []).AndRaise(self.exceptions.nova)

@@ -1596,11 +1598,11 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'keypair_list',
'server_group_list',
'availability_zone_list',),
api.network: ('security_group_list',),
cinder: ('volume_snapshot_list',
'volume_list',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.glance: ('image_list_detailed',),
quotas: ('tenant_limit_usages',)})
def test_launch_instance_get(self,
@@ -1832,11 +1834,11 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'keypair_list',
'server_group_list',
'availability_zone_list',),
api.network: ('security_group_list',),
cinder: ('volume_snapshot_list',
'volume_list',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.glance: ('image_list_detailed',),
quotas: ('tenant_limit_usages',)})
def test_launch_instance_get_bootable_volumes(self,
@@ -1925,7 +1927,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_create',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
@@ -1933,7 +1936,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'availability_zone_list',
'server_group_list',
'server_create',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
@@ -2037,14 +2039,14 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_create',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
'keypair_list',
'availability_zone_list',
'server_create',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
@@ -2159,7 +2161,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_create',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('server_create',
'extension_supported',
'is_feature_available',
@@ -2167,7 +2170,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'keypair_list',
'availability_zone_list',
'server_group_list',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
@@ -2260,13 +2262,13 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
'keypair_list',
'availability_zone_list'),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',
@@ -2337,7 +2339,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_create',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
@@ -2345,7 +2348,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'availability_zone_list',
'server_group_list',
'server_create',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
@@ -2463,7 +2465,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_create',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
@@ -2471,7 +2474,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'availability_zone_list',
'server_create',
'tenant_absolute_limits'),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',
'tenant_absolute_limits'),
@@ -2532,10 +2534,10 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
api.network: ('security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
@@ -2571,7 +2573,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
.AndRaise(self.exceptions.nova)
api.nova.keypair_list(IsA(http.HttpRequest)) \
.AndReturn(self.keypairs.list())
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.nova.availability_zone_list(IsA(http.HttpRequest)) \
.AndReturn(self.availability_zones.list())
@@ -2591,7 +2593,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.neutron: ('network_list',
'port_create',
'port_delete',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
@@ -2599,7 +2602,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'availability_zone_list',
'server_group_list',
'server_create',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
@@ -2629,7 +2631,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
.AndReturn(volumes)
api.nova.flavor_list(IgnoreArg()).AndReturn(self.flavors.list())
api.nova.keypair_list(IgnoreArg()).AndReturn(self.keypairs.list())
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.nova.availability_zone_list(IsA(http.HttpRequest)) \
.AndReturn(self.availability_zones.list())
@@ -2699,13 +2701,13 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
'keypair_list',
'availability_zone_list',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_limit_usages',
@@ -2778,14 +2780,14 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
'keypair_list',
'server_group_list',
'availability_zone_list',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',
@@ -2884,13 +2886,13 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
'keypair_list',
'availability_zone_list',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',
@@ -2982,13 +2984,13 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
'keypair_list',
'availability_zone_list',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',
@@ -3013,7 +3015,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
IsA(http.HttpRequest)).AndReturn(self.flavors.list())
api.nova.keypair_list(
IsA(http.HttpRequest)).AndReturn(self.keypairs.list())
api.network.security_group_list(
api.neutron.security_group_list(
IsA(http.HttpRequest)).AndReturn(self.security_groups.list())
api.nova.availability_zone_list(
IsA(http.HttpRequest)).AndReturn(self.availability_zones.list())
@@ -3126,14 +3128,14 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
'keypair_list',
'server_group_list',
'availability_zone_list',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',
@@ -3160,7 +3162,7 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
.AndReturn(True)
api.nova.keypair_list(IsA(http.HttpRequest)) \
.AndReturn(self.keypairs.list())
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.nova.availability_zone_list(IsA(http.HttpRequest)) \
.AndReturn(self.availability_zones.list())
@@ -3244,9 +3246,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
'extension_supported', 'is_feature_available',),
api.glance: ('image_list_detailed',),
api.network: ('floating_ip_simple_associate_supported',
'floating_ip_supported',
'servers_update_addresses',),
api.neutron: ('floating_ip_simple_associate_supported',
'floating_ip_supported',),
api.network: ('servers_update_addresses',),
})
def test_launch_button_attributes(self):
servers = self.servers.list()
@@ -3270,9 +3272,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(limits)
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()
@@ -3293,9 +3295,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
'extension_supported', 'is_feature_available',),
api.glance: ('image_list_detailed',),
api.network: ('floating_ip_simple_associate_supported',
'floating_ip_supported',
'servers_update_addresses',),
api.neutron: ('floating_ip_simple_associate_supported',
'floating_ip_supported',),
api.network: ('servers_update_addresses',),
})
def test_launch_button_disabled_when_quota_exceeded(self):
servers = self.servers.list()
@@ -3319,9 +3321,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(limits)
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()
@@ -3339,7 +3341,8 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

@helpers.create_stubs({api.glance: ('image_list_detailed',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.nova: ('extension_supported',
'is_feature_available',
'flavor_list',
@@ -3348,7 +3351,6 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'server_group_list',
'tenant_absolute_limits',
'server_create',),
api.network: ('security_group_list',),
cinder: ('volume_list',
'volume_snapshot_list',),
quotas: ('tenant_quota_usages',)})
@@ -3445,9 +3447,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
'extension_supported', 'is_feature_available',),
api.glance: ('image_list_detailed',),
api.network: ('floating_ip_simple_associate_supported',
'floating_ip_supported',
'servers_update_addresses',),
api.neutron: ('floating_ip_simple_associate_supported',
'floating_ip_supported',),
api.network: ('servers_update_addresses',),
})
def test_index_options_after_migrate(self):
servers = self.servers.list()
@@ -3471,9 +3473,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.network.servers_update_addresses(IsA(http.HttpRequest), servers)
api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(self.limits['absolute'])
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()
@@ -3487,11 +3489,11 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
'flavor_list',
'keypair_list',
'availability_zone_list'),
api.network: ('security_group_list',),
cinder: ('volume_snapshot_list',
'volume_list',),
api.neutron: ('network_list',
'port_list'),
'port_list',
'security_group_list',),
api.glance: ('image_list_detailed',),
quotas: ('tenant_limit_usages',)})
def test_select_default_keypair_if_only_one(self):
@@ -3537,13 +3539,15 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
def test_select_default_keypair_if_only_one_glance_v1(self):
self.test_select_default_keypair_if_only_one()

@helpers.create_stubs({api.network: ('floating_ip_target_list_by_instance',
'tenant_floating_ip_list',
'floating_ip_disassociate',
'servers_update_addresses',),
api.glance: ('image_list_detailed',),
api.nova: ('server_list',
'flavor_list')})
@helpers.create_stubs({
api.neutron: ('floating_ip_target_list_by_instance',
'tenant_floating_ip_list',
'floating_ip_disassociate',),
api.network: ('servers_update_addresses',),
api.glance: ('image_list_detailed',),
api.nova: ('server_list',
'flavor_list'),
})
def test_disassociate_floating_ip(self):
servers = self.servers.list()
server = servers[0]
@@ -3557,12 +3561,12 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova.flavor_list(IgnoreArg()).AndReturn(self.flavors.list())
api.glance.image_list_detailed(IgnoreArg()) \
.AndReturn((self.images.list(), False, False))
api.network.floating_ip_target_list_by_instance(
api.neutron.floating_ip_target_list_by_instance(
IsA(http.HttpRequest),
server.id).AndReturn([server.id, ])
api.network.tenant_floating_ip_list(
api.neutron.tenant_floating_ip_list(
IsA(http.HttpRequest)).AndReturn([fip])
api.network.floating_ip_disassociate(
api.neutron.floating_ip_disassociate(
IsA(http.HttpRequest), fip.id)

self.mox.ReplayAll()
@@ -3911,9 +3915,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
api.nova: ('flavor_list', 'server_list', 'tenant_absolute_limits',
'extension_supported', 'is_feature_available',),
api.glance: ('image_list_detailed',),
api.network: ('floating_ip_simple_associate_supported',
'floating_ip_supported',
'servers_update_addresses',),
api.neutron: ('floating_ip_simple_associate_supported',
'floating_ip_supported',),
api.network: ('servers_update_addresses',),
})
def test_index_form_action_with_pagination(self):
"""The form action on the next page should have marker
@@ -3948,9 +3952,9 @@ class InstanceTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):

api.nova.tenant_absolute_limits(IsA(http.HttpRequest), reserved=True) \
.MultipleTimes().AndReturn(self.limits['absolute'])
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.network.floating_ip_simple_associate_supported(
api.neutron.floating_ip_simple_associate_supported(
IsA(http.HttpRequest)).MultipleTimes().AndReturn(True)

self.mox.ReplayAll()
@@ -4067,8 +4071,7 @@ class InstanceAjaxTests(helpers.TestCase):
"flavor_get",
"extension_supported",
"is_feature_available"),
api.network: ('servers_update_addresses',),
api.neutron: ("is_extension_supported",)})
api.network: ('servers_update_addresses',)})
def test_row_update(self):
server = self.servers.first()
instance_id = server.id
@@ -4083,13 +4086,12 @@ class InstanceAjaxTests(helpers.TestCase):
).MultipleTimes().AndReturn(True)
api.nova.extension_supported('Shelve', IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'security-group')\
.MultipleTimes().AndReturn(True)
api.nova.server_get(IsA(http.HttpRequest), instance_id)\
.AndReturn(server)
api.nova.flavor_get(IsA(http.HttpRequest), flavor_id)\
.AndReturn(full_flavors[flavor_id])
api.network.servers_update_addresses(IsA(http.HttpRequest), server) \
.AndReturn(None)

self.mox.ReplayAll()

@@ -4105,7 +4107,6 @@ class InstanceAjaxTests(helpers.TestCase):
"flavor_get",
'is_feature_available',
"extension_supported"),
api.neutron: ("is_extension_supported",),
api.network: ('servers_update_addresses',)})
def test_row_update_instance_error(self):
server = self.servers.first()
@@ -4132,13 +4133,12 @@ class InstanceAjaxTests(helpers.TestCase):
).MultipleTimes().AndReturn(True)
api.nova.extension_supported('Shelve', IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'security-group')\
.MultipleTimes().AndReturn(True)
api.nova.server_get(IsA(http.HttpRequest), instance_id)\
.AndReturn(server)
api.nova.flavor_get(IsA(http.HttpRequest), flavor_id)\
.AndReturn(full_flavors[flavor_id])
api.network.servers_update_addresses(IsA(http.HttpRequest), server) \
.AndReturn(None)

self.mox.ReplayAll()

@@ -4164,8 +4164,7 @@ class InstanceAjaxTests(helpers.TestCase):
"flavor_get",
'is_feature_available',
"extension_supported"),
api.neutron: ("is_extension_supported",
"servers_update_addresses",)})
api.network: ('servers_update_addresses',)})
def test_row_update_flavor_not_found(self):
server = self.servers.first()
instance_id = server.id
@@ -4178,13 +4177,12 @@ class InstanceAjaxTests(helpers.TestCase):
).MultipleTimes().AndReturn(True)
api.nova.extension_supported('Shelve', IsA(http.HttpRequest)) \
.MultipleTimes().AndReturn(True)
api.neutron.is_extension_supported(IsA(http.HttpRequest),
'security-group')\
.MultipleTimes().AndReturn(True)
api.nova.server_get(IsA(http.HttpRequest), instance_id)\
.AndReturn(server)
api.nova.flavor_get(IsA(http.HttpRequest), server.flavor["id"])\
.AndRaise(self.exceptions.nova)
api.network.servers_update_addresses(IsA(http.HttpRequest), server) \
.AndReturn(None)

self.mox.ReplayAll()


+ 1
- 1
openstack_dashboard/dashboards/project/instances/views.py View File

@@ -375,7 +375,7 @@ class DetailView(tabs.TabView):
exceptions.handle(self.request, msg, ignore=True)

try:
instance.security_groups = api.network.server_security_groups(
instance.security_groups = api.neutron.server_security_groups(
self.request, instance_id)
except Exception:
msg = _('Unable to retrieve security groups for instance '

+ 1
- 1
openstack_dashboard/dashboards/project/instances/workflows/create_instance.py View File

@@ -580,7 +580,7 @@ class SetAccessControlsAction(workflows.Action):

def populate_groups_choices(self, request, context):
try:
groups = api.network.security_group_list(request)
groups = api.neutron.security_group_list(request)
security_group_list = [(sg.id, sg.name) for sg in groups]
except Exception:
exceptions.handle(request,

+ 3
- 3
openstack_dashboard/dashboards/project/instances/workflows/update_instance.py View File

@@ -48,14 +48,14 @@ class UpdateInstanceSecurityGroupsAction(workflows.MembershipAction):
# Get list of available security groups
all_groups = []
try:
all_groups = api.network.security_group_list(request)
all_groups = api.neutron.security_group_list(request)
except Exception:
exceptions.handle(request, err_msg)
groups_list = [(group.id, group.name) for group in all_groups]

instance_groups = []
try:
instance_groups = api.network.server_security_groups(request,
instance_groups = api.neutron.server_security_groups(request,
instance_id)
except Exception:
exceptions.handle(request, err_msg)
@@ -69,7 +69,7 @@ class UpdateInstanceSecurityGroupsAction(workflows.MembershipAction):
instance_id = data['instance_id']
wanted_groups = map(filters.get_int_or_uuid, data['wanted_groups'])
try:
api.network.server_update_security_groups(request, instance_id,
api.neutron.server_update_security_groups(request, instance_id,
wanted_groups)
except Exception as e:
exceptions.handle(request, str(e))

+ 10
- 10
openstack_dashboard/dashboards/project/overview/tests.py View File

@@ -67,20 +67,20 @@ class UsageViewTests(test.TestCase):
api.cinder.tenant_absolute_limits(IsA(http.HttpRequest)) \
.AndReturn(self.cinder_limits['absolute'])

@test.create_stubs({api.neutron: ('is_extension_supported',),
api.network: ('floating_ip_supported',
@test.create_stubs({api.neutron: ('is_extension_supported',
'floating_ip_supported',
'tenant_floating_ip_list',
'security_group_list')})
def _stub_neutron_api_calls(self, neutron_sg_enabled=True):
api.neutron.is_extension_supported(
IsA(http.HttpRequest),
'security-group').AndReturn(neutron_sg_enabled)
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.AndReturn(True)
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
if neutron_sg_enabled:
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())

def _nova_stu_enabled(self, exception=False, overview_days_range=1):
@@ -248,8 +248,8 @@ class UsageViewTests(test.TestCase):
self._test_usage_with_neutron(neutron_fip_enabled=False)

@test.create_stubs({api.neutron: ('tenant_quota_get',
'is_extension_supported'),
api.network: ('floating_ip_supported',
'is_extension_supported',
'floating_ip_supported',
'tenant_floating_ip_list',
'security_group_list')})
def _test_usage_with_neutron_prepare(self):
@@ -264,13 +264,13 @@ class UsageViewTests(test.TestCase):
api.neutron.is_extension_supported(
IsA(http.HttpRequest),
'security-group').AndReturn(neutron_sg_enabled)
api.network.floating_ip_supported(IsA(http.HttpRequest)) \
api.neutron.floating_ip_supported(IsA(http.HttpRequest)) \
.AndReturn(neutron_fip_enabled)
if neutron_fip_enabled:
api.network.tenant_floating_ip_list(IsA(http.HttpRequest)) \
api.neutron.tenant_floating_ip_list(IsA(http.HttpRequest)) \
.AndReturn(self.floating_ips.list())
if neutron_sg_enabled:
api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.neutron.tenant_quota_get(IsA(http.HttpRequest), self.tenant.id) \
.AndReturn(self.neutron_quotas.first())

+ 3
- 3
openstack_dashboard/dashboards/project/security_groups/forms.py View File

@@ -78,7 +78,7 @@ class CreateGroup(GroupBase):
error_message = _('Unable to create security group: %s')

def _call_network_api(self, request, data):
return api.network.security_group_create(request,
return api.neutron.security_group_create(request,
data['name'],
data['description'])

@@ -90,7 +90,7 @@ class UpdateGroup(GroupBase):
id = forms.CharField(widget=forms.HiddenInput())

def _call_network_api(self, request, data):
return api.network.security_group_update(request,
return api.neutron.security_group_update(request,
data['id'],
data['name'],
data['description'])
@@ -415,7 +415,7 @@ class AddRule(forms.SelfHandlingForm):
redirect = reverse("horizon:project:security_groups:detail",
args=[data['id']])
try:
rule = api.network.security_group_rule_create(
rule = api.neutron.security_group_rule_create(
request,
filters.get_int_or_uuid(data['id']),
data['direction'],

+ 2
- 2
openstack_dashboard/dashboards/project/security_groups/tables.py View File

@@ -52,7 +52,7 @@ class DeleteGroup(policy.PolicyTargetMixin, tables.DeleteAction):
return security_group.name != 'default'

def delete(self, request, obj_id):
api.network.security_group_delete(request, obj_id)
api.neutron.security_group_delete(request, obj_id)


class CreateGroup(tables.LinkAction):
@@ -149,7 +149,7 @@ class DeleteRule(tables.DeleteAction):
)

def delete(self, request, obj_id):
api.network.security_group_rule_delete(request, obj_id)
api.neutron.security_group_rule_delete(request, obj_id)

def get_success_url(self, request):
sg_id = self.table.kwargs['security_group_id']

+ 76
- 76
openstack_dashboard/dashboards/project/security_groups/tests.py View File

@@ -65,14 +65,14 @@ class SecurityGroupsViewTests(test.TestCase):
self.edit_url = reverse(SG_ADD_RULE_VIEW, args=[sec_group.id])
self.update_url = reverse(SG_UPDATE_VIEW, args=[sec_group.id])

@test.create_stubs({api.network: ('security_group_list',),
@test.create_stubs({api.neutron: ('security_group_list',),
quotas: ('tenant_quota_usages',)})
def test_index(self):
sec_groups = self.security_groups.list()
quota_data = self.quota_usages.first()
quota_data['security_groups']['available'] = 10

api.network.security_group_list(IsA(http.HttpRequest)) \
api.neutron.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(sec_groups)
quotas.tenant_quota_usages(IsA(http.HttpRequest)).MultipleTimes() \
.AndReturn(quota_data)
@@ -96,14 +96,14 @@ class SecurityGroupsViewTests(test.TestCase):
all([sec_groups_from_ctx[i].name <= sec_groups_from_ctx[i + 1].name
for i in range(len(sec_groups_from_ctx) - 1)]))

@test.create_stubs({api.network: ('security_group_list',),
@test.create_stubs({api.neutron: ('security_group_list',),
quotas: ('tenant_quota_usages',)})
def test_create_button_attributes(self):
sec_groups = self.security_groups.list()
quota_data = self.quota_usages.first()
quota_data['security_groups']['available'] = 10