From 242cc3ff31713e66e9e39590a0d4df5a21f2a46c Mon Sep 17 00:00:00 2001 From: Tzu-Mainn Chen Date: Mon, 15 Jul 2013 16:47:03 -0400 Subject: [PATCH] Update management to tuskar Renamed management to tuskar for API related code Change-Id: I52f1a654ae58fd235378caa61e0ef5e81c16d2db --- openstack_dashboard/api/__init__.py | 2 + .../api/{management.py => tuskar.py} | 0 .../resource_management/flavors/forms.py | 6 +- .../resource_management/flavors/tables.py | 2 +- .../resource_management/flavors/tests.py | 46 ++++---- .../resource_management/flavors/views.py | 6 +- .../resource_management/nodes/tables.py | 2 +- .../resource_management/nodes/tests.py | 6 +- .../resource_management/nodes/views.py | 4 +- .../resource_management/racks/forms.py | 6 +- .../resource_management/racks/tables.py | 2 +- .../resource_management/racks/tests.py | 24 ++-- .../resource_management/racks/views.py | 4 +- .../resource_management/racks/workflows.py | 10 +- .../resource_classes/tables.py | 2 +- .../resource_classes/tests.py | 106 +++++++++--------- .../resource_classes/views.py | 4 +- .../resource_classes/workflows.py | 14 +-- .../resource_management/tabs.py | 12 +- .../resource_management/tests.py | 22 ++-- openstack_dashboard/exceptions.py | 2 +- .../{management_tests.py => tuskar_tests.py} | 32 +++--- .../{management_data.py => tuskar_data.py} | 18 +-- openstack_dashboard/test/test_data/utils.py | 2 +- 24 files changed, 168 insertions(+), 166 deletions(-) rename openstack_dashboard/api/{management.py => tuskar.py} (100%) rename openstack_dashboard/test/api_tests/{management_tests.py => tuskar_tests.py} (65%) rename openstack_dashboard/test/test_data/{management_data.py => tuskar_data.py} (89%) diff --git a/openstack_dashboard/api/__init__.py b/openstack_dashboard/api/__init__.py index 7c9f83000..0e0141f34 100644 --- a/openstack_dashboard/api/__init__.py +++ b/openstack_dashboard/api/__init__.py @@ -44,6 +44,7 @@ from openstack_dashboard.api import network from openstack_dashboard.api import neutron from openstack_dashboard.api import nova from openstack_dashboard.api import swift +from openstack_dashboard.api import tuskar assert base assert cinder @@ -55,3 +56,4 @@ assert nova assert neutron assert lbaas assert swift +assert tuskar diff --git a/openstack_dashboard/api/management.py b/openstack_dashboard/api/tuskar.py similarity index 100% rename from openstack_dashboard/api/management.py rename to openstack_dashboard/api/tuskar.py diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/forms.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/forms.py index f9a37780d..633f10481 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/forms.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/forms.py @@ -53,7 +53,7 @@ class CreateFlavor(forms.SelfHandlingForm): name = cleaned_data.get('name') flavor_id = self.initial.get('flavor_id', None) try: - flavors = api.management.Flavor.list(self.request) + flavors = api.tuskar.Flavor.list(self.request) except: flavors = [] msg = _('Unable to get flavor list') @@ -70,7 +70,7 @@ class CreateFlavor(forms.SelfHandlingForm): def handle(self, request, data): try: - flavor = api.management.Flavor.create( + flavor = api.tuskar.Flavor.create( request, data['name'], data['vcpu'], @@ -90,7 +90,7 @@ class EditFlavor(CreateFlavor): def handle(self, request, data): try: - flavor = api.management.Flavor.update( + flavor = api.tuskar.Flavor.update( self.request, self.initial['flavor_id'], data['name'], diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tables.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tables.py index a849ab2b6..5be4683a7 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tables.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tables.py @@ -30,7 +30,7 @@ class DeleteFlavors(tables.DeleteAction): data_type_plural = _("Flavors") def delete(self, request, obj_id): - api.management.Flavor.delete(request, obj_id) + api.tuskar.Flavor.delete(request, obj_id) class CreateFlavor(tables.LinkAction): diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py index 71182367d..9120172f3 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/tests.py @@ -8,13 +8,13 @@ from openstack_dashboard.test import helpers as test class FlavorsTests(test.BaseAdminViewTests): - @test.create_stubs({api.management.Flavor: ('list', 'create')}) + @test.create_stubs({api.tuskar.Flavor: ('list', 'create')}) def test_create_flavor(self): - flavor = self.management_flavors.first() + flavor = self.tuskar_flavors.first() - api.management.Flavor.list( + api.tuskar.Flavor.list( IsA(http.HttpRequest)).AndReturn([]) - api.management.Flavor.create(IsA(http.HttpRequest), + api.tuskar.Flavor.create(IsA(http.HttpRequest), flavor.name, 0, 0, 0, 0, 0).AndReturn(flavor) self.mox.ReplayAll() @@ -36,11 +36,11 @@ class FlavorsTests(test.BaseAdminViewTests): self.assertRedirectsNoFollow( resp, reverse('horizon:infrastructure:resource_management:index')) - @test.create_stubs({api.management.Flavor: ('list', 'update', 'get')}) + @test.create_stubs({api.tuskar.Flavor: ('list', 'update', 'get')}) def test_edit_flavor_get(self): - flavor = self.management_flavors.first() # has no extra spec + flavor = self.tuskar_flavors.first() # has no extra spec - api.management.Flavor.get(IsA(http.HttpRequest), + api.tuskar.Flavor.get(IsA(http.HttpRequest), flavor.id).AndReturn(flavor) self.mox.ReplayAll() @@ -52,17 +52,17 @@ class FlavorsTests(test.BaseAdminViewTests): self.assertTemplateUsed( resp, "infrastructure/resource_management/flavors/edit.html") - @test.create_stubs({api.management.Flavor: ('list', 'update', 'get')}) + @test.create_stubs({api.tuskar.Flavor: ('list', 'update', 'get')}) def test_edit_flavor_post(self): - flavor = self.management_flavors.first() # has no extra spec + flavor = self.tuskar_flavors.first() # has no extra spec - api.management.Flavor.list( - IsA(http.HttpRequest)).AndReturn(self.management_flavors.list()) - api.management.Flavor.update(IsA(http.HttpRequest), + api.tuskar.Flavor.list( + IsA(http.HttpRequest)).AndReturn(self.tuskar_flavors.list()) + api.tuskar.Flavor.update(IsA(http.HttpRequest), flavor.id, flavor.name, 0, 0, 0, 0, 0).AndReturn(flavor) - api.management.Flavor.get(IsA(http.HttpRequest), + api.tuskar.Flavor.get(IsA(http.HttpRequest), flavor.id).AndReturn(flavor) self.mox.ReplayAll() @@ -82,13 +82,13 @@ class FlavorsTests(test.BaseAdminViewTests): self.assertRedirectsNoFollow( resp, reverse('horizon:infrastructure:resource_management:index')) - @test.create_stubs({api.management.Flavor: ('list', 'delete')}) + @test.create_stubs({api.tuskar.Flavor: ('list', 'delete')}) def test_delete_flavor(self): - flavor = self.management_flavors.first() + flavor = self.tuskar_flavors.first() - api.management.Flavor.list(IsA(http.HttpRequest)).\ - AndReturn(self.management_flavors.list()) - api.management.Flavor.delete(IsA(http.HttpRequest), flavor.id) + api.tuskar.Flavor.list(IsA(http.HttpRequest)).\ + AndReturn(self.tuskar_flavors.list()) + api.tuskar.Flavor.delete(IsA(http.HttpRequest), flavor.id) self.mox.ReplayAll() form_data = {'action': 'flavors__delete__%s' % flavor.id} @@ -99,14 +99,14 @@ class FlavorsTests(test.BaseAdminViewTests): self.assertRedirectsNoFollow( res, reverse('horizon:infrastructure:resource_management:index')) - @test.create_stubs({api.management.Flavor: ('get',)}) + @test.create_stubs({api.tuskar.Flavor: ('get',)}) def test_detail_flavor(self): - flavor = self.management_flavors.first() + flavor = self.tuskar_flavors.first() - api.management.Flavor.get(IsA(http.HttpRequest), + api.tuskar.Flavor.get(IsA(http.HttpRequest), flavor.id).AndReturn(flavor) - api.management.Flavor.resource_classes = self. \ - management_resource_classes + api.tuskar.Flavor.resource_classes = self. \ + tuskar_resource_classes self.mox.ReplayAll() diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py index f49d2ab15..670fef83a 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/flavors/views.py @@ -57,7 +57,7 @@ class EditView(forms.ModalFormView): def get_initial(self): try: - flavor = api.management.Flavor.get( + flavor = api.tuskar.Flavor.get( self.request, self.kwargs['flavor_id']) except: exceptions.handle(self.request, @@ -84,7 +84,7 @@ class DetailView(tabs.TabView): if not hasattr(self, "_flavor"): try: flavor_id = self.kwargs['flavor_id'] - flavor = api.management.Flavor.get(self.request, flavor_id) + flavor = api.tuskar.Flavor.get(self.request, flavor_id) except: redirect = reverse('horizon:infrastructure:' 'resource_management:index') @@ -106,7 +106,7 @@ class ActiveInstancesDataView(View): def get(self, request, *args, **kwargs): try: - flavor = api.management.Flavor.get( + flavor = api.tuskar.Flavor.get( self.request, self.kwargs['flavor_id']) values = flavor.vms_over_time( datetime.now() - timedelta(days=7), datetime.now()) diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/tables.py b/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/tables.py index 9d77f4429..0b54922db 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/tables.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/tables.py @@ -24,7 +24,7 @@ class DeleteNodes(tables.DeleteAction): data_type_plural = _("Nodes") def delete(self, request, obj_id): - api.management.node_delete(request, obj_id) + api.tuskar.node_delete(request, obj_id) class NodesFilterAction(tables.FilterAction): diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/tests.py b/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/tests.py index 3ccb8ce08..16865b8bc 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/tests.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/tests.py @@ -9,11 +9,11 @@ class ResourceViewTests(test.BaseAdminViewTests): unracked_page = reverse('horizon:infrastructure:' 'resource_management:nodes:unracked') - @test.create_stubs({api.management.Node: ('list_unracked',), }) + @test.create_stubs({api.tuskar.Node: ('list_unracked',), }) def test_unracked(self): - unracked_nodes = self.management_racks.list() + unracked_nodes = self.tuskar_racks.list() - api.management.Node.list_unracked(IsA(http.HttpRequest)) \ + api.tuskar.Node.list_unracked(IsA(http.HttpRequest)) \ .AndReturn(unracked_nodes) self.mox.ReplayAll() diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/views.py b/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/views.py index a761b8ab8..ca73a49ac 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/views.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/nodes/views.py @@ -31,7 +31,7 @@ class UnrackedView(tables.DataTableView): def get_data(self): try: - nodes = api.management.Node.list_unracked(self.request) + nodes = api.tuskar.Node.list_unracked(self.request) except: nodes = [] exceptions.handle(self.request, @@ -52,7 +52,7 @@ class DetailView(tabs.TabView): if not hasattr(self, "_node"): try: node_id = self.kwargs['node_id'] - node = api.management.Node.get(self.request, node_id) + node = api.tuskar.Node.get(self.request, node_id) except: redirect = reverse('horizon:infrastructure:' 'resource_management:index') diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/forms.py b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/forms.py index ac7ea0cb8..200d5eff1 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/forms.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/forms.py @@ -68,13 +68,13 @@ class UploadRack(forms.SelfHandlingForm): racks = CSVRack.from_str(base64.b64decode(racks_str)) # get the resource class ids by resource class names rclass_ids = dict((rc.name, rc.id) for rc in - api.management.ResourceClass.list(request)) + api.tuskar.ResourceClass.list(request)) for rack in racks: try: - r = api.management.Rack.create(request, rack.name, + r = api.tuskar.Rack.create(request, rack.name, rclass_ids[rack.resource_class], rack.region, rack.subnet) - api.management.Rack.register_nodes(r, rack.nodes) + api.tuskar.Rack.register_nodes(r, rack.nodes) successes.append(rack.name) except: LOG.exception("Exception in processing rack CSV file.") diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tables.py b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tables.py index 463ebb4f5..c42bf414b 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tables.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tables.py @@ -28,7 +28,7 @@ class DeleteRacks(tables.DeleteAction): data_type_plural = _("Racks") def delete(self, request, obj_id): - api.management.Rack.delete(request, obj_id) + api.tuskar.Rack.delete(request, obj_id) class CreateRack(tables.LinkAction): diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tests.py b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tests.py index 5cbf04142..7ad2f1a80 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tests.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tests.py @@ -35,9 +35,9 @@ class RackViewTests(test.BaseAdminViewTests): # FIXME (mawagner) - After moving EditRack to use workflows, we need # to circle back and fix these tests. # - @test.create_stubs({api.management.Rack: ('create',)}) + @test.create_stubs({api.tuskar.Rack: ('create',)}) def test_create_rack_post(self): - api.management.Rack.create(IsA(http.request.HttpRequest), 'New Rack', + api.tuskar.Rack.create(IsA(http.request.HttpRequest), 'New Rack', u'2', 'Tokyo', '1.2.3.4').AndReturn(None) self.mox.ReplayAll() @@ -56,13 +56,13 @@ class RackViewTests(test.BaseAdminViewTests): self.assertTemplateUsed(rack, 'horizon/common/_workflow_base.html') - @test.create_stubs({api.management.Rack: ('update',)}) + @test.create_stubs({api.tuskar.Rack: ('update',)}) def test_edit_rack_post(self): data = {'name': 'Updated Rack', 'resource_class_id': u'1', 'rack_id': u'1', 'location': 'New Location', 'subnet': '127.10.10.0/24', 'node_macs': 'foo'} - api.management.Rack.update(u'1', data) + api.tuskar.Rack.update(u'1', data) self.mox.ReplayAll() url = reverse('horizon:infrastructure:resource_management:' + @@ -72,10 +72,10 @@ class RackViewTests(test.BaseAdminViewTests): self.assertMessageCount(success=1) self.assertRedirectsNoFollow(response, self.index_page) - @test.create_stubs({api.management.Rack: ('delete',)}) + @test.create_stubs({api.tuskar.Rack: ('delete',)}) def test_delete_rack(self): rack_id = u'1' - api.management.Rack.delete(IsA(http.request.HttpRequest), rack_id) \ + api.tuskar.Rack.delete(IsA(http.request.HttpRequest), rack_id) \ .AndReturn(None) self.mox.ReplayAll() data = {'action': 'racks__delete__%s' % rack_id} @@ -121,16 +121,16 @@ class RackViewTests(test.BaseAdminViewTests): self.assertEqual(resp.context['form']['uploaded_data'].value(), None) - @test.create_stubs({api.management.Rack: ('create', 'register_nodes'), - api.management.ResourceClass: ('list',)}) + @test.create_stubs({api.tuskar.Rack: ('create', 'register_nodes'), + api.tuskar.ResourceClass: ('list',)}) def test_upload_rack_create(self): - api.management.Rack.create(IsA(http.request.HttpRequest), 'Rack1', + api.tuskar.Rack.create(IsA(http.request.HttpRequest), 'Rack1', '1', 'regionX', '192.168.111.0/24').AndReturn(None) - api.management.Rack.register_nodes(IgnoreArg(), + api.tuskar.Rack.register_nodes(IgnoreArg(), IgnoreArg()).AndReturn(None) - api.management.ResourceClass.list( + api.tuskar.ResourceClass.list( IsA(http.request.HttpRequest)).AndReturn( - self.management_resource_classes.list()) + self.tuskar_resource_classes.list()) self.mox.ReplayAll() csv_data = 'Rack1,rclass1,192.168.111.0/24,regionX,f0:dd:f1:da:f9:b5 '\ 'f2:de:f1:da:f9:66 f2:de:ff:da:f9:67' diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/views.py b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/views.py index a835cbad2..2cccd98b3 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/views.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/views.py @@ -66,7 +66,7 @@ class EditView(workflows.WorkflowView): workflow_class = EditRack def get_initial(self): - obj = api.management.Rack.get(None, + obj = api.tuskar.Rack.get(None, rack_id=self.kwargs['rack_id']) mac_str = "\n".join([x.mac_address for x in obj.nodes]) return {'name': obj.name, 'resource_class_id': obj.resource_class_id, @@ -87,7 +87,7 @@ class DetailView(tabs.TabView): if not hasattr(self, "_rack"): try: rack_id = self.kwargs['rack_id'] - rack = api.management.Rack.get(self.request, rack_id) + rack = api.tuskar.Rack.get(self.request, rack_id) except: redirect = reverse('horizon:infrastructure:' 'resource_management:index') diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/workflows.py b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/workflows.py index e2eb57f7b..1fceb7f10 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/workflows.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/workflows.py @@ -69,7 +69,7 @@ class RackCreateInfoAction(workflows.Action): location = cleaned_data.get('location') subnet = cleaned_data.get('subnet') try: - racks = api.management.Rack.list(self.request) + racks = api.tuskar.Rack.list(self.request) except: racks = [] exceptions.check_message(['Connection', 'refused'], @@ -93,7 +93,7 @@ class RackCreateInfoAction(workflows.Action): def __init__(self, request, *args, **kwargs): super(RackCreateInfoAction, self).__init__(request, *args, **kwargs) resource_class_id_choices = [('', _("Select a Resource Class"))] - for rc in api.management.ResourceClass.list(request): + for rc in api.tuskar.ResourceClass.list(request): resource_class_id_choices.append((rc.id, rc.name)) self.fields['resource_class_id'].choices = resource_class_id_choices @@ -144,14 +144,14 @@ class CreateRack(workflows.Workflow): def handle(self, request, data): try: - rack = api.management.Rack.create(request, data['name'], + rack = api.tuskar.Rack.create(request, data['name'], data['resource_class_id'], data['location'], data['subnet']) if data['node_macs'] is not None: nodes = data['node_macs'].splitlines(False) - api.management.Rack.register_nodes(rack, nodes) + api.tuskar.Rack.register_nodes(rack, nodes) return True except: @@ -169,7 +169,7 @@ class EditRack(CreateRack): def handle(self, request, data): try: rack_id = self.context['rack_id'] - rack = api.management.Rack.update(rack_id, data) + rack = api.tuskar.Rack.update(rack_id, data) return True except: diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/tables.py b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/tables.py index dc73f34d3..94e0b906c 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/tables.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/tables.py @@ -55,7 +55,7 @@ class DeleteResourceClass(tables.DeleteAction): def delete(self, request, obj_id): try: - api.management.ResourceClass.delete(request, obj_id) + api.tuskar.ResourceClass.delete(request, obj_id) except: msg = _('Failed to delete resource class %s') % obj_id LOG.info(msg) diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/tests.py b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/tests.py index ffb340a38..c50ff569b 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/tests.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/tests.py @@ -22,16 +22,16 @@ from openstack_dashboard.test import helpers as test class ResourceClassViewTests(test.BaseAdminViewTests): @test.create_stubs({ - api.management.Flavor: ('list',), - api.management.Rack: ('list',) + api.tuskar.Flavor: ('list',), + api.tuskar.Rack: ('list',) }) def test_create_resource_class_get(self): - all_flavors = self.management_flavors.list() - all_racks = self.management_racks.list() + all_flavors = self.tuskar_flavors.list() + all_racks = self.tuskar_racks.list() - api.management.Flavor.\ + api.tuskar.Flavor.\ list(IsA(http.HttpRequest)).AndReturn(all_flavors) - api.management.Rack.\ + api.tuskar.Rack.\ list(IsA(http.HttpRequest), True).AndReturn(all_racks) self.mox.ReplayAll() @@ -42,26 +42,26 @@ class ResourceClassViewTests(test.BaseAdminViewTests): self.assertEqual(res.status_code, 200) @test.create_stubs({ - api.management.ResourceClass: ('create', 'set_flavors', + api.tuskar.ResourceClass: ('create', 'set_flavors', 'set_racks'), - api.management.Flavor: ('list',), - api.management.Rack: ('list',) + api.tuskar.Flavor: ('list',), + api.tuskar.Rack: ('list',) }) def test_create_resource_class_post(self): - new_resource_class = self.management_resource_classes.first() + new_resource_class = self.tuskar_resource_classes.first() new_unique_name = "unique_name_for_sure" add_flavors_ids = [] add_max_vms = {} add_racks_ids = [] - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ create(IsA(http.HttpRequest), name=new_unique_name, service_type=new_resource_class.service_type).\ AndReturn(new_resource_class) - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ set_racks(IsA(http.HttpRequest), add_racks_ids) - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ set_flavors(IsA(http.HttpRequest), add_flavors_ids, add_max_vms) self.mox.ReplayAll() @@ -76,13 +76,13 @@ class ResourceClassViewTests(test.BaseAdminViewTests): ("%s?tab=resource_management_tabs__resource_classes_tab" % reverse("horizon:infrastructure:resource_management:index"))) - @test.create_stubs({api.management.ResourceClass: ('get',)}) + @test.create_stubs({api.tuskar.ResourceClass: ('get',)}) def test_edit_resource_class_get(self): - resource_class = self.management_resource_classes.first() + resource_class = self.tuskar_resource_classes.first() all_flavors = [] all_racks = [] - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ get(IsA(http.HttpRequest), resource_class.id).MultipleTimes().\ AndReturn(resource_class) self.mox.ReplayAll() @@ -90,8 +90,8 @@ class ResourceClassViewTests(test.BaseAdminViewTests): # FIXME I should probably track the racks and flavors methods # so maybe they shouldn't be a @property # properties set - api.management.ResourceClass.all_racks = all_racks - api.management.ResourceClass.all_flavors = all_flavors + api.tuskar.ResourceClass.all_racks = all_racks + api.tuskar.ResourceClass.all_flavors = all_flavors url = reverse( 'horizon:infrastructure:resource_management:' @@ -101,24 +101,24 @@ class ResourceClassViewTests(test.BaseAdminViewTests): self.assertEqual(res.status_code, 200) @test.create_stubs({ - api.management.ResourceClass: ('update', 'set_racks', + api.tuskar.ResourceClass: ('update', 'set_racks', 'set_flavors') }) def test_edit_resource_class_post(self): - resource_class = self.management_resource_classes.first() + resource_class = self.tuskar_resource_classes.first() add_flavors_ids = [] add_max_vms = {} add_racks_ids = [] - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ update(IsA(http.HttpRequest), resource_class.id, name=resource_class.name, service_type=resource_class.service_type).\ AndReturn(resource_class) - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ set_racks(IsA(http.HttpRequest), add_racks_ids) - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ set_flavors(IsA(http.HttpRequest), add_flavors_ids, add_max_vms) self.mox.ReplayAll() @@ -134,15 +134,15 @@ class ResourceClassViewTests(test.BaseAdminViewTests): ("%s?tab=resource_management_tabs__resource_classes_tab" % reverse("horizon:infrastructure:resource_management:index"))) - @test.create_stubs({api.management.ResourceClass: ('delete', 'list')}) + @test.create_stubs({api.tuskar.ResourceClass: ('delete', 'list')}) def test_delete_resource_class(self): - resource_class = self.management_resource_classes.first() - all_resource_classes = self.management_resource_classes.list() + resource_class = self.tuskar_resource_classes.first() + all_resource_classes = self.tuskar_resource_classes.list() - api.management.ResourceClass.delete( + api.tuskar.ResourceClass.delete( IsA(http.HttpRequest), resource_class.id) - api.management.ResourceClass.list( + api.tuskar.ResourceClass.list( IsA(http.HttpRequest)).\ AndReturn(all_resource_classes) self.mox.ReplayAll() @@ -156,21 +156,21 @@ class ResourceClassViewTests(test.BaseAdminViewTests): res, reverse('horizon:infrastructure:resource_management:index')) @test.create_stubs({ - api.management.ResourceClass: ('get', 'flavors', 'racks') + api.tuskar.ResourceClass: ('get', 'flavors', 'racks') }) def test_detail_get(self): - resource_class = self.management_resource_classes.first() + resource_class = self.tuskar_resource_classes.first() flavors = [] racks = [] - api.management.ResourceClass.get( + api.tuskar.ResourceClass.get( IsA(http.HttpRequest), resource_class.id).\ MultipleTimes().AndReturn(resource_class) self.mox.ReplayAll() - api.management.ResourceClass.flavors = flavors - api.management.ResourceClass.racks = racks + api.tuskar.ResourceClass.flavors = flavors + api.tuskar.ResourceClass.racks = racks url = reverse('horizon:infrastructure:resource_management:' 'resource_classes:detail', args=[resource_class.id]) @@ -183,13 +183,13 @@ class ResourceClassViewTests(test.BaseAdminViewTests): self.assertTemplateUsed(res, 'infrastructure/resource_management/resource_classes/detail.html') - @test.create_stubs({api.management.ResourceClass: ('get',)}) + @test.create_stubs({api.tuskar.ResourceClass: ('get',)}) def test_detail_edit_racks_get(self): - resource_class = self.management_resource_classes.first() + resource_class = self.tuskar_resource_classes.first() all_flavors = [] all_racks = [] - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ get(IsA(http.HttpRequest), resource_class.id).\ MultipleTimes().AndReturn(resource_class) self.mox.ReplayAll() @@ -197,8 +197,8 @@ class ResourceClassViewTests(test.BaseAdminViewTests): # FIXME I should probably track the racks and flavors methods # so maybe they shouldn't be a @property # properties set - api.management.ResourceClass.all_racks = all_racks - api.management.ResourceClass.all_flavors = all_flavors + api.tuskar.ResourceClass.all_racks = all_racks + api.tuskar.ResourceClass.all_flavors = all_flavors url = reverse( 'horizon:infrastructure:resource_management:' @@ -208,24 +208,24 @@ class ResourceClassViewTests(test.BaseAdminViewTests): self.assertEqual(res.status_code, 200) @test.create_stubs({ - api.management.ResourceClass: ('update', 'set_racks', + api.tuskar.ResourceClass: ('update', 'set_racks', 'set_flavors') }) def test_detail_edit_racks_post(self): - resource_class = self.management_resource_classes.first() + resource_class = self.tuskar_resource_classes.first() add_flavors_ids = [] add_max_vms = {} add_racks_ids = [] - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ update(IsA(http.HttpRequest), resource_class.id, name=resource_class.name, service_type=resource_class.service_type).\ AndReturn(resource_class) - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ set_racks(IsA(http.HttpRequest), add_racks_ids) - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ set_flavors(IsA(http.HttpRequest), add_flavors_ids, add_max_vms) self.mox.ReplayAll() @@ -245,13 +245,13 @@ class ResourceClassViewTests(test.BaseAdminViewTests): reverse(detail_url, args=(resource_class.id,))) self.assertRedirectsNoFollow(res, redirect_url) - @test.create_stubs({api.management.ResourceClass: ('get',)}) + @test.create_stubs({api.tuskar.ResourceClass: ('get',)}) def test_detail_edit_flavors_get(self): - resource_class = self.management_resource_classes.first() + resource_class = self.tuskar_resource_classes.first() all_flavors = [] all_racks = [] - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ get(IsA(http.HttpRequest), resource_class.id).\ MultipleTimes().AndReturn(resource_class) self.mox.ReplayAll() @@ -259,8 +259,8 @@ class ResourceClassViewTests(test.BaseAdminViewTests): # FIXME I should probably track the racks and flavors methods # so maybe they shouldn't be a @property # properties set - api.management.ResourceClass.all_racks = all_racks - api.management.ResourceClass.all_flavors = all_flavors + api.tuskar.ResourceClass.all_racks = all_racks + api.tuskar.ResourceClass.all_flavors = all_flavors url = reverse( 'horizon:infrastructure:resource_management:' @@ -270,24 +270,24 @@ class ResourceClassViewTests(test.BaseAdminViewTests): self.assertEqual(res.status_code, 200) @test.create_stubs({ - api.management.ResourceClass: ('update', 'set_racks', + api.tuskar.ResourceClass: ('update', 'set_racks', 'set_flavors') }) def test_detail_edit_flavors_post(self): - resource_class = self.management_resource_classes.first() + resource_class = self.tuskar_resource_classes.first() add_flavors_ids = [] add_max_vms = {} add_racks_ids = [] - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ update(IsA(http.HttpRequest), resource_class.id, name=resource_class.name, service_type=resource_class.service_type).\ AndReturn(resource_class) - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ set_racks(IsA(http.HttpRequest), add_racks_ids) - api.management.ResourceClass.\ + api.tuskar.ResourceClass.\ set_flavors(IsA(http.HttpRequest), add_flavors_ids, add_max_vms) self.mox.ReplayAll() diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/views.py b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/views.py index b02342ae9..910f93854 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/views.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/views.py @@ -59,7 +59,7 @@ class UpdateView(workflows.WorkflowView): resource_class_id = self.kwargs['resource_class_id'] try: self._object = \ - api.management.ResourceClass.get(self.request, + api.tuskar.ResourceClass.get(self.request, resource_class_id) except: redirect = self.success_url @@ -98,7 +98,7 @@ class DetailView(tabs.TabView): if not hasattr(self, "_resource_class"): try: resource_class_id = self.kwargs['resource_class_id'] - resource_class = api.management.\ + resource_class = api.tuskar.\ ResourceClass.get(self.request, resource_class_id) except: diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/workflows.py b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/workflows.py index 4354b5b07..ef621d398 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/workflows.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/resource_classes/workflows.py @@ -51,7 +51,7 @@ class ResourceClassInfoAndFlavorsAction(workflows.Action): name = cleaned_data.get('name') resource_class_id = self.initial.get('resource_class_id', None) try: - resource_classes = api.management.ResourceClass.list(self.request) + resource_classes = api.tuskar.ResourceClass.list(self.request) except: resource_classes = [] msg = _('Unable to get resource class list') @@ -106,7 +106,7 @@ class CreateResourceClassInfoAndFlavors(workflows.TableStep): try: resource_class_id = self.workflow.context.get("resource_class_id") if resource_class_id: - resource_class = api.management.ResourceClass.get( + resource_class = api.tuskar.ResourceClass.get( self.workflow.request, resource_class_id) @@ -116,7 +116,7 @@ class CreateResourceClassInfoAndFlavors(workflows.TableStep): all_flavors = resource_class.all_flavors else: - all_flavors = api.management.Flavor.list(self.workflow.request) + all_flavors = api.tuskar.Flavor.list(self.workflow.request) except: all_flavors = [] exceptions.handle(self.workflow.request, @@ -149,7 +149,7 @@ class CreateRacks(workflows.TableStep): try: resource_class_id = self.workflow.context.get("resource_class_id") if resource_class_id: - resource_class = api.management.ResourceClass.get( + resource_class = api.tuskar.ResourceClass.get( self.workflow.request, resource_class_id) # TODO: lsmola ugly interface, rewrite @@ -159,7 +159,7 @@ class CreateRacks(workflows.TableStep): resource_class.all_racks else: racks = \ - api.management.Rack.list(self.workflow.request, True) + api.tuskar.Rack.list(self.workflow.request, True) except: racks = [] exceptions.handle(self.workflow.request, @@ -212,7 +212,7 @@ class CreateResourceClass(ResourceClassWorkflowMixin, workflows.Workflow): def _create_resource_class_info(self, request, data): try: - return api.management.ResourceClass.create( + return api.tuskar.ResourceClass.create( request, name=data['name'], service_type=data['service_type']) @@ -250,7 +250,7 @@ class UpdateResourceClass(ResourceClassWorkflowMixin, workflows.Workflow): def _update_resource_class_info(self, request, data): try: - return api.management.ResourceClass.update( + return api.tuskar.ResourceClass.update( request, data['resource_class_id'], name=data['name'], diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/tabs.py b/openstack_dashboard/dashboards/infrastructure/resource_management/tabs.py index a330a443d..0131df1ca 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/tabs.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/tabs.py @@ -20,7 +20,7 @@ from horizon import exceptions from horizon import messages from horizon import tabs -from openstack_dashboard.api import management +from openstack_dashboard.api import tuskar from .flavors.tables import FlavorsTable from .racks.tables import RacksTable @@ -36,7 +36,7 @@ class RacksTab(tabs.TableTab): def get_racks_data(self): try: - racks = management.Rack.list(self.request) + racks = tuskar.Rack.list(self.request) except: racks = [] exceptions.handle(self.request, @@ -46,7 +46,7 @@ class RacksTab(tabs.TableTab): def get_context_data(self, request): context = super(RacksTab, self).get_context_data(request) try: - context["nodes"] = management.Node.list_unracked(self.request) + context["nodes"] = tuskar.Node.list_unracked(self.request) except: context["nodes"] = [] exceptions.handle(request, @@ -62,11 +62,11 @@ class FlavorsTab(tabs.TableTab): def get_flavors_data(self): try: - flavors = management.Flavor.list(self.request) + flavors = tuskar.Flavor.list(self.request) except: flavors = [] exceptions.handle(self.request, - _('Unable to retrieve management flavors.')) + _('Unable to retrieve tuskar flavors.')) return flavors @@ -79,7 +79,7 @@ class ResourceClassesTab(tabs.TableTab): def get_resource_classes_data(self): try: - resource_classes = management.ResourceClass.list(self.request) + resource_classes = tuskar.ResourceClass.list(self.request) except: resource_classes = [] exceptions.handle(self.request, diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/tests.py b/openstack_dashboard/dashboards/infrastructure/resource_management/tests.py index a136e5e3c..8fd65ae66 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/tests.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/tests.py @@ -28,38 +28,38 @@ class ResourceManagementTests(test.BaseAdminViewTests): super(ResourceManagementTests, self).setUp() @test.create_stubs({ - api.management.ResourceClass: ( + api.tuskar.ResourceClass: ( 'list', 'racks', 'nodes'), - api.management.Flavor: ( + api.tuskar.Flavor: ( 'list',), - api.management.Rack: ( + api.tuskar.Rack: ( 'list',)}) def test_index(self): # Flavor stubs - flavors = self.management_flavors.list() + flavors = self.tuskar_flavors.list() - api.management.Flavor.list(IsA(http.HttpRequest)).AndReturn(flavors) + api.tuskar.Flavor.list(IsA(http.HttpRequest)).AndReturn(flavors) # Flavor stubs end # ResourceClass stubs - all_resource_classes = self.management_resource_classes.list() + all_resource_classes = self.tuskar_resource_classes.list() nodes = [] racks = [] - api.management.ResourceClass.nodes = nodes - api.management.ResourceClass.racks = racks + api.tuskar.ResourceClass.nodes = nodes + api.tuskar.ResourceClass.racks = racks - api.management.ResourceClass.list( + api.tuskar.ResourceClass.list( IsA(http.HttpRequest)).\ AndReturn(all_resource_classes) # ResourceClass stubs end # Rack stubs - racks = self.management_racks.list() + racks = self.tuskar_racks.list() - api.management.Rack.list(IsA(http.HttpRequest)).AndReturn(racks) + api.tuskar.Rack.list(IsA(http.HttpRequest)).AndReturn(racks) # Rack stubs end self.mox.ReplayAll() diff --git a/openstack_dashboard/exceptions.py b/openstack_dashboard/exceptions.py index 264f46dd9..958e075ae 100644 --- a/openstack_dashboard/exceptions.py +++ b/openstack_dashboard/exceptions.py @@ -49,7 +49,7 @@ NOT_FOUND = (keystoneclient.NotFound, neutronclient.PortNotFoundClient, heatclient.HTTPNotFound, # FIXME: this exception and the related import should be replaced - # by the one thrown by the management api client + # by the one thrown by the tuskar api client ObjectDoesNotExist) # NOTE(gabriel): This is very broad, and may need to be dialed in. diff --git a/openstack_dashboard/test/api_tests/management_tests.py b/openstack_dashboard/test/api_tests/tuskar_tests.py similarity index 65% rename from openstack_dashboard/test/api_tests/management_tests.py rename to openstack_dashboard/test/api_tests/tuskar_tests.py index aec2157a7..6fd9fd8ea 100644 --- a/openstack_dashboard/test/api_tests/management_tests.py +++ b/openstack_dashboard/test/api_tests/tuskar_tests.py @@ -27,51 +27,51 @@ from openstack_dashboard.test import helpers as test import openstack_dashboard.dashboards.infrastructure.models as dummymodels -class ManagementApiTests(test.APITestCase): +class TuskarApiTests(test.APITestCase): def setUp(self): - super(ManagementApiTests, self).setUp() + super(TuskarApiTests, self).setUp() # dummy data are seeded from fixtures self.rclass1 = dummymodels.ResourceClass.objects.get(name='rclass1') self.flavor1 = dummymodels.Flavor.objects.get(name='flavor1') def test_resource_class_list(self): - rc_list = api.management.ResourceClass.list(self.request) + rc_list = api.tuskar.ResourceClass.list(self.request) self.assertEquals(3, len(rc_list)) for rc in rc_list: - self.assertIsInstance(rc, api.management.ResourceClass) + self.assertIsInstance(rc, api.tuskar.ResourceClass) def test_resource_class_get(self): - rc = api.management.ResourceClass.get(self.request, self.rclass1.id) - self.assertIsInstance(rc, api.management.ResourceClass) + rc = api.tuskar.ResourceClass.get(self.request, self.rclass1.id) + self.assertIsInstance(rc, api.tuskar.ResourceClass) self.assertEquals(rc.name, self.rclass1.name) def test_resource_class_flavor_counts(self): - rc = api.management.ResourceClass.get(self.request, self.rclass1.id) + rc = api.tuskar.ResourceClass.get(self.request, self.rclass1.id) for f in rc.resource_class_flavors: - self.assertIsInstance(f, api.management.ResourceClassFlavor) + self.assertIsInstance(f, api.tuskar.ResourceClassFlavor) self.assertEquals(3, len(rc.resource_class_flavors)) def test_resource_class_racks(self): - rc = api.management.ResourceClass.get(self.request, self.rclass1.id) + rc = api.tuskar.ResourceClass.get(self.request, self.rclass1.id) for rack in rc.racks: - self.assertIsInstance(rack, api.management.Rack) + self.assertIsInstance(rack, api.tuskar.Rack) self.assertEquals(2, len(rc.racks)) def test_resource_class_nodes(self): - rc = api.management.ResourceClass.get(self.request, self.rclass1.id) + rc = api.tuskar.ResourceClass.get(self.request, self.rclass1.id) for node in rc.nodes: - self.assertIsInstance(node, api.management.Node) + self.assertIsInstance(node, api.tuskar.Node) self.assertEquals(4, len(rc.nodes)) # TODO: create, delete operations def test_flavor_list(self): - flist = api.management.Flavor.list(self.request) + flist = api.tuskar.Flavor.list(self.request) self.assertEquals(6, len(flist)) for f in flist: - self.assertIsInstance(f, api.management.Flavor) + self.assertIsInstance(f, api.tuskar.Flavor) def test_flavor_get(self): - flavor = api.management.Flavor.get(self.request, self.flavor1.id) - self.assertIsInstance(flavor, api.management.Flavor) + flavor = api.tuskar.Flavor.get(self.request, self.flavor1.id) + self.assertIsInstance(flavor, api.tuskar.Flavor) self.assertEquals(flavor.name, self.flavor1.name) diff --git a/openstack_dashboard/test/test_data/management_data.py b/openstack_dashboard/test/test_data/tuskar_data.py similarity index 89% rename from openstack_dashboard/test/test_data/management_data.py rename to openstack_dashboard/test/test_data/tuskar_data.py index 349935040..465f5facd 100644 --- a/openstack_dashboard/test/test_data/management_data.py +++ b/openstack_dashboard/test/test_data/tuskar_data.py @@ -10,7 +10,7 @@ # License for the specific language governing permissions and limitations # under the License. -from openstack_dashboard.api.management import ( +from openstack_dashboard.api.tuskar import ( Flavor, ResourceClass, Node, Rack, ResourceClassFlavor) @@ -21,17 +21,17 @@ from .utils import TestDataContainer def data(TEST): # Flavors - TEST.management_flavors = TestDataContainer() + TEST.tuskar_flavors = TestDataContainer() flavor_1 = Flavor(dummymodels.Flavor( id="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", name='m1.tiny')) flavor_2 = Flavor(dummymodels.Flavor( id="bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", name='m1.massive')) - TEST.management_flavors.add(flavor_1, flavor_2) + TEST.tuskar_flavors.add(flavor_1, flavor_2) # Resource Classes - TEST.management_resource_classes = TestDataContainer() + TEST.tuskar_resource_classes = TestDataContainer() resource_class_1 = ResourceClass(dummymodels.ResourceClass( id="1", @@ -67,19 +67,19 @@ def data(TEST): resource_class_2.all_flavors = all_flavors """ - TEST.management_resource_classes.add(resource_class_1, resource_class_2) + TEST.tuskar_resource_classes.add(resource_class_1, resource_class_2) #Racks - TEST.management_racks = TestDataContainer() + TEST.tuskar_racks = TestDataContainer() rack_1 = Rack(dummymodels.Rack( id="1", name='rack1', resource_class_id='1')) - TEST.management_racks.add(rack_1) + TEST.tuskar_racks.add(rack_1) #ResourceClassFlavors - TEST.management_resource_class_flavors = TestDataContainer() + TEST.tuskar_resource_class_flavors = TestDataContainer() resource_class_flavor_1 = ResourceClassFlavor( dummymodels.ResourceClassFlavor( id="1", @@ -87,7 +87,7 @@ def data(TEST): resource_class_id=1, flavor_id=1)) - TEST.management_resource_class_flavors.add(resource_class_flavor_1) + TEST.tuskar_resource_class_flavors.add(resource_class_flavor_1) # Nodes TEST.nodes = TestDataContainer() diff --git a/openstack_dashboard/test/test_data/utils.py b/openstack_dashboard/test/test_data/utils.py index 101c2a6d7..3509cd651 100644 --- a/openstack_dashboard/test/test_data/utils.py +++ b/openstack_dashboard/test/test_data/utils.py @@ -33,7 +33,7 @@ def load_test_data(load_onto=None): neutron_data.data, swift_data.data, heat_data.data, - management_data.data) + tuskar_data.data) if load_onto: for data_func in loaders: data_func(load_onto)