Merge "Clean up pep8 E122, E123 violations"

This commit is contained in:
Jenkins
2012-09-21 16:24:00 +00:00
committed by Gerrit Code Review
25 changed files with 72 additions and 78 deletions

View File

@@ -29,7 +29,7 @@ context_opts = [
cfg.BoolOpt('owner_is_tenant', default=True), cfg.BoolOpt('owner_is_tenant', default=True),
cfg.StrOpt('admin_role', default='admin'), cfg.StrOpt('admin_role', default='admin'),
cfg.BoolOpt('allow_anonymous_access', default=False), cfg.BoolOpt('allow_anonymous_access', default=False),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(context_opts) CONF.register_opts(context_opts)

View File

@@ -27,10 +27,10 @@ from glance.openstack.common import policy
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
policy_opts = ( policy_opts = [
cfg.StrOpt('policy_file', default='policy.json'), cfg.StrOpt('policy_file', default='policy.json'),
cfg.StrOpt('policy_default_rule', default='default'), cfg.StrOpt('policy_default_rule', default='default'),
) ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(policy_opts) CONF.register_opts(policy_opts)

View File

@@ -195,9 +195,9 @@ class KeystoneStrategy(BaseStrategy):
"passwordCredentials": { "passwordCredentials": {
"username": creds['username'], "username": creds['username'],
"password": creds['password'] "password": creds['password']
}
} }
} }
}
headers = {} headers = {}
headers['Content-Type'] = 'application/json' headers['Content-Type'] = 'application/json'

View File

@@ -34,7 +34,7 @@ from glance.version import version_info as version
paste_deploy_opts = [ paste_deploy_opts = [
cfg.StrOpt('flavor'), cfg.StrOpt('flavor'),
cfg.StrOpt('config_file'), cfg.StrOpt('config_file'),
] ]
common_opts = [ common_opts = [
cfg.BoolOpt('allow_additional_image_properties', default=True, cfg.BoolOpt('allow_additional_image_properties', default=True,
help=_('Whether to allow users to specify image properties ' help=_('Whether to allow users to specify image properties '

View File

@@ -54,7 +54,7 @@ db_opts = [
cfg.IntOpt('sql_max_retries', default=10), cfg.IntOpt('sql_max_retries', default=10),
cfg.IntOpt('sql_retry_interval', default=1), cfg.IntOpt('sql_retry_interval', default=1),
cfg.BoolOpt('db_auto_create', default=False), cfg.BoolOpt('db_auto_create', default=False),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(db_opts) CONF.register_opts(db_opts)

View File

@@ -89,12 +89,14 @@ def upgrade(migrate_engine):
# which returns all the images that have a type set # which returns all the images that have a type set
# but that DO NOT yet have an image_property record # but that DO NOT yet have an image_property record
# with key of type. # with key of type.
sel = select([images], from_obj=[ from_stmt = [
images.outerjoin(image_properties, images.outerjoin(image_properties,
and_(images.c.id == image_properties.c.image_id, and_(images.c.id == image_properties.c.image_id,
image_properties.c.key == 'type'))]).where( image_properties.c.key == 'type'))
and_(image_properties.c.image_id == None, ]
images.c.type != None)) and_stmt = and_(image_properties.c.image_id == None,
images.c.type != None)
sel = select([images], from_obj=from_stmt).where(and_stmt)
image_records = conn.execute(sel).fetchall() image_records = conn.execute(sel).fetchall()
property_insert = image_properties.insert() property_insert = image_properties.insert()
for record in image_records: for record in image_records:

View File

@@ -104,14 +104,12 @@ def legacy_parse_uri(self, uri):
# swift://user:pass@http://authurl.com/v1/container/obj # swift://user:pass@http://authurl.com/v1/container/obj
# are immediately rejected. # are immediately rejected.
if uri.count('://') != 1: if uri.count('://') != 1:
reason = _( reason = _("URI cannot contain more than one occurrence of a scheme."
"URI cannot contain more than one occurrence of a scheme." "If you have specified a URI like "
"If you have specified a URI like " "swift://user:pass@http://authurl.com/v1/container/obj"
"swift://user:pass@http://authurl.com/v1/container/obj" ", you need to change it to use the swift+http:// scheme, "
", you need to change it to use the swift+http:// scheme, " "like so: "
"like so: " "swift+http://user:pass@authurl.com/v1/container/obj")
"swift+http://user:pass@authurl.com/v1/container/obj"
)
LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals()) LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
raise exception.BadStoreUri(message=reason) raise exception.BadStoreUri(message=reason)

View File

@@ -34,7 +34,7 @@ image_cache_opts = [
cfg.IntOpt('image_cache_max_size', default=10 * (1024 ** 3)), # 10 GB cfg.IntOpt('image_cache_max_size', default=10 * (1024 ** 3)), # 10 GB
cfg.IntOpt('image_cache_stall_time', default=86400), # 24 hours cfg.IntOpt('image_cache_stall_time', default=86400), # 24 hours
cfg.StrOpt('image_cache_dir'), cfg.StrOpt('image_cache_dir'),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(image_cache_opts) CONF.register_opts(image_cache_opts)

View File

@@ -37,7 +37,7 @@ LOG = logging.getLogger(__name__)
sqlite_opts = [ sqlite_opts = [
cfg.StrOpt('image_cache_sqlite_db', default='cache.db'), cfg.StrOpt('image_cache_sqlite_db', default='cache.db'),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(sqlite_opts) CONF.register_opts(sqlite_opts)

View File

@@ -27,7 +27,7 @@ from glance.openstack.common import timeutils
notifier_opts = [ notifier_opts = [
cfg.StrOpt('notifier_strategy', default='default') cfg.StrOpt('notifier_strategy', default='default')
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(notifier_opts) CONF.register_opts(notifier_opts)

View File

@@ -39,7 +39,7 @@ rabbit_opts = [
cfg.StrOpt('rabbit_max_retries', default=0), cfg.StrOpt('rabbit_max_retries', default=0),
cfg.StrOpt('rabbit_retry_backoff', default=2), cfg.StrOpt('rabbit_retry_backoff', default=2),
cfg.StrOpt('rabbit_retry_max_backoff', default=30) cfg.StrOpt('rabbit_retry_max_backoff', default=30)
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(rabbit_opts) CONF.register_opts(rabbit_opts)

View File

@@ -70,7 +70,7 @@ qpid_opts = [
cfg.BoolOpt('qpid_tcp_nodelay', cfg.BoolOpt('qpid_tcp_nodelay',
default=True, default=True,
help='Disable Nagle algorithm'), help='Disable Nagle algorithm'),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(qpid_opts) CONF.register_opts(qpid_opts)

View File

@@ -31,14 +31,14 @@ LOG = logging.getLogger(__name__)
registry_addr_opts = [ registry_addr_opts = [
cfg.StrOpt('registry_host', default='0.0.0.0'), cfg.StrOpt('registry_host', default='0.0.0.0'),
cfg.IntOpt('registry_port', default=9191), cfg.IntOpt('registry_port', default=9191),
] ]
registry_client_opts = [ registry_client_opts = [
cfg.StrOpt('registry_client_protocol', default='http'), cfg.StrOpt('registry_client_protocol', default='http'),
cfg.StrOpt('registry_client_key_file'), cfg.StrOpt('registry_client_key_file'),
cfg.StrOpt('registry_client_cert_file'), cfg.StrOpt('registry_client_cert_file'),
cfg.StrOpt('registry_client_ca_file'), cfg.StrOpt('registry_client_ca_file'),
cfg.StrOpt('metadata_encryption_key', secret=True), cfg.StrOpt('metadata_encryption_key', secret=True),
] ]
registry_client_ctx_opts = [ registry_client_ctx_opts = [
cfg.StrOpt('admin_user', secret=True), cfg.StrOpt('admin_user', secret=True),
cfg.StrOpt('admin_password', secret=True), cfg.StrOpt('admin_password', secret=True),
@@ -46,7 +46,7 @@ registry_client_ctx_opts = [
cfg.StrOpt('auth_url'), cfg.StrOpt('auth_url'),
cfg.StrOpt('auth_strategy', default='noauth'), cfg.StrOpt('auth_strategy', default='noauth'),
cfg.StrOpt('auth_region'), cfg.StrOpt('auth_region'),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(registry_addr_opts) CONF.register_opts(registry_addr_opts)
@@ -85,7 +85,7 @@ def configure_registry_client():
'key_file': CONF.registry_client_key_file, 'key_file': CONF.registry_client_key_file,
'cert_file': CONF.registry_client_cert_file, 'cert_file': CONF.registry_client_cert_file,
'ca_file': CONF.registry_client_ca_file 'ca_file': CONF.registry_client_ca_file
} }
def configure_registry_admin_creds(): def configure_registry_admin_creds():

View File

@@ -40,7 +40,7 @@ store_opts = [
default='/var/lib/glance/scrubber'), default='/var/lib/glance/scrubber'),
cfg.BoolOpt('delayed_delete', default=False), cfg.BoolOpt('delayed_delete', default=False),
cfg.IntOpt('scrub_time', default=0), cfg.IntOpt('scrub_time', default=0),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(store_opts) CONF.register_opts(store_opts)

View File

@@ -51,7 +51,7 @@ rbd_opts = [
cfg.StrOpt('rbd_store_pool', default=DEFAULT_POOL), cfg.StrOpt('rbd_store_pool', default=DEFAULT_POOL),
cfg.StrOpt('rbd_store_user', default=DEFAULT_USER), cfg.StrOpt('rbd_store_user', default=DEFAULT_USER),
cfg.StrOpt('rbd_store_ceph_conf', default=DEFAULT_CONFFILE), cfg.StrOpt('rbd_store_ceph_conf', default=DEFAULT_CONFFILE),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(rbd_opts) CONF.register_opts(rbd_opts)
@@ -196,11 +196,11 @@ class Store(glance.store.base.Store):
librbd.create(ioctx, name, size, order, old_format=False, librbd.create(ioctx, name, size, order, old_format=False,
features=rbd.RBD_FEATURE_LAYERING) features=rbd.RBD_FEATURE_LAYERING)
return StoreLocation({ return StoreLocation({
'fsid': fsid, 'fsid': fsid,
'pool': self.pool, 'pool': self.pool,
'image': name, 'image': name,
'snapshot': DEFAULT_SNAPNAME, 'snapshot': DEFAULT_SNAPNAME,
}) })
else: else:
librbd.create(ioctx, name, size, order, old_format=True) librbd.create(ioctx, name, size, order, old_format=True)
return StoreLocation({'image': name}) return StoreLocation({'image': name})

View File

@@ -41,7 +41,7 @@ s3_opts = [
cfg.StrOpt('s3_store_object_buffer_dir'), cfg.StrOpt('s3_store_object_buffer_dir'),
cfg.BoolOpt('s3_store_create_bucket_on_put', default=False), cfg.BoolOpt('s3_store_create_bucket_on_put', default=False),
cfg.StrOpt('s3_store_bucket_url_format', default='subdomain'), cfg.StrOpt('s3_store_bucket_url_format', default='subdomain'),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(s3_opts) CONF.register_opts(s3_opts)
@@ -102,16 +102,14 @@ class StoreLocation(glance.store.location.StoreLocation):
# s3://accesskey:secretkey@https://s3.amazonaws.com/bucket/key-id # s3://accesskey:secretkey@https://s3.amazonaws.com/bucket/key-id
# are immediately rejected. # are immediately rejected.
if uri.count('://') != 1: if uri.count('://') != 1:
reason = _( reason = _("URI cannot contain more than one occurrence "
"URI cannot contain more than one occurrence of a scheme." "of a scheme. If you have specified a URI like "
"If you have specified a URI like " "s3://accesskey:secretkey@"
"s3://accesskey:secretkey@https://s3.amazonaws.com/bucket/" "https://s3.amazonaws.com/bucket/key-id"
"key-id" ", you need to change it to use the "
", you need to change it to use the s3+https:// scheme, " "s3+https:// scheme, like so: "
"like so: " "s3+https://accesskey:secretkey@"
"s3+https://accesskey:secretkey@s3.amazonaws.com/bucket/" "s3.amazonaws.com/bucket/key-id")
"key-id"
)
LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals()) LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
raise exception.BadStoreUri(message=reason) raise exception.BadStoreUri(message=reason)

View File

@@ -36,7 +36,7 @@ LOG = logging.getLogger(__name__)
scrubber_opts = [ scrubber_opts = [
cfg.BoolOpt('cleanup_scrubber', default=False), cfg.BoolOpt('cleanup_scrubber', default=False),
cfg.IntOpt('cleanup_scrubber_time', default=86400) cfg.IntOpt('cleanup_scrubber_time', default=86400)
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(scrubber_opts) CONF.register_opts(scrubber_opts)

View File

@@ -61,7 +61,7 @@ swift_opts = [
cfg.BoolOpt('swift_store_create_container_on_put', default=False), cfg.BoolOpt('swift_store_create_container_on_put', default=False),
cfg.BoolOpt('swift_store_multi_tenant', default=False), cfg.BoolOpt('swift_store_multi_tenant', default=False),
cfg.ListOpt('swift_store_admin_tenants', default=[]), cfg.ListOpt('swift_store_admin_tenants', default=[]),
] ]
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_opts(swift_opts) CONF.register_opts(swift_opts)
@@ -128,14 +128,12 @@ class StoreLocation(glance.store.location.StoreLocation):
# swift://user:pass@http://authurl.com/v1/container/obj # swift://user:pass@http://authurl.com/v1/container/obj
# are immediately rejected. # are immediately rejected.
if uri.count('://') != 1: if uri.count('://') != 1:
reason = _( reason = _("URI cannot contain more than one occurrence "
"URI cannot contain more than one occurrence of a scheme." "of a scheme. If you have specified a URI like "
"If you have specified a URI like " "swift://user:pass@http://authurl.com/v1/container/obj"
"swift://user:pass@http://authurl.com/v1/container/obj" ", you need to change it to use the "
", you need to change it to use the swift+http:// scheme, " "swift+http:// scheme, like so: "
"like so: " "swift+http://user:pass@authurl.com/v1/container/obj")
"swift+http://user:pass@authurl.com/v1/container/obj"
)
LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals()) LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
raise exception.BadStoreUri(message=reason) raise exception.BadStoreUri(message=reason)

View File

@@ -78,7 +78,7 @@ class V2Token(object):
"adminURL": "http://localhost:9292", "adminURL": "http://localhost:9292",
"internalURL": "http://localhost:9292", "internalURL": "http://localhost:9292",
"publicURL": "http://localhost:9292" "publicURL": "http://localhost:9292"
} }
@property @property
def base_token(self): def base_token(self):

View File

@@ -341,23 +341,21 @@ class TestMigrations(utils.BaseTestCase):
unquoted_locations = [ unquoted_locations = [
'swift://acct:usr:pass@example.com/container/obj-id', 'swift://acct:usr:pass@example.com/container/obj-id',
'file://foo', 'file://foo',
] ]
quoted_locations = [ quoted_locations = [
'swift://acct%3Ausr:pass@example.com/container/obj-id', 'swift://acct%3Ausr:pass@example.com/container/obj-id',
'file://foo', 'file://foo',
] ]
# Insert images with an unquoted image location # Insert images with an unquoted image location
now = datetime.datetime.now() now = datetime.datetime.now()
kwargs = dict( kwargs = dict(deleted=False,
deleted=False, created_at=now,
created_at=now, updated_at=now,
updated_at=now, status='active',
status='active', is_public=True,
is_public=True, min_disk=0,
min_disk=0, min_ram=0)
min_ram=0,
)
for i, location in enumerate(unquoted_locations): for i, location in enumerate(unquoted_locations):
kwargs.update(location=location, id=i) kwargs.update(location=location, id=i)
conn.execute(images_table.insert(), [kwargs]) conn.execute(images_table.insert(), [kwargs])

View File

@@ -53,7 +53,7 @@ class TestStoreLocation(base.StoreClearingUnitTest):
'rbd://imagename', 'rbd://imagename',
'rbd://fsid/pool/image/snap', 'rbd://fsid/pool/image/snap',
'rbd://%2F/%2F/%2F/%2F', 'rbd://%2F/%2F/%2F/%2F',
] ]
for uri in good_store_uris: for uri in good_store_uris:
loc = location.get_location_from_uri(uri) loc = location.get_location_from_uri(uri)

View File

@@ -236,8 +236,8 @@ class SwiftTests(object):
http:// in the swift_store_auth_address config value http:// in the swift_store_auth_address config value
""" """
loc = get_location_from_uri("swift+http://%s:key@auth_address/" loc = get_location_from_uri("swift+http://%s:key@auth_address/"
"glance/%s" % ( "glance/%s" %
self.swift_store_user, FAKE_UUID)) (self.swift_store_user, FAKE_UUID))
(image_swift, image_size) = self.store.get(loc) (image_swift, image_size) = self.store.get(loc)
self.assertEqual(image_size, 5120) self.assertEqual(image_size, 5120)

View File

@@ -40,11 +40,11 @@ def get_fake_request(path='', method='POST', is_admin=False, user=USER1):
req.method = method req.method = method
kwargs = { kwargs = {
'user': user, 'user': user,
'tenant': TENANT1, 'tenant': TENANT1,
'roles': [], 'roles': [],
'is_admin': is_admin, 'is_admin': is_admin,
} }
req.context = glance.context.RequestContext(**kwargs) req.context = glance.context.RequestContext(**kwargs)

View File

@@ -3270,7 +3270,7 @@ class TestImageSerializer(base.IsolatedUnitTest):
'receiver_tenant_id': self.receiving_tenant, 'receiver_tenant_id': self.receiving_tenant,
'receiver_user_id': self.receiving_user, 'receiver_user_id': self.receiving_user,
'destination_ip': '1.2.3.4', 'destination_ip': '1.2.3.4',
} }
def fake_info(_event_type, _payload): def fake_info(_event_type, _payload):
self.assertEqual(_payload, expected_payload) self.assertEqual(_payload, expected_payload)
@@ -3299,7 +3299,7 @@ class TestImageSerializer(base.IsolatedUnitTest):
'receiver_tenant_id': self.receiving_tenant, 'receiver_tenant_id': self.receiving_tenant,
'receiver_user_id': self.receiving_user, 'receiver_user_id': self.receiving_user,
'destination_ip': '1.2.3.4', 'destination_ip': '1.2.3.4',
} }
def fake_error(_event_type, _payload): def fake_error(_event_type, _payload):
self.assertEqual(_payload, expected_payload) self.assertEqual(_payload, expected_payload)

View File

@@ -18,7 +18,7 @@ downloadcache = ~/cache/pip
[testenv:pep8] [testenv:pep8]
deps = pep8==1.3.3 deps = pep8==1.3.3
commands = pep8 --ignore=E122,E123,E124,E125,E126,E127,E128,E711 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack . commands = pep8 --ignore=E124,E125,E126,E127,E128,E711 --repeat --show-source --exclude=.venv,.tox,dist,doc,openstack .
[testenv:cover] [testenv:cover]
setenv = NOSE_WITH_COVERAGE=1 setenv = NOSE_WITH_COVERAGE=1