Backslash continuation removal (Nova folsom-2)

Fixes bug #938588

Backslash continuations removal for scripts in bin/, plugin/, and etc.

Change-Id: Idd17048b6e8db6e939946968e011e68da8585b8d
This commit is contained in:
Zhongyue Luo 2012-05-16 17:08:27 +08:00
parent d02cc36034
commit bee7d99a97
6 changed files with 63 additions and 64 deletions

View File

@ -10,6 +10,8 @@ General
------- -------
- Put two newlines between top-level code (funcs, classes, etc) - Put two newlines between top-level code (funcs, classes, etc)
- Put one newline between methods in classes and anywhere else - Put one newline between methods in classes and anywhere else
- Long lines should be wrapped in parentheses
in preference to using a backslash for line continuation.
- Do not write "except:", use "except Exception:" at the very least - Do not write "except:", use "except Exception:" at the very least
- Include your name with TODOs as in "#TODO(termie)" - Include your name with TODOs as in "#TODO(termie)"
- Do not shadow a built-in or reserved word. Example:: - Do not shadow a built-in or reserved word. Example::

View File

@ -48,10 +48,9 @@ from nova.openstack.common import cfg
from nova import rpc from nova import rpc
delete_exchange_opt = \ delete_exchange_opt = cfg.BoolOpt('delete_exchange',
cfg.BoolOpt('delete_exchange', default=False,
default=False, help='delete nova exchange too.')
help='delete nova exchange too.')
FLAGS = flags.FLAGS FLAGS = flags.FLAGS
FLAGS.register_cli_opt(delete_exchange_opt) FLAGS.register_cli_opt(delete_exchange_opt)

View File

@ -108,10 +108,10 @@ def main():
if action in ['add', 'del', 'old']: if action in ['add', 'del', 'old']:
mac = argv[2] mac = argv[2]
ip = argv[3] ip = argv[3]
msg = _("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") % \ msg = (_("Called '%(action)s' for mac '%(mac)s' with ip '%(ip)s'") %
{"action": action, {"action": action,
"mac": mac, "mac": mac,
"ip": ip} "ip": ip})
LOG.debug(msg) LOG.debug(msg)
globals()[action + '_lease'](mac, ip) globals()[action + '_lease'](mac, ip)
else: else:

View File

@ -593,8 +593,8 @@ class FixedIpCommands(object):
hostname = instance['hostname'] hostname = instance['hostname']
host = instance['host'] host = instance['host']
else: else:
print 'WARNING: fixed ip %s allocated to missing' \ print ('WARNING: fixed ip %s allocated to missing'
' instance' % str(fixed_ip['address']) ' instance' % str(fixed_ip['address']))
print "%-18s\t%-15s\t%-15s\t%s" % ( print "%-18s\t%-15s\t%-15s\t%s" % (
network['cidr'], network['cidr'],
fixed_ip['address'], fixed_ip['address'],
@ -760,8 +760,8 @@ class NetworkCommands(object):
if FLAGS.network_manager in bridge_required: if FLAGS.network_manager in bridge_required:
raise exception.NetworkNotCreated(req='--bridge') raise exception.NetworkNotCreated(req='--bridge')
bridge_interface = bridge_interface or FLAGS.flat_interface or \ bridge_interface = (bridge_interface or FLAGS.flat_interface or
FLAGS.vlan_interface FLAGS.vlan_interface)
if not bridge_interface: if not bridge_interface:
interface_required = ['nova.network.manager.VlanManager'] interface_required = ['nova.network.manager.VlanManager']
if FLAGS.network_manager in interface_required: if FLAGS.network_manager in interface_required:
@ -873,8 +873,8 @@ class NetworkCommands(object):
if uuid is None: if uuid is None:
raise Exception("UUID is required to delete Quantum Networks") raise Exception("UUID is required to delete Quantum Networks")
if fixed_range: if fixed_range:
raise Exception("Deleting by fixed_range is not supported " \ raise Exception("Deleting by fixed_range is not supported "
"with the QuantumManager") "with the QuantumManager")
# delete the network # delete the network
net_manager.delete_network(context.get_admin_context(), net_manager.delete_network(context.get_admin_context(),
fixed_range, uuid) fixed_range, uuid)
@ -920,20 +920,19 @@ class VmCommands(object):
def list(self, host=None): def list(self, host=None):
"""Show a list of all instances""" """Show a list of all instances"""
print "%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s" \ print ("%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s"
" %-10s %-10s %-10s %-5s" % ( " %-10s %-10s %-10s %-5s" % (_('instance'),
_('instance'), _('node'),
_('node'), _('type'),
_('type'), _('state'),
_('state'), _('launched'),
_('launched'), _('image'),
_('image'), _('kernel'),
_('kernel'), _('ramdisk'),
_('ramdisk'), _('project'),
_('project'), _('user'),
_('user'), _('zone'),
_('zone'), _('index')))
_('index'))
if host is None: if host is None:
instances = db.instance_get_all(context.get_admin_context()) instances = db.instance_get_all(context.get_admin_context())
@ -942,20 +941,19 @@ class VmCommands(object):
context.get_admin_context(), host) context.get_admin_context(), host)
for instance in instances: for instance in instances:
print "%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s" \ print ("%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s"
" %-10s %-10s %-10s %-5d" % ( " %-10s %-10s %-10s %-5d" % (instance['display_name'],
instance['display_name'], instance['host'],
instance['host'], instance['instance_type'].name,
instance['instance_type'].name, instance['vm_state'],
instance['vm_state'], instance['launched_at'],
instance['launched_at'], instance['image_ref'],
instance['image_ref'], instance['kernel_id'],
instance['kernel_id'], instance['ramdisk_id'],
instance['ramdisk_id'], instance['project_id'],
instance['project_id'], instance['user_id'],
instance['user_id'], instance['availability_zone'],
instance['availability_zone'], instance['launch_index']))
instance['launch_index'])
class ServiceCommands(object): class ServiceCommands(object):
@ -1040,17 +1038,17 @@ class ServiceCommands(object):
"c": _('cpu'), "c": _('cpu'),
"d": _('mem(mb)'), "d": _('mem(mb)'),
"e": _('hdd')} "e": _('hdd')}
print '%(a)-16s(total)%(b)26s%(c)8s%(d)8s' %\ print ('%(a)-16s(total)%(b)26s%(c)8s%(d)8s' %
{"a": host, {"a": host,
"b": result['resource']['vcpus'], "b": result['resource']['vcpus'],
"c": result['resource']['memory_mb'], "c": result['resource']['memory_mb'],
"d": result['resource']['local_gb']} "d": result['resource']['local_gb']})
print '%(a)-16s(used_now)%(b)23s%(c)8s%(d)8s' %\ print ('%(a)-16s(used_now)%(b)23s%(c)8s%(d)8s' %
{"a": host, {"a": host,
"b": result['resource']['vcpus_used'], "b": result['resource']['vcpus_used'],
"c": result['resource']['memory_mb_used'], "c": result['resource']['memory_mb_used'],
"d": result['resource']['local_gb_used']} "d": result['resource']['local_gb_used']})
# Printing a used_max # Printing a used_max
cpu_sum = 0 cpu_sum = 0
@ -1121,9 +1119,9 @@ class VersionCommands(object):
pass pass
def list(self): def list(self):
print _("%(version)s (%(vcs)s)") % \ print (_("%(version)s (%(vcs)s)") %
{'version': version.version_string(), {'version': version.version_string(),
'vcs': version.version_string_with_vcs()} 'vcs': version.version_string_with_vcs()})
def __call__(self): def __call__(self):
self.list() self.list()
@ -1689,9 +1687,9 @@ def main():
script_name = argv.pop(0) script_name = argv.pop(0)
if len(argv) < 1: if len(argv) < 1:
print _("\nOpenStack Nova version: %(version)s (%(vcs)s)\n") % \ print (_("\nOpenStack Nova version: %(version)s (%(vcs)s)\n") %
{'version': version.version_string(), {'version': version.version_string(),
'vcs': version.version_string_with_vcs()} 'vcs': version.version_string_with_vcs()})
print script_name + " category action [<args>]" print script_name + " category action [<args>]"
print _("Available categories:") print _("Available categories:")
for k, _v in CATEGORIES: for k, _v in CATEGORIES:

View File

@ -68,8 +68,8 @@ def send_update_with_states(context, instance, old_vm_state, new_vm_state,
if old_vm_state != new_vm_state: if old_vm_state != new_vm_state:
# yes, the vm state is changing: # yes, the vm state is changing:
fire_update = True fire_update = True
elif FLAGS.notify_on_state_change.lower() == "vm_and_task_state" and \ elif (FLAGS.notify_on_state_change.lower() == "vm_and_task_state" and
old_task_state != new_task_state: old_task_state != new_task_state):
# yes, the task state is changing: # yes, the task state is changing:
fire_update = True fire_update = True

View File

@ -128,8 +128,8 @@ class VolumeTestCase(test.TestCase):
self.volume.create_volume(self.context, volume_id) self.volume.create_volume(self.context, volume_id)
self.mox.StubOutWithMock(self.volume.driver, 'delete_volume') self.mox.StubOutWithMock(self.volume.driver, 'delete_volume')
self.volume.driver.delete_volume(mox.IgnoreArg()) \ self.volume.driver.delete_volume(mox.IgnoreArg()).AndRaise(
.AndRaise(exception.VolumeIsBusy) exception.VolumeIsBusy)
self.mox.ReplayAll() self.mox.ReplayAll()
res = self.volume.delete_volume(self.context, volume_id) res = self.volume.delete_volume(self.context, volume_id)
self.assertEqual(True, res) self.assertEqual(True, res)
@ -374,8 +374,8 @@ class VolumeTestCase(test.TestCase):
self.volume.create_snapshot(self.context, volume_id, snapshot_id) self.volume.create_snapshot(self.context, volume_id, snapshot_id)
self.mox.StubOutWithMock(self.volume.driver, 'delete_snapshot') self.mox.StubOutWithMock(self.volume.driver, 'delete_snapshot')
self.volume.driver.delete_snapshot(mox.IgnoreArg()) \ self.volume.driver.delete_snapshot(mox.IgnoreArg()).AndRaise(
.AndRaise(exception.SnapshotIsBusy) exception.SnapshotIsBusy)
self.mox.ReplayAll() self.mox.ReplayAll()
self.volume.delete_snapshot(self.context, snapshot_id) self.volume.delete_snapshot(self.context, snapshot_id)
snapshot_ref = db.snapshot_get(self.context, snapshot_id) snapshot_ref = db.snapshot_get(self.context, snapshot_id)