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