From b814f9fef3efa1bdcb7e03a9161e08721b7bc8c4 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Fri, 15 Jul 2011 17:56:27 -0700 Subject: VSA: first cut. merged with 1279 --- bin/nova-api | 0 bin/nova-manage | 250 +++++++++++++++++++++++++++++++++++++++++++++++++++++- bin/nova-vncproxy | 0 3 files changed, 249 insertions(+), 1 deletion(-) mode change 100755 => 100644 bin/nova-api mode change 100755 => 100644 bin/nova-vncproxy (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api old mode 100755 new mode 100644 diff --git a/bin/nova-manage b/bin/nova-manage index b892d958a..4cf27ec8c 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -62,6 +62,10 @@ import sys import time +import tempfile +import zipfile +import ast + # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -84,6 +88,7 @@ from nova import rpc from nova import utils from nova import version from nova.api.ec2 import ec2utils +from nova.api.ec2 import cloud from nova.auth import manager from nova.cloudpipe import pipelib from nova.compute import instance_types @@ -870,6 +875,243 @@ class VersionCommands(object): (version.version_string(), version.version_string_with_vcs()) +class VsaCommands(object): + """Methods for dealing with VSAs""" + + def __init__(self, *args, **kwargs): + self.controller = cloud.CloudController() + self.manager = manager.AuthManager() + + # VP-TMP Solution for APIs. Project should be provided per API call + #self.context = context.get_admin_context() + + try: + project = self.manager.get_projects().pop() + except IndexError: + print (_("No projects defined")) + raise + + self.context = context.RequestContext(user=project.project_manager, + project=project) + + def _list(self, vsas): + format_str = "%-5s %-15s %-25s %-30s %-5s %-10s %-10s %-10s %10s" + if len(vsas): + print format_str %\ + (_('ID'), + _('vsa_id'), + _('displayName'), + _('description'), + _('count'), + _('vc_type'), + _('status'), + _('AZ'), + _('createTime')) + + for vsa in vsas: + print format_str %\ + (vsa['vsaId'], + vsa['name'], + vsa['displayName'], + vsa['displayDescription'], + vsa['vcCount'], + vsa['vcType'], + vsa['status'], + vsa['availabilityZone'], + str(vsa['createTime'])) + + def create(self, storage='[]', name=None, description=None, vc_count=1, + instance_type_name=None, image_name=None, shared=None, + az=None): + """Create a VSA. + args: [storage] [name] [description] [vc_count] + [instance_type] [image_name] [--shared|--full_drives] + [availability_zone] + + where is a string representing list of dictionaries + in the following format: + [{'drive_name': 'type', 'num_drives': N, 'size': M},..] + """ + + # Sanity check for storage string + storage_list = [] + if storage is not None: + try: + storage_list = ast.literal_eval(storage) + except: + print _("Invalid string format %s") % storage + raise + + for node in storage_list: + if ('drive_name' not in node) or ('num_drives' not in node): + print (_("Invalid string format for element %s. " \ + "Expecting keys 'drive_name' & 'num_drives'"), + str(node)) + raise KeyError + + if instance_type_name == '': + instance_type_name = None + + if shared is None or shared == "--full_drives": + shared = False + elif shared == "--shared": + shared = True + else: + raise ValueError(_('Shared parameter should be set either to "\ + "--shared or --full_drives')) + + values = { + 'display_name': name, + 'display_description': description, + 'vc_count': int(vc_count), + 'vc_type': instance_type_name, + 'image_name': image_name, + 'storage': storage_list, + 'shared': shared, + 'placement': {'AvailabilityZone': az} + } + + result = self.controller.create_vsa(self.context, **values) + self._list(result['vsaSet']) + + def update(self, vsa_id, name=None, description=None, vc_count=None): + """Updates name/description of vsa and number of VCs + args: vsa_id [display_name] [display_description] [vc_count]""" + + values = {} + if name is not None: + values['display_name'] = name + if description is not None: + values['display_description'] = description + if vc_count is not None: + values['vc_count'] = int(vc_count) + + self.controller.update_vsa(self.context, vsa_id, **values) + + def delete(self, vsa_id): + """Delete a vsa + args: vsa_id""" + + self.controller.delete_vsa(self.context, vsa_id) + + def list(self, vsa_id=None): + """Describe all available VSAs (or particular one) + args: [vsa_id]""" + + if vsa_id is not None: + vsa_id = [vsa_id] + + result = self.controller.describe_vsas(self.context, vsa_id) + self._list(result['vsaSet']) + + +class VsaDriveTypeCommands(object): + """Methods for dealing with VSA drive types""" + + def __init__(self, *args, **kwargs): + super(VsaDriveTypeCommands, self).__init__(*args, **kwargs) + + def _list(self, drives): + format_str = "%-5s %-30s %-10s %-10s %-10s %-20s %-10s %s" + if len(drives): + print format_str %\ + (_('ID'), + _('name'), + _('type'), + _('size_gb'), + _('rpm'), + _('capabilities'), + _('visible'), + _('createTime')) + + for drive in drives: + print format_str %\ + (str(drive['id']), + drive['name'], + drive['type'], + str(drive['size_gb']), + drive['rpm'], + drive['capabilities'], + str(drive['visible']), + str(drive['created_at'])) + + def create(self, type, size_gb, rpm, capabilities='', + visible=None, name=None): + """Create drive type. + args: type size_gb rpm [capabilities] [--show|--hide] [custom_name] + """ + + if visible is None or visible == "--show": + visible = True + elif visible == "--hide": + visible = False + else: + raise ValueError(_('Visible parameter should be set to --show '\ + 'or --hide')) + + values = { + 'type': type, + 'size_gb': int(size_gb), + 'rpm': rpm, + 'capabilities': capabilities, + 'visible': visible, + 'name': name + } + result = self.controller.create_drive_type(context.get_admin_context(), + **values) + self._list(result['driveTypeSet']) + + def delete(self, name): + """Delete drive type + args: name""" + + self.controller.delete_drive_type(context.get_admin_context(), name) + + def rename(self, name, new_name=None): + """Rename drive type + args: name [new_name]""" + + self.controller.rename_drive_type(context.get_admin_context(), + name, new_name) + + def list(self, visible=None, name=None): + """Describe all available VSA drive types (or particular one) + args: [--all] [drive_name]""" + + visible = False if visible == "--all" else True + + if name is not None: + name = [name] + + result = self.controller.describe_drive_types( + context.get_admin_context(), name, visible) + self._list(result['driveTypeSet']) + + def update(self, name, type=None, size_gb=None, rpm=None, + capabilities='', visible=None): + """Update drive type. + args: name [type] [size_gb] [rpm] [capabilities] [--show|--hide] + """ + + if visible is None or visible == "--show": + visible = True + elif visible == "--hide": + visible = False + else: + raise ValueError(_('Visible parameter should be set to --show '\ + 'or --hide')) + + values = { + 'type': type, + 'size_gb': size_gb, + 'rpm': rpm, + 'capabilities': capabilities, + 'visible': visible + } + self.controller.update_drive_type(context.get_admin_context(), + name, **values) + + class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" @@ -1214,6 +1456,7 @@ CATEGORIES = [ ('agent', AgentBuildCommands), ('config', ConfigCommands), ('db', DbCommands), + ('drive', VsaDriveTypeCommands), ('fixed', FixedIpCommands), ('flavor', InstanceTypeCommands), ('floating', FloatingIpCommands), @@ -1229,7 +1472,8 @@ CATEGORIES = [ ('version', VersionCommands), ('vm', VmCommands), ('volume', VolumeCommands), - ('vpn', VpnCommands)] + ('vpn', VpnCommands), + ('vsa', VsaCommands)] def lazy_match(name, key_value_tuples): @@ -1295,6 +1539,10 @@ def main(): action, fn = matches[0] # call the action with the remaining arguments try: + for arg in sys.argv: + if arg == '-h' or arg == '--help': + print "%s %s: %s" % (category, action, fn.__doc__) + sys.exit(0) fn(*argv) sys.exit(0) except TypeError: diff --git a/bin/nova-vncproxy b/bin/nova-vncproxy old mode 100755 new mode 100644 -- cgit From 3983bca4c9528d286b4e154956ceb749b4875274 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Mon, 18 Jul 2011 14:00:19 -0700 Subject: VSA schedulers reorg --- bin/nova-api | 0 bin/nova-logspool | 0 bin/nova-manage | 2 ++ bin/nova-spoolsentry | 0 bin/nova-vncproxy | 0 5 files changed, 2 insertions(+) mode change 100644 => 100755 bin/nova-api mode change 100644 => 100755 bin/nova-logspool mode change 100644 => 100755 bin/nova-spoolsentry mode change 100644 => 100755 bin/nova-vncproxy (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api old mode 100644 new mode 100755 diff --git a/bin/nova-logspool b/bin/nova-logspool old mode 100644 new mode 100755 diff --git a/bin/nova-manage b/bin/nova-manage index 4cf27ec8c..63db4ca56 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1009,6 +1009,8 @@ class VsaDriveTypeCommands(object): """Methods for dealing with VSA drive types""" def __init__(self, *args, **kwargs): + self.controller = cloud.CloudController() + self.manager = manager.AuthManager() super(VsaDriveTypeCommands, self).__init__(*args, **kwargs) def _list(self, drives): diff --git a/bin/nova-spoolsentry b/bin/nova-spoolsentry old mode 100644 new mode 100755 diff --git a/bin/nova-vncproxy b/bin/nova-vncproxy old mode 100644 new mode 100755 -- cgit From 9e74803d5eb8a70ba829ac0569f1cd6cd372a6f2 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Fri, 22 Jul 2011 15:14:29 -0700 Subject: Reverted volume driver part --- bin/nova-vsa | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 bin/nova-vsa (limited to 'bin') diff --git a/bin/nova-vsa b/bin/nova-vsa new file mode 100755 index 000000000..b15b7c7ed --- /dev/null +++ b/bin/nova-vsa @@ -0,0 +1,49 @@ +#!/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. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +"""Starter script for Nova VSA.""" + +import eventlet +eventlet.monkey_patch() + +import gettext +import os +import sys + +# If ../nova/__init__.py exists, add ../ to Python search path, so that +# it will override what happens to be installed in /usr/(local/)lib/python... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + +gettext.install('nova', unicode=1) + +from nova import flags +from nova import log as logging +from nova import service +from nova import utils + +if __name__ == '__main__': + utils.default_flagfile() + flags.FLAGS(sys.argv) + logging.setup() + service.serve() + service.wait() -- cgit From a719befe3e28994c02aab70e4b0e1871b318d971 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Sun, 24 Jul 2011 00:24:31 -0700 Subject: some file attrib changes --- bin/nova-logspool | 0 bin/nova-spoolsentry | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 bin/nova-logspool mode change 100755 => 100644 bin/nova-spoolsentry (limited to 'bin') diff --git a/bin/nova-logspool b/bin/nova-logspool old mode 100755 new mode 100644 diff --git a/bin/nova-spoolsentry b/bin/nova-spoolsentry old mode 100755 new mode 100644 -- cgit From c500eac4589e9cb22e5e71b900164a151290ec03 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Mon, 25 Jul 2011 16:26:23 -0700 Subject: some cleanup. VSA flag status changes. returned some files --- bin/nova-vsa | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-vsa b/bin/nova-vsa index b15b7c7ed..a67fe952d 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 -- cgit From b4159d95c32382d124c3f3f0a49f8ad9f2d41036 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Thu, 28 Jul 2011 00:27:16 -0700 Subject: some minor cosmetic work. addressed some dead code section --- bin/nova-vsa | 3 --- 1 file changed, 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-vsa b/bin/nova-vsa index a67fe952d..07f998117 100755 --- a/bin/nova-vsa +++ b/bin/nova-vsa @@ -18,7 +18,6 @@ # under the License. """Starter script for Nova VSA.""" -import gettext import os import sys @@ -30,8 +29,6 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) -gettext.install('nova', unicode=1) - from nova import flags from nova import log as logging from nova import service -- cgit From f4359a7789ae96a36aaab8f53aa3234d13b1725a Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Thu, 28 Jul 2011 15:54:02 -0700 Subject: returned vsa_manager, nova-manage arg and print changes --- bin/nova-manage | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 78b88e9ba..19793197c 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1018,15 +1018,15 @@ class VsaCommands(object): project=project) def _list(self, vsas): - format_str = "%-5s %-15s %-25s %-30s %-5s %-10s %-10s %-10s %10s" + format_str = "%-5s %-15s %-25s %-10s %-6s %-9s %-10s %-10s %10s" if len(vsas): print format_str %\ (_('ID'), _('vsa_id'), _('displayName'), - _('description'), - _('count'), _('vc_type'), + _('vc_cnt'), + _('drive_cnt'), _('status'), _('AZ'), _('createTime')) @@ -1036,9 +1036,9 @@ class VsaCommands(object): (vsa['vsaId'], vsa['name'], vsa['displayName'], - vsa['displayDescription'], - vsa['vcCount'], vsa['vcType'], + vsa['vcCount'], + vsa['volCount'], vsa['status'], vsa['availabilityZone'], str(vsa['createTime'])) @@ -1053,7 +1053,8 @@ class VsaCommands(object): @args('--instance_type', dest='instance_type_name', metavar="", help='Instance type name') @args('--image', dest='image_name', metavar="", help='Image name') - @args('--shared', dest='shared', metavar="", help='Use shared drives') + @args('--shared', dest='shared', action="store_true", default=False, + help='Use shared drives') @args('--az', dest='az', metavar="", help='Availability zone') def create(self, storage='[]', name=None, description=None, vc_count=1, instance_type_name=None, image_name=None, shared=None, @@ -1079,9 +1080,9 @@ class VsaCommands(object): if instance_type_name == '': instance_type_name = None - if shared is None or shared == "--full_drives": + if shared in [None, False, "--full_drives"]: shared = False - elif shared == "--shared": + elif shared in [True, "--shared"]: shared = True else: raise ValueError(_('Shared parameter should be set either to "\ @@ -1181,7 +1182,7 @@ class VsaDriveTypeCommands(object): visible=None, name=None): """Create drive type.""" - if visible is None or visible in ["--show", "show"]: + if visible in [None, "--show", "show"]: visible = True elif visible in ["--hide", "hide"]: visible = False @@ -1223,7 +1224,7 @@ class VsaDriveTypeCommands(object): def list(self, visible=None, name=None): """Describe all available VSA drive types (or particular one).""" - visible = False if visible == "--all" or visible == False else True + visible = False if visible in ["--all", False] else True if name is not None: name = [name] @@ -1245,21 +1246,21 @@ class VsaDriveTypeCommands(object): capabilities='', visible=None): """Update drive type.""" - if visible is None or visible in ["--show", "show"]: - visible = True - elif visible in ["--hide", "hide"]: - visible = False - else: - raise ValueError(_('Visible parameter should be set to --show '\ - 'or --hide')) - values = { 'type': type, 'size_gb': size_gb, 'rpm': rpm, 'capabilities': capabilities, - 'visible': visible } + if visible: + if visible in ["--show", "show"]: + values['visible'] = True + elif visible in ["--hide", "hide"]: + values['visible'] = False + else: + raise ValueError(_("Visible parameter should be set to "\ + "--show or --hide")) + self.controller.update_drive_type(context.get_admin_context(), name, **values) -- cgit From b66ea57ae10bac1656e11663e273837dfae67814 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Fri, 12 Aug 2011 12:51:54 -0700 Subject: removed VSA/drive_type code from EC2 cloud. changed nova-manage not to use cloud APIs --- bin/nova-manage | 87 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 40 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index a1732cb97..3b0bf47e2 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -96,6 +96,8 @@ from nova.auth import manager from nova.cloudpipe import pipelib from nova.compute import instance_types from nova.db import migration +from nova import vsa +from nova.vsa import drive_types FLAGS = flags.FLAGS flags.DECLARE('fixed_range', 'nova.network.manager') @@ -1028,9 +1030,8 @@ class VsaCommands(object): """Methods for dealing with VSAs""" def __init__(self, *args, **kwargs): - self.controller = cloud.CloudController() self.manager = manager.AuthManager() - + self.vsa_api = vsa.API() self.context = context.get_admin_context() def _list(self, vsas): @@ -1049,15 +1050,15 @@ class VsaCommands(object): for vsa in vsas: print format_str %\ - (vsa['vsaId'], + (vsa['id'], vsa['name'], - vsa['displayName'], - vsa['vcType'], - vsa['vcCount'], - vsa['volCount'], + vsa['display_name'], + vsa['vsa_instance_type'].get('name', None), + vsa['vc_count'], + vsa['vol_count'], vsa['status'], - vsa['availabilityZone'], - str(vsa['createTime'])) + vsa['availability_zone'], + str(vsa['created_at'])) @args('--storage', dest='storage', metavar="[{'drive_name': 'type', 'num_drives': N, 'size': M},..]", @@ -1124,6 +1125,9 @@ class VsaCommands(object): if instance_type_name == '': instance_type_name = None + if image_name == '': + image_name = None + if shared in [None, False, "--full_drives"]: shared = False elif shared in [True, "--shared"]: @@ -1136,15 +1140,15 @@ class VsaCommands(object): 'display_name': name, 'display_description': description, 'vc_count': int(vc_count), - 'vc_type': instance_type_name, + 'instance_type': instance_type_name, 'image_name': image_name, + 'availability_zone': az, 'storage': storage_list, 'shared': shared, - 'placement': {'AvailabilityZone': az} } - result = self.controller.create_vsa(ctxt, **values) - self._list(result['vsaSet']) + result = self.vsa_api.create(ctxt, **values) + self._list([result]) @args('--id', dest='vsa_id', metavar="", help='VSA ID') @args('--name', dest='name', metavar="", help='VSA name') @@ -1162,32 +1166,38 @@ class VsaCommands(object): if vc_count is not None: values['vc_count'] = int(vc_count) - self.controller.update_vsa(self.context, vsa_id, **values) + vsa_id = ec2utils.ec2_id_to_id(vsa_id) + result = self.vsa_api.update(self.context, vsa_id=vsa_id, **values) + self._list([result]) @args('--id', dest='vsa_id', metavar="", help='VSA ID') def delete(self, vsa_id): """Delete a VSA.""" - self.controller.delete_vsa(self.context, vsa_id) + vsa_id = ec2utils.ec2_id_to_id(vsa_id) + self.vsa_api.delete(self.context, vsa_id) @args('--id', dest='vsa_id', metavar="", help='VSA ID (optional)') def list(self, vsa_id=None): """Describe all available VSAs (or particular one).""" + vsas = [] if vsa_id is not None: - vsa_id = [vsa_id] + internal_id = ec2utils.ec2_id_to_id(vsa_id) + vsa = self.vsa_api.get(self.context, internal_id) + vsas.append(vsa) + else: + vsas = self.vsa_api.get_all(self.context) - result = self.controller.describe_vsas(self.context, vsa_id) - self._list(result['vsaSet']) + self._list(vsas) class VsaDriveTypeCommands(object): """Methods for dealing with VSA drive types""" def __init__(self, *args, **kwargs): - self.controller = cloud.CloudController() - self.manager = manager.AuthManager() super(VsaDriveTypeCommands, self).__init__(*args, **kwargs) + self.context = context.get_admin_context() def _list(self, drives): format_str = "%-5s %-30s %-10s %-10s %-10s %-20s %-10s %s" @@ -1234,23 +1244,17 @@ class VsaDriveTypeCommands(object): raise ValueError(_('Visible parameter should be set to --show '\ 'or --hide')) - values = { - 'type': type, - 'size_gb': int(size_gb), - 'rpm': rpm, - 'capabilities': capabilities, - 'visible': visible, - 'name': name - } - result = self.controller.create_drive_type(context.get_admin_context(), - **values) - self._list(result['driveTypeSet']) + result = drive_types.create(self.context, + type, int(size_gb), rpm, + capabilities, visible, name) + self._list([result]) @args('--name', dest='name', metavar="", help='Drive name') def delete(self, name): """Delete drive type.""" - self.controller.delete_drive_type(context.get_admin_context(), name) + dtype = drive_types.get_by_name(self.context, name) + drive_types.delete(self.context, dtype['id']) @args('--name', dest='name', metavar="", help='Drive name') @args('--new_name', dest='new_name', metavar="", @@ -1258,8 +1262,9 @@ class VsaDriveTypeCommands(object): def rename(self, name, new_name=None): """Rename drive type.""" - self.controller.rename_drive_type(context.get_admin_context(), - name, new_name) + dtype = drive_types.rename(self.context, + name, new_name) + self._list([dtype]) @args('--all', dest='visible', action="store_false", help='Show all drives') @@ -1271,11 +1276,12 @@ class VsaDriveTypeCommands(object): visible = False if visible in ["--all", False] else True if name is not None: - name = [name] + drive = drive_types.get_by_name(self.context, name) + drives = [drive] + else: + drives = drive_types.get_all(self.context, visible) - result = self.controller.describe_drive_types( - context.get_admin_context(), name, visible) - self._list(result['driveTypeSet']) + self._list(drives) @args('--name', dest='name', metavar="", help='Drive name') @args('--type', dest='type', metavar="", @@ -1305,8 +1311,9 @@ class VsaDriveTypeCommands(object): raise ValueError(_("Visible parameter should be set to "\ "--show or --hide")) - self.controller.update_drive_type(context.get_admin_context(), - name, **values) + dtype = drive_types.get_by_name(self.context, name) + dtype = drive_types.update(self.context, dtype['id'], **values) + self._list([dtype]) class VolumeCommands(object): -- cgit From 711a02450d24ba7385f2f22bf70a60ecfb452cfc Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Fri, 12 Aug 2011 13:37:22 -0700 Subject: nova-manage: fixed instance type in vsa creation --- bin/nova-manage | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 3b0bf47e2..dafcd5de0 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1124,6 +1124,8 @@ class VsaCommands(object): if instance_type_name == '': instance_type_name = None + instance_type = instance_types.get_instance_type_by_name( + instance_type_name) if image_name == '': image_name = None @@ -1140,7 +1142,7 @@ class VsaCommands(object): 'display_name': name, 'display_description': description, 'vc_count': int(vc_count), - 'instance_type': instance_type_name, + 'instance_type': instance_type, 'image_name': image_name, 'availability_zone': az, 'storage': storage_list, -- cgit From cabf9cc8f29ad8c99971c434516e1b911f07f32f Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Wed, 17 Aug 2011 16:27:12 -0700 Subject: nova-manage VSA print & forced update_cap changes; fixed bug with report capabilities; added IP address to VSA APIs; added instances to APIs --- bin/nova-manage | 196 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 169 insertions(+), 27 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index dafcd5de0..2b9bc48b8 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -96,6 +96,8 @@ from nova.auth import manager from nova.cloudpipe import pipelib from nova.compute import instance_types from nova.db import migration +from nova import compute +from nova import volume from nova import vsa from nova.vsa import drive_types @@ -1032,33 +1034,153 @@ class VsaCommands(object): def __init__(self, *args, **kwargs): self.manager = manager.AuthManager() self.vsa_api = vsa.API() + self.compute_api = compute.API() + self.volume_api = volume.API() self.context = context.get_admin_context() - def _list(self, vsas): - format_str = "%-5s %-15s %-25s %-10s %-6s %-9s %-10s %-10s %10s" - if len(vsas): - print format_str %\ - (_('ID'), - _('vsa_id'), - _('displayName'), - _('vc_type'), - _('vc_cnt'), - _('drive_cnt'), - _('status'), - _('AZ'), - _('createTime')) + self._format_str_vsa = "%-5s %-15s %-25s %-10s %-6s "\ + "%-9s %-10s %-10s %10s" + self._format_str_volume = "\t%-4s %-15s %-5s %-10s %-20s %s" + self._format_str_drive = "\t%-4s %-15s %-5s %-10s %-20s %s" + self._format_str_instance = "\t%-4s %-10s %-20s %-12s %-10s "\ + "%-15s %-15s %-10s %-15s %s" + + def _print_vsa_header(self): + print self._format_str_vsa %\ + (_('ID'), + _('vsa_id'), + _('displayName'), + _('vc_type'), + _('vc_cnt'), + _('drive_cnt'), + _('status'), + _('AZ'), + _('createTime')) + + def _print_vsa(self, vsa): + print self._format_str_vsa %\ + (vsa['id'], + vsa['name'], + vsa['display_name'], + vsa['vsa_instance_type'].get('name', None), + vsa['vc_count'], + vsa['vol_count'], + vsa['status'], + vsa['availability_zone'], + str(vsa['created_at'])) + + def _print_volume_header(self): + print _(' === Volumes ===') + print self._format_str_volume %\ + (_('ID'), + _('name'), + _('size'), + _('status'), + _('attachment'), + _('createTime')) + + def _print_volume(self, vol): + print self._format_str_volume %\ + (vol['id'], + vol['display_name'], + vol['size'], + vol['status'], + vol['attach_status'], + str(vol['created_at'])) + + def _print_drive_header(self): + print _(' === Drives ===') + print self._format_str_drive %\ + (_('ID'), + _('name'), + _('size'), + _('status'), + _('host'), + _('createTime')) + + def _print_drive(self, drive): + print self._format_str_volume %\ + (drive['id'], + drive['display_name'], + drive['size'], + drive['status'], + drive['host'], + str(drive['created_at'])) + + def _print_instance_header(self): + print _(' === Instances ===') + print self._format_str_instance %\ + (_('ID'), + _('name'), + _('disp_name'), + _('image'), + _('type'), + _('floating_IP'), + _('fixed_IP'), + _('status'), + _('host'), + _('createTime')) + + def _print_instance(self, vc): + + fixed_addr = None + floating_addr = None + if vc['fixed_ips']: + fixed = vc['fixed_ips'][0] + fixed_addr = fixed['address'] + if fixed['floating_ips']: + floating_addr = fixed['floating_ips'][0]['address'] + floating_addr = floating_addr or fixed_addr + + print self._format_str_instance %\ + (vc['id'], + ec2utils.id_to_ec2_id(vc['id']), + vc['display_name'], + ('ami-%08x' % int(vc['image_ref'])), + vc['instance_type']['name'], + floating_addr, + fixed_addr, + vc['state_description'], + vc['host'], + str(vc['created_at'])) + + def _list(self, context, vsas, print_drives=False, + print_volumes=False, print_instances=False): + if vsas: + self._print_vsa_header() for vsa in vsas: - print format_str %\ - (vsa['id'], - vsa['name'], - vsa['display_name'], - vsa['vsa_instance_type'].get('name', None), - vsa['vc_count'], - vsa['vol_count'], - vsa['status'], - vsa['availability_zone'], - str(vsa['created_at'])) + self._print_vsa(vsa) + vsa_id = vsa.get('id') + + if print_instances: + instances = self.compute_api.get_all(context, + search_opts={'metadata': + dict(vsa_id=str(vsa_id))}) + if instances: + print + self._print_instance_header() + for instance in instances: + self._print_instance(instance) + print + + if print_drives: + drives = self.volume_api.get_all_by_vsa(context, + vsa_id, "to") + if drives: + self._print_drive_header() + for drive in drives: + self._print_drive(drive) + print + + if print_volumes: + volumes = self.volume_api.get_all_by_vsa(context, + vsa_id, "from") + if volumes: + self._print_volume_header() + for volume in volumes: + self._print_volume(volume) + print @args('--storage', dest='storage', metavar="[{'drive_name': 'type', 'num_drives': N, 'size': M},..]", @@ -1150,7 +1272,7 @@ class VsaCommands(object): } result = self.vsa_api.create(ctxt, **values) - self._list([result]) + self._list(ctxt, [result]) @args('--id', dest='vsa_id', metavar="", help='VSA ID') @args('--name', dest='name', metavar="", help='VSA name') @@ -1170,7 +1292,7 @@ class VsaCommands(object): vsa_id = ec2utils.ec2_id_to_id(vsa_id) result = self.vsa_api.update(self.context, vsa_id=vsa_id, **values) - self._list([result]) + self._list(self.context, [result]) @args('--id', dest='vsa_id', metavar="", help='VSA ID') def delete(self, vsa_id): @@ -1180,7 +1302,16 @@ class VsaCommands(object): @args('--id', dest='vsa_id', metavar="", help='VSA ID (optional)') - def list(self, vsa_id=None): + @args('--all', dest='all', action="store_true", + help='Show all available details') + @args('--drives', dest='drives', action="store_true", + help='Include drive-level details') + @args('--volumes', dest='volumes', action="store_true", + help='Include volume-level details') + @args('--instances', dest='instances', action="store_true", + help='Include instance-level details') + def list(self, vsa_id=None, all=False, + drives=False, volumes=False, instances=False): """Describe all available VSAs (or particular one).""" vsas = [] @@ -1191,7 +1322,18 @@ class VsaCommands(object): else: vsas = self.vsa_api.get_all(self.context) - self._list(vsas) + if all: + drives = volumes = instances = True + + self._list(self.context, vsas, drives, volumes, instances) + + def update_capabilities(self): + """Forces updates capabilities on all nova-volume nodes.""" + + rpc.fanout_cast(context.get_admin_context(), + FLAGS.volume_topic, + {"method": "notification", + "args": {"event": "startup"}}) class VsaDriveTypeCommands(object): -- cgit From 48cd9689de31e408c792052747f714a9dbe1f8f7 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Wed, 24 Aug 2011 15:51:29 -0700 Subject: added virtio flag; associate address for VSA; cosmetic changes. Prior to volume_types merge --- bin/nova-manage | 4 ---- bin/nova-vsa | 1 - 2 files changed, 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 18a008d8c..d7636b811 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -64,9 +64,6 @@ import time from optparse import OptionParser - -import tempfile -import zipfile import ast # If ../nova/__init__.py exists, add ../ to Python search path, so that @@ -91,7 +88,6 @@ from nova import rpc from nova import utils from nova import version from nova.api.ec2 import ec2utils -from nova.api.ec2 import cloud from nova.auth import manager from nova.cloudpipe import pipelib from nova.compute import instance_types diff --git a/bin/nova-vsa b/bin/nova-vsa index 07f998117..d765e8f9e 100755 --- a/bin/nova-vsa +++ b/bin/nova-vsa @@ -3,7 +3,6 @@ # 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 # not use this file except in compliance with the License. You may obtain -- cgit From 4834b920e3186712ab56e65a88c2e8c838d16f9c Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Thu, 25 Aug 2011 18:38:35 -0700 Subject: VSA code redesign. Drive types completely replaced by Volume types --- bin/nova-manage | 206 ++++++++++++++++++++++++++++++++------------------------ bin/nova-vsa | 10 ++- 2 files changed, 128 insertions(+), 88 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index bd2d43139..977ad5c66 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -53,6 +53,7 @@ CLI interface for nova management. """ +import ast import gettext import glob import json @@ -64,8 +65,6 @@ import time from optparse import OptionParser -import ast - # If ../nova/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -87,15 +86,13 @@ from nova import quota from nova import rpc from nova import utils from nova import version +from nova import vsa from nova.api.ec2 import ec2utils from nova.auth import manager from nova.cloudpipe import pipelib from nova.compute import instance_types from nova.db import migration -from nova import compute -from nova import volume -from nova import vsa -from nova.vsa import drive_types +from nova.volume import volume_types FLAGS = flags.FLAGS flags.DECLARE('fixed_range', 'nova.network.manager') @@ -1076,14 +1073,12 @@ class VsaCommands(object): def __init__(self, *args, **kwargs): self.manager = manager.AuthManager() self.vsa_api = vsa.API() - self.compute_api = compute.API() - self.volume_api = volume.API() self.context = context.get_admin_context() self._format_str_vsa = "%-5s %-15s %-25s %-10s %-6s "\ "%-9s %-10s %-10s %10s" self._format_str_volume = "\t%-4s %-15s %-5s %-10s %-20s %s" - self._format_str_drive = "\t%-4s %-15s %-5s %-10s %-20s %s" + self._format_str_drive = "\t%-4s %-15s %-5s %-10s %-20s %-4s %-10s %s" self._format_str_instance = "\t%-4s %-10s %-20s %-12s %-10s "\ "%-15s %-15s %-10s %-15s %s" @@ -1124,7 +1119,7 @@ class VsaCommands(object): def _print_volume(self, vol): print self._format_str_volume %\ (vol['id'], - vol['display_name'], + vol['display_name'] or vol['name'], vol['size'], vol['status'], vol['attach_status'], @@ -1138,15 +1133,24 @@ class VsaCommands(object): _('size'), _('status'), _('host'), + _('type'), + _('typeName'), _('createTime')) def _print_drive(self, drive): - print self._format_str_volume %\ + if drive['volume_type_id'] is not None and drive.get('volume_type'): + drive_type_name = drive['volume_type'].get('name') + else: + drive_type_name = '' + + print self._format_str_drive %\ (drive['id'], drive['display_name'], drive['size'], drive['status'], drive['host'], + drive['volume_type_id'], + drive_type_name, str(drive['created_at'])) def _print_instance_header(self): @@ -1196,9 +1200,7 @@ class VsaCommands(object): vsa_id = vsa.get('id') if print_instances: - instances = self.compute_api.get_all(context, - search_opts={'metadata': - dict(vsa_id=str(vsa_id))}) + instances = self.vsa_api.get_all_vsa_instances(context, vsa_id) if instances: print self._print_instance_header() @@ -1207,8 +1209,7 @@ class VsaCommands(object): print if print_drives: - drives = self.volume_api.get_all_by_vsa(context, - vsa_id, "to") + drives = self.vsa_api.get_all_vsa_drives(context, vsa_id) if drives: self._print_drive_header() for drive in drives: @@ -1216,8 +1217,7 @@ class VsaCommands(object): print if print_volumes: - volumes = self.volume_api.get_all_by_vsa(context, - vsa_id, "from") + volumes = self.vsa_api.get_all_vsa_volumes(context, vsa_id) if volumes: self._print_volume_header() for volume in volumes: @@ -1344,7 +1344,7 @@ class VsaCommands(object): @args('--id', dest='vsa_id', metavar="", help='VSA ID (optional)') - @args('--all', dest='all', action="store_true", + @args('--all', dest='all', action="store_true", default=False, help='Show all available details') @args('--drives', dest='drives', action="store_true", help='Include drive-level details') @@ -1384,6 +1384,7 @@ class VsaDriveTypeCommands(object): def __init__(self, *args, **kwargs): super(VsaDriveTypeCommands, self).__init__(*args, **kwargs) self.context = context.get_admin_context() + self._drive_type_template = '%s_%sGB_%sRPM' def _list(self, drives): format_str = "%-5s %-30s %-10s %-10s %-10s %-20s %-10s %s" @@ -1398,75 +1399,94 @@ class VsaDriveTypeCommands(object): _('visible'), _('createTime')) - for drive in drives: + for name, vol_type in drives.iteritems(): + drive = vol_type.get('extra_specs') print format_str %\ - (str(drive['id']), - drive['name'], - drive['type'], - str(drive['size_gb']), - drive['rpm'], - drive['capabilities'], - str(drive['visible']), - str(drive['created_at'])) + (str(vol_type['id']), + drive['drive_name'], + drive['drive_type'], + drive['drive_size'], + drive['drive_rpm'], + drive.get('capabilities', ''), + str(drive.get('visible', '')), + str(vol_type['created_at'])) @args('--type', dest='type', metavar="", help='Drive type (SATA, SAS, SSD, etc.)') @args('--size', dest='size_gb', metavar="", help='Drive size in GB') @args('--rpm', dest='rpm', metavar="", help='RPM') - @args('--capabilities', dest='capabilities', metavar="", - help='Different capabilities') - @args('--visible', dest='visible', metavar="", + @args('--capabilities', dest='capabilities', default=None, + metavar="", help='Different capabilities') + @args('--hide', dest='hide', action="store_true", default=False, help='Show or hide drive') @args('--name', dest='name', metavar="", help='Drive name') - def create(self, type, size_gb, rpm, capabilities='', - visible=None, name=None): + def create(self, type, size_gb, rpm, capabilities=None, + hide=False, name=None): """Create drive type.""" - if visible in [None, "--show", "show"]: - visible = True - elif visible in ["--hide", "hide"]: - visible = False - else: - raise ValueError(_('Visible parameter should be set to --show '\ - 'or --hide')) + hide = True if hide in [True, "True", "--hide", "hide"] else False - result = drive_types.create(self.context, - type, int(size_gb), rpm, - capabilities, visible, name) - self._list([result]) + if name is None: + name = self._drive_type_template % (type, size_gb, rpm) - @args('--name', dest='name', metavar="", help='Drive name') - def delete(self, name): - """Delete drive type.""" + extra_specs = {'type': 'vsa_drive', + 'drive_name': name, + 'drive_type': type, + 'drive_size': size_gb, + 'drive_rpm': rpm, + 'visible': True, + } + if hide: + extra_specs['visible'] = False - dtype = drive_types.get_by_name(self.context, name) - drive_types.delete(self.context, dtype['id']) + if capabilities is not None and capabilities != '': + extra_specs['capabilities'] = capabilities - @args('--name', dest='name', metavar="", help='Drive name') - @args('--new_name', dest='new_name', metavar="", - help='New Drive name (optional)') - def rename(self, name, new_name=None): - """Rename drive type.""" + volume_types.create(self.context, name, extra_specs) + result = volume_types.get_volume_type_by_name(self.context, name) + self._list({name: result}) - dtype = drive_types.rename(self.context, - name, new_name) - self._list([dtype]) + @args('--name', dest='name', metavar="", help='Drive name') + @args('--purge', action="store_true", dest='purge', default=False, + help='purge record from database') + def delete(self, name, purge): + """Marks instance types / flavors as deleted""" + try: + if purge: + volume_types.purge(self.context, name) + verb = "purged" + else: + volume_types.destroy(self.context, name) + verb = "deleted" + except exception.ApiError: + print "Valid volume type name is required" + sys.exit(1) + except exception.DBError, e: + print "DB Error: %s" % e + sys.exit(2) + except: + sys.exit(3) + else: + print "%s %s" % (name, verb) - @args('--all', dest='visible', action="store_false", - help='Show all drives') + @args('--all', dest='all', action="store_true", default=False, + help='Show all drives (including invisible)') @args('--name', dest='name', metavar="", help='Show only specified drive') - def list(self, visible=None, name=None): + def list(self, all=False, name=None): """Describe all available VSA drive types (or particular one).""" - visible = False if visible in ["--all", False] else True + all = False if all in ["--all", False, "False"] else True + search_opts = {'extra_specs': {'type': 'vsa_drive'}} if name is not None: - drive = drive_types.get_by_name(self.context, name) - drives = [drive] - else: - drives = drive_types.get_all(self.context, visible) + search_opts['extra_specs']['name'] = name + if all == False: + search_opts['extra_specs']['visible'] = '1' + + drives = volume_types.get_all_types(self.context, + search_opts=search_opts) self._list(drives) @args('--name', dest='name', metavar="", help='Drive name') @@ -1474,32 +1494,44 @@ class VsaDriveTypeCommands(object): help='Drive type (SATA, SAS, SSD, etc.)') @args('--size', dest='size_gb', metavar="", help='Drive size in GB') @args('--rpm', dest='rpm', metavar="", help='RPM') - @args('--capabilities', dest='capabilities', metavar="", - help='Different capabilities') - @args('--visible', dest='visible', metavar="", - help='Show or hide drive') + @args('--capabilities', dest='capabilities', default=None, + metavar="", help='Different capabilities') + @args('--visible', dest='visible', + metavar="", help='Show or hide drive') def update(self, name, type=None, size_gb=None, rpm=None, - capabilities='', visible=None): + capabilities=None, visible=None): """Update drive type.""" - values = { - 'type': type, - 'size_gb': size_gb, - 'rpm': rpm, - 'capabilities': capabilities, - } - if visible: - if visible in ["--show", "show"]: - values['visible'] = True - elif visible in ["--hide", "hide"]: - values['visible'] = False - else: - raise ValueError(_("Visible parameter should be set to "\ - "--show or --hide")) + volume_type = volume_types.get_volume_type_by_name(self.context, name) + + extra_specs = {'type': 'vsa_drive'} - dtype = drive_types.get_by_name(self.context, name) - dtype = drive_types.update(self.context, dtype['id'], **values) - self._list([dtype]) + if type: + extra_specs['drive_type'] = type + + if size_gb: + extra_specs['drive_size'] = size_gb + + if rpm: + extra_specs['drive_rpm'] = rpm + + if capabilities: + extra_specs['capabilities'] = capabilities + + if visible is not None: + if visible in ["show", True, "True"]: + extra_specs['visible'] = True + elif visible in ["hide", False, "False"]: + extra_specs['visible'] = False + else: + raise ValueError(_('visible parameter should be set to '\ + 'show or hide')) + + db.api.volume_type_extra_specs_update_or_create(self.context, + volume_type['id'], + extra_specs) + result = volume_types.get_volume_type_by_name(self.context, name) + self._list({name: result}) class VolumeCommands(object): diff --git a/bin/nova-vsa b/bin/nova-vsa index d765e8f9e..2d6eee2c0 100755 --- a/bin/nova-vsa +++ b/bin/nova-vsa @@ -4,6 +4,7 @@ # Copyright (c) 2011 Zadara Storage Inc. # Copyright (c) 2011 OpenStack LLC. # +# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at @@ -17,6 +18,10 @@ # under the License. """Starter script for Nova VSA.""" + +import eventlet +eventlet.monkey_patch() + import os import sys @@ -28,6 +33,7 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) + from nova import flags from nova import log as logging from nova import service @@ -37,5 +43,7 @@ if __name__ == '__main__': utils.default_flagfile() flags.FLAGS(sys.argv) logging.setup() - service.serve() + utils.monkey_patch() + server = service.Service.create(binary='nova-vsa') + service.serve(server) service.wait() -- cgit From 209334e4740087aa0fd4b1aac8fcaf1a74ff7220 Mon Sep 17 00:00:00 2001 From: "vladimir.p" Date: Fri, 26 Aug 2011 15:07:34 -0700 Subject: changed format string in nova-manage --- bin/nova-manage | 152 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 78 insertions(+), 74 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 76e188596..c9cf4266d 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -1108,67 +1108,71 @@ class VsaCommands(object): self.vsa_api = vsa.API() self.context = context.get_admin_context() - self._format_str_vsa = "%-5s %-15s %-25s %-10s %-6s "\ - "%-9s %-10s %-10s %10s" - self._format_str_volume = "\t%-4s %-15s %-5s %-10s %-20s %s" - self._format_str_drive = "\t%-4s %-15s %-5s %-10s %-20s %-4s %-10s %s" - self._format_str_instance = "\t%-4s %-10s %-20s %-12s %-10s "\ - "%-15s %-15s %-10s %-15s %s" + self._format_str_vsa = "%(id)-5s %(vsa_id)-15s %(name)-25s "\ + "%(type)-10s %(vcs)-6s %(drives)-9s %(stat)-10s "\ + "%(az)-10s %(time)-10s" + self._format_str_volume = "\t%(id)-4s %(name)-15s %(size)-5s "\ + "%(stat)-10s %(att)-20s %(time)s" + self._format_str_drive = "\t%(id)-4s %(name)-15s %(size)-5s "\ + "%(stat)-10s %(host)-20s %(type)-4s %(tname)-10s %(time)s" + self._format_str_instance = "\t%(id)-4s %(name)-10s %(dname)-20s "\ + "%(image)-12s %(type)-10s %(fl_ip)-15s %(fx_ip)-15s "\ + "%(stat)-10s %(host)-15s %(time)s" def _print_vsa_header(self): print self._format_str_vsa %\ - (_('ID'), - _('vsa_id'), - _('displayName'), - _('vc_type'), - _('vc_cnt'), - _('drive_cnt'), - _('status'), - _('AZ'), - _('createTime')) + dict(id=_('ID'), + vsa_id=_('vsa_id'), + name=_('displayName'), + type=_('vc_type'), + vcs=_('vc_cnt'), + drives=_('drive_cnt'), + stat=_('status'), + az=_('AZ'), + time=_('createTime')) def _print_vsa(self, vsa): print self._format_str_vsa %\ - (vsa['id'], - vsa['name'], - vsa['display_name'], - vsa['vsa_instance_type'].get('name', None), - vsa['vc_count'], - vsa['vol_count'], - vsa['status'], - vsa['availability_zone'], - str(vsa['created_at'])) + dict(id=vsa['id'], + vsa_id=vsa['name'], + name=vsa['display_name'], + type=vsa['vsa_instance_type'].get('name', None), + vcs=vsa['vc_count'], + drives=vsa['vol_count'], + stat=vsa['status'], + az=vsa['availability_zone'], + time=str(vsa['created_at'])) def _print_volume_header(self): print _(' === Volumes ===') print self._format_str_volume %\ - (_('ID'), - _('name'), - _('size'), - _('status'), - _('attachment'), - _('createTime')) + dict(id=_('ID'), + name=_('name'), + size=_('size'), + stat=_('status'), + att=_('attachment'), + time=_('createTime')) def _print_volume(self, vol): print self._format_str_volume %\ - (vol['id'], - vol['display_name'] or vol['name'], - vol['size'], - vol['status'], - vol['attach_status'], - str(vol['created_at'])) + dict(id=vol['id'], + name=vol['display_name'] or vol['name'], + size=vol['size'], + stat=vol['status'], + att=vol['attach_status'], + time=str(vol['created_at'])) def _print_drive_header(self): print _(' === Drives ===') print self._format_str_drive %\ - (_('ID'), - _('name'), - _('size'), - _('status'), - _('host'), - _('type'), - _('typeName'), - _('createTime')) + dict(id=_('ID'), + name=_('name'), + size=_('size'), + stat=_('status'), + host=_('host'), + type=_('type'), + tname=_('typeName'), + time=_('createTime')) def _print_drive(self, drive): if drive['volume_type_id'] is not None and drive.get('volume_type'): @@ -1177,28 +1181,28 @@ class VsaCommands(object): drive_type_name = '' print self._format_str_drive %\ - (drive['id'], - drive['display_name'], - drive['size'], - drive['status'], - drive['host'], - drive['volume_type_id'], - drive_type_name, - str(drive['created_at'])) + dict(id=drive['id'], + name=drive['display_name'], + size=drive['size'], + stat=drive['status'], + host=drive['host'], + type=drive['volume_type_id'], + tname=drive_type_name, + time=str(drive['created_at'])) def _print_instance_header(self): print _(' === Instances ===') print self._format_str_instance %\ - (_('ID'), - _('name'), - _('disp_name'), - _('image'), - _('type'), - _('floating_IP'), - _('fixed_IP'), - _('status'), - _('host'), - _('createTime')) + dict(id=_('ID'), + name=_('name'), + dname=_('disp_name'), + image=_('image'), + type=_('type'), + fl_ip=_('floating_IP'), + fx_ip=_('fixed_IP'), + stat=_('status'), + host=_('host'), + time=_('createTime')) def _print_instance(self, vc): @@ -1212,16 +1216,16 @@ class VsaCommands(object): floating_addr = floating_addr or fixed_addr print self._format_str_instance %\ - (vc['id'], - ec2utils.id_to_ec2_id(vc['id']), - vc['display_name'], - ('ami-%08x' % int(vc['image_ref'])), - vc['instance_type']['name'], - floating_addr, - fixed_addr, - vc['state_description'], - vc['host'], - str(vc['created_at'])) + dict(id=vc['id'], + name=ec2utils.id_to_ec2_id(vc['id']), + dname=vc['display_name'], + image=('ami-%08x' % int(vc['image_ref'])), + type=vc['instance_type']['name'], + fl_ip=floating_addr, + fx_ip=fixed_addr, + stat=vc['state_description'], + host=vc['host'], + time=str(vc['created_at'])) def _list(self, context, vsas, print_drives=False, print_volumes=False, print_instances=False): @@ -1283,7 +1287,7 @@ class VsaCommands(object): try: project_id = os.getenv("EC2_ACCESS_KEY").split(':')[1] except Exception as exc: - print _("Failed to retrieve project id: %(exc)s") % locals() + print _("Failed to retrieve project id: %(exc)s") % exc raise if user_id is None: @@ -1291,7 +1295,7 @@ class VsaCommands(object): project = self.manager.get_project(project_id) user_id = project.project_manager_id except Exception as exc: - print _("Failed to retrieve user info: %(exc)s") % locals() + print _("Failed to retrieve user info: %(exc)s") % exc raise is_admin = self.manager.is_admin(user_id) -- cgit From e5310d666f167efe6e3c9f97176d13801489fdfd Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Sun, 28 Aug 2011 18:18:40 -0700 Subject: fix nova-ajax-console-proxy --- bin/nova-ajax-console-proxy | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-console-proxy b/bin/nova-ajax-console-proxy index 0a789b4b9..b3205ec56 100755 --- a/bin/nova-ajax-console-proxy +++ b/bin/nova-ajax-console-proxy @@ -113,11 +113,11 @@ class AjaxConsoleProxy(object): AjaxConsoleProxy.tokens[kwargs['token']] = \ {'args': kwargs, 'last_activity': time.time()} - conn = rpc.create_connection(new=True) - consumer = rpc.create_consumer( - conn, - FLAGS.ajax_console_proxy_topic, - TopicProxy) + self.conn = rpc.create_connection(new=True) + rpc.create_consumer( + self.conn, + FLAGS.ajax_console_proxy_topic, + TopicProxy) def delete_expired_tokens(): now = time.time() @@ -129,7 +129,7 @@ class AjaxConsoleProxy(object): for k in to_delete: del AjaxConsoleProxy.tokens[k] - utils.LoopingCall(consumer.fetch, enable_callbacks=True).start(0.1) + self.conn.consume_in_thread() utils.LoopingCall(delete_expired_tokens).start(1) if __name__ == '__main__': @@ -142,3 +142,4 @@ if __name__ == '__main__': server = wsgi.Server("AJAX Console Proxy", acp, port=acp_port) service.serve(server) service.wait() + self.conn.close() -- cgit From 468ed475207b023cfa3eada48338d34375f55be2 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Mon, 29 Aug 2011 15:15:58 -0700 Subject: fix ajax console proxy for new create_consumer method --- bin/nova-ajax-console-proxy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-ajax-console-proxy b/bin/nova-ajax-console-proxy index b3205ec56..23fb42fb5 100755 --- a/bin/nova-ajax-console-proxy +++ b/bin/nova-ajax-console-proxy @@ -114,8 +114,7 @@ class AjaxConsoleProxy(object): {'args': kwargs, 'last_activity': time.time()} self.conn = rpc.create_connection(new=True) - rpc.create_consumer( - self.conn, + self.conn.create_consumer( FLAGS.ajax_console_proxy_topic, TopicProxy) -- cgit From dcf5970dd9bed27201c593d7d053970a632e5eee Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 30 Aug 2011 12:01:18 -0700 Subject: make two functions instead of fast flag and add compute api commands instead of hitting db directly --- bin/instance-usage-audit | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/instance-usage-audit b/bin/instance-usage-audit index a06c6b1b3..7ce5732e7 100755 --- a/bin/instance-usage-audit +++ b/bin/instance-usage-audit @@ -102,9 +102,8 @@ if __name__ == '__main__': logging.setup() begin, end = time_period(FLAGS.instance_usage_audit_period) print "Creating usages for %s until %s" % (str(begin), str(end)) - instances = db.instance_get_active_by_window(context.get_admin_context(), - begin, - end) + ctxt = context.get_admin_context() + instances = db.instance_get_active_by_window_joined(ctxt, begin, end) print "%s instances" % len(instances) for instance_ref in instances: usage_info = utils.usage_from_instance(instance_ref, -- cgit From 59be9be68c0fd9b33b72257b8a1eb8c357ce9217 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 1 Sep 2011 12:22:32 -0700 Subject: remove extra references to state_description --- bin/nova-manage | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index c9cf4266d..c3b2c71ce 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -166,7 +166,7 @@ class VpnCommands(object): print address, print vpn['host'], print ec2utils.id_to_ec2_id(vpn['id']), - print vpn['state_description'], + print vpn['vm_state'], print state else: print None @@ -869,7 +869,7 @@ class VmCommands(object): instance['hostname'], instance['host'], instance['instance_type'].name, - instance['state_description'], + instance['vm_state'], instance['launched_at'], instance['image_ref'], instance['kernel_id'], @@ -1223,7 +1223,7 @@ class VsaCommands(object): type=vc['instance_type']['name'], fl_ip=floating_addr, fx_ip=fixed_addr, - stat=vc['state_description'], + stat=vc['vm_state'], host=vc['host'], time=str(vc['created_at'])) -- cgit