summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-05-31 22:19:07 +0000
committerGerrit Code Review <review@openstack.org>2012-05-31 22:19:07 +0000
commit79cb3bf9d9559cba5c59ea47f30147bfe89faecb (patch)
treeec50b2fb4fd5a481eedbe0a0b99c14f91f248dd7 /nova/virt
parentf86ef06e6d5a9b3e0039e05c42b45ec136a17862 (diff)
parent61c5597a09945982f093412cd134850346b82e3b (diff)
Merge "Backslash continuation removal (Nova folsom-2)"
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/disk/api.py5
-rw-r--r--nova/virt/libvirt/config.py6
-rw-r--r--nova/virt/libvirt/connection.py4
-rw-r--r--nova/virt/xenapi/host.py113
-rw-r--r--nova/virt/xenapi/vif.py4
-rw-r--r--nova/virt/xenapi/vmops.py4
6 files changed, 67 insertions, 69 deletions
diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py
index 09ede2d50..5978399db 100644
--- a/nova/virt/disk/api.py
+++ b/nova/virt/disk/api.py
@@ -129,9 +129,8 @@ def bind(src, target, instance_name):
s = os.stat(src)
cgroup_info = "b %s:%s rwm\n" % (os.major(s.st_rdev),
os.minor(s.st_rdev))
- cgroups_path = \
- "/sys/fs/cgroup/devices/libvirt/lxc/%s/devices.allow" \
- % instance_name
+ cgroups_path = ("/sys/fs/cgroup/devices/libvirt/lxc/"
+ "%s/devices.allow" % instance_name)
utils.execute('tee', cgroups_path,
process_input=cgroup_info, run_as_root=True)
diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py
index 2ccfd35fb..3f068fa05 100644
--- a/nova/virt/libvirt/config.py
+++ b/nova/virt/libvirt/config.py
@@ -95,9 +95,9 @@ class LibvirtConfigGuestDisk(LibvirtConfigGuestDevice):
dev.set("type", self.source_type)
dev.set("device", self.source_device)
- if self.driver_name is not None or \
- self.driver_format is not None or \
- self.driver_cache is not None:
+ if (self.driver_name is not None or
+ self.driver_format is not None or
+ self.driver_cache is not None):
drv = etree.Element("driver")
if self.driver_name is not None:
drv.set("name", self.driver_name)
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 8a24c4e55..ab32ff927 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -1760,8 +1760,8 @@ class LibvirtConnection(driver.ComputeDriver):
return []
return filter(bool,
- [target.get("dev") \
- for target in doc.findall('devices/disk/target')])
+ [target.get("dev")
+ for target in doc.findall('devices/disk/target')])
def get_interfaces(self, instance_name):
"""
diff --git a/nova/virt/xenapi/host.py b/nova/virt/xenapi/host.py
index d5f568360..a6fb4a92e 100644
--- a/nova/virt/xenapi/host.py
+++ b/nova/virt/xenapi/host.py
@@ -50,66 +50,65 @@ class Host(object):
def host_maintenance_mode(self, host, mode):
"""Start/Stop host maintenance window. On start, it triggers
guest VMs evacuation."""
- if mode:
- host_list = [host_ref for host_ref in
- self._session.call_xenapi('host.get_all') \
- if host_ref != self._session.get_xenapi_host()]
- migrations_counter = vm_counter = 0
- ctxt = context.get_admin_context()
- for vm_ref, vm_rec in vm_utils.VMHelper.list_vms(self._session):
- for host_ref in host_list:
- try:
- # Ensure only guest instances are migrated
- uuid = vm_rec['other_config'].get('nova_uuid')
+ if not mode:
+ return 'off_maintenance'
+ host_list = [host_ref for host_ref in
+ self._session.call_xenapi('host.get_all')
+ if host_ref != self._session.get_xenapi_host()]
+ migrations_counter = vm_counter = 0
+ ctxt = context.get_admin_context()
+ for vm_ref, vm_rec in vm_utils.VMHelper.list_vms(self._session):
+ for host_ref in host_list:
+ try:
+ # Ensure only guest instances are migrated
+ uuid = vm_rec['other_config'].get('nova_uuid')
+ if not uuid:
+ name = vm_rec['name_label']
+ uuid = _uuid_find(ctxt, host, name)
if not uuid:
- name = vm_rec['name_label']
- uuid = _uuid_find(ctxt, host, name)
- if not uuid:
- msg = _('Instance %(name)s running on %(host)s'
- ' could not be found in the database:'
- ' assuming it is a worker VM and skip'
- 'ping migration to a new host')
- LOG.info(msg % locals())
- continue
- instance = db.instance_get_by_uuid(ctxt, uuid)
- vm_counter = vm_counter + 1
-
- dest = _host_find(ctxt, self._session, host, host_ref)
- (old_ref, new_ref) = \
- db.instance_update_and_get_original(ctxt,
- instance.id,
- {'host': dest,
- 'vm_state': vm_states.MIGRATING})
- notifications.send_update(ctxt, old_ref, new_ref)
-
- self._session.call_xenapi('VM.pool_migrate',
- vm_ref, host_ref, {})
- migrations_counter = migrations_counter + 1
-
- (old_ref, new_ref) = \
- db.instance_update_and_get_original(ctxt,
- instance.id,
- {'vm_state': vm_states.ACTIVE})
- notifications.send_update(ctxt, old_ref, new_ref)
-
- break
- except self.XenAPI.Failure:
- LOG.exception('Unable to migrate VM %(vm_ref)s'
- 'from %(host)s' % locals())
- (old_ref, new_ref) = \
- db.instance_update_and_get_original(ctxt,
+ msg = _('Instance %(name)s running on %(host)s'
+ ' could not be found in the database:'
+ ' assuming it is a worker VM and skip'
+ ' ping migration to a new host')
+ LOG.info(msg % locals())
+ continue
+ instance = db.instance_get_by_uuid(ctxt, uuid)
+ vm_counter = vm_counter + 1
+
+ dest = _host_find(ctxt, self._session, host, host_ref)
+ (old_ref, new_ref) = db.instance_update_and_get_original(
+ ctxt,
instance.id,
- {'hosts': host,
- 'vm_state': vm_states.ACTIVE})
- notifications.send_update(ctxt, old_ref, new_ref)
-
- if vm_counter == migrations_counter:
- return 'on_maintenance'
- else:
- raise exception.NoValidHost(reason='Unable to find suitable '
- 'host for VMs evacuation')
+ {'host': dest,
+ 'vm_state': vm_states.MIGRATING})
+ notifications.send_update(ctxt, old_ref, new_ref)
+
+ self._session.call_xenapi('VM.pool_migrate',
+ vm_ref, host_ref, {})
+ migrations_counter = migrations_counter + 1
+
+ (old_ref, new_ref) = db.instance_update_and_get_original(
+ ctxt,
+ instance.id,
+ {'vm_state': vm_states.ACTIVE})
+ notifications.send_update(ctxt, old_ref, new_ref)
+
+ break
+ except self.XenAPI.Failure:
+ LOG.exception('Unable to migrate VM %(vm_ref)s'
+ 'from %(host)s' % locals())
+ (old_ref, new_ref) = db.instance_update_and_get_original(
+ ctxt,
+ instance.id,
+ {'hosts': host,
+ 'vm_state': vm_states.ACTIVE})
+ notifications.send_update(ctxt, old_ref, new_ref)
+
+ if vm_counter == migrations_counter:
+ return 'on_maintenance'
else:
- return 'off_maintenance'
+ raise exception.NoValidHost(reason='Unable to find suitable '
+ 'host for VMs evacuation')
def set_host_enabled(self, _host, enabled):
"""Sets the specified host's ability to accept new instances."""
diff --git a/nova/virt/xenapi/vif.py b/nova/virt/xenapi/vif.py
index 905cbc30c..05bbc33c1 100644
--- a/nova/virt/xenapi/vif.py
+++ b/nova/virt/xenapi/vif.py
@@ -76,8 +76,8 @@ class XenAPIBridgeDriver(XenVIFDriver):
vlan_num = network.get_meta('vlan')
bridge = network['bridge']
- bridge_interface = FLAGS.vlan_interface or \
- network.get_meta('bridge_interface')
+ bridge_interface = (FLAGS.vlan_interface or
+ network.get_meta('bridge_interface'))
# Check whether bridge already exists
# Retrieve network whose name_label is "bridge"
network_ref = network_utils.NetworkHelper.find_network_with_name_label(
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index 8ede49983..c2f2d3b4a 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -1433,8 +1433,8 @@ class VMOps(object):
for vif in network_info:
xs_data = self._vif_xenstore_data(vif)
- location = \
- 'vm-data/networking/%s' % vif['address'].replace(':', '')
+ location = ('vm-data/networking/%s' %
+ vif['address'].replace(':', ''))
self._add_to_param_xenstore(vm_ref, location, json.dumps(xs_data))
try:
self._write_to_xenstore(instance, location, xs_data,