Merge "Show instance lock/unlock actions based on the locked status"
This commit is contained in:
commit
aad5ad8c63
@ -51,6 +51,7 @@ LOG = logging.getLogger(__name__)
|
||||
VERSIONS = base.APIVersionManager("compute", preferred_version=2)
|
||||
VERSIONS.load_supported_version(1.1, {"client": nova_client, "version": 1.1})
|
||||
VERSIONS.load_supported_version(2, {"client": nova_client, "version": 2})
|
||||
VERSIONS.load_supported_version(2.9, {"client": nova_client, "version": 2.9})
|
||||
|
||||
# API static values
|
||||
INSTANCE_ACTIVE_STATE = 'ACTIVE'
|
||||
@ -100,10 +101,10 @@ class Server(base.APIResourceWrapper):
|
||||
_attrs = ['addresses', 'attrs', 'id', 'image', 'links',
|
||||
'metadata', 'name', 'private_ip', 'public_ip', 'status', 'uuid',
|
||||
'image_name', 'VirtualInterfaces', 'flavor', 'key_name', 'fault',
|
||||
'tenant_id', 'user_id', 'created', 'OS-EXT-STS:power_state',
|
||||
'OS-EXT-STS:task_state', 'OS-EXT-SRV-ATTR:instance_name',
|
||||
'OS-EXT-SRV-ATTR:host', 'OS-EXT-AZ:availability_zone',
|
||||
'OS-DCF:diskConfig']
|
||||
'tenant_id', 'user_id', 'created', 'locked',
|
||||
'OS-EXT-STS:power_state', 'OS-EXT-STS:task_state',
|
||||
'OS-EXT-SRV-ATTR:instance_name', 'OS-EXT-SRV-ATTR:host',
|
||||
'OS-EXT-AZ:availability_zone', 'OS-DCF:diskConfig']
|
||||
|
||||
def __init__(self, apiresource, request):
|
||||
super(Server, self).__init__(apiresource)
|
||||
|
@ -878,9 +878,11 @@ class LockInstance(policy.PolicyTargetMixin, tables.BatchAction):
|
||||
count
|
||||
)
|
||||
|
||||
# TODO(akrivoka): When the lock status is added to nova, revisit this
|
||||
# to only allow unlocked instances to be locked
|
||||
def allowed(self, request, instance):
|
||||
# if not locked, lock should be available
|
||||
if getattr(instance, 'locked', False):
|
||||
return False
|
||||
if not api.nova.extension_supported('AdminActions', request):
|
||||
return False
|
||||
return True
|
||||
@ -909,9 +911,10 @@ class UnlockInstance(policy.PolicyTargetMixin, tables.BatchAction):
|
||||
count
|
||||
)
|
||||
|
||||
# TODO(akrivoka): When the lock status is added to nova, revisit this
|
||||
# to only allow locked instances to be unlocked
|
||||
def allowed(self, request, instance):
|
||||
if not getattr(instance, 'locked', True):
|
||||
return False
|
||||
if not api.nova.extension_supported('AdminActions', request):
|
||||
return False
|
||||
return True
|
||||
|
@ -53,6 +53,7 @@ WEBROOT = '/'
|
||||
# NOTE: The version should be formatted as it appears in the URL for the
|
||||
# service API. For example, The identity service APIs have inconsistent
|
||||
# use of the decimal point, so valid options would be 2.0 or 3.
|
||||
# Minimum compute version to get the instance locked status is 2.9.
|
||||
#OPENSTACK_API_VERSIONS = {
|
||||
# "data-processing": 1.1,
|
||||
# "identity": 3,
|
||||
|
Loading…
Reference in New Issue
Block a user