diff options
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/api/openstack/compute/contrib/extended_server_attributes.py | 16 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/flavorextradata.py | 13 | ||||
| -rw-r--r-- | nova/network/model.py | 19 | ||||
| -rw-r--r-- | nova/network/quantum/manager.py | 4 | ||||
| -rw-r--r-- | nova/notifications.py | 4 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 15 | ||||
| -rw-r--r-- | nova/tests/test_volume.py | 8 | ||||
| -rw-r--r-- | nova/virt/disk/api.py | 5 | ||||
| -rw-r--r-- | nova/virt/libvirt/config.py | 6 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 4 | ||||
| -rw-r--r-- | nova/virt/xenapi/host.py | 113 | ||||
| -rw-r--r-- | nova/virt/xenapi/vif.py | 4 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 4 |
13 files changed, 108 insertions, 107 deletions
diff --git a/nova/api/openstack/compute/contrib/extended_server_attributes.py b/nova/api/openstack/compute/contrib/extended_server_attributes.py index 2da5badc3..4c584ec05 100644 --- a/nova/api/openstack/compute/contrib/extended_server_attributes.py +++ b/nova/api/openstack/compute/contrib/extended_server_attributes.py @@ -104,8 +104,8 @@ class Extended_server_attributes(extensions.ExtensionDescriptor): name = "ExtendedServerAttributes" alias = "OS-EXT-SRV-ATTR" - namespace = "http://docs.openstack.org/compute/ext/" \ - "extended_status/api/v1.1" + namespace = ("http://docs.openstack.org/compute/ext/" + "extended_status/api/v1.1") updated = "2011-11-03T00:00:00+00:00" def get_controller_extensions(self): @@ -125,9 +125,9 @@ class ExtendedServerAttributeTemplate(xmlutil.TemplateBuilder): def construct(self): root = xmlutil.TemplateElement('server', selector='server') make_server(root) - return xmlutil.SlaveTemplate(root, 1, nsmap={ - Extended_server_attributes.alias: \ - Extended_server_attributes.namespace}) + alias = Extended_server_attributes.alias + namespace = Extended_server_attributes.namespace + return xmlutil.SlaveTemplate(root, 1, nsmap={alias: namespace}) class ExtendedServerAttributesTemplate(xmlutil.TemplateBuilder): @@ -135,6 +135,6 @@ class ExtendedServerAttributesTemplate(xmlutil.TemplateBuilder): root = xmlutil.TemplateElement('servers') elem = xmlutil.SubTemplateElement(root, 'server', selector='servers') make_server(elem) - return xmlutil.SlaveTemplate(root, 1, nsmap={ - Extended_server_attributes.alias: \ - Extended_server_attributes.namespace}) + alias = Extended_server_attributes.alias + namespace = Extended_server_attributes.namespace + return xmlutil.SlaveTemplate(root, 1, nsmap={alias: namespace}) diff --git a/nova/api/openstack/compute/contrib/flavorextradata.py b/nova/api/openstack/compute/contrib/flavorextradata.py index 9a07270ce..2864ada5e 100644 --- a/nova/api/openstack/compute/contrib/flavorextradata.py +++ b/nova/api/openstack/compute/contrib/flavorextradata.py @@ -55,8 +55,7 @@ class FlavorextradataController(wsgi.Controller): resp_obj.attach(xml=FlavorextradatumTemplate()) try: - flavor_ref = instance_types.\ - get_instance_type_by_flavor_id(id) + flavor_ref = instance_types.get_instance_type_by_flavor_id(id) except exception.FlavorNotFound: explanation = _("Flavor not found.") raise exception.HTTPNotFound(explanation=explanation) @@ -118,8 +117,9 @@ class FlavorextradatumTemplate(xmlutil.TemplateBuilder): def construct(self): root = xmlutil.TemplateElement('flavor', selector='flavor') make_flavor(root) - return xmlutil.SlaveTemplate(root, 1, nsmap={ - Flavorextradata.alias: Flavorextradata.namespace}) + alias = Flavorextradata.alias + namespace = Flavorextradata.namespace + return xmlutil.SlaveTemplate(root, 1, nsmap={alias: namespace}) class FlavorextradataTemplate(xmlutil.TemplateBuilder): @@ -127,5 +127,6 @@ class FlavorextradataTemplate(xmlutil.TemplateBuilder): root = xmlutil.TemplateElement('flavors') elem = xmlutil.SubTemplateElement(root, 'flavor', selector='flavors') make_flavor(elem) - return xmlutil.SlaveTemplate(root, 1, nsmap={ - Flavorextradata.alias: Flavorextradata.namespace}) + alias = Flavorextradata.alias + namespace = Flavorextradata.namespace + return xmlutil.SlaveTemplate(root, 1, nsmap={alias: namespace}) diff --git a/nova/network/model.py b/nova/network/model.py index 84a8ab35e..e0851ded2 100644 --- a/nova/network/model.py +++ b/nova/network/model.py @@ -344,15 +344,16 @@ class NetworkInfo(list): gateway = get_ip(subnet_v4['gateway']) dhcp_server = subnet_v4.get_meta('dhcp_server', gateway) - network_dict = \ - {'bridge': network['bridge'], - 'id': network['id'], - 'cidr': subnet_v4['cidr'], - 'cidr_v6': subnet_v6['cidr'] if subnet_v6 else None, - 'vlan': network.get_meta('vlan'), - 'injected': network.get_meta('injected', False), - 'multi_host': network.get_meta('multi_host', False), - 'bridge_interface': network.get_meta('bridge_interface')} + network_dict = { + 'bridge': network['bridge'], + 'id': network['id'], + 'cidr': subnet_v4['cidr'], + 'cidr_v6': subnet_v6['cidr'] if subnet_v6 else None, + 'vlan': network.get_meta('vlan'), + 'injected': network.get_meta('injected', False), + 'multi_host': network.get_meta('multi_host', False), + 'bridge_interface': network.get_meta('bridge_interface') + } # NOTE(tr3buchet): 'ips' bit here is tricky, we support a single # subnet but we want all the IPs to be there # so use the v4_subnets[0] and its IPs are first diff --git a/nova/network/quantum/manager.py b/nova/network/quantum/manager.py index 50bc8cf14..689c787fd 100644 --- a/nova/network/quantum/manager.py +++ b/nova/network/quantum/manager.py @@ -283,8 +283,8 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager): # Now we can delete the network self.q_conn.delete_network(q_tenant_id, net_uuid) - LOG.debug("Deleting network %s for tenant: %s" % \ - (net_uuid, q_tenant_id)) + LOG.debug("Deleting network %s for tenant: %s" % + (net_uuid, q_tenant_id)) self.ipam.delete_subnets_by_net_id(context, net_uuid, project_id) # Get rid of dnsmasq if FLAGS.quantum_use_dhcp: diff --git a/nova/notifications.py b/nova/notifications.py index 4e3d1362d..b7c320fbe 100644 --- a/nova/notifications.py +++ b/nova/notifications.py @@ -68,8 +68,8 @@ def send_update_with_states(context, instance, old_vm_state, new_vm_state, if old_vm_state != new_vm_state: # yes, the vm state is changing: fire_update = True - elif FLAGS.notify_on_state_change.lower() == "vm_and_task_state" and \ - old_task_state != new_task_state: + elif (FLAGS.notify_on_state_change.lower() == "vm_and_task_state" and + old_task_state != new_task_state): # yes, the task state is changing: fire_update = True diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index f1903bd4c..cdcf0ec8c 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -4094,13 +4094,14 @@ class KeypairAPITestCase(BaseTestCase): self.keypair_api = compute_api.KeypairAPI() self.ctxt = context.RequestContext('fake', 'fake') self._keypair_db_call_stubs() - self.pub_key = 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLnVkqJu9WVf' \ - '/5StU3JCrBR2r1s1j8K1tux+5XeSvdqaM8lMFNorzbY5iyoBbRS56gy' \ - '1jmm43QsMPJsrpfUZKcJpRENSe3OxIIwWXRoiapZe78u/a9xKwj0avF' \ - 'YMcws9Rk9iAB7W4K1nEJbyCPl5lRBoyqeHBqrnnuXWEgGxJCK0Ah6wc' \ - 'OzwlEiVjdf4kxzXrwPHyi7Ea1qvnNXTziF8yYmUlH4C8UXfpTQckwSw' \ - 'pDyxZUc63P8q+vPbs3Q2kw+/7vvkCKHJAXVI+oCiyMMfffoTq16M1xf' \ - 'V58JstgtTqAXG+ZFpicGajREUE/E3hO5MGgcHmyzIrWHKpe1n3oEGuz' + self.pub_key = ('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLnVkqJu9WVf' + '/5StU3JCrBR2r1s1j8K1tux+5XeSvdqaM8lMFNorzbY5iyoBbR' + 'S56gy1jmm43QsMPJsrpfUZKcJpRENSe3OxIIwWXRoiapZe78u/' + 'a9xKwj0avFYMcws9Rk9iAB7W4K1nEJbyCPl5lRBoyqeHBqrnnu' + 'XWEgGxJCK0Ah6wcOzwlEiVjdf4kxzXrwPHyi7Ea1qvnNXTziF8' + 'yYmUlH4C8UXfpTQckwSwpDyxZUc63P8q+vPbs3Q2kw+/7vvkCK' + 'HJAXVI+oCiyMMfffoTq16M1xfV58JstgtTqAXG+ZFpicGajREU' + 'E/E3hO5MGgcHmyzIrWHKpe1n3oEGuz') self.fingerprint = '4e:48:c6:a0:4a:f9:dd:b5:4c:85:54:5a:af:43:47:5a' def _keypair_db_call_stubs(self): diff --git a/nova/tests/test_volume.py b/nova/tests/test_volume.py index 2909b51f7..20ac495c9 100644 --- a/nova/tests/test_volume.py +++ b/nova/tests/test_volume.py @@ -128,8 +128,8 @@ class VolumeTestCase(test.TestCase): self.volume.create_volume(self.context, volume_id) self.mox.StubOutWithMock(self.volume.driver, 'delete_volume') - self.volume.driver.delete_volume(mox.IgnoreArg()) \ - .AndRaise(exception.VolumeIsBusy) + self.volume.driver.delete_volume(mox.IgnoreArg()).AndRaise( + exception.VolumeIsBusy) self.mox.ReplayAll() res = self.volume.delete_volume(self.context, volume_id) self.assertEqual(True, res) @@ -374,8 +374,8 @@ class VolumeTestCase(test.TestCase): self.volume.create_snapshot(self.context, volume_id, snapshot_id) self.mox.StubOutWithMock(self.volume.driver, 'delete_snapshot') - self.volume.driver.delete_snapshot(mox.IgnoreArg()) \ - .AndRaise(exception.SnapshotIsBusy) + self.volume.driver.delete_snapshot(mox.IgnoreArg()).AndRaise( + exception.SnapshotIsBusy) self.mox.ReplayAll() self.volume.delete_snapshot(self.context, snapshot_id) snapshot_ref = db.snapshot_get(self.context, snapshot_id) 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, |
