From c5c621bbe64b2bc9a9645c542417ff28a8bd45d6 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Mon, 25 Jul 2011 16:26:23 -0700 Subject: [PATCH] some cleanup. VSA flag status changes. returned some files --- bin/nova-vsa | 8 ++------ nova/flags.py | 14 -------------- nova/scheduler/vsa.py | 6 ++++-- nova/tests/test_drive_types.py | 1 + nova/vsa/__init__.py | 1 + nova/vsa/api.py | 22 ++++++++++++++++------ nova/vsa/connection.py | 1 + nova/vsa/drive_types.py | 1 + nova/vsa/fake.py | 1 + nova/vsa/manager.py | 12 ++++++------ 10 files changed, 33 insertions(+), 34 deletions(-) diff --git a/bin/nova-vsa b/bin/nova-vsa index b15b7c7e..a67fe952 100755 --- a/bin/nova-vsa +++ b/bin/nova-vsa @@ -1,8 +1,8 @@ #!/usr/bin/env python # vim: tabstop=4 shiftwidth=4 softtabstop=4 -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. +# Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -18,10 +18,6 @@ # under the License. """Starter script for Nova VSA.""" - -import eventlet -eventlet.monkey_patch() - import gettext import os import sys diff --git a/nova/flags.py b/nova/flags.py index 8000eac4..9f596591 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -378,20 +378,6 @@ DEFINE_integer('max_vcs_in_vsa', 32, DEFINE_integer('vsa_part_size_gb', 100, 'default partition size for shared capacity') -DEFINE_string('vsa_status_creating', 'creating', - 'VSA creating (not ready yet)') -DEFINE_string('vsa_status_launching', 'launching', - 'Launching VCs (all BE volumes were created)') -DEFINE_string('vsa_status_created', 'created', - 'VSA fully created and ready for use') -DEFINE_string('vsa_status_partial', 'partial', - 'Some BE storage allocations failed') -DEFINE_string('vsa_status_failed', 'failed', - 'Some BE storage allocations failed') -DEFINE_string('vsa_status_deleting', 'deleting', - 'VSA started the deletion procedure') - - # The service to use for image search and retrieval DEFINE_string('image_service', 'nova.image.glance.GlanceImageService', 'The service to use for retrieving and searching for images.') diff --git a/nova/scheduler/vsa.py b/nova/scheduler/vsa.py index 059afce6..6931afc2 100644 --- a/nova/scheduler/vsa.py +++ b/nova/scheduler/vsa.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -24,6 +25,7 @@ from nova import rpc from nova import db from nova import flags from nova import utils +from nova.vsa.api import VsaState from nova.volume import api as volume_api from nova.scheduler import driver from nova.scheduler import simple @@ -301,7 +303,7 @@ class VsaScheduler(simple.SimpleScheduler): except: if vsa_id: db.vsa_update(context, vsa_id, - dict(status=FLAGS.vsa_status_failed)) + dict(status=VsaState.FAILED)) for vol in volume_params: if 'capabilities' in vol: @@ -346,7 +348,7 @@ class VsaScheduler(simple.SimpleScheduler): except: if volume_ref['to_vsa_id']: db.vsa_update(context, volume_ref['to_vsa_id'], - dict(status=FLAGS.vsa_status_failed)) + dict(status=VsaState.FAILED)) raise #return super(VsaScheduler, self).schedule_create_volume(context, # volume_id, *_args, **_kwargs) diff --git a/nova/tests/test_drive_types.py b/nova/tests/test_drive_types.py index 8534bcde..e91c4132 100644 --- a/nova/tests/test_drive_types.py +++ b/nova/tests/test_drive_types.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/nova/vsa/__init__.py b/nova/vsa/__init__.py index a94a6b7a..779b7fb6 100644 --- a/nova/vsa/__init__.py +++ b/nova/vsa/__init__.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/nova/vsa/api.py b/nova/vsa/api.py index 80637cc9..99793efa 100644 --- a/nova/vsa/api.py +++ b/nova/vsa/api.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -19,12 +20,10 @@ Handles all requests relating to Virtual Storage Arrays (VSAs). """ -#import datetime import sys import base64 from xml.etree import ElementTree -from xml.etree.ElementTree import Element, SubElement from nova import db from nova import exception @@ -47,6 +46,15 @@ flags.DEFINE_boolean('vsa_multi_vol_creation', True, LOG = logging.getLogger('nova.vsa') +class VsaState: + CREATING = 'creating' # VSA creating (not ready yet) + LAUNCHING = 'launching' # Launching VCs (all BE volumes were created) + CREATED = 'created' # VSA fully created and ready for use + PARTIAL = 'partial' # Some BE storage allocations failed + FAILED = 'failed' # Some BE storage allocations failed + DELETING = 'deleting' # VSA started the deletion procedure + + class API(base.Base): """API for interacting with the VSA manager.""" @@ -160,7 +168,7 @@ class API(base.Base): 'instance_type_id': instance_type['id'], 'image_ref': vc_image_href, 'vc_count': vc_count, - 'status': FLAGS.vsa_status_creating, + 'status': VsaState.CREATING, } LOG.info(_("Creating VSA: %s") % options) @@ -178,7 +186,7 @@ class API(base.Base): storage, shared) except exception.ApiError: self.update_vsa_status(context, vsa_id, - status=FLAGS.vsa_status_failed) + status=VsaState.FAILED) raise # after creating DB entry, re-check and set some defaults @@ -227,7 +235,7 @@ class API(base.Base): availability_zone=availability_zone) except: self.update_vsa_status(context, vsa_id, - status=FLAGS.vsa_status_partial) + status=VsaState.PARTIAL) raise if len(volume_params) == 0: @@ -369,7 +377,9 @@ class API(base.Base): return self.db.vsa_get_all_by_project(context, context.project_id) def generate_user_data(self, context, vsa, volumes): - e_vsa = Element("vsa") + SubElement = ElementTree.SubElement + + e_vsa = ElementTree.Element("vsa") e_vsa_detail = SubElement(e_vsa, "id") e_vsa_detail.text = str(vsa['id']) diff --git a/nova/vsa/connection.py b/nova/vsa/connection.py index 6c61acee..5de8021a 100644 --- a/nova/vsa/connection.py +++ b/nova/vsa/connection.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/nova/vsa/drive_types.py b/nova/vsa/drive_types.py index 5bec9604..86ff76b9 100644 --- a/nova/vsa/drive_types.py +++ b/nova/vsa/drive_types.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/nova/vsa/fake.py b/nova/vsa/fake.py index 308d21fe..d9613825 100644 --- a/nova/vsa/fake.py +++ b/nova/vsa/fake.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/nova/vsa/manager.py b/nova/vsa/manager.py index c6735867..1390f814 100644 --- a/nova/vsa/manager.py +++ b/nova/vsa/manager.py @@ -1,6 +1,7 @@ # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 Zadara Storage Inc. +# Copyright (c) 2011 OpenStack LLC. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -30,6 +31,7 @@ from nova import exception from nova import compute from nova import volume from nova import vsa +from nova.vsa.api import VsaState from nova.compute import instance_types @@ -114,9 +116,9 @@ class VsaManager(manager.SchedulerDependentManager): """Start VCs for VSA """ vsa_id = vsa['id'] - if vsa['status'] == FLAGS.vsa_status_creating: + if vsa['status'] == VsaState.CREATING: self.vsa_api.update_vsa_status(context, vsa_id, - FLAGS.vsa_status_launching) + VsaState.LAUNCHING) else: return @@ -144,8 +146,7 @@ class VsaManager(manager.SchedulerDependentManager): if has_failed_volumes: LOG.info(_("VSA ID %(vsa_id)d: Delete all BE volumes"), locals()) self.vsa_api.delete_be_volumes(context, vsa_id, force_delete=True) - self.vsa_api.update_vsa_status(context, vsa_id, - FLAGS.vsa_status_failed) + self.vsa_api.update_vsa_status(context, vsa_id, VsaState.FAILED) return # create user-data record for VC @@ -170,5 +171,4 @@ class VsaManager(manager.SchedulerDependentManager): user_data=storage_data, vsa_id=vsa_id) - self.vsa_api.update_vsa_status(context, vsa_id, - FLAGS.vsa_status_created) + self.vsa_api.update_vsa_status(context, vsa_id, VsaState.CREATED)