From e719f92b6be4ca76bb2cbc684a93e169d634d47d Mon Sep 17 00:00:00 2001 From: Thijs Metsch Date: Mon, 8 Oct 2012 15:08:53 +0200 Subject: [PATCH] cleared all unresolved references --- api/registry.py | 5 ++++- api/wsgi.py | 9 ++++----- nova_glue/security.py | 7 +++---- nova_glue/vm.py | 15 ++++++--------- nova_glue/vol.py | 5 +++-- runme.py | 10 +++++----- tests/system_test.py | 3 +++ 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/api/registry.py b/api/registry.py index 4e7fdbb..cb06912 100644 --- a/api/registry.py +++ b/api/registry.py @@ -40,6 +40,9 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry): self.transient = {} def set_hostname(self, hostname): + """ + Set the hostname. + """ if FLAGS.occi_custom_location_hostname: hostname = FLAGS.occi_custom_location_hostname super(OCCIRegistry, self).set_hostname(hostname) @@ -95,7 +98,7 @@ class OCCIRegistry(occi_registry.NonePersistentRegistry): """ # TODO: move to pyssf! if self.resources[key].extras is not None and self.resources[key]\ - .extras != self.get_extras(extras): + .extras != self.get_extras(extras): raise KeyError return self.resources[key] diff --git a/api/wsgi.py b/api/wsgi.py index 3111469..f069bd2 100644 --- a/api/wsgi.py +++ b/api/wsgi.py @@ -27,8 +27,8 @@ import logging from nova import flags from nova import wsgi from nova import context -from nova import image from nova import db +from nova.image import glance from nova.compute import instance_types from nova.network import api from nova.openstack.common import cfg @@ -66,9 +66,8 @@ OCCI_OPTS = [ default=8787, help="Port OCCI interface will listen on."), cfg.StrOpt("occi_custom_location_hostname", - default=None, - help="Override OCCI location hostname with custom value") - + default=None, + help="Override OCCI location hostname with custom value") ] FLAGS = flags.FLAGS @@ -223,7 +222,7 @@ class OCCIApplication(occi_wsgi.Application, wsgi.Application): information retrieved from glance (shared and user-specific). """ template_schema = 'http://schemas.openstack.org/template/os#' - image_service = image.get_default_image_service() + image_service = glance.get_default_image_service() images = image_service.detail(extras['nova_ctx']) filter_kernel_and_ram_images = \ diff --git a/nova_glue/security.py b/nova_glue/security.py index 4a8b75b..3f7c004 100644 --- a/nova_glue/security.py +++ b/nova_glue/security.py @@ -19,19 +19,18 @@ Security related 'glue' """ - from nova import compute from nova import db -from nova import utils from nova.flags import FLAGS +from nova.openstack.common import importutils # connect to nova from occi import exceptions COMPUTE_API = compute.API() -SEC_HANDLER = utils.import_object(FLAGS.security_group_handler) -#SEC_HANDLER = importutils.import_object(FLAGS.security_group_handler) +# SEC_HANDLER = utils.import_object(FLAGS.security_group_handler) +SEC_HANDLER = importutils.import_object(FLAGS.security_group_handler) def create_group(name, description, context): diff --git a/nova_glue/vm.py b/nova_glue/vm.py index 3caf6cf..65acc7d 100644 --- a/nova_glue/vm.py +++ b/nova_glue/vm.py @@ -109,8 +109,8 @@ def create_vm(entity, context): raise AttributeError('Please provide a valid OS Template.') if resource_template: - inst_type = compute.instance_types.get_instance_type_by_name\ - (resource_template.term) + inst_type = compute.instance_types.\ + get_instance_type_by_name(resource_template.term) else: inst_type = compute.instance_types.get_default_instance_type() msg = ('No resource template was found in the request. ' @@ -190,8 +190,6 @@ def resize_vm(uid, flavor_name, context): **kwargs) except exception.FlavorNotFound: raise AttributeError('Unable to locate requested flavor.') - except exception.CannotResizeToSameSize: - raise AttributeError('Resize requires a change in size.') except exception.InstanceInvalidState as error: raise error #raise AttributeError('VM is in an invalid state.') @@ -387,8 +385,8 @@ def get_vnc(uid, context): instance = get_vm(uid, context) try: console = COMPUTE_API.get_vnc_console(context, instance, 'novnc') - except Exception as error: - LOG.warn('Console info is not available yet!') + except exception.ConsoleTypeInvalid: + LOG.warn('Console info is not availabl!') return None return console @@ -461,8 +459,7 @@ def get_occi_state(uid, context): state = 'inactive' actions = [] - if instance['vm_state'] in [vm_states.ACTIVE, - vm_states.RESIZING]: + if instance['vm_state'] in [vm_states.ACTIVE]: state = 'active' actions.append(infrastructure.STOP) actions.append(infrastructure.SUSPEND) @@ -474,7 +471,7 @@ def get_occi_state(uid, context): state = 'inactive' actions.append(infrastructure.START) elif instance['vm_state'] in [vm_states.RESCUED, - vm_states.ERROR, vm_states.SOFT_DELETE, + vm_states.ERROR, vm_states.DELETED]: state = 'inactive' diff --git a/nova_glue/vol.py b/nova_glue/vol.py index 16127c8..a116c23 100644 --- a/nova_glue/vol.py +++ b/nova_glue/vol.py @@ -21,8 +21,9 @@ Storage related glue :-) import random -from nova import image, exception +from nova import exception from nova import volume +from nova.image import glance from occi import exceptions @@ -31,7 +32,7 @@ from nova_glue import vm VOLUME_API = volume.API() -IMAGE_API = image.get_default_image_service() +IMAGE_API = glance.get_default_image_service() def create_storage(size, context, name=None, description=None): diff --git a/runme.py b/runme.py index e6b0622..9a5d8e2 100755 --- a/runme.py +++ b/runme.py @@ -1,4 +1,6 @@ #!/usr/bin/env python + +# coding=utf-8 # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,16 +29,14 @@ TOPDIR = os.path.normpath(os.path.join(os.path.abspath( if os.path.exists(os.path.join(TOPDIR, "nova", "__init__.py")): sys.path.insert(0, TOPDIR) - from nova import flags -from nova import log as logging from nova import service from nova import utils +from nova.openstack.common import log as logging if __name__ == '__main__': - utils.default_flagfile() - flags.FLAGS(sys.argv) - logging.setup() + flags.parse_args(sys.argv) + logging.setup("nova") utils.monkey_patch() SERVER = service.WSGIService('occiapi') service.serve(SERVER) diff --git a/tests/system_test.py b/tests/system_test.py index 21dc34d..782c1f7 100644 --- a/tests/system_test.py +++ b/tests/system_test.py @@ -173,6 +173,9 @@ class SystemTest(unittest.TestCase): def setUp(self): + """ + Setup the test. + """ # Get a security token: self.token = get_os_token('admin', 'os4all') LOG.info('security token is: ' + self.token)