Rename tuskar classes and role.id to match the tuskar API

Change-Id: I9b83ee2abec21372ab8c84b23b0d25ff5b2d70fd
This commit is contained in:
Lennart Regebro 2014-09-09 12:48:57 +02:00
parent c569b431ce
commit 8d6ab7c1c4
19 changed files with 134 additions and 134 deletions

View File

@ -108,7 +108,7 @@ class Flavor(object):
servers = nova.server_list(request)[0]
deployed_ids = set(server.flavor['id'] for server in servers)
deployed_names = []
for plan in tuskar_ui.api.tuskar.OvercloudPlan.list(request):
for plan in tuskar_ui.api.tuskar.Plan.list(request):
deployed_names.extend(
[plan.parameter_value(role.instance_type_parameter_name)
for role in plan.role_list])

View File

@ -122,7 +122,7 @@ class Stack(base.APIResourceWrapper):
@classmethod
@handle_errors(_("Unable to retrieve stack"))
def get_by_plan(cls, request, plan):
"""Return the Heat Stack associated with an OvercloudPlan
"""Return the Heat Stack associated with a Plan
:return: Heat Stack associated with the plan; or None
if no Stack is associated, or no Stack can be
@ -211,7 +211,7 @@ class Stack(base.APIResourceWrapper):
"""Return count of associated Resources
:param overcloud_role: role of resources to be counted; None means all
:type overcloud_role: tuskar_ui.api.tuskar.OvercloudRole
:type overcloud_role: tuskar_ui.api.tuskar.Role
:return: Number of matching resources
:rtype: int
@ -228,21 +228,21 @@ class Stack(base.APIResourceWrapper):
@cached_property
def plan(self):
"""return associated OvercloudPlan if a plan_id exists within stack
"""return associated Plan if a plan_id exists within stack
parameters.
:return: associated OvercloudPlan if plan_id exists and a matching plan
:return: associated Plan if plan_id exists and a matching plan
exists as well; None otherwise
:rtype: tuskar_ui.api.tuskar.OvercloudPlan
:rtype: tuskar_ui.api.tuskar.Plan
"""
# TODO(lsmola) replace this by actual reference, I am pretty sure
# the relation won't be stored in parameters, that would mean putting
# that into template, which doesn't make sense
#if 'plan_id' in self.parameters:
# return tuskar.OvercloudPlan.get(self._request,
# return tuskar.Plan.get(self._request,
# self.parameters['plan_id'])
try:
plan = tuskar.OvercloudPlan.list(self._request)[0]
plan = tuskar.Plan.list(self._request)[0]
except IndexError:
return None
return plan
@ -436,11 +436,11 @@ class Resource(base.APIResourceWrapper):
@cached_property
def role(self):
"""Return the OvercloudRole associated with this Resource
"""Return the Role associated with this Resource
:return: OvercloudRole associated with this Resource, or None if no
OvercloudRole is associated
:rtype: tuskar_ui.api.tuskar.OvercloudRole
:return: Role associated with this Resource, or None if no
Role is associated
:rtype: tuskar_ui.api.tuskar.Role
"""
if hasattr(self, '_role'):
return self._role

View File

@ -49,17 +49,17 @@ def tuskarclient(request, password=None):
return client
class OvercloudPlan(base.APIResourceWrapper):
class Plan(base.APIResourceWrapper):
_attrs = ('uuid', 'name', 'description', 'created_at', 'modified_at',
'roles', 'parameters')
def __init__(self, apiresource, request=None):
super(OvercloudPlan, self).__init__(apiresource)
super(Plan, self).__init__(apiresource)
self._request = request
@classmethod
def create(cls, request, name, description):
"""Create an OvercloudPlan in Tuskar
"""Create a Plan in Tuskar
:param request: request object
:type request: django.http.HttpRequest
@ -70,8 +70,8 @@ class OvercloudPlan(base.APIResourceWrapper):
:param description: plan description
:type description: string
:return: the created OvercloudPlan object
:rtype: tuskar_ui.api.tuskar.OvercloudPlan
:return: the created Plan object
:rtype: tuskar_ui.api.tuskar.Plan
"""
plan = tuskarclient(request).plans.create(name=name,
description=description)
@ -79,7 +79,7 @@ class OvercloudPlan(base.APIResourceWrapper):
@classmethod
def patch(cls, request, plan_id, parameters):
"""Update an OvercloudPlan in Tuskar
"""Update a Plan in Tuskar
:param request: request object
:type request: django.http.HttpRequest
@ -90,8 +90,8 @@ class OvercloudPlan(base.APIResourceWrapper):
:param parameters: new values for the plan's parameters
:type parameters: dict
:return: the updated OvercloudPlan object
:rtype: tuskar_ui.api.tuskar.OvercloudPlan
:return: the updated Plan object
:rtype: tuskar_ui.api.tuskar.Plan
"""
parameter_list = [{
'name': unicode(name),
@ -102,13 +102,13 @@ class OvercloudPlan(base.APIResourceWrapper):
@classmethod
def list(cls, request):
"""Return a list of OvercloudPlans in Tuskar
"""Return a list of Plans in Tuskar
:param request: request object
:type request: django.http.HttpRequest
:return: list of OvercloudPlans, or an empty list if there are none
:rtype: list of tuskar_ui.api.tuskar.OvercloudPlan
:return: list of Plans, or an empty list if there are none
:rtype: list of tuskar_ui.api.tuskar.Plan
"""
plans = tuskarclient(request).plans.list()
return [cls(plan, request=request) for plan in plans]
@ -116,17 +116,17 @@ class OvercloudPlan(base.APIResourceWrapper):
@classmethod
@handle_errors(_("Unable to retrieve plan"))
def get(cls, request, plan_id):
"""Return the OvercloudPlan that matches the ID
"""Return the Plan that matches the ID
:param request: request object
:type request: django.http.HttpRequest
:param plan_id: id of OvercloudPlan to be retrieved
:param plan_id: id of Plan to be retrieved
:type plan_id: int
:return: matching OvercloudPlan, or None if no OvercloudPlan matches
:return: matching Plan, or None if no Plan matches
the ID
:rtype: tuskar_ui.api.tuskar.OvercloudPlan
:rtype: tuskar_ui.api.tuskar.Plan
"""
plan = tuskarclient(request).plans.get(plan_uuid=plan_id)
return cls(plan, request=request)
@ -150,7 +150,7 @@ class OvercloudPlan(base.APIResourceWrapper):
@classmethod
def delete(cls, request, plan_id):
"""Delete an OvercloudPlan
"""Delete a Plan
:param request: request object
:type request: django.http.HttpRequest
@ -162,7 +162,7 @@ class OvercloudPlan(base.APIResourceWrapper):
@cached_property
def role_list(self):
return [OvercloudRole.get(self._request, role.uuid)
return [Role.get(self._request, role.uuid)
for role in self.roles]
@cached_property
@ -211,11 +211,11 @@ class OvercloudPlan(base.APIResourceWrapper):
return self.uuid
class OvercloudRole(base.APIResourceWrapper):
class Role(base.APIResourceWrapper):
_attrs = ('uuid', 'name', 'version', 'description', 'created')
def __init__(self, apiresource, request=None):
super(OvercloudRole, self).__init__(apiresource)
super(Role, self).__init__(apiresource)
self._request = request
@classmethod
@ -228,7 +228,7 @@ class OvercloudRole(base.APIResourceWrapper):
:return: list of Overcloud Roles, or an empty list if there
are none
:rtype: list of tuskar_ui.api.tuskar.OvercloudRole
:rtype: list of tuskar_ui.api.tuskar.Role
"""
roles = tuskarclient(request).roles.list()
return [cls(role, request=request) for role in roles]
@ -236,42 +236,42 @@ class OvercloudRole(base.APIResourceWrapper):
@classmethod
@handle_errors(_("Unable to retrieve overcloud role"))
def get(cls, request, role_id):
"""Return the Tuskar OvercloudRole that matches the ID
"""Return the Tuskar Role that matches the ID
:param request: request object
:type request: django.http.HttpRequest
:param role_id: ID of OvercloudRole to be retrieved
:param role_id: ID of Role to be retrieved
:type role_id: int
:return: matching OvercloudRole, or None if no matching
OvercloudRole can be found
:rtype: tuskar_ui.api.tuskar.OvercloudRole
:return: matching Role, or None if no matching
Role can be found
:rtype: tuskar_ui.api.tuskar.Role
"""
for role in OvercloudRole.list(request):
for role in Role.list(request):
if role.uuid == role_id:
return role
@classmethod
@handle_errors(_("Unable to retrieve overcloud role"))
def get_by_image(cls, request, plan, image):
"""Return the Tuskar OvercloudRole whose ImageID
"""Return the Tuskar Role whose ImageID
parameter matches the passed in image
:param request: request object
:type request: django.http.HttpRequest
:param plan: associated plan to check against
:type plan: OvercloudPlan
:type plan: Plan
:param image: image to be matched
:type image: Image
:return: matching OvercloudRole, or None if no matching
OvercloudRole can be found
:rtype: tuskar_ui.api.tuskar.OvercloudRole
:return: matching Role, or None if no matching
Role can be found
:rtype: tuskar_ui.api.tuskar.Role
"""
for role in OvercloudRole.list(request):
for role in Role.list(request):
image_id_from_plan = plan.parameter_value(
role.image_id_parameter_name)
if image_id_from_plan == image.id:
@ -280,7 +280,7 @@ class OvercloudRole(base.APIResourceWrapper):
@classmethod
@handle_errors(_("Unable to retrieve overcloud role"))
def get_by_resource_type(cls, request, resource_type):
for role in OvercloudRole.list(request):
for role in Role.list(request):
if role.provider_resource_type == resource_type:
return role

View File

@ -82,7 +82,7 @@ class FlavorRolesTable(tables.DataTable):
def __init__(self, request, *args, **kwargs):
# TODO(dtantsur): support multiple overclouds
try:
stack = api.tuskar.OvercloudPlan.get_the_plan(request).stack
stack = api.tuskar.Plan.get_the_plan(request).stack
except Exception:
count_getter = lambda role: _("Not deployed")
else:

View File

@ -67,15 +67,15 @@ def _prepare_create():
class FlavorsTest(test.BaseAdminViewTests):
def test_index(self):
plans = [api.tuskar.OvercloudPlan(plan, self.request)
plans = [api.tuskar.Plan(plan, self.request)
for plan in TEST_DATA.tuskarclient_plans.list()]
roles = [api.tuskar.OvercloudRole(role)
roles = [api.tuskar.Role(role)
for role in self.tuskarclient_roles.list()]
with contextlib.nested(
patch('tuskar_ui.api.tuskar.OvercloudPlan.list',
patch('tuskar_ui.api.tuskar.Plan.list',
return_value=plans),
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=roles),
patch('openstack_dashboard.api.nova.flavor_list',
return_value=TEST_DATA.novaclient_flavors.list()),
@ -140,9 +140,9 @@ class FlavorsTest(test.BaseAdminViewTests):
patch('openstack_dashboard.api.nova.flavor_delete'),
patch('openstack_dashboard.api.nova.server_list',
return_value=([], False)),
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=[]),
patch('tuskar_ui.api.tuskar.OvercloudPlan.list',
patch('tuskar_ui.api.tuskar.Plan.list',
return_value=[]),
patch('openstack_dashboard.api.glance.image_list_detailed',
return_value=([], False)),
@ -170,9 +170,9 @@ class FlavorsTest(test.BaseAdminViewTests):
patch('openstack_dashboard.api.nova.flavor_delete'),
patch('openstack_dashboard.api.nova.server_list',
return_value=([server], False)),
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=[]),
patch('tuskar_ui.api.tuskar.OvercloudPlan.list',
patch('tuskar_ui.api.tuskar.Plan.list',
return_value=[]),
patch('openstack_dashboard.api.glance.image_list_detailed',
return_value=([], False)),
@ -194,9 +194,9 @@ class FlavorsTest(test.BaseAdminViewTests):
side_effect=images),
patch('tuskar_ui.api.flavor.Flavor.get',
return_value=flavor),
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=roles),
patch('tuskar_ui.api.tuskar.OvercloudPlan.get_the_plan',
patch('tuskar_ui.api.tuskar.Plan.get_the_plan',
side_effect=Exception)
) as (image_mock, get_mock, roles_mock, plan_mock):
res = self.client.get(urlresolvers.reverse(DETAILS_VIEW,
@ -211,7 +211,7 @@ class FlavorsTest(test.BaseAdminViewTests):
flavor = api.flavor.Flavor(TEST_DATA.novaclient_flavors.first())
images = TEST_DATA.glanceclient_images.list()[:2]
roles = TEST_DATA.tuskarclient_roles.list()
plan = api.tuskar.OvercloudPlan(
plan = api.tuskar.Plan(
TEST_DATA.tuskarclient_plans.first())
stack = api.heat.Stack(
TEST_DATA.heatclient_stacks.first())
@ -220,9 +220,9 @@ class FlavorsTest(test.BaseAdminViewTests):
side_effect=images),
patch('tuskar_ui.api.flavor.Flavor.get',
return_value=flavor),
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=roles),
patch('tuskar_ui.api.tuskar.OvercloudPlan.get_the_plan',
patch('tuskar_ui.api.tuskar.Plan.get_the_plan',
return_value=plan),
patch('tuskar_ui.api.heat.Stack.get',
return_value=stack),

View File

@ -35,14 +35,14 @@ INDEX_URL = urlresolvers.reverse(
class HistoryTest(test.BaseAdminViewTests):
def test_index(self):
plan = api.tuskar.OvercloudPlan(
plan = api.tuskar.Plan(
TEST_DATA.tuskarclient_plans.first())
stack = api.heat.Stack(
TEST_DATA.heatclient_stacks.first())
events = TEST_DATA.heatclient_events.list()
with contextlib.nested(
patch('tuskar_ui.api.tuskar.OvercloudPlan.get_the_plan',
patch('tuskar_ui.api.tuskar.Plan.get_the_plan',
return_value=plan),
patch('tuskar_ui.api.heat.Stack.get_by_plan',
return_value=stack),

View File

@ -23,7 +23,7 @@ class IndexView(horizon_tables.DataTableView):
template_name = "infrastructure/history/index.html"
def get_data(self):
plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
plan = api.tuskar.Plan.get_the_plan(self.request)
if plan:
stack = api.heat.Stack.get_by_plan(self.request, plan)
if stack:

View File

@ -28,15 +28,15 @@ INDEX_URL = urlresolvers.reverse(
class ImagesTest(test.BaseAdminViewTests):
def test_index(self):
roles = [api.tuskar.OvercloudRole(role) for role in
roles = [api.tuskar.Role(role) for role in
self.tuskarclient_roles.list()]
plans = [api.tuskar.OvercloudPlan(plan) for plan in
plans = [api.tuskar.Plan(plan) for plan in
self.tuskarclient_plans.list()]
with contextlib.nested(
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=roles),
patch('tuskar_ui.api.tuskar.OvercloudPlan.list',
patch('tuskar_ui.api.tuskar.Plan.list',
return_value=plans),
patch('openstack_dashboard.api.glance.image_list_detailed',
return_value=[self.images.list(), False, False]),):

View File

@ -25,10 +25,10 @@ class IndexView(horizon_tables.DataTableView):
template_name = "infrastructure/images/index.html"
def get_data(self):
plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
plan = api.tuskar.Plan.get_the_plan(self.request)
images = glance.image_list_detailed(self.request)[0]
# TODO(tzumainn): re-architect a bit to avoid inefficiency
for image in images:
image.role = api.tuskar.OvercloudRole.get_by_image(
image.role = api.tuskar.Role.get_by_image(
self.request, plan, image)
return images

View File

@ -65,7 +65,7 @@ class NodesTests(test.BaseAdminViewTests, helpers.APITestCase):
def test_registered_nodes(self):
registered_nodes = [api.node.Node(api.node.IronicNode(node))
for node in self.ironicclient_nodes.list()]
roles = [api.tuskar.OvercloudRole(r)
roles = [api.tuskar.Role(r)
for r in TEST_DATA.tuskarclient_roles.list()]
instance = TEST_DATA.novaclient_servers.first()
image = TEST_DATA.glanceclient_images.first()
@ -77,7 +77,7 @@ class NodesTests(test.BaseAdminViewTests, helpers.APITestCase):
node.ip_address = '1.1.1.1'
with contextlib.nested(
patch('tuskar_ui.api.tuskar.OvercloudRole', **{
patch('tuskar_ui.api.tuskar.Role', **{
'spec_set': ['list', 'name'],
'list.return_value': roles,
}),
@ -100,7 +100,7 @@ class NodesTests(test.BaseAdminViewTests, helpers.APITestCase):
self._raise_horizon_exception_not_found),
'list_all_resources.return_value': [],
}),
) as (_OvercloudRole, Node, _nova, _glance, _resource):
) as (_Role, Node, _nova, _glance, _resource):
res = self.client.get(INDEX_URL + '?tab=nodes__registered')
# FIXME(lsmola) horrible count, optimize
self.assertEqual(Node.list.call_count, 6)
@ -285,7 +285,7 @@ class NodesTests(test.BaseAdminViewTests, helpers.APITestCase):
registered_nodes = [api.node.Node(api.node.IronicNode(node))
for node in self.ironicclient_nodes.list()]
node = registered_nodes[6]
roles = [api.tuskar.OvercloudRole(r)
roles = [api.tuskar.Role(r)
for r in TEST_DATA.tuskarclient_roles.list()]
instance = TEST_DATA.novaclient_servers.first()
image = TEST_DATA.glanceclient_images.first()
@ -302,7 +302,7 @@ class NodesTests(test.BaseAdminViewTests, helpers.APITestCase):
'list.return_value': registered_nodes,
'set_power_state.return_value': node,
}),
patch('tuskar_ui.api.tuskar.OvercloudRole', **{
patch('tuskar_ui.api.tuskar.Role', **{
'spec_set': ['list', 'name'],
'list.return_value': roles,
}),
@ -333,7 +333,7 @@ class NodesTests(test.BaseAdminViewTests, helpers.APITestCase):
registered_nodes = [api.node.Node(api.node.IronicNode(node))
for node in self.ironicclient_nodes.list()]
node = registered_nodes[8]
roles = [api.tuskar.OvercloudRole(r)
roles = [api.tuskar.Role(r)
for r in TEST_DATA.tuskarclient_roles.list()]
instance = TEST_DATA.novaclient_servers.first()
image = TEST_DATA.glanceclient_images.first()
@ -350,7 +350,7 @@ class NodesTests(test.BaseAdminViewTests, helpers.APITestCase):
'list.return_value': registered_nodes,
'set_power_state.return_value': node,
}),
patch('tuskar_ui.api.tuskar.OvercloudRole', **{
patch('tuskar_ui.api.tuskar.Role', **{
'spec_set': ['list', 'name'],
'list.return_value': roles,
}),

View File

@ -37,7 +37,7 @@ def _get_role_count(plan, role):
class EditPlan(horizon.forms.SelfHandlingForm):
def __init__(self, *args, **kwargs):
super(EditPlan, self).__init__(*args, **kwargs)
self.plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
self.plan = api.tuskar.Plan.get_the_plan(self.request)
self.fields.update(self._role_count_fields(self.plan))
def _role_count_fields(self, plan):
@ -73,7 +73,7 @@ class EditPlan(horizon.forms.SelfHandlingForm):
class DeployOvercloud(horizon.forms.SelfHandlingForm):
def handle(self, request, data):
try:
plan = api.tuskar.OvercloudPlan.get_the_plan(request)
plan = api.tuskar.Plan.get_the_plan(request)
stack = api.heat.Stack.get_by_plan(self.request, plan)
if not stack:
api.heat.Stack.create(request,
@ -95,7 +95,7 @@ class DeployOvercloud(horizon.forms.SelfHandlingForm):
class UndeployOvercloud(horizon.forms.SelfHandlingForm):
def handle(self, request, data):
try:
plan = api.tuskar.OvercloudPlan.get_the_plan(request)
plan = api.tuskar.Plan.get_the_plan(request)
stack = api.heat.Stack.get_by_plan(self.request, plan)
if stack:
api.heat.Stack.delete(request, stack.id)
@ -135,7 +135,7 @@ class PostDeployInit(horizon.forms.SelfHandlingForm):
def handle(self, request, data):
try:
plan = api.tuskar.OvercloudPlan.get_the_plan(request)
plan = api.tuskar.Plan.get_the_plan(request)
stack = api.heat.Stack.get_by_plan(self.request, plan)
admin_token = plan.parameter_value('AdminToken')

View File

@ -66,9 +66,9 @@ def _mock_plan(**kwargs):
}
params.update(kwargs)
with patch(
'tuskar_ui.api.tuskar.OvercloudPlan', **params) as OvercloudPlan:
plan = OvercloudPlan
yield OvercloudPlan
'tuskar_ui.api.tuskar.Plan', **params) as Plan:
plan = Plan
yield Plan
class OverviewTests(test.BaseAdminViewTests):
@ -80,7 +80,7 @@ class OverviewTests(test.BaseAdminViewTests):
return_value=[]),
):
res = self.client.get(INDEX_URL)
get_the_plan = api.tuskar.OvercloudPlan.get_the_plan
get_the_plan = api.tuskar.Plan.get_the_plan
request = get_the_plan.call_args_list[0][0][0]
self.assertListEqual(get_the_plan.call_args_list, [
call(request),
@ -107,13 +107,13 @@ class OverviewTests(test.BaseAdminViewTests):
res = self.client.post(INDEX_URL, data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res, INDEX_URL)
get_the_plan = api.tuskar.OvercloudPlan.get_the_plan
get_the_plan = api.tuskar.Plan.get_the_plan
request = get_the_plan.call_args_list[0][0][0]
self.assertListEqual(get_the_plan.call_args_list, [
call(request),
])
self.assertListEqual(
api.tuskar.OvercloudPlan.patch.call_args_list,
api.tuskar.Plan.patch.call_args_list,
[call(request, plan.id, {})],
)
@ -126,11 +126,11 @@ class OverviewTests(test.BaseAdminViewTests):
return_value=stack),
patch('tuskar_ui.api.heat.Stack.events',
return_value=[]),
) as (OvercloudPlan, stack_get_mock, stack_events_mock):
) as (Plan, stack_get_mock, stack_events_mock):
res = self.client.get(INDEX_URL)
request = OvercloudPlan.get_the_plan.call_args_list[0][0][0]
request = Plan.get_the_plan.call_args_list[0][0][0]
self.assertListEqual(
OvercloudPlan.get_the_plan.call_args_list,
Plan.get_the_plan.call_args_list,
[
call(request),
call(request),

View File

@ -26,7 +26,7 @@ INDEX_URL = 'horizon:infrastructure:overview:index'
def _get_role_data(plan, stack, role, field):
"""Gathers data about a single deployment role from the related Overcloud
and OvercloudRole objects, and presents it in the form convenient for use
and Role objects, and presents it in the form convenient for use
from the template.
"""
@ -76,7 +76,7 @@ class StackMixin(object):
def get_stack(self, redirect=None):
if redirect is None:
redirect = reverse(INDEX_URL)
plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
plan = api.tuskar.Plan.get_the_plan(self.request)
stack = api.heat.Stack.get_by_plan(self.request, plan)
return stack
@ -96,7 +96,7 @@ class IndexView(horizon.forms.ModalFormView, StackMixin):
return context
def get_data(self, request, context, *args, **kwargs):
plan = api.tuskar.OvercloudPlan.get_the_plan(request)
plan = api.tuskar.Plan.get_the_plan(request)
stack = self.get_stack()
context['plan'] = plan

View File

@ -35,15 +35,15 @@ from tuskar_ui.infrastructure.parameters import views
class ParametersTest(test.BaseAdminViewTests):
def test_index(self):
plans = [api.tuskar.OvercloudPlan(plan)
plans = [api.tuskar.Plan(plan)
for plan in self.tuskarclient_plans.list()]
roles = [api.tuskar.OvercloudRole(role)
roles = [api.tuskar.Role(role)
for role in self.tuskarclient_roles.list()]
with contextlib.nested(
patch('tuskar_ui.api.tuskar.OvercloudPlan.list',
patch('tuskar_ui.api.tuskar.Plan.list',
return_value=plans),
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=roles),
):
res = self.client.get(INDEX_URL)

View File

@ -32,7 +32,7 @@ class IndexView(horizon_tables.DataTableView):
template_name = "infrastructure/parameters/index.html"
def get_data(self):
plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
plan = api.tuskar.Plan.get_the_plan(self.request)
base_parameters = plan.parameter_list(
include_key_parameters=False)
params = [ServiceParameter(param, ind)

View File

@ -42,17 +42,17 @@ tuskar_data.data(TEST_DATA)
class RolesTest(test.BaseAdminViewTests):
def test_index_get(self):
roles = [api.tuskar.OvercloudRole(role)
roles = [api.tuskar.Role(role)
for role in self.tuskarclient_roles.list()]
plans = [api.tuskar.OvercloudPlan(plan)
plans = [api.tuskar.Plan(plan)
for plan in self.tuskarclient_plans.list()]
flavor = self.novaclient_flavors.first()
image = self.glanceclient_images.first()
with contextlib.nested(
patch('tuskar_ui.api.tuskar.OvercloudPlan.list',
patch('tuskar_ui.api.tuskar.Plan.list',
return_value=plans),
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=roles),
patch('openstack_dashboard.api.glance.image_get',
return_value=image),
@ -63,16 +63,16 @@ class RolesTest(test.BaseAdminViewTests):
self.assertTemplateUsed(res, 'infrastructure/roles/index.html')
def test_detail_get(self):
roles = [api.tuskar.OvercloudRole(role)
roles = [api.tuskar.Role(role)
for role in self.tuskarclient_roles.list()]
plans = [api.tuskar.OvercloudPlan(plan)
plans = [api.tuskar.Plan(plan)
for plan in self.tuskarclient_plans.list()]
flavor = self.novaclient_flavors.first()
image = self.glanceclient_images.first()
stack = api.heat.Stack(TEST_DATA.heatclient_stacks.first())
with contextlib.nested(
patch('tuskar_ui.api.tuskar.OvercloudRole.list',
patch('tuskar_ui.api.tuskar.Role.list',
return_value=roles),
patch('tuskar_ui.api.heat.Stack.get_by_plan',
return_value=stack),
@ -80,7 +80,7 @@ class RolesTest(test.BaseAdminViewTests):
return_value=[]),
patch('tuskar_ui.api.heat.Stack.resources',
return_value=[]),
patch('tuskar_ui.api.tuskar.OvercloudPlan.list',
patch('tuskar_ui.api.tuskar.Plan.list',
return_value=plans),
patch('openstack_dashboard.api.glance.image_get',
return_value=image),

View File

@ -26,12 +26,12 @@ from tuskar_ui.infrastructure.roles import tables
INDEX_URL = 'horizon:infrastructure:roles:index'
class OvercloudRoleMixin(object):
class RoleMixin(object):
@memoized.memoized
def get_role(self, redirect=None):
role_id = self.kwargs['role_id']
role = api.tuskar.OvercloudRole.get(self.request, role_id,
_error_redirect=redirect)
role = api.tuskar.Role.get(self.request, role_id,
_error_redirect=redirect)
return role
@ -40,7 +40,7 @@ class StackMixin(object):
def get_stack(self, redirect=None):
if redirect is None:
redirect = reverse(INDEX_URL)
plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
plan = api.tuskar.Plan.get_the_plan(self.request)
stack = api.heat.Stack.get_by_plan(self.request, plan)
return stack
@ -51,8 +51,8 @@ class IndexView(horizon_tables.DataTableView):
template_name = "infrastructure/roles/index.html"
def get_data(self):
roles = api.tuskar.OvercloudRole.list(self.request)
plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
roles = api.tuskar.Role.list(self.request)
plan = api.tuskar.Plan.get_the_plan(self.request)
for role in roles:
role_flavor = role.flavor(plan)
role_image = role.image(plan)
@ -68,7 +68,7 @@ class IndexView(horizon_tables.DataTableView):
return roles
class DetailView(horizon_tables.DataTableView, OvercloudRoleMixin, StackMixin):
class DetailView(horizon_tables.DataTableView, RoleMixin, StackMixin):
table_class = tables.NodeTable
template_name = 'infrastructure/roles/detail.html'
@ -101,7 +101,7 @@ class DetailView(horizon_tables.DataTableView, OvercloudRoleMixin, StackMixin):
context = super(DetailView, self).get_context_data(**kwargs)
redirect = reverse(INDEX_URL)
plan = api.tuskar.OvercloudPlan.get_the_plan(self.request)
plan = api.tuskar.Plan.get_the_plan(self.request)
stack = self.get_stack(redirect)
role = self.get_role(redirect)

View File

@ -51,7 +51,7 @@ class HeatAPITests(test.APITestCase):
with patch('tuskarclient.v2.plans.PlanManager.list',
return_value=[plan]):
ret_val = stack.plan
self.assertIsInstance(ret_val, api.tuskar.OvercloudPlan)
self.assertIsInstance(ret_val, api.tuskar.Plan)
def test_stack_events(self):
event_list = self.heatclient_events.list()
@ -99,7 +99,7 @@ class HeatAPITests(test.APITestCase):
def test_stack_dashboard_url(self):
stack = api.heat.Stack(self.heatclient_stacks.first())
stack.plan = api.tuskar.OvercloudPlan(self.tuskarclient_plans.first())
stack.plan = api.tuskar.Plan(self.tuskarclient_plans.first())
mocked_service = mock.Mock(id='horizon_id')
mocked_service.name = 'horizon'

View File

@ -25,17 +25,17 @@ class TuskarAPITests(test.APITestCase):
with patch('tuskarclient.v2.plans.PlanManager.create',
return_value=plan):
ret_val = api.tuskar.OvercloudPlan.create(self.request, {}, {})
self.assertIsInstance(ret_val, api.tuskar.OvercloudPlan)
ret_val = api.tuskar.Plan.create(self.request, {}, {})
self.assertIsInstance(ret_val, api.tuskar.Plan)
def test_plan_list(self):
plans = self.tuskarclient_plans.list()
with patch('tuskarclient.v2.plans.PlanManager.list',
return_value=plans):
ret_val = api.tuskar.OvercloudPlan.list(self.request)
ret_val = api.tuskar.Plan.list(self.request)
for plan in ret_val:
self.assertIsInstance(plan, api.tuskar.OvercloudPlan)
self.assertIsInstance(plan, api.tuskar.Plan)
self.assertEqual(1, len(ret_val))
def test_plan_get(self):
@ -43,9 +43,9 @@ class TuskarAPITests(test.APITestCase):
with patch('tuskarclient.v2.plans.PlanManager.get',
return_value=plan):
ret_val = api.tuskar.OvercloudPlan.get(self.request, plan.uuid)
ret_val = api.tuskar.Plan.get(self.request, plan.uuid)
self.assertIsInstance(ret_val, api.tuskar.OvercloudPlan)
self.assertIsInstance(ret_val, api.tuskar.Plan)
def test_plan_get_the_plan(self):
plan = self.tuskarclient_plans.first()
@ -54,39 +54,39 @@ class TuskarAPITests(test.APITestCase):
return_value=[plan]):
with patch('tuskarclient.v2.plans.PlanManager.create',
return_value=plan):
ret_val = api.tuskar.OvercloudPlan.get_the_plan(self.request)
ret_val = api.tuskar.Plan.get_the_plan(self.request)
self.assertIsInstance(ret_val, api.tuskar.OvercloudPlan)
self.assertIsInstance(ret_val, api.tuskar.Plan)
def test_plan_delete(self):
plan = self.tuskarclient_plans.first()
with patch('tuskarclient.v2.plans.PlanManager.delete',
return_value=None):
api.tuskar.OvercloudPlan.delete(self.request, plan.uuid)
api.tuskar.Plan.delete(self.request, plan.uuid)
def test_plan_role_list(self):
with patch('tuskarclient.v2.plans.PlanManager.get',
return_value=[]):
plan = api.tuskar.OvercloudPlan(self.tuskarclient_plans.first(),
self.request)
plan = api.tuskar.Plan(self.tuskarclient_plans.first(),
self.request)
with patch('tuskarclient.v2.roles.RoleManager.list',
return_value=self.tuskarclient_roles.list()):
ret_val = plan.role_list
self.assertEqual(4, len(ret_val))
for r in ret_val:
self.assertIsInstance(r, api.tuskar.OvercloudRole)
self.assertIsInstance(r, api.tuskar.Role)
def test_role_list(self):
roles = self.tuskarclient_roles.list()
with patch('tuskarclient.v2.roles.RoleManager.list',
return_value=roles):
ret_val = api.tuskar.OvercloudRole.list(self.request)
ret_val = api.tuskar.Role.list(self.request)
for r in ret_val:
self.assertIsInstance(r, api.tuskar.OvercloudRole)
self.assertIsInstance(r, api.tuskar.Role)
self.assertEqual(4, len(ret_val))
def test_role_get(self):
@ -94,18 +94,18 @@ class TuskarAPITests(test.APITestCase):
with patch('tuskarclient.v2.roles.RoleManager.list',
return_value=roles):
ret_val = api.tuskar.OvercloudRole.get(self.request,
roles[0].uuid)
self.assertIsInstance(ret_val, api.tuskar.OvercloudRole)
ret_val = api.tuskar.Role.get(self.request,
roles[0].uuid)
self.assertIsInstance(ret_val, api.tuskar.Role)
def test_role_get_by_image(self):
plan = api.tuskar.OvercloudPlan(self.tuskarclient_plans.first())
plan = api.tuskar.Plan(self.tuskarclient_plans.first())
image = self.glanceclient_images.first()
roles = self.tuskarclient_roles.list()
with patch('tuskarclient.v2.roles.RoleManager.list',
return_value=roles):
ret_val = api.tuskar.OvercloudRole.get_by_image(
ret_val = api.tuskar.Role.get_by_image(
self.request, plan, image)
self.assertIsInstance(ret_val, api.tuskar.OvercloudRole)
self.assertIsInstance(ret_val, api.tuskar.Role)
self.assertEqual(ret_val.name, 'Controller')