Fixed flake8 errors
This commit is contained in:
parent
0d33cb038f
commit
4f5dde7db5
@ -19,9 +19,9 @@ import webob
|
||||
from webob import exc
|
||||
|
||||
from manila.api import common
|
||||
from manila.api.v1 import shares
|
||||
from manila.api import extensions
|
||||
from manila.api.openstack import wsgi
|
||||
from manila.api.v1 import shares
|
||||
from manila.api.views import share_snapshots as snapshot_views
|
||||
from manila.api import xmlutil
|
||||
from manila import exception
|
||||
|
@ -274,7 +274,6 @@ def _service_get_all_topic_subquery(context, session, topic, subq, label):
|
||||
all()
|
||||
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def service_get_all_share_sorted(context):
|
||||
session = get_session()
|
||||
@ -973,19 +972,19 @@ def share_snapshot_create(context, values):
|
||||
|
||||
@require_admin_context
|
||||
def snapshot_data_get_for_project(context, project_id, session=None):
|
||||
# TODO: Add
|
||||
# TODO(yportnova): Uncomment when snapshot size implemented
|
||||
raise NotImplementedError()
|
||||
|
||||
query = model_query(context,
|
||||
func.count(models.ShareSnapshot.id),
|
||||
func.sum(models.ShareSnapshot.share.size),
|
||||
read_deleted="no",
|
||||
session=session).\
|
||||
filter_by(project_id=project_id)
|
||||
|
||||
result = query.first()
|
||||
|
||||
return (result[0] or 0, result[1] or 0)
|
||||
#
|
||||
# query = model_query(context,
|
||||
# func.count(models.ShareSnapshot.id),
|
||||
# func.sum(models.ShareSnapshot.size),
|
||||
# read_deleted="no",
|
||||
# session=session).\
|
||||
# filter_by(project_id=project_id)
|
||||
#
|
||||
# result = query.first()
|
||||
#
|
||||
# return (result[0] or 0, result[1] or 0)
|
||||
|
||||
|
||||
@require_admin_context
|
||||
|
@ -460,6 +460,3 @@ class InvalidShareSnapshot(ManilaException):
|
||||
|
||||
class SwiftConnectionFailed(ManilaException):
|
||||
message = _("Connection to swift failed") + ": %(reason)s"
|
||||
|
||||
|
||||
|
||||
|
@ -248,5 +248,3 @@ def fetch_to_raw(context, image_service,
|
||||
reason=_("Converted to raw, but format is now %s") %
|
||||
data.file_format)
|
||||
os.unlink(tmp)
|
||||
|
||||
|
||||
|
@ -795,7 +795,7 @@ def _sync_gigabytes(context, project_id, session):
|
||||
if FLAGS.no_snapshot_gb_quota:
|
||||
return {'gigabytes': share_gigs}
|
||||
|
||||
# TODO: Uncomment when Snapshot size is implemented
|
||||
# TODO(yportnova): Uncomment when Snapshot size is implemented
|
||||
# (_junk, snap_gigs) = db.snapshot_data_get_for_project(context,
|
||||
# project_id,
|
||||
# session=session)
|
||||
@ -808,7 +808,7 @@ QUOTAS = QuotaEngine()
|
||||
|
||||
resources = [
|
||||
ReservableResource('shares', _sync_shares, 'quota_shares'),
|
||||
# TODO: Uncomment when Snapshot size is implemented
|
||||
# TODO(yportnova): Uncomment when Snapshot size is implemented
|
||||
# ReservableResource('snapshots', _sync_snapshots, 'quota_snapshots'),
|
||||
ReservableResource('gigabytes', _sync_gigabytes, 'quota_gigabytes'), ]
|
||||
|
||||
|
@ -132,6 +132,7 @@ class HostState(object):
|
||||
|
||||
self.updated = capability['timestamp']
|
||||
|
||||
|
||||
class HostManager(object):
|
||||
"""Base HostManager class."""
|
||||
|
||||
|
@ -187,7 +187,7 @@ class API(base.Base):
|
||||
project_id = share['project_id']
|
||||
else:
|
||||
project_id = context.project_id
|
||||
|
||||
|
||||
share_id = share['id']
|
||||
if not share['host']:
|
||||
try:
|
||||
|
@ -30,8 +30,8 @@ from manila.openstack.common import excutils
|
||||
from manila.openstack.common import importutils
|
||||
from manila.openstack.common import log as logging
|
||||
from manila.openstack.common import timeutils
|
||||
from manila.share.configuration import Configuration
|
||||
from manila import quota
|
||||
from manila.share.configuration import Configuration
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
|
@ -29,4 +29,3 @@ class AdminActionsTest(test.TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tempdir)
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from manila.api.contrib import services
|
||||
from manila import context
|
||||
from manila import db
|
||||
@ -22,7 +23,6 @@ from manila.openstack.common import timeutils
|
||||
from manila import policy
|
||||
from manila import test
|
||||
from manila.tests.api import fakes
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
fake_services_list = [{'binary': 'manila-scheduler',
|
||||
|
@ -117,4 +117,3 @@ class VolumeRouterTestCase(test.TestCase):
|
||||
result = resource.dispatch(resource.index, req, {})
|
||||
ids = [v['id'] for v in result['versions']]
|
||||
self.assertEqual(set(ids), set(['v1.0']))
|
||||
|
||||
|
@ -41,7 +41,7 @@ class _FakeImageService(object):
|
||||
self.images = {}
|
||||
# NOTE(justinsb): The OpenStack API can't upload an image?
|
||||
# So, make sure we've got one..
|
||||
timestamp = datetime.datetime(2011, 01, 01, 01, 02, 03)
|
||||
timestamp = datetime.datetime(2011, 0o1, 0o1, 0o1, 0o2, 0o3)
|
||||
|
||||
image1 = {'id': '155d900f-4e14-4e4c-a73d-069cbf4541e6',
|
||||
'name': 'fakeimage123456',
|
||||
|
@ -21,6 +21,7 @@ import random
|
||||
import time
|
||||
|
||||
import glanceclient.exc
|
||||
from glanceclient.v2.client import Client as glanceclient_v2
|
||||
|
||||
from manila import context
|
||||
from manila import exception
|
||||
@ -28,7 +29,6 @@ from manila import flags
|
||||
from manila.image import glance
|
||||
from manila import test
|
||||
from manila.tests.glance import stubs as glance_stubs
|
||||
from glanceclient.v2.client import Client as glanceclient_v2
|
||||
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__)
|
||||
|
||||
class XmlTests(integrated_helpers._IntegratedTestBase):
|
||||
""""Some basic XML sanity checks."""
|
||||
|
||||
|
||||
def test_namespace_volumes(self):
|
||||
"""/servers should have v1.1 namespace (has changed in 1.1)."""
|
||||
headers = {}
|
||||
|
@ -163,7 +163,6 @@ class HostManagerTestCase(test.TestCase):
|
||||
class HostStateTestCase(test.TestCase):
|
||||
"""Test case for HostState class."""
|
||||
|
||||
|
||||
def test_update_from_share_capability(self):
|
||||
fake_host = host_manager.HostState('host1')
|
||||
self.assertEqual(fake_host.free_capacity_gb, None)
|
||||
|
@ -370,261 +370,3 @@ class TestMigrations(test.TestCase):
|
||||
(version, engine))
|
||||
raise
|
||||
|
||||
# migration 004 - change volume types to UUID
|
||||
@test.skip_test("migrations fix")
|
||||
def _prerun_004(self, engine):
|
||||
data = {
|
||||
'volumes': [{'id': str(uuid.uuid4()), 'host': 'test1',
|
||||
'volume_type_id': 1},
|
||||
{'id': str(uuid.uuid4()), 'host': 'test2',
|
||||
'volume_type_id': 1},
|
||||
{'id': str(uuid.uuid4()), 'host': 'test3',
|
||||
'volume_type_id': 3},
|
||||
],
|
||||
'volume_types': [{'name': 'vtype1'},
|
||||
{'name': 'vtype2'},
|
||||
{'name': 'vtype3'},
|
||||
],
|
||||
'volume_type_extra_specs': [{'volume_type_id': 1,
|
||||
'key': 'v1',
|
||||
'value': 'hotep',
|
||||
},
|
||||
{'volume_type_id': 1,
|
||||
'key': 'v2',
|
||||
'value': 'bending rodrigez',
|
||||
},
|
||||
{'volume_type_id': 2,
|
||||
'key': 'v3',
|
||||
'value': 'bending rodrigez',
|
||||
},
|
||||
]}
|
||||
|
||||
volume_types = get_table(engine, 'volume_types')
|
||||
for vtype in data['volume_types']:
|
||||
r = volume_types.insert().values(vtype).execute()
|
||||
vtype['id'] = r.inserted_primary_key[0]
|
||||
|
||||
volume_type_es = get_table(engine, 'volume_type_extra_specs')
|
||||
for vtes in data['volume_type_extra_specs']:
|
||||
r = volume_type_es.insert().values(vtes).execute()
|
||||
vtes['id'] = r.inserted_primary_key[0]
|
||||
|
||||
volumes = get_table(engine, 'volumes')
|
||||
for vol in data['volumes']:
|
||||
r = volumes.insert().values(vol).execute()
|
||||
vol['id'] = r.inserted_primary_key[0]
|
||||
|
||||
return data
|
||||
|
||||
def _check_004(self, engine, data):
|
||||
volumes = get_table(engine, 'volumes')
|
||||
v1 = volumes.select(volumes.c.id ==
|
||||
data['volumes'][0]['id']
|
||||
).execute().first()
|
||||
v2 = volumes.select(volumes.c.id ==
|
||||
data['volumes'][1]['id']
|
||||
).execute().first()
|
||||
v3 = volumes.select(volumes.c.id ==
|
||||
data['volumes'][2]['id']
|
||||
).execute().first()
|
||||
|
||||
volume_types = get_table(engine, 'volume_types')
|
||||
vt1 = volume_types.select(volume_types.c.name ==
|
||||
data['volume_types'][0]['name']
|
||||
).execute().first()
|
||||
vt2 = volume_types.select(volume_types.c.name ==
|
||||
data['volume_types'][1]['name']
|
||||
).execute().first()
|
||||
vt3 = volume_types.select(volume_types.c.name ==
|
||||
data['volume_types'][2]['name']
|
||||
).execute().first()
|
||||
|
||||
vtes = get_table(engine, 'volume_type_extra_specs')
|
||||
vtes1 = vtes.select(vtes.c.key ==
|
||||
data['volume_type_extra_specs'][0]['key']
|
||||
).execute().first()
|
||||
vtes2 = vtes.select(vtes.c.key ==
|
||||
data['volume_type_extra_specs'][1]['key']
|
||||
).execute().first()
|
||||
vtes3 = vtes.select(vtes.c.key ==
|
||||
data['volume_type_extra_specs'][2]['key']
|
||||
).execute().first()
|
||||
|
||||
self.assertEqual(v1['volume_type_id'], vt1['id'])
|
||||
self.assertEqual(v2['volume_type_id'], vt1['id'])
|
||||
self.assertEqual(v3['volume_type_id'], vt3['id'])
|
||||
|
||||
self.assertEqual(vtes1['volume_type_id'], vt1['id'])
|
||||
self.assertEqual(vtes2['volume_type_id'], vt1['id'])
|
||||
self.assertEqual(vtes3['volume_type_id'], vt2['id'])
|
||||
@test.skip_test("migrations fix")
|
||||
def test_migration_005(self):
|
||||
"""Test that adding source_volid column works correctly."""
|
||||
for (key, engine) in self.engines.items():
|
||||
migration_api.version_control(engine,
|
||||
TestMigrations.REPOSITORY,
|
||||
migration.INIT_VERSION)
|
||||
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 4)
|
||||
metadata = sqlalchemy.schema.MetaData()
|
||||
metadata.bind = engine
|
||||
|
||||
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 5)
|
||||
volumes = sqlalchemy.Table('volumes',
|
||||
metadata,
|
||||
autoload=True)
|
||||
self.assertTrue(isinstance(volumes.c.source_volid.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
|
||||
def _metadatas(self, upgrade_to, downgrade_to=None):
|
||||
for (key, engine) in self.engines.items():
|
||||
migration_api.version_control(engine,
|
||||
TestMigrations.REPOSITORY,
|
||||
migration.INIT_VERSION)
|
||||
migration_api.upgrade(engine,
|
||||
TestMigrations.REPOSITORY,
|
||||
upgrade_to)
|
||||
|
||||
if downgrade_to is not None:
|
||||
migration_api.downgrade(
|
||||
engine, TestMigrations.REPOSITORY, downgrade_to)
|
||||
|
||||
metadata = sqlalchemy.schema.MetaData()
|
||||
metadata.bind = engine
|
||||
yield metadata
|
||||
|
||||
def metadatas_upgraded_to(self, revision):
|
||||
return self._metadatas(revision)
|
||||
|
||||
def metadatas_downgraded_from(self, revision):
|
||||
return self._metadatas(revision, revision - 1)
|
||||
@test.skip_test("migrations fix")
|
||||
def test_upgrade_006_adds_provider_location(self):
|
||||
for metadata in self.metadatas_upgraded_to(6):
|
||||
snapshots = sqlalchemy.Table('snapshots', metadata, autoload=True)
|
||||
self.assertTrue(isinstance(snapshots.c.provider_location.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
@test.skip_test("migrations fix")
|
||||
def test_downgrade_006_removes_provider_location(self):
|
||||
for metadata in self.metadatas_downgraded_from(6):
|
||||
snapshots = sqlalchemy.Table('snapshots', metadata, autoload=True)
|
||||
|
||||
self.assertTrue('provider_location' not in snapshots.c)
|
||||
@test.skip_test("migrations fix")
|
||||
def test_upgrade_007_adds_fk(self):
|
||||
for metadata in self.metadatas_upgraded_to(7):
|
||||
snapshots = sqlalchemy.Table('snapshots', metadata, autoload=True)
|
||||
volumes = sqlalchemy.Table('volumes', metadata, autoload=True)
|
||||
|
||||
fkey, = snapshots.c.volume_id.foreign_keys
|
||||
|
||||
self.assertEquals(volumes.c.id, fkey.column)
|
||||
@test.skip_test("migrations fix")
|
||||
def test_downgrade_007_removes_fk(self):
|
||||
for metadata in self.metadatas_downgraded_from(7):
|
||||
snapshots = sqlalchemy.Table('snapshots', metadata, autoload=True)
|
||||
|
||||
self.assertEquals(0, len(snapshots.c.volume_id.foreign_keys))
|
||||
@test.skip_test("migrations fix")
|
||||
def test_migration_008(self):
|
||||
"""Test that adding and removing the backups table works correctly"""
|
||||
for (key, engine) in self.engines.items():
|
||||
migration_api.version_control(engine,
|
||||
TestMigrations.REPOSITORY,
|
||||
migration.INIT_VERSION)
|
||||
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 7)
|
||||
metadata = sqlalchemy.schema.MetaData()
|
||||
metadata.bind = engine
|
||||
|
||||
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 8)
|
||||
|
||||
self.assertTrue(engine.dialect.has_table(engine.connect(),
|
||||
"backups"))
|
||||
backups = sqlalchemy.Table('backups',
|
||||
metadata,
|
||||
autoload=True)
|
||||
|
||||
self.assertTrue(isinstance(backups.c.created_at.type,
|
||||
sqlalchemy.types.DATETIME))
|
||||
self.assertTrue(isinstance(backups.c.updated_at.type,
|
||||
sqlalchemy.types.DATETIME))
|
||||
self.assertTrue(isinstance(backups.c.deleted_at.type,
|
||||
sqlalchemy.types.DATETIME))
|
||||
self.assertTrue(isinstance(backups.c.deleted.type,
|
||||
sqlalchemy.types.BOOLEAN))
|
||||
self.assertTrue(isinstance(backups.c.id.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.volume_id.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.user_id.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.project_id.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.host.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.availability_zone.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.display_name.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.display_description.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.container.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.status.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.fail_reason.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.service_metadata.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.service.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(backups.c.size.type,
|
||||
sqlalchemy.types.INTEGER))
|
||||
self.assertTrue(isinstance(backups.c.object_count.type,
|
||||
sqlalchemy.types.INTEGER))
|
||||
|
||||
migration_api.downgrade(engine, TestMigrations.REPOSITORY, 7)
|
||||
|
||||
self.assertFalse(engine.dialect.has_table(engine.connect(),
|
||||
"backups"))
|
||||
@test.skip_test("migrations fix")
|
||||
def test_migration_009(self):
|
||||
"""Test adding snapshot_metadata table works correctly."""
|
||||
for (key, engine) in self.engines.items():
|
||||
migration_api.version_control(engine,
|
||||
TestMigrations.REPOSITORY,
|
||||
migration.INIT_VERSION)
|
||||
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 8)
|
||||
metadata = sqlalchemy.schema.MetaData()
|
||||
metadata.bind = engine
|
||||
|
||||
migration_api.upgrade(engine, TestMigrations.REPOSITORY, 9)
|
||||
|
||||
self.assertTrue(engine.dialect.has_table(engine.connect(),
|
||||
"snapshot_metadata"))
|
||||
snapshot_metadata = sqlalchemy.Table('snapshot_metadata',
|
||||
metadata,
|
||||
autoload=True)
|
||||
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.created_at.type,
|
||||
sqlalchemy.types.DATETIME))
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.updated_at.type,
|
||||
sqlalchemy.types.DATETIME))
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.deleted_at.type,
|
||||
sqlalchemy.types.DATETIME))
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.deleted.type,
|
||||
sqlalchemy.types.BOOLEAN))
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.deleted.type,
|
||||
sqlalchemy.types.BOOLEAN))
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.id.type,
|
||||
sqlalchemy.types.INTEGER))
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.snapshot_id.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.key.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
self.assertTrue(isinstance(snapshot_metadata.c.value.type,
|
||||
sqlalchemy.types.VARCHAR))
|
||||
|
||||
migration_api.downgrade(engine, TestMigrations.REPOSITORY, 8)
|
||||
|
||||
self.assertFalse(engine.dialect.has_table(engine.connect(),
|
||||
"snapshot_metadata"))
|
||||
|
@ -24,14 +24,13 @@ from manila import context
|
||||
from manila import db as db_driver
|
||||
from manila import exception
|
||||
from manila.openstack.common import timeutils
|
||||
from manila.context import RequestContext
|
||||
from manila import quota
|
||||
from manila.scheduler import rpcapi as scheduler_rpcapi
|
||||
from manila import share
|
||||
from manila.share import api as share_api
|
||||
from manila.share import rpcapi as share_rpcapi
|
||||
from manila import test
|
||||
from manila.tests.db import fakes as db_fakes
|
||||
from manila import quota
|
||||
|
||||
|
||||
def fake_share(id, **kwargs):
|
||||
@ -106,7 +105,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
|
||||
self.stubs.Set(self.api, 'scheduler_rpcapi', self.scheduler_rpcapi)
|
||||
self.stubs.Set(self.api, 'share_rpcapi', self.share_rpcapi)
|
||||
self.stubs.Set(quota.QUOTAS, 'reserve', lambda *args, **kwargs : None)
|
||||
self.stubs.Set(quota.QUOTAS, 'reserve', lambda *args, **kwargs: None)
|
||||
|
||||
def tearDown(self):
|
||||
super(ShareAPITestCase, self).tearDown()
|
||||
@ -317,7 +316,7 @@ class ShareAPITestCase(test.TestCase):
|
||||
share['host'] = None
|
||||
|
||||
self.mox.StubOutWithMock(db_driver, 'share_delete')
|
||||
db_driver.share_delete(mox.IsA(RequestContext), 'fakeid')
|
||||
db_driver.share_delete(mox.IsA(context.RequestContext), 'fakeid')
|
||||
self.mox.ReplayAll()
|
||||
self.api.delete(self.context, share)
|
||||
|
||||
|
@ -65,7 +65,7 @@ echo $runs > "$1"
|
||||
exit 1
|
||||
''')
|
||||
fp.close()
|
||||
os.chmod(tmpfilename, 0755)
|
||||
os.chmod(tmpfilename, 0o755)
|
||||
self.assertRaises(exception.ProcessExecutionError,
|
||||
utils.execute,
|
||||
tmpfilename, tmpfilename2, attempts=10,
|
||||
@ -110,7 +110,7 @@ echo foo > "$1"
|
||||
grep foo
|
||||
''')
|
||||
fp.close()
|
||||
os.chmod(tmpfilename, 0755)
|
||||
os.chmod(tmpfilename, 0o755)
|
||||
utils.execute(tmpfilename,
|
||||
tmpfilename2,
|
||||
process_input='foo',
|
||||
|
@ -18,8 +18,8 @@
|
||||
TestCase for MockProxy based tests and related classes.
|
||||
"""
|
||||
|
||||
import manila.test
|
||||
import gzip
|
||||
import manila.test
|
||||
import os
|
||||
import pickle
|
||||
|
||||
|
@ -49,6 +49,7 @@ PY_EXT = ".py"
|
||||
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))
|
||||
WORDWRAP_WIDTH = 60
|
||||
|
||||
|
||||
def main(srcfiles):
|
||||
print('\n'.join(['#' * 20, '# manila.conf sample #', '#' * 20,
|
||||
'', '[DEFAULT]', '']))
|
||||
|
Loading…
Reference in New Issue
Block a user