From 17df872bebe00dfabc783f7baece9f9315aa3d20 Mon Sep 17 00:00:00 2001 From: Mike Perez Date: Mon, 5 Aug 2013 22:37:06 -0700 Subject: [PATCH] Remove Storage Manager from cinder-manage Removing leftover sm_backend manage code that was missed in the previous code removal in 40cb16784f920387ef. Fixes: bug #1207189 Change-Id: I52c44785924f489a85e4b5f947ed9b4adf679dd8 --- bin/cinder-manage | 154 ---------------------------------------------- 1 file changed, 154 deletions(-) diff --git a/bin/cinder-manage b/bin/cinder-manage index 021c1c8d4db..6732c04d525 100755 --- a/bin/cinder-manage +++ b/bin/cinder-manage @@ -57,12 +57,8 @@ import os import sys -import uuid from oslo.config import cfg -from sqlalchemy import create_engine, MetaData, Table -from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import sessionmaker # If ../cinder/__init__.py exists, add ../ to Python search path, so that @@ -80,7 +76,6 @@ from cinder.common import config # Need to register global_opts from cinder import context from cinder import db from cinder.db import migration -from cinder import exception from cinder.openstack.common import log as logging from cinder.openstack.common import rpc from cinder.openstack.common import uuidutils @@ -296,154 +291,6 @@ class VolumeCommands(object): "mountpoint": volume['mountpoint']}}) -class StorageManagerCommands(object): - """Class for mangaging Storage Backends and Flavors.""" - - @args('flavor', nargs='?', - help='flavor to be listed') - def flavor_list(self, flavor=None): - ctxt = context.get_admin_context() - - try: - if flavor is None: - flavors = db.sm_flavor_get_all(ctxt) - else: - flavors = db.sm_flavor_get(ctxt, flavor) - except exception.NotFound as ex: - print "error: %s" % ex - sys.exit(2) - - print "%-18s\t%-20s\t%s" % (_('id'), - _('Label'), - _('Description')) - - for flav in flavors: - print "%-18s\t%-20s\t%s" % ( - flav['id'], - flav['label'], - flav['description']) - - @args('label', help='flavor label') - @args('desc', help='flavor description') - def flavor_create(self, label, desc): - # TODO(renukaapte) flavor name must be unique - try: - db.sm_flavor_create(context.get_admin_context(), - dict(label=label, - description=desc)) - except exception.DBError as e: - _db_error(e) - - @args('label', help='label of flavor to be deleted') - def flavor_delete(self, label): - try: - db.sm_flavor_delete(context.get_admin_context(), label) - - except exception.DBError as e: - _db_error(e) - - def _splitfun(self, item): - i = item.split("=") - return i[0:2] - - @args('backend_conf_id', nargs='?', default=None) - def backend_list(self, backend_conf_id=None): - ctxt = context.get_admin_context() - - try: - if backend_conf_id is None: - backends = db.sm_backend_conf_get_all(ctxt) - else: - backends = db.sm_backend_conf_get(ctxt, backend_conf_id) - - except exception.NotFound as ex: - print "error: %s" % ex - sys.exit(2) - - print "%-5s\t%-10s\t%-40s\t%-10s\t%s" % (_('id'), - _('Flavor id'), - _('SR UUID'), - _('SR Type'), - _('Config Parameters'),) - - for b in backends: - print "%-5s\t%-10s\t%-40s\t%-10s\t%s" % (b['id'], - b['flavor_id'], - b['sr_uuid'], - b['sr_type'], - b['config_params'],) - - @args('flavor_label') - @args('sr_type') - @args('args', nargs='*') - def backend_add(self, flavor_label, sr_type, *args): - # TODO(renukaapte) Add backend_introduce. - ctxt = context.get_admin_context() - params = dict(map(self._splitfun, args)) - sr_uuid = uuid.uuid4() - - if flavor_label is None: - print "error: backend needs to be associated with flavor" - sys.exit(2) - - try: - flavors = db.sm_flavor_get(ctxt, flavor_label) - - except exception.NotFound as ex: - print "error: %s" % ex - sys.exit(2) - - config_params = " ".join( - ['%s=%s' % (key, params[key]) for key in params]) - - if 'sr_uuid' in params: - sr_uuid = params['sr_uuid'] - try: - backend = db.sm_backend_conf_get_by_sr(ctxt, sr_uuid) - except exception.DBError as e: - _db_error(e) - - if backend: - print 'Backend config found. Would you like to recreate this?' - print '(WARNING:Recreating will destroy all VDIs on backend!!)' - c = raw_input('Proceed? (y/n) ') - if c == 'y' or c == 'Y': - try: - db.sm_backend_conf_update( - ctxt, backend['id'], - dict(created=False, - flavor_id=flavors['id'], - sr_type=sr_type, - config_params=config_params)) - except exception.DBError as e: - _db_error(e) - return - - else: - print 'Backend config not found. Would you like to create it?' - - print '(WARNING: Creating will destroy all data on backend!!!)' - c = raw_input('Proceed? (y/n) ') - if c == 'y' or c == 'Y': - try: - db.sm_backend_conf_create(ctxt, - dict(flavor_id=flavors['id'], - sr_uuid=sr_uuid, - sr_type=sr_type, - config_params=config_params)) - except exception.DBError as e: - _db_error(e) - - @args('backend_conf_id') - def backend_remove(self, backend_conf_id): - try: - db.sm_backend_conf_delete(context.get_admin_context(), - backend_conf_id) - - except exception.DBError as e: - _db_error(e) - - class ConfigCommands(object): """Class for exposing the flags defined by flag_file(s).""" @@ -588,7 +435,6 @@ CATEGORIES = { 'logs': GetLogCommands, 'service': ServiceCommands, 'shell': ShellCommands, - 'sm': StorageManagerCommands, 'version': VersionCommands, 'volume': VolumeCommands, }