minor fixes
This commit is contained in:
@@ -125,10 +125,10 @@ class ComputeBackend(KindBackend, ActionBackend):
|
||||
LOG.debug('Updating an Virtual machine: ', uid)
|
||||
|
||||
# update title, summary etc.
|
||||
if len(new.attributes['occi.core.title']) > 0:
|
||||
if 'occi.core.title' in new.attributes:
|
||||
old.attributes['occi.core.title'] = \
|
||||
new.attributes['occi.core.title']
|
||||
if len(new.attributes['occi.core.summary']) > 0:
|
||||
if 'occi.core.summary' in new.attributes:
|
||||
old.attributes['occi.core.summary'] = \
|
||||
new.attributes['occi.core.summary']
|
||||
|
||||
|
@@ -158,7 +158,7 @@ class SecurityGroupBackend(backend.UserDefinedMixinBackend):
|
||||
context = extras['nova_ctx']
|
||||
security_group = security.retrieve_group(category.term,
|
||||
extras['nova_ctx'].project_id,
|
||||
extras)
|
||||
extras['nova_ctx'])
|
||||
security.remove_group(security_group, context)
|
||||
|
||||
|
||||
|
@@ -76,7 +76,6 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry):
|
||||
if (hasattr(category, 'related') and
|
||||
occi_future.SEC_GROUP in category.related):
|
||||
backend = openstack.SecurityGroupBackend()
|
||||
backend = backend
|
||||
backend.init_sec_group(category, extras)
|
||||
|
||||
super(OCCIRegistry, self).set_backend(category, backend, extras)
|
||||
|
@@ -34,6 +34,8 @@ class StorageLinkBackend(backend.KindBackend):
|
||||
A backend for the storage links.
|
||||
"""
|
||||
|
||||
# TODO: need to implement retrieve so states get updated!!!!
|
||||
|
||||
def create(self, link, extras):
|
||||
"""
|
||||
Creates a link from a compute instance to a storage volume.
|
||||
|
@@ -111,7 +111,7 @@ class StorageBackend(backend.KindBackend, backend.ActionBackend):
|
||||
Deletes the storage resource
|
||||
"""
|
||||
context = extras['nova_ctx']
|
||||
volume_id = int(entity.attributes['occi.core.id'])
|
||||
volume_id = entity.attributes['occi.core.id']
|
||||
|
||||
vol.delete_storage_instance(volume_id, context)
|
||||
|
||||
|
@@ -60,12 +60,17 @@ def remove_group(group_id, context):
|
||||
context -- The os context.
|
||||
"""
|
||||
# TODO: check exception handling!
|
||||
if db.security_group_in_use(context, group_id):
|
||||
raise AttributeError('Security group is still in use')
|
||||
|
||||
db.security_group_destroy(context, group_id)
|
||||
SEC_HANDLER.trigger_security_group_destroy_refresh(
|
||||
context, group_id)
|
||||
|
||||
try:
|
||||
if db.security_group_in_use(context, group_id):
|
||||
raise AttributeError('Security group is still in use')
|
||||
|
||||
db.security_group_destroy(context, group_id)
|
||||
SEC_HANDLER.trigger_security_group_destroy_refresh(
|
||||
context, group_id)
|
||||
except Exception as error:
|
||||
raise AttributeError(error)
|
||||
|
||||
|
||||
def retrieve_group(mixin_term, project_id, context):
|
||||
@@ -118,8 +123,9 @@ def remove_rule(rule, context):
|
||||
db.security_group_rule_destroy(context, rule['id'])
|
||||
SEC_HANDLER.trigger_security_group_rule_destroy_refresh(context,
|
||||
[rule['id']])
|
||||
COMPUTE_API.trigger_security_group_rules_refresh(context,
|
||||
security_group['id'])
|
||||
# TODO: method is one!
|
||||
#SEC_HANDLER.trigger_security_group_rules_refresh(context,
|
||||
# security_group['id'])
|
||||
|
||||
|
||||
def get_rule(uid, context):
|
||||
|
@@ -168,7 +168,7 @@ def rebuild_vm(uid, image_href, context):
|
||||
COMPUTE_API.rebuild(context, instance, image_href, admin_password,
|
||||
**kwargs)
|
||||
except exception.InstanceInvalidState:
|
||||
raise exceptions.HTTPError(409, 'VM is in an invalid state.')
|
||||
raise AttributeError('VM is in an invalid state.')
|
||||
except exception.ImageNotFound:
|
||||
raise AttributeError('Cannot find image for rebuild')
|
||||
|
||||
@@ -194,8 +194,9 @@ def resize_vm(uid, flavor_name, context):
|
||||
raise AttributeError('Unable to locate requested flavor.')
|
||||
except exception.CannotResizeToSameSize:
|
||||
raise AttributeError('Resize requires a change in size.')
|
||||
except exception.InstanceInvalidState:
|
||||
raise exceptions.HTTPError(409, 'VM is in an invalid state.')
|
||||
except exception.InstanceInvalidState as error:
|
||||
raise error
|
||||
#raise AttributeError('VM is in an invalid state.')
|
||||
|
||||
|
||||
def delete_vm(uid, context):
|
||||
@@ -309,7 +310,7 @@ def restart_vm(uid, method, context):
|
||||
try:
|
||||
COMPUTE_API.reboot(context, instance, reboot_type)
|
||||
except exception.InstanceInvalidState:
|
||||
raise exceptions.HTTPError(409, 'VM is in an invalid state.')
|
||||
raise exceptions.HTTPError(406, 'VM is in an invalid state.')
|
||||
except Exception as error:
|
||||
msg = ("Error in reboot %s") % error
|
||||
raise exceptions.HTTPError(500, msg)
|
||||
@@ -330,7 +331,6 @@ def attach_volume(instance_id, volume_id, mount_point, context):
|
||||
vol_instance = VOLUME_API.get(context, volume_id)
|
||||
except exception.NotFound:
|
||||
raise exceptions.HTTPError(404, 'Volume not found!')
|
||||
LOG.debug(str(vol_instance) + ',' + str(dir(vol_instance)))
|
||||
volume_id = vol_instance['id']
|
||||
|
||||
try:
|
||||
@@ -355,9 +355,14 @@ def detach_volume(volume_id, context):
|
||||
instance = VOLUME_API.get(context, volume_id)
|
||||
except exception.NotFound:
|
||||
raise exceptions.HTTPError(404, 'Volume not found!')
|
||||
volume_id = instance[0]
|
||||
volume_id = instance['id']
|
||||
|
||||
COMPUTE_API.detach_volumne(context, volume_id)
|
||||
try:
|
||||
#TODO(dizz): see issue #15
|
||||
COMPUTE_API.detach_volume(context, volume_id)
|
||||
except Exception as error:
|
||||
LOG.error(str(error) + volume_id)
|
||||
raise error
|
||||
|
||||
|
||||
def set_password_for_vm(uid, password, context):
|
||||
@@ -403,7 +408,7 @@ def revert_resize_vm(uid, context):
|
||||
except exception.MigrationNotFound:
|
||||
raise AttributeError('Instance has not been resized.')
|
||||
except exception.InstanceInvalidState:
|
||||
raise exceptions.HTTPError(409, 'VM is an invalid state.')
|
||||
raise exceptions.HTTPError(406, 'VM is an invalid state.')
|
||||
except Exception:
|
||||
raise AttributeError('Error in revert-resize.')
|
||||
|
||||
@@ -420,8 +425,9 @@ def confirm_resize_vm(uid, context):
|
||||
COMPUTE_API.confirm_resize(context, instance)
|
||||
except exception.MigrationNotFound:
|
||||
raise AttributeError('Instance has not been resized.')
|
||||
except exception.InstanceInvalidState:
|
||||
raise exceptions.HTTPError(409, 'VM is an invalid state.')
|
||||
except exception.InstanceInvalidState as error:
|
||||
raise error
|
||||
# raise exceptions.HTTPError(406, 'VM is an invalid state.')
|
||||
except Exception:
|
||||
raise AttributeError('Error in confirm-resize.')
|
||||
|
||||
|
Reference in New Issue
Block a user