Update management to tuskar

Renamed management to tuskar for API related
code

Change-Id: I52f1a654ae58fd235378caa61e0ef5e81c16d2db
This commit is contained in:
Tzu-Mainn Chen 2013-07-15 16:47:03 -04:00 committed by Tomas Sedovic
parent 2b78b0878f
commit 242cc3ff31
24 changed files with 168 additions and 166 deletions

View File

@ -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

View File

@ -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'],

View File

@ -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):

View File

@ -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()

View File

@ -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())

View File

@ -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):

View File

@ -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()

View File

@ -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')

View File

@ -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.")

View File

@ -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):

View File

@ -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'

View File

@ -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')

View File

@ -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:

View File

@ -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)

View File

@ -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()

View File

@ -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:

View File

@ -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'],

View File

@ -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,

View File

@ -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()

View File

@ -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.

View File

@ -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)

View File

@ -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()

View File

@ -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)