Remove nova-volume DB
* Remove volume calls from nova.db.api * Remove volume calls from nova.db.sqlalchemy.api * Remove tables from nova/db/sqlalchemy/models.py * Remove Xen Storage Manager Volume Driver code * No migration to preserve data in unused tables * Remove quota support for volumes DocImpact part of bp delete-nova-volume Change-Id: I2c82c96d67f3746e5de28f917dd8ceb0c8037e27
This commit is contained in:
141
bin/nova-manage
141
bin/nova-manage
@@ -915,146 +915,6 @@ class InstanceTypeCommands(object):
|
||||
_db_error(e)
|
||||
|
||||
|
||||
class StorageManagerCommands(object):
|
||||
"""Class for mangaging Storage Backends and Flavors"""
|
||||
|
||||
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'])
|
||||
|
||||
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, e:
|
||||
_db_error(e)
|
||||
|
||||
def flavor_delete(self, label):
|
||||
try:
|
||||
db.sm_flavor_delete(context.get_admin_context(), label)
|
||||
|
||||
except exception.DBError, e:
|
||||
_db_error(e)
|
||||
|
||||
def _splitfun(self, item):
|
||||
i = item.split("=")
|
||||
return i[0:2]
|
||||
|
||||
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'],)
|
||||
|
||||
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))
|
||||
|
||||
if 'sr_uuid' in params:
|
||||
try:
|
||||
backend = db.sm_backend_conf_get_by_sr(ctxt,
|
||||
params['sr_uuid'])
|
||||
except exception.DBError, 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))
|
||||
except exception.DBError, 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' and c != 'Y':
|
||||
return
|
||||
|
||||
print _('(WARNING: Creating will destroy all data on backend!!!)')
|
||||
c = raw_input(_('Proceed? (y/n) '))
|
||||
if c == 'y' or c == 'Y':
|
||||
if flavor_label is None:
|
||||
print _('error: backend needs to be associated with flavor')
|
||||
sys.exit(2)
|
||||
|
||||
try:
|
||||
flavors = db.sm_flavor_get_by_label(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])
|
||||
|
||||
try:
|
||||
db.sm_backend_conf_create(ctxt,
|
||||
dict(flavor_id=flavors['id'],
|
||||
sr_uuid=None,
|
||||
sr_type=sr_type,
|
||||
config_params=config_params))
|
||||
except exception.DBError, e:
|
||||
_db_error(e)
|
||||
|
||||
def backend_remove(self, backend_conf_id):
|
||||
try:
|
||||
db.sm_backend_conf_delete(context.get_admin_context(),
|
||||
backend_conf_id)
|
||||
|
||||
except exception.DBError, e:
|
||||
_db_error(e)
|
||||
|
||||
|
||||
class AgentBuildCommands(object):
|
||||
"""Class for managing agent builds."""
|
||||
|
||||
@@ -1179,7 +1039,6 @@ CATEGORIES = [
|
||||
('project', ProjectCommands),
|
||||
('service', ServiceCommands),
|
||||
('shell', ShellCommands),
|
||||
('sm', StorageManagerCommands),
|
||||
('version', VersionCommands),
|
||||
('vm', VmCommands),
|
||||
('vpn', VpnCommands),
|
||||
|
@@ -1077,187 +1077,3 @@ class InstanceDestroyConstraints(test.TestCase):
|
||||
ctx, instance['uuid'], constraint)
|
||||
instance = db.instance_get_by_uuid(ctx, instance['uuid'])
|
||||
self.assertFalse(instance['deleted'])
|
||||
|
||||
|
||||
def _get_sm_backend_params():
|
||||
config_params = ("name_label=testsmbackend "
|
||||
"server=localhost "
|
||||
"serverpath=/tmp/nfspath")
|
||||
params = dict(flavor_id=1,
|
||||
sr_uuid=None,
|
||||
sr_type='nfs',
|
||||
config_params=config_params)
|
||||
return params
|
||||
|
||||
|
||||
def _get_sm_flavor_params():
|
||||
params = dict(label="gold",
|
||||
description="automatic backups")
|
||||
return params
|
||||
|
||||
|
||||
class SMVolumeDBApiTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(SMVolumeDBApiTestCase, self).setUp()
|
||||
self.user_id = 'fake'
|
||||
self.project_id = 'fake'
|
||||
self.context = context.RequestContext(self.user_id, self.project_id)
|
||||
|
||||
def test_sm_backend_conf_create(self):
|
||||
params = _get_sm_backend_params()
|
||||
ctxt = context.get_admin_context()
|
||||
beconf = db.sm_backend_conf_create(ctxt,
|
||||
params)
|
||||
self.assertIsInstance(beconf['id'], int)
|
||||
|
||||
def test_sm_backend_conf_create_raise_duplicate(self):
|
||||
params = _get_sm_backend_params()
|
||||
ctxt = context.get_admin_context()
|
||||
beconf = db.sm_backend_conf_create(ctxt,
|
||||
params)
|
||||
self.assertIsInstance(beconf['id'], int)
|
||||
self.assertRaises(exception.Duplicate,
|
||||
db.sm_backend_conf_create,
|
||||
ctxt,
|
||||
params)
|
||||
|
||||
def test_sm_backend_conf_update(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_backend_params()
|
||||
beconf = db.sm_backend_conf_create(ctxt,
|
||||
params)
|
||||
beconf = db.sm_backend_conf_update(ctxt,
|
||||
beconf['id'],
|
||||
dict(sr_uuid="FA15E-1D"))
|
||||
self.assertEqual(beconf['sr_uuid'], "FA15E-1D")
|
||||
|
||||
def test_sm_backend_conf_update_raise_notfound(self):
|
||||
ctxt = context.get_admin_context()
|
||||
self.assertRaises(exception.NotFound,
|
||||
db.sm_backend_conf_update,
|
||||
ctxt,
|
||||
7,
|
||||
dict(sr_uuid="FA15E-1D"))
|
||||
|
||||
def test_sm_backend_conf_get(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_backend_params()
|
||||
beconf = db.sm_backend_conf_create(ctxt,
|
||||
params)
|
||||
val = db.sm_backend_conf_get(ctxt, beconf['id'])
|
||||
self.assertDictMatch(dict(val), dict(beconf))
|
||||
|
||||
def test_sm_backend_conf_get_raise_notfound(self):
|
||||
ctxt = context.get_admin_context()
|
||||
self.assertRaises(exception.NotFound,
|
||||
db.sm_backend_conf_get,
|
||||
ctxt,
|
||||
7)
|
||||
|
||||
def test_sm_backend_conf_get_by_sr(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_backend_params()
|
||||
beconf = db.sm_backend_conf_create(ctxt,
|
||||
params)
|
||||
val = db.sm_backend_conf_get_by_sr(ctxt, beconf['sr_uuid'])
|
||||
self.assertDictMatch(dict(val), dict(beconf))
|
||||
|
||||
def test_sm_backend_conf_get_by_sr_raise_notfound(self):
|
||||
ctxt = context.get_admin_context()
|
||||
self.assertRaises(exception.NotFound,
|
||||
db.sm_backend_conf_get_by_sr,
|
||||
ctxt,
|
||||
"FA15E-1D")
|
||||
|
||||
def test_sm_backend_conf_delete(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_backend_params()
|
||||
beconf = db.sm_backend_conf_create(ctxt,
|
||||
params)
|
||||
db.sm_backend_conf_delete(ctxt, beconf['id'])
|
||||
self.assertRaises(exception.NotFound,
|
||||
db.sm_backend_conf_get,
|
||||
ctxt,
|
||||
beconf['id'])
|
||||
|
||||
def test_sm_backend_conf_delete_nonexisting(self):
|
||||
ctxt = context.get_admin_context()
|
||||
db.sm_backend_conf_delete(ctxt, "FA15E-1D")
|
||||
|
||||
def test_sm_flavor_create(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_flavor_params()
|
||||
flav = db.sm_flavor_create(ctxt,
|
||||
params)
|
||||
self.assertIsInstance(flav['id'], int)
|
||||
|
||||
def sm_flavor_create_raise_duplicate(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_flavor_params()
|
||||
flav = db.sm_flavor_create(ctxt,
|
||||
params)
|
||||
self.assertRaises(exception.Duplicate,
|
||||
db.sm_flavor_create,
|
||||
params)
|
||||
|
||||
def test_sm_flavor_update(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_flavor_params()
|
||||
flav = db.sm_flavor_create(ctxt,
|
||||
params)
|
||||
newparms = dict(description="basic volumes")
|
||||
flav = db.sm_flavor_update(ctxt, flav['id'], newparms)
|
||||
self.assertEqual(flav['description'], "basic volumes")
|
||||
|
||||
def test_sm_flavor_update_raise_notfound(self):
|
||||
ctxt = context.get_admin_context()
|
||||
self.assertRaises(exception.NotFound,
|
||||
db.sm_flavor_update,
|
||||
ctxt,
|
||||
7,
|
||||
dict(description="fakedesc"))
|
||||
|
||||
def test_sm_flavor_delete(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_flavor_params()
|
||||
flav = db.sm_flavor_create(ctxt,
|
||||
params)
|
||||
db.sm_flavor_delete(ctxt, flav['id'])
|
||||
self.assertRaises(exception.NotFound,
|
||||
db.sm_flavor_get,
|
||||
ctxt,
|
||||
"gold")
|
||||
|
||||
def test_sm_flavor_delete_nonexisting(self):
|
||||
ctxt = context.get_admin_context()
|
||||
db.sm_flavor_delete(ctxt, 7)
|
||||
|
||||
def test_sm_flavor_get(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_flavor_params()
|
||||
flav = db.sm_flavor_create(ctxt,
|
||||
params)
|
||||
val = db.sm_flavor_get(ctxt, flav['id'])
|
||||
self.assertDictMatch(dict(val), dict(flav))
|
||||
|
||||
def test_sm_flavor_get_raise_notfound(self):
|
||||
ctxt = context.get_admin_context()
|
||||
self.assertRaises(exception.NotFound,
|
||||
db.sm_flavor_get,
|
||||
ctxt,
|
||||
7)
|
||||
|
||||
def test_sm_flavor_get_by_label(self):
|
||||
ctxt = context.get_admin_context()
|
||||
params = _get_sm_flavor_params()
|
||||
flav = db.sm_flavor_create(ctxt,
|
||||
params)
|
||||
val = db.sm_flavor_get_by_label(ctxt, flav['label'])
|
||||
self.assertDictMatch(dict(val), dict(flav))
|
||||
|
||||
def test_sm_flavor_get_by_label_raise_notfound(self):
|
||||
ctxt = context.get_admin_context()
|
||||
self.assertRaises(exception.NotFound,
|
||||
db.sm_flavor_get,
|
||||
ctxt,
|
||||
"fake")
|
||||
|
@@ -2071,12 +2071,6 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
instance_ref = db.instance_create(self.context, self.test_instance)
|
||||
instance_ref = db.instance_update(self.context, instance_ref['uuid'],
|
||||
instance_dict)
|
||||
vol_dict = {'status': 'migrating', 'size': 1}
|
||||
volume_ref = db.volume_create(self.context, vol_dict)
|
||||
db.volume_attached(self.context,
|
||||
volume_ref['id'],
|
||||
instance_ref['uuid'],
|
||||
'/dev/fake')
|
||||
|
||||
# Preparing mocks
|
||||
vdmock = self.mox.CreateMock(libvirt.virDomain)
|
||||
@@ -2107,10 +2101,7 @@ class LibvirtConnTestCase(test.TestCase):
|
||||
instance_ref = db.instance_get(self.context, instance_ref['id'])
|
||||
self.assertTrue(instance_ref['vm_state'] == vm_states.ACTIVE)
|
||||
self.assertTrue(instance_ref['power_state'] == power_state.RUNNING)
|
||||
volume_ref = db.volume_get(self.context, volume_ref['id'])
|
||||
self.assertTrue(volume_ref['status'] == 'in-use')
|
||||
|
||||
db.volume_destroy(self.context, volume_ref['id'])
|
||||
db.instance_destroy(self.context, instance_ref['uuid'])
|
||||
|
||||
def test_pre_live_migration_works_correctly_mocked(self):
|
||||
|
@@ -235,7 +235,6 @@ class XenAPIVolumeTestCase(stubs.XenAPITestBase):
|
||||
"""This shows how to test Ops classes' methods."""
|
||||
stubs.stubout_session(self.stubs, stubs.FakeSessionForVolumeTests)
|
||||
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
volume = self._create_volume()
|
||||
instance = db.instance_create(self.context, self.instance_values)
|
||||
vm = xenapi_fake.create_vm(instance.name, 'Running')
|
||||
result = conn.attach_volume(self._make_connection_info(),
|
||||
@@ -253,7 +252,6 @@ class XenAPIVolumeTestCase(stubs.XenAPITestBase):
|
||||
stubs.stubout_session(self.stubs,
|
||||
stubs.FakeSessionForVolumeFailedTests)
|
||||
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
volume = self._create_volume()
|
||||
instance = db.instance_create(self.context, self.instance_values)
|
||||
xenapi_fake.create_vm(instance.name, 'Running')
|
||||
self.assertRaises(exception.VolumeDriverNotFound,
|
||||
|
Reference in New Issue
Block a user