Merge "Clean up pep8 E122, E123 violations"
This commit is contained in:
		@@ -29,7 +29,7 @@ context_opts = [
 | 
			
		||||
    cfg.BoolOpt('owner_is_tenant', default=True),
 | 
			
		||||
    cfg.StrOpt('admin_role', default='admin'),
 | 
			
		||||
    cfg.BoolOpt('allow_anonymous_access', default=False),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(context_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -27,10 +27,10 @@ from glance.openstack.common import policy
 | 
			
		||||
 | 
			
		||||
LOG = logging.getLogger(__name__)
 | 
			
		||||
 | 
			
		||||
policy_opts = (
 | 
			
		||||
policy_opts = [
 | 
			
		||||
    cfg.StrOpt('policy_file', default='policy.json'),
 | 
			
		||||
    cfg.StrOpt('policy_default_rule', default='default'),
 | 
			
		||||
    )
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(policy_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -195,9 +195,9 @@ class KeystoneStrategy(BaseStrategy):
 | 
			
		||||
                "passwordCredentials": {
 | 
			
		||||
                    "username": creds['username'],
 | 
			
		||||
                    "password": creds['password']
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        headers = {}
 | 
			
		||||
        headers['Content-Type'] = 'application/json'
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ from glance.version import version_info as version
 | 
			
		||||
paste_deploy_opts = [
 | 
			
		||||
    cfg.StrOpt('flavor'),
 | 
			
		||||
    cfg.StrOpt('config_file'),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
common_opts = [
 | 
			
		||||
    cfg.BoolOpt('allow_additional_image_properties', default=True,
 | 
			
		||||
                help=_('Whether to allow users to specify image properties '
 | 
			
		||||
 
 | 
			
		||||
@@ -54,7 +54,7 @@ db_opts = [
 | 
			
		||||
    cfg.IntOpt('sql_max_retries', default=10),
 | 
			
		||||
    cfg.IntOpt('sql_retry_interval', default=1),
 | 
			
		||||
    cfg.BoolOpt('db_auto_create', default=False),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(db_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -89,12 +89,14 @@ def upgrade(migrate_engine):
 | 
			
		||||
    # which returns all the images that have a type set
 | 
			
		||||
    # but that DO NOT yet have an image_property record
 | 
			
		||||
    # with key of type.
 | 
			
		||||
    sel = select([images], from_obj=[
 | 
			
		||||
    from_stmt = [
 | 
			
		||||
        images.outerjoin(image_properties,
 | 
			
		||||
                         and_(images.c.id == image_properties.c.image_id,
 | 
			
		||||
                              image_properties.c.key == 'type'))]).where(
 | 
			
		||||
            and_(image_properties.c.image_id == None,
 | 
			
		||||
                 images.c.type != None))
 | 
			
		||||
                              image_properties.c.key == 'type'))
 | 
			
		||||
    ]
 | 
			
		||||
    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()
 | 
			
		||||
    property_insert = image_properties.insert()
 | 
			
		||||
    for record in image_records:
 | 
			
		||||
 
 | 
			
		||||
@@ -104,14 +104,12 @@ def legacy_parse_uri(self, uri):
 | 
			
		||||
    # swift://user:pass@http://authurl.com/v1/container/obj
 | 
			
		||||
    # are immediately rejected.
 | 
			
		||||
    if uri.count('://') != 1:
 | 
			
		||||
        reason = _(
 | 
			
		||||
                "URI cannot contain more than one occurrence of a scheme."
 | 
			
		||||
                "If you have specified a URI like "
 | 
			
		||||
                "swift://user:pass@http://authurl.com/v1/container/obj"
 | 
			
		||||
                ", you need to change it to use the swift+http:// scheme, "
 | 
			
		||||
                "like so: "
 | 
			
		||||
                "swift+http://user:pass@authurl.com/v1/container/obj"
 | 
			
		||||
                )
 | 
			
		||||
        reason = _("URI cannot contain more than one occurrence of a scheme."
 | 
			
		||||
                   "If you have specified a URI like "
 | 
			
		||||
                   "swift://user:pass@http://authurl.com/v1/container/obj"
 | 
			
		||||
                   ", you need to change it to use the swift+http:// scheme, "
 | 
			
		||||
                   "like so: "
 | 
			
		||||
                   "swift+http://user:pass@authurl.com/v1/container/obj")
 | 
			
		||||
 | 
			
		||||
        LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
 | 
			
		||||
        raise exception.BadStoreUri(message=reason)
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ image_cache_opts = [
 | 
			
		||||
    cfg.IntOpt('image_cache_max_size', default=10 * (1024 ** 3)),  # 10 GB
 | 
			
		||||
    cfg.IntOpt('image_cache_stall_time', default=86400),  # 24 hours
 | 
			
		||||
    cfg.StrOpt('image_cache_dir'),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(image_cache_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,7 @@ LOG = logging.getLogger(__name__)
 | 
			
		||||
 | 
			
		||||
sqlite_opts = [
 | 
			
		||||
    cfg.StrOpt('image_cache_sqlite_db', default='cache.db'),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(sqlite_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,7 @@ from glance.openstack.common import timeutils
 | 
			
		||||
 | 
			
		||||
notifier_opts = [
 | 
			
		||||
    cfg.StrOpt('notifier_strategy', default='default')
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(notifier_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ rabbit_opts = [
 | 
			
		||||
    cfg.StrOpt('rabbit_max_retries', default=0),
 | 
			
		||||
    cfg.StrOpt('rabbit_retry_backoff', default=2),
 | 
			
		||||
    cfg.StrOpt('rabbit_retry_max_backoff', default=30)
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(rabbit_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -70,7 +70,7 @@ qpid_opts = [
 | 
			
		||||
    cfg.BoolOpt('qpid_tcp_nodelay',
 | 
			
		||||
                default=True,
 | 
			
		||||
                help='Disable Nagle algorithm'),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(qpid_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -31,14 +31,14 @@ LOG = logging.getLogger(__name__)
 | 
			
		||||
registry_addr_opts = [
 | 
			
		||||
    cfg.StrOpt('registry_host', default='0.0.0.0'),
 | 
			
		||||
    cfg.IntOpt('registry_port', default=9191),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
registry_client_opts = [
 | 
			
		||||
    cfg.StrOpt('registry_client_protocol', default='http'),
 | 
			
		||||
    cfg.StrOpt('registry_client_key_file'),
 | 
			
		||||
    cfg.StrOpt('registry_client_cert_file'),
 | 
			
		||||
    cfg.StrOpt('registry_client_ca_file'),
 | 
			
		||||
    cfg.StrOpt('metadata_encryption_key', secret=True),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
registry_client_ctx_opts = [
 | 
			
		||||
    cfg.StrOpt('admin_user', secret=True),
 | 
			
		||||
    cfg.StrOpt('admin_password', secret=True),
 | 
			
		||||
@@ -46,7 +46,7 @@ registry_client_ctx_opts = [
 | 
			
		||||
    cfg.StrOpt('auth_url'),
 | 
			
		||||
    cfg.StrOpt('auth_strategy', default='noauth'),
 | 
			
		||||
    cfg.StrOpt('auth_region'),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(registry_addr_opts)
 | 
			
		||||
@@ -85,7 +85,7 @@ def configure_registry_client():
 | 
			
		||||
        'key_file': CONF.registry_client_key_file,
 | 
			
		||||
        'cert_file': CONF.registry_client_cert_file,
 | 
			
		||||
        'ca_file': CONF.registry_client_ca_file
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def configure_registry_admin_creds():
 | 
			
		||||
 
 | 
			
		||||
@@ -40,7 +40,7 @@ store_opts = [
 | 
			
		||||
               default='/var/lib/glance/scrubber'),
 | 
			
		||||
    cfg.BoolOpt('delayed_delete', default=False),
 | 
			
		||||
    cfg.IntOpt('scrub_time', default=0),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(store_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -51,7 +51,7 @@ rbd_opts = [
 | 
			
		||||
    cfg.StrOpt('rbd_store_pool', default=DEFAULT_POOL),
 | 
			
		||||
    cfg.StrOpt('rbd_store_user', default=DEFAULT_USER),
 | 
			
		||||
    cfg.StrOpt('rbd_store_ceph_conf', default=DEFAULT_CONFFILE),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(rbd_opts)
 | 
			
		||||
@@ -196,11 +196,11 @@ class Store(glance.store.base.Store):
 | 
			
		||||
            librbd.create(ioctx, name, size, order, old_format=False,
 | 
			
		||||
                          features=rbd.RBD_FEATURE_LAYERING)
 | 
			
		||||
            return StoreLocation({
 | 
			
		||||
                    'fsid': fsid,
 | 
			
		||||
                    'pool': self.pool,
 | 
			
		||||
                    'image': name,
 | 
			
		||||
                    'snapshot': DEFAULT_SNAPNAME,
 | 
			
		||||
                    })
 | 
			
		||||
                'fsid': fsid,
 | 
			
		||||
                'pool': self.pool,
 | 
			
		||||
                'image': name,
 | 
			
		||||
                'snapshot': DEFAULT_SNAPNAME,
 | 
			
		||||
            })
 | 
			
		||||
        else:
 | 
			
		||||
            librbd.create(ioctx, name, size, order, old_format=True)
 | 
			
		||||
            return StoreLocation({'image': name})
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ s3_opts = [
 | 
			
		||||
    cfg.StrOpt('s3_store_object_buffer_dir'),
 | 
			
		||||
    cfg.BoolOpt('s3_store_create_bucket_on_put', default=False),
 | 
			
		||||
    cfg.StrOpt('s3_store_bucket_url_format', default='subdomain'),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
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
 | 
			
		||||
        # are immediately rejected.
 | 
			
		||||
        if uri.count('://') != 1:
 | 
			
		||||
            reason = _(
 | 
			
		||||
                    "URI cannot contain more than one occurrence of a scheme."
 | 
			
		||||
                    "If you have specified a URI like "
 | 
			
		||||
                    "s3://accesskey:secretkey@https://s3.amazonaws.com/bucket/"
 | 
			
		||||
                    "key-id"
 | 
			
		||||
                    ", you need to change it to use the s3+https:// scheme, "
 | 
			
		||||
                    "like so: "
 | 
			
		||||
                    "s3+https://accesskey:secretkey@s3.amazonaws.com/bucket/"
 | 
			
		||||
                    "key-id"
 | 
			
		||||
                      )
 | 
			
		||||
            reason = _("URI cannot contain more than one occurrence "
 | 
			
		||||
                       "of a scheme. If you have specified a URI like "
 | 
			
		||||
                       "s3://accesskey:secretkey@"
 | 
			
		||||
                       "https://s3.amazonaws.com/bucket/key-id"
 | 
			
		||||
                       ", you need to change it to use the "
 | 
			
		||||
                       "s3+https:// scheme, like so: "
 | 
			
		||||
                       "s3+https://accesskey:secretkey@"
 | 
			
		||||
                       "s3.amazonaws.com/bucket/key-id")
 | 
			
		||||
            LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
 | 
			
		||||
            raise exception.BadStoreUri(message=reason)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -36,7 +36,7 @@ LOG = logging.getLogger(__name__)
 | 
			
		||||
scrubber_opts = [
 | 
			
		||||
    cfg.BoolOpt('cleanup_scrubber', default=False),
 | 
			
		||||
    cfg.IntOpt('cleanup_scrubber_time', default=86400)
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(scrubber_opts)
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ swift_opts = [
 | 
			
		||||
    cfg.BoolOpt('swift_store_create_container_on_put', default=False),
 | 
			
		||||
    cfg.BoolOpt('swift_store_multi_tenant', default=False),
 | 
			
		||||
    cfg.ListOpt('swift_store_admin_tenants', default=[]),
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
CONF = cfg.CONF
 | 
			
		||||
CONF.register_opts(swift_opts)
 | 
			
		||||
@@ -128,14 +128,12 @@ class StoreLocation(glance.store.location.StoreLocation):
 | 
			
		||||
        # swift://user:pass@http://authurl.com/v1/container/obj
 | 
			
		||||
        # are immediately rejected.
 | 
			
		||||
        if uri.count('://') != 1:
 | 
			
		||||
            reason = _(
 | 
			
		||||
                    "URI cannot contain more than one occurrence of a scheme."
 | 
			
		||||
                    "If you have specified a URI like "
 | 
			
		||||
                    "swift://user:pass@http://authurl.com/v1/container/obj"
 | 
			
		||||
                    ", you need to change it to use the swift+http:// scheme, "
 | 
			
		||||
                    "like so: "
 | 
			
		||||
                    "swift+http://user:pass@authurl.com/v1/container/obj"
 | 
			
		||||
                    )
 | 
			
		||||
            reason = _("URI cannot contain more than one occurrence "
 | 
			
		||||
                       "of a scheme. If you have specified a URI like "
 | 
			
		||||
                       "swift://user:pass@http://authurl.com/v1/container/obj"
 | 
			
		||||
                       ", you need to change it to use the "
 | 
			
		||||
                       "swift+http:// scheme, like so: "
 | 
			
		||||
                       "swift+http://user:pass@authurl.com/v1/container/obj")
 | 
			
		||||
            LOG.error(_("Invalid store uri %(uri)s: %(reason)s") % locals())
 | 
			
		||||
            raise exception.BadStoreUri(message=reason)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -78,7 +78,7 @@ class V2Token(object):
 | 
			
		||||
            "adminURL": "http://localhost:9292",
 | 
			
		||||
            "internalURL": "http://localhost:9292",
 | 
			
		||||
            "publicURL": "http://localhost:9292"
 | 
			
		||||
    }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    @property
 | 
			
		||||
    def base_token(self):
 | 
			
		||||
 
 | 
			
		||||
@@ -341,23 +341,21 @@ class TestMigrations(utils.BaseTestCase):
 | 
			
		||||
        unquoted_locations = [
 | 
			
		||||
            'swift://acct:usr:pass@example.com/container/obj-id',
 | 
			
		||||
            'file://foo',
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
        quoted_locations = [
 | 
			
		||||
            'swift://acct%3Ausr:pass@example.com/container/obj-id',
 | 
			
		||||
            'file://foo',
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
        # Insert images with an unquoted image location
 | 
			
		||||
        now = datetime.datetime.now()
 | 
			
		||||
        kwargs = dict(
 | 
			
		||||
            deleted=False,
 | 
			
		||||
            created_at=now,
 | 
			
		||||
            updated_at=now,
 | 
			
		||||
            status='active',
 | 
			
		||||
            is_public=True,
 | 
			
		||||
            min_disk=0,
 | 
			
		||||
            min_ram=0,
 | 
			
		||||
            )
 | 
			
		||||
        kwargs = dict(deleted=False,
 | 
			
		||||
                      created_at=now,
 | 
			
		||||
                      updated_at=now,
 | 
			
		||||
                      status='active',
 | 
			
		||||
                      is_public=True,
 | 
			
		||||
                      min_disk=0,
 | 
			
		||||
                      min_ram=0)
 | 
			
		||||
        for i, location in enumerate(unquoted_locations):
 | 
			
		||||
            kwargs.update(location=location, id=i)
 | 
			
		||||
            conn.execute(images_table.insert(), [kwargs])
 | 
			
		||||
 
 | 
			
		||||
@@ -53,7 +53,7 @@ class TestStoreLocation(base.StoreClearingUnitTest):
 | 
			
		||||
            'rbd://imagename',
 | 
			
		||||
            'rbd://fsid/pool/image/snap',
 | 
			
		||||
            'rbd://%2F/%2F/%2F/%2F',
 | 
			
		||||
            ]
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
        for uri in good_store_uris:
 | 
			
		||||
            loc = location.get_location_from_uri(uri)
 | 
			
		||||
 
 | 
			
		||||
@@ -236,8 +236,8 @@ class SwiftTests(object):
 | 
			
		||||
        http:// in the swift_store_auth_address config value
 | 
			
		||||
        """
 | 
			
		||||
        loc = get_location_from_uri("swift+http://%s:key@auth_address/"
 | 
			
		||||
                                    "glance/%s" % (
 | 
			
		||||
                self.swift_store_user, FAKE_UUID))
 | 
			
		||||
                                    "glance/%s" %
 | 
			
		||||
                                    (self.swift_store_user, FAKE_UUID))
 | 
			
		||||
        (image_swift, image_size) = self.store.get(loc)
 | 
			
		||||
        self.assertEqual(image_size, 5120)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -40,11 +40,11 @@ def get_fake_request(path='', method='POST', is_admin=False, user=USER1):
 | 
			
		||||
    req.method = method
 | 
			
		||||
 | 
			
		||||
    kwargs = {
 | 
			
		||||
            'user': user,
 | 
			
		||||
            'tenant': TENANT1,
 | 
			
		||||
            'roles': [],
 | 
			
		||||
            'is_admin': is_admin,
 | 
			
		||||
        }
 | 
			
		||||
        'user': user,
 | 
			
		||||
        'tenant': TENANT1,
 | 
			
		||||
        'roles': [],
 | 
			
		||||
        'is_admin': is_admin,
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    req.context = glance.context.RequestContext(**kwargs)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -3270,7 +3270,7 @@ class TestImageSerializer(base.IsolatedUnitTest):
 | 
			
		||||
            'receiver_tenant_id': self.receiving_tenant,
 | 
			
		||||
            'receiver_user_id': self.receiving_user,
 | 
			
		||||
            'destination_ip': '1.2.3.4',
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        def fake_info(_event_type, _payload):
 | 
			
		||||
            self.assertEqual(_payload, expected_payload)
 | 
			
		||||
@@ -3299,7 +3299,7 @@ class TestImageSerializer(base.IsolatedUnitTest):
 | 
			
		||||
            'receiver_tenant_id': self.receiving_tenant,
 | 
			
		||||
            'receiver_user_id': self.receiving_user,
 | 
			
		||||
            'destination_ip': '1.2.3.4',
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        def fake_error(_event_type, _payload):
 | 
			
		||||
            self.assertEqual(_payload, expected_payload)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								tox.ini
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								tox.ini
									
									
									
									
									
								
							@@ -18,7 +18,7 @@ downloadcache = ~/cache/pip
 | 
			
		||||
 | 
			
		||||
[testenv:pep8]
 | 
			
		||||
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]
 | 
			
		||||
setenv = NOSE_WITH_COVERAGE=1
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user