Merge "Add instance locked status on instances table"
This commit is contained in:
commit
4a4c50a78e
@ -493,15 +493,21 @@ def server_delete(request, instance_id):
|
||||
novaclient(request).servers.delete(instance_id)
|
||||
|
||||
|
||||
def get_novaclient_with_locked_status(request):
|
||||
microversion = get_microversion(request, "locked_attribute")
|
||||
return novaclient(request, version=microversion)
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def server_get(request, instance_id):
|
||||
return Server(novaclient(request).servers.get(instance_id), request)
|
||||
return Server(get_novaclient_with_locked_status(request).servers.get(
|
||||
instance_id), request)
|
||||
|
||||
|
||||
@profiler.trace
|
||||
def server_list(request, search_opts=None, all_tenants=False, detailed=True):
|
||||
nova_client = get_novaclient_with_locked_status(request)
|
||||
page_size = utils.get_page_size(request)
|
||||
c = novaclient(request)
|
||||
paginate = False
|
||||
if search_opts is None:
|
||||
search_opts = {}
|
||||
@ -515,7 +521,7 @@ def server_list(request, search_opts=None, all_tenants=False, detailed=True):
|
||||
else:
|
||||
search_opts['project_id'] = request.user.tenant_id
|
||||
servers = [Server(s, request)
|
||||
for s in c.servers.list(detailed, search_opts)]
|
||||
for s in nova_client.servers.list(detailed, search_opts)]
|
||||
|
||||
has_more_data = False
|
||||
if paginate and len(servers) > page_size:
|
||||
|
@ -152,6 +152,9 @@ class AdminInstancesTable(tables.DataTable):
|
||||
status=True,
|
||||
status_choices=STATUS_CHOICES,
|
||||
display_choices=project_tables.STATUS_DISPLAY_CHOICES)
|
||||
locked = tables.Column(project_tables.render_locked,
|
||||
verbose_name=_(" "),
|
||||
sortable=False)
|
||||
task = tables.Column("OS-EXT-STS:task_state",
|
||||
verbose_name=_("Task"),
|
||||
empty_value=project_tables.TASK_DISPLAY_NONE,
|
||||
|
@ -22,6 +22,7 @@ from django import shortcuts
|
||||
from django import template
|
||||
from django.template.defaultfilters import title
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import npgettext_lazy
|
||||
from django.utils.translation import pgettext_lazy
|
||||
from django.utils.translation import string_concat
|
||||
@ -1183,6 +1184,23 @@ class InstancesFilterAction(tables.FilterAction):
|
||||
filter_choices = INSTANCE_FILTER_CHOICES
|
||||
|
||||
|
||||
def render_locked(instance):
|
||||
if not hasattr(instance, 'locked'):
|
||||
return ""
|
||||
if instance.locked:
|
||||
icon_classes = "fa fa-fw fa-lock"
|
||||
help_tooltip = _("This instance is currently locked. To enable more "
|
||||
"actions on it, please unlock it by selecting Unlock "
|
||||
"Instance from the actions menu.")
|
||||
else:
|
||||
icon_classes = "fa fa-fw fa-unlock text-muted"
|
||||
help_tooltip = _("This instance is unlocked.")
|
||||
|
||||
locked_status = ('<span data-toggle="tooltip" title="{}" class="{}">'
|
||||
'</span>').format(help_tooltip, icon_classes)
|
||||
return mark_safe(locked_status)
|
||||
|
||||
|
||||
class InstancesTable(tables.DataTable):
|
||||
TASK_STATUS_CHOICES = (
|
||||
(None, True),
|
||||
@ -1216,6 +1234,9 @@ class InstancesTable(tables.DataTable):
|
||||
status=True,
|
||||
status_choices=STATUS_CHOICES,
|
||||
display_choices=STATUS_DISPLAY_CHOICES)
|
||||
locked = tables.Column(render_locked,
|
||||
verbose_name="",
|
||||
sortable=False)
|
||||
az = tables.Column("availability_zone",
|
||||
verbose_name=_("Availability Zone"))
|
||||
task = tables.Column("OS-EXT-STS:task_state",
|
||||
|
@ -8,6 +8,10 @@
|
||||
<dd>{{ instance.id }}</dd>
|
||||
<dt>{% trans "Status" %}</dt>
|
||||
<dd>{{ instance.status_label|title }}</dd>
|
||||
{% if instance.locked != None %}
|
||||
<dt>{% trans "Locked" %}</dt>
|
||||
<dd>{{ instance.locked }}</dd>
|
||||
{% endif %}
|
||||
<dt>{% trans "Availability Zone" %}</dt>
|
||||
<dd>{{ instance.availability_zone|default:_("-") }}</dd>
|
||||
<dt>{% trans "Created" %}</dt>
|
||||
|
@ -1093,6 +1093,8 @@ class NeutronApiFloatingIpTests(NeutronApiTestBase):
|
||||
servers = self.servers.list()
|
||||
novaclient = self.stub_novaclient()
|
||||
novaclient.servers = self.mox.CreateMockAnything()
|
||||
novaclient.versions = self.mox.CreateMockAnything()
|
||||
novaclient.versions.get_current().AndReturn("2.45")
|
||||
search_opts = {'project_id': self.request.user.tenant_id}
|
||||
novaclient.servers.list(False, search_opts).AndReturn(servers)
|
||||
|
||||
|
@ -141,6 +141,8 @@ class ComputeApiTests(test.APITestCase):
|
||||
|
||||
novaclient = self.stub_novaclient()
|
||||
novaclient.servers = self.mox.CreateMockAnything()
|
||||
novaclient.versions = self.mox.CreateMockAnything()
|
||||
novaclient.versions.get_current().AndReturn("2.45")
|
||||
novaclient.servers.list(True, {'all_tenants': True}).AndReturn(servers)
|
||||
self.mox.ReplayAll()
|
||||
|
||||
@ -154,6 +156,8 @@ class ComputeApiTests(test.APITestCase):
|
||||
servers = self.servers.list()
|
||||
novaclient = self.stub_novaclient()
|
||||
novaclient.servers = self.mox.CreateMockAnything()
|
||||
novaclient.versions = self.mox.CreateMockAnything()
|
||||
novaclient.versions.get_current().AndReturn("2.45")
|
||||
novaclient.servers.list(True,
|
||||
{'all_tenants': True,
|
||||
'marker': None,
|
||||
@ -174,6 +178,8 @@ class ComputeApiTests(test.APITestCase):
|
||||
servers = self.servers.list()
|
||||
novaclient = self.stub_novaclient()
|
||||
novaclient.servers = self.mox.CreateMockAnything()
|
||||
novaclient.versions = self.mox.CreateMockAnything()
|
||||
novaclient.versions.get_current().AndReturn("2.45")
|
||||
novaclient.servers.list(True,
|
||||
{'all_tenants': True,
|
||||
'marker': None,
|
||||
@ -267,6 +273,8 @@ class ComputeApiTests(test.APITestCase):
|
||||
server = self.servers.first()
|
||||
|
||||
novaclient = self.stub_novaclient()
|
||||
novaclient.versions = self.mox.CreateMockAnything()
|
||||
novaclient.versions.get_current().AndReturn("2.45")
|
||||
novaclient.servers = self.mox.CreateMockAnything()
|
||||
novaclient.servers.get(server.id).AndReturn(server)
|
||||
self.mox.ReplayAll()
|
||||
@ -385,6 +393,8 @@ class ComputeApiTests(test.APITestCase):
|
||||
novaclient = self.stub_novaclient()
|
||||
server_uuid = hypervisor.servers[0]["uuid"]
|
||||
|
||||
novaclient.versions = self.mox.CreateMockAnything()
|
||||
novaclient.versions.get_current().AndReturn("2.45")
|
||||
novaclient.hypervisors = self.mox.CreateMockAnything()
|
||||
novaclient.hypervisors.search('host', True).AndReturn([hypervisor])
|
||||
|
||||
@ -405,6 +415,8 @@ class ComputeApiTests(test.APITestCase):
|
||||
novaclient = self.stub_novaclient()
|
||||
server_uuid = hypervisor.servers[0]["uuid"]
|
||||
|
||||
novaclient.versions = self.mox.CreateMockAnything()
|
||||
novaclient.versions.get_current().AndReturn("2.45")
|
||||
novaclient.hypervisors = self.mox.CreateMockAnything()
|
||||
novaclient.hypervisors.search('host', True).AndReturn([hypervisor])
|
||||
|
||||
@ -425,6 +437,8 @@ class ComputeApiTests(test.APITestCase):
|
||||
novaclient = self.stub_novaclient()
|
||||
server_uuid = hypervisor.servers[0]["uuid"]
|
||||
|
||||
novaclient.versions = self.mox.CreateMockAnything()
|
||||
novaclient.versions.get_current().AndReturn("2.45")
|
||||
novaclient.hypervisors = self.mox.CreateMockAnything()
|
||||
novaclient.hypervisors.search('host', True).AndReturn([hypervisor])
|
||||
|
||||
|
@ -417,6 +417,9 @@ class APITestCase(TestCase):
|
||||
"""
|
||||
return self.stub_glanceclient()
|
||||
|
||||
def fake_novaclient(request, version=None):
|
||||
return self.stub_novaclient()
|
||||
|
||||
# Store the original clients
|
||||
self._original_glanceclient = api.glance.glanceclient
|
||||
self._original_keystoneclient = api.keystone.keystoneclient
|
||||
@ -428,7 +431,7 @@ class APITestCase(TestCase):
|
||||
# Replace the clients with our stubs.
|
||||
api.glance.glanceclient = fake_glanceclient
|
||||
api.keystone.keystoneclient = fake_keystoneclient
|
||||
api.nova.novaclient = lambda request: self.stub_novaclient()
|
||||
api.nova.novaclient = fake_novaclient
|
||||
api.neutron.neutronclient = lambda request: self.stub_neutronclient()
|
||||
api.cinder.cinderclient = lambda request: self.stub_cinderclient()
|
||||
api.heat.heatclient = (lambda request, password=None:
|
||||
|
6
releasenotes/notes/bug-1593903-8fb8721dc2449f71.yaml
Normal file
6
releasenotes/notes/bug-1593903-8fb8721dc2449f71.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Added a locked status column on admin/project instances table. It will
|
||||
show a locked or unlocked icon if nova 2.9 or above is used. The locked
|
||||
status is also available on instance details panel.
|
Loading…
Reference in New Issue
Block a user