Skip to content

Commit

Permalink
Backslash continuations (misc.)
Browse files Browse the repository at this point in the history
Fixes bug #925166

This patch for packages which have few backslash continuations.

Follow up patches will be for packages network, scheduler, virt,
db/sqlalchemy, tests, and api/openstack.

Change-Id: I4200010b47b33fa8b9115b5d379b543200f6668d
  • Loading branch information
Zhongyue Luo committed Feb 8, 2012
1 parent b0a708f commit 525ba40
Show file tree
Hide file tree
Showing 28 changed files with 173 additions and 197 deletions.
9 changes: 4 additions & 5 deletions nova/api/auth.py
Expand Up @@ -28,11 +28,10 @@
from nova import wsgi


use_forwarded_for_opt = \
cfg.BoolOpt('use_forwarded_for',
default=False,
help='Treat X-Forwarded-For as the canonical remote address. '
'Only enable this if you have a sanitizing proxy.')
use_forwarded_for_opt = cfg.BoolOpt('use_forwarded_for',
default=False,
help='Treat X-Forwarded-For as the canonical remote address. '
'Only enable this if you have a sanitizing proxy.')

FLAGS = flags.FLAGS
FLAGS.add_option(use_forwarded_for_opt)
Expand Down
21 changes: 10 additions & 11 deletions nova/api/ec2/cloud.py
Expand Up @@ -257,7 +257,7 @@ def _describe_availability_zones_verbose(self, context, **kwargs):
for host in hosts:
rv['availabilityZoneInfo'].append({'zoneName': '|- %s' % host,
'zoneState': ''})
hsvcs = [service for service in services \
hsvcs = [service for service in services
if service['host'] == host]
for svc in hsvcs:
alive = utils.service_is_up(svc)
Expand Down Expand Up @@ -348,8 +348,7 @@ def describe_key_pairs(self, context, key_name=None, **kwargs):
for key_pair in key_pairs:
# filter out the vpn keys
suffix = FLAGS.vpn_key_suffix
if context.is_admin or \
not key_pair['name'].endswith(suffix):
if context.is_admin or not key_pair['name'].endswith(suffix):
result.append({
'keyName': key_pair['name'],
'keyFingerprint': key_pair['fingerprint'],
Expand Down Expand Up @@ -513,10 +512,10 @@ def _rule_dict_last_step(self, context, to_port=None, from_port=None,
source_project_id = self._get_source_project_id(context,
source_security_group_owner_id)

source_security_group = \
db.security_group_get_by_name(context.elevated(),
source_project_id,
source_security_group_name)
source_security_group = db.security_group_get_by_name(
context.elevated(),
source_project_id,
source_security_group_name)
notfound = exception.SecurityGroupNotFound
if not source_security_group:
raise notfound(security_group_id=source_security_group_name)
Expand Down Expand Up @@ -1389,8 +1388,8 @@ def register_image(self, context, image_location=None, **kwargs):
metadata = {'properties': {'image_location': image_location}}

if 'root_device_name' in kwargs:
metadata['properties']['root_device_name'] = \
kwargs.get('root_device_name')
metadata['properties']['root_device_name'] = kwargs.get(
'root_device_name')

mappings = [_parse_block_device_mapping(bdm) for bdm in
kwargs.get('block_device_mapping', [])]
Expand All @@ -1413,8 +1412,8 @@ def _launch_permission_attribute(image, result):
result['launchPermission'].append({'group': 'all'})

def _root_device_name_attribute(image, result):
result['rootDeviceName'] = \
block_device.properties_root_device_name(image['properties'])
_prop_root_dev_name = block_device.properties_root_device_name
result['rootDeviceName'] = _prop_root_dev_name(image['properties'])
if result['rootDeviceName'] is None:
result['rootDeviceName'] = block_device.DEFAULT_ROOT_DEV_NAME

Expand Down
3 changes: 1 addition & 2 deletions nova/api/metadata/handler.py
Expand Up @@ -100,8 +100,7 @@ def _format_instance_mapping(self, ctxt, instance_ref):
mappings = {}
mappings['ami'] = block_device.strip_dev(root_device_name)
mappings['root'] = root_device_name
default_ephemeral_device = \
instance_ref.get('default_ephemeral_device')
default_ephemeral_device = instance_ref.get('default_ephemeral_device')
if default_ephemeral_device:
mappings['ephemeral0'] = default_ephemeral_device
default_swap_device = instance_ref.get('default_swap_device')
Expand Down
4 changes: 2 additions & 2 deletions nova/auth/ldapdriver.py
Expand Up @@ -713,8 +713,8 @@ def __to_user(attr):
"""Convert ldap attributes to User object"""
if attr is None:
return None
if ('accessKey' in attr.keys() and 'secretKey' in attr.keys() \
and LdapDriver.isadmin_attribute in attr.keys()):
if ('accessKey' in attr.keys() and 'secretKey' in attr.keys() and
LdapDriver.isadmin_attribute in attr.keys()):
return {
'id': attr[FLAGS.ldap_user_id_attribute][0],
'name': attr[FLAGS.ldap_user_name_attribute][0],
Expand Down
46 changes: 22 additions & 24 deletions nova/compute/api.py
Expand Up @@ -50,10 +50,9 @@

LOG = logging.getLogger('nova.compute.api')

find_host_timeout_opt = \
cfg.StrOpt('find_host_timeout',
default=30,
help='Timeout after NN seconds when looking for a host.')
find_host_timeout_opt = cfg.StrOpt('find_host_timeout',
default=30,
help='Timeout after NN seconds when looking for a host.')

FLAGS = flags.FLAGS
FLAGS.add_option(find_host_timeout_opt)
Expand All @@ -75,15 +74,14 @@ def check_instance_state(vm_state=None, task_state=None):
def outer(f):
@functools.wraps(f)
def inner(self, context, instance, *args, **kw):
if vm_state is not None and \
instance['vm_state'] not in vm_state:
if vm_state is not None and instance['vm_state'] not in vm_state:
raise exception.InstanceInvalidState(
attr='vm_state',
instance_uuid=instance['uuid'],
state=instance['vm_state'],
method=f.__name__)
if task_state is not None and \
instance['task_state'] not in task_state:
if (task_state is not None and
instance['task_state'] not in task_state):
raise exception.InstanceInvalidState(
attr='task_state',
instance_uuid=instance['uuid'],
Expand Down Expand Up @@ -114,8 +112,8 @@ class API(base.Base):

def __init__(self, image_service=None, network_api=None, volume_api=None,
**kwargs):
self.image_service = image_service or \
nova.image.get_default_image_service()
self.image_service = (image_service or
nova.image.get_default_image_service())

self.network_api = network_api or network.API()
self.volume_api = volume_api or volume.API()
Expand Down Expand Up @@ -1600,8 +1598,8 @@ def get_vnc_console(self, context, instance, console_type):
'console_type': console_type,
'host': connect_info['host'],
'port': connect_info['port'],
'internal_access_path':\
connect_info['internal_access_path']}})
'internal_access_path':
connect_info['internal_access_path']}})

return {'url': connect_info['access_url']}

Expand Down Expand Up @@ -1822,10 +1820,10 @@ def add_host_to_aggregate(self, context, aggregate_id, host):
if aggregate.operational_state in [aggregate_states.CREATED,
aggregate_states.ACTIVE]:
if service.availability_zone != aggregate.availability_zone:
raise exception.\
InvalidAggregateAction(action='add host',
aggregate_id=aggregate_id,
reason='availibility zone mismatch')
raise exception.InvalidAggregateAction(
action='add host',
aggregate_id=aggregate_id,
reason='availibility zone mismatch')
self.db.aggregate_host_add(context, aggregate_id, host)
if aggregate.operational_state == aggregate_states.CREATED:
values = {'operational_state': aggregate_states.CHANGING}
Expand All @@ -1840,10 +1838,10 @@ def add_host_to_aggregate(self, context, aggregate_id, host):
aggregate_states.DISMISSED: 'aggregate deleted',
aggregate_states.ERROR: 'aggregate in error', }
if aggregate.operational_state in invalid.keys():
raise exception.\
InvalidAggregateAction(action='add host',
aggregate_id=aggregate_id,
reason=invalid[aggregate.operational_state])
raise exception.InvalidAggregateAction(
action='add host',
aggregate_id=aggregate_id,
reason=invalid[aggregate.operational_state])

def remove_host_from_aggregate(self, context, aggregate_id, host):
"""Removes host from the aggregate."""
Expand All @@ -1862,10 +1860,10 @@ def remove_host_from_aggregate(self, context, aggregate_id, host):
invalid = {aggregate_states.CHANGING: 'setup in progress',
aggregate_states.DISMISSED: 'aggregate deleted', }
if aggregate.operational_state in invalid.keys():
raise exception.\
InvalidAggregateAction(action='remove host',
aggregate_id=aggregate_id,
reason=invalid[aggregate.operational_state])
raise exception.InvalidAggregateAction(
action='remove host',
aggregate_id=aggregate_id,
reason=invalid[aggregate.operational_state])

def _get_aggregate_info(self, context, aggregate):
"""Builds a dictionary with aggregate props, metadata and hosts."""
Expand Down
16 changes: 8 additions & 8 deletions nova/compute/manager.py
Expand Up @@ -226,14 +226,14 @@ def init_host(self):
db_state = instance['power_state']
drv_state = self._get_power_state(context, instance)

expect_running = db_state == power_state.RUNNING \
and drv_state != db_state
expect_running = (db_state == power_state.RUNNING and
drv_state != db_state)

LOG.debug(_('Current state of %(instance_uuid)s is %(drv_state)s, '
'state in DB is %(db_state)s.'), locals())

if (expect_running and FLAGS.resume_guests_state_on_host_boot)\
or FLAGS.start_guests_on_host_boot:
if ((expect_running and FLAGS.resume_guests_state_on_host_boot) or
FLAGS.start_guests_on_host_boot):
LOG.info(_('Rebooting instance %(instance_uuid)s after '
'nova-compute restart.'), locals())
self.reboot_instance(context, instance['uuid'])
Expand Down Expand Up @@ -1784,8 +1784,8 @@ def pre_live_migration(self, context, instance_id, time=None,
instance_ref = self.db.instance_get(context, instance_id)

# If any volume is mounted, prepare here.
block_device_info = \
self._get_instance_volume_block_device_info(context, instance_id)
block_device_info = self._get_instance_volume_block_device_info(
context, instance_id)
if not block_device_info['block_device_mapping']:
LOG.info(_("%s has no volume."), instance_ref['uuid'])

Expand Down Expand Up @@ -2049,8 +2049,8 @@ def rollback_live_migration_at_destination(self, context, instance_id):

# NOTE(vish): The mapping is passed in so the driver can disconnect
# from remote volumes if necessary
block_device_info = \
self._get_instance_volume_block_device_info(context, instance_id)
block_device_info = self._get_instance_volume_block_device_info(
context, instance_id)
self.driver.destroy(instance_ref, self._legacy_nw_info(network_info),
block_device_info)

Expand Down
9 changes: 4 additions & 5 deletions nova/console/vmrc.py
Expand Up @@ -129,11 +129,10 @@ def generate_password(self, vim_session, pool, instance_name):
vm_ref = vm.obj
if vm_ref is None:
raise exception.InstanceNotFound(instance_id=instance_name)
virtual_machine_ticket = \
vim_session._call_method(
vim_session._get_vim(),
'AcquireCloneTicket',
vim_session._get_vim().get_service_content().sessionManager)
virtual_machine_ticket = vim_session._call_method(
vim_session._get_vim(),
'AcquireCloneTicket',
vim_session._get_vim().get_service_content().sessionManager)
json_data = json.dumps({'vm_id': str(vm_ref.value),
'username': virtual_machine_ticket,
'password': virtual_machine_ticket})
Expand Down
7 changes: 3 additions & 4 deletions nova/consoleauth/__init__.py
Expand Up @@ -22,10 +22,9 @@
from nova.openstack.common import cfg


consoleauth_topic_opt = \
cfg.StrOpt('consoleauth_topic',
default='consoleauth',
help='the topic console auth proxy nodes listen on')
consoleauth_topic_opt = cfg.StrOpt('consoleauth_topic',
default='consoleauth',
help='the topic console auth proxy nodes listen on')

FLAGS = flags.FLAGS
FLAGS.add_option(consoleauth_topic_opt)
4 changes: 2 additions & 2 deletions nova/ipv6/account_identifier.py
Expand Up @@ -24,8 +24,8 @@


def to_global(prefix, mac, project_id):
project_hash = netaddr.IPAddress(int(hashlib.sha1(project_id).\
hexdigest()[:8], 16) << 32)
project_hash = netaddr.IPAddress(
int(hashlib.sha1(project_id).hexdigest()[:8], 16) << 32)
static_num = netaddr.IPAddress(0xff << 24)

try:
Expand Down
7 changes: 3 additions & 4 deletions nova/ipv6/api.py
Expand Up @@ -19,10 +19,9 @@
from nova import utils


ipv6_backend_opt = \
cfg.StrOpt('ipv6_backend',
default='rfc2462',
help='Backend to use for IPv6 generation')
ipv6_backend_opt = cfg.StrOpt('ipv6_backend',
default='rfc2462',
help='Backend to use for IPv6 generation')

FLAGS = flags.FLAGS
FLAGS.add_option(ipv6_backend_opt)
Expand Down
4 changes: 2 additions & 2 deletions nova/ipv6/rfc2462.py
Expand Up @@ -28,8 +28,8 @@ def to_global(prefix, mac, project_id):
int_addr = int(''.join(['%02x' % i for i in mac64]), 16)
mac64_addr = netaddr.IPAddress(int_addr)
maskIP = netaddr.IPNetwork(prefix).ip
return (mac64_addr ^ netaddr.IPAddress('::0200:0:0:0') | maskIP).\
format()
return (mac64_addr ^ netaddr.IPAddress('::0200:0:0:0') |
maskIP).format()
except netaddr.AddrFormatError:
raise TypeError(_('Bad mac for to_global_ipv6: %s') % mac)
except TypeError:
Expand Down
7 changes: 3 additions & 4 deletions nova/log.py
Expand Up @@ -132,8 +132,7 @@
def _dictify_context(context):
if context is None:
return None
if not isinstance(context, dict) \
and getattr(context, 'to_dict', None):
if not isinstance(context, dict) and getattr(context, 'to_dict', None):
context = context.to_dict()
return context

Expand Down Expand Up @@ -290,8 +289,8 @@ def format(self, record):
else:
self._fmt = FLAGS.logging_default_format_string

if record.levelno == logging.DEBUG \
and FLAGS.logging_debug_format_suffix:
if (record.levelno == logging.DEBUG and
FLAGS.logging_debug_format_suffix):
self._fmt += " " + FLAGS.logging_debug_format_suffix

# Cache this on the record, Logger will respect our formated copy
Expand Down
7 changes: 3 additions & 4 deletions nova/notifier/list_notifier.py
Expand Up @@ -20,10 +20,9 @@
from nova.exception import ClassNotFound


list_notifier_drivers_opt = \
cfg.MultiStrOpt('list_notifier_drivers',
default=['nova.notifier.no_op_notifier'],
help='List of drivers to send notifications')
list_notifier_drivers_opt = cfg.MultiStrOpt('list_notifier_drivers',
default=['nova.notifier.no_op_notifier'],
help='List of drivers to send notifications')

FLAGS = flags.FLAGS
FLAGS.add_option(list_notifier_drivers_opt)
Expand Down
7 changes: 3 additions & 4 deletions nova/notifier/rabbit_notifier.py
Expand Up @@ -21,10 +21,9 @@
from nova import rpc


notification_topic_opt = \
cfg.StrOpt('notification_topic',
default='notifications',
help='RabbitMQ topic used for Nova notifications')
notification_topic_opt = cfg.StrOpt('notification_topic',
default='notifications',
help='RabbitMQ topic used for Nova notifications')

FLAGS = flags.FLAGS
FLAGS.add_option(notification_topic_opt)
Expand Down

0 comments on commit 525ba40

Please sign in to comment.