From c500eac4589e9cb22e5e71b900164a151290ec03 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/CA/newcerts/.placeholder | 0 nova/CA/private/.placeholder | 0 nova/CA/projects/.gitignore | 1 + nova/CA/projects/.placeholder | 0 nova/CA/reqs/.gitignore | 1 + nova/CA/reqs/.placeholder | 0 nova/api/ec2/cloud.py | 1 - nova/api/openstack/contrib/drive_types.py | 2 +- .../contrib/virtual_storage_arrays.py | 19 +++++++++------- .../migrate_repo/versions/036_add_vsa_data.py | 1 + nova/flags.py | 14 ------------ nova/scheduler/vsa.py | 6 +++-- nova/tests/api/openstack/contrib/test_vsa.py | 4 +++- nova/tests/test_drive_types.py | 1 + nova/volume/driver.py | 21 +++--------------- 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 +++++----- 22 files changed, 54 insertions(+), 63 deletions(-) create mode 100644 nova/CA/newcerts/.placeholder create mode 100644 nova/CA/private/.placeholder create mode 100644 nova/CA/projects/.gitignore create mode 100644 nova/CA/projects/.placeholder create mode 100644 nova/CA/reqs/.gitignore create mode 100644 nova/CA/reqs/.placeholder diff --git a/bin/nova-vsa b/bin/nova-vsa index b15b7c7edf40..a67fe952da7a 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/CA/newcerts/.placeholder b/nova/CA/newcerts/.placeholder new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/nova/CA/private/.placeholder b/nova/CA/private/.placeholder new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/nova/CA/projects/.gitignore b/nova/CA/projects/.gitignore new file mode 100644 index 000000000000..72e8ffc0db8a --- /dev/null +++ b/nova/CA/projects/.gitignore @@ -0,0 +1 @@ +* diff --git a/nova/CA/projects/.placeholder b/nova/CA/projects/.placeholder new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/nova/CA/reqs/.gitignore b/nova/CA/reqs/.gitignore new file mode 100644 index 000000000000..72e8ffc0db8a --- /dev/null +++ b/nova/CA/reqs/.gitignore @@ -0,0 +1 @@ +* diff --git a/nova/CA/reqs/.placeholder b/nova/CA/reqs/.placeholder new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 56a5850f6d16..6fc74c92a7a4 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -902,7 +902,6 @@ class CloudController(object): image_name = kwargs.get('image_name') availability_zone = kwargs.get('placement', {}).get( 'AvailabilityZone') - #storage = ast.literal_eval(kwargs.get('storage', '[]')) storage = kwargs.get('storage', []) shared = kwargs.get('shared', False) diff --git a/nova/api/openstack/contrib/drive_types.py b/nova/api/openstack/contrib/drive_types.py index 590eaaec011f..6454fd81f87f 100644 --- a/nova/api/openstack/contrib/drive_types.py +++ b/nova/api/openstack/contrib/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 @@ -118,7 +119,6 @@ class DriveTypeController(object): drive_types.delete(context, id) except exception.NotFound: return faults.Fault(exc.HTTPNotFound()) - # return exc.HTTPAccepted() class Drive_types(extensions.ExtensionDescriptor): diff --git a/nova/api/openstack/contrib/virtual_storage_arrays.py b/nova/api/openstack/contrib/virtual_storage_arrays.py index 6139b494eb04..68a00fd7d755 100644 --- a/nova/api/openstack/contrib/virtual_storage_arrays.py +++ b/nova/api/openstack/contrib/virtual_storage_arrays.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 @@ -153,7 +154,6 @@ class VsaController(object): self.vsa_api.delete(context, vsa_id=id) except exception.NotFound: return faults.Fault(exc.HTTPNotFound()) - # return exc.HTTPAccepted() class VsaVolumeDriveController(volumes.VolumeController): @@ -193,6 +193,7 @@ class VsaVolumeDriveController(volumes.VolumeController): d = translation(context, vol) d['vsaId'] = vol[self.direction] + d['name'] = vol['name'] return d def _check_volume_ownership(self, context, vsa_id, id): @@ -265,15 +266,17 @@ class VsaVolumeDriveController(volumes.VolumeController): return faults.Fault(exc.HTTPBadRequest()) vol = body[self.object] - updatable_fields = ['display_name', - 'display_description', - 'status', - 'provider_location', - 'provider_auth'] + updatable_fields = [{'displayName': 'display_name'}, + {'displayDescription': 'display_description'}, + {'status': 'status'}, + {'providerLocation': 'provider_location'}, + {'providerAuth': 'provider_auth'}] changes = {} for field in updatable_fields: - if field in vol: - changes[field] = vol[field] + key = field.keys()[0] + val = field[key] + if key in vol: + changes[val] = vol[key] obj = self.object LOG.audit(_("Update %(obj)s with id: %(id)s, changes: %(changes)s"), diff --git a/nova/db/sqlalchemy/migrate_repo/versions/036_add_vsa_data.py b/nova/db/sqlalchemy/migrate_repo/versions/036_add_vsa_data.py index 7fc8f955c1d2..5d2e56a7edad 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/036_add_vsa_data.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/036_add_vsa_data.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/flags.py b/nova/flags.py index 8000eac4a1ca..9f5965919f58 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 059afce683c3..6931afc2bfce 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/api/openstack/contrib/test_vsa.py b/nova/tests/api/openstack/contrib/test_vsa.py index c3150fa9c256..3c9136e141ad 100644 --- a/nova/tests/api/openstack/contrib/test_vsa.py +++ b/nova/tests/api/openstack/contrib/test_vsa.py @@ -234,6 +234,7 @@ def _get_default_volume_param(): 'availability_zone': 'nova', 'created_at': None, 'attach_status': 'detached', + 'name': 'vol name', 'display_name': 'Default vol name', 'display_description': 'Default vol description', 'from_vsa_id': None, @@ -386,7 +387,8 @@ class VSAVolumeApiTest(test.TestCase): def test_vsa_volume_update(self): obj_num = 234 if self.test_objs == "volumes" else 345 - update = {"status": "available"} + update = {"status": "available", + "displayName": "Test Display name"} body = {self.test_obj: update} req = webob.Request.blank('/v1.1/zadr-vsa/123/%s/%s' % \ (self.test_objs, obj_num)) diff --git a/nova/tests/test_drive_types.py b/nova/tests/test_drive_types.py index 8534bcde5cab..e91c41321568 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/volume/driver.py b/nova/volume/driver.py index b93fc1d92104..2e3da57b244e 100644 --- a/nova/volume/driver.py +++ b/nova/volume/driver.py @@ -507,15 +507,7 @@ class ISCSIDriver(VolumeDriver): iscsi_properties = self._get_iscsi_properties(volume) if not iscsi_properties['target_discovered']: - # zadara-begin: Bug in cactus. _run_iscsiadm() cannot accept - # multiple args for iscsi-command. Like in --op new. Hence - # using a local version here which does the same thing - (out, err) = self._execute('sudo', 'iscsiadm', '--op', 'new', - '-m', 'node', - '-T', iscsi_properties['target_iqn'], - '-p', iscsi_properties['target_portal']) - # self._run_iscsiadm(iscsi_properties, ('--op', 'new')) - # zadara-end + self._run_iscsiadm(iscsi_properties, ('--op', 'new')) if iscsi_properties.get('auth_method'): self._iscsiadm_update(iscsi_properties, @@ -567,15 +559,7 @@ class ISCSIDriver(VolumeDriver): iscsi_properties = self._get_iscsi_properties(volume) self._iscsiadm_update(iscsi_properties, "node.startup", "manual") self._run_iscsiadm(iscsi_properties, "--logout") - # zadara-begin: Bug in cactus. _run_iscsiadm() cannot accept - # multiple args for iscsi-command. Like in --op delete. Hence - # using a local version here which does the same thing - (out, err) = self._execute('sudo', 'iscsiadm', '--op', 'delete', - '-m', 'node', - '-T', iscsi_properties['target_iqn'], - '-p', iscsi_properties['target_portal']) - #self._run_iscsiadm(iscsi_properties, ('--op', 'delete')) - # zadara-end + self._run_iscsiadm(iscsi_properties, ('--op', 'delete')) def check_for_export(self, context, volume_id): """Make sure volume is exported.""" @@ -916,6 +900,7 @@ class ZadaraBEDriver(ISCSIDriver): ret = self._common_be_export(context, volume, iscsi_target) except: raise exception.ProcessExecutionError + return ret def remove_export(self, context, volume): """Removes BE export for a volume.""" diff --git a/nova/vsa/__init__.py b/nova/vsa/__init__.py index a94a6b7a440f..779b7fb65a8e 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 80637cc9e817..99793efa3d9b 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 6c61acee4852..5de8021a77ae 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 5bec96047da5..86ff76b96f6f 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 308d21fec36e..d96138255b4b 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 c6735867201a..1390f81460db 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)