Merge "pep8 ovirt classes, added copyright statement to ovirt files"

This commit is contained in:
Zuul 2018-05-18 09:14:04 +00:00 committed by Gerrit Code Review
commit 09e4707b61
5 changed files with 25 additions and 22 deletions

View File

@ -39,5 +39,5 @@ class InvalidIPMITimestamp(exception.IronicException):
pass
class oVirtError(exception.IronicException):
class OVirtError(exception.IronicException):
message = _("oVirt call failed: %(err)s.")

View File

@ -1,5 +1,6 @@
# -*- encoding: utf-8 -*-
#
# Copyright 2017 Red Hat, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@ -20,7 +21,7 @@ from ironic.drivers import generic
from ironic_staging_drivers.ovirt import ovirt
class oVirtHardware(generic.GenericHardware):
class OVirtHardware(generic.GenericHardware):
"""oVirt hardware type.
Uses oVirt for power and management.
@ -29,9 +30,9 @@ class oVirtHardware(generic.GenericHardware):
@property
def supported_management_interfaces(self):
"""List of supported management interfaces."""
return [ovirt.oVirtManagement]
return [ovirt.OVirtManagement]
@property
def supported_power_interfaces(self):
"""List of supported power interfaces."""
return [ovirt.oVirtPower]
return [ovirt.OVirtPower]

View File

@ -1,3 +1,4 @@
# Copyright 2017 Red Hat, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@ -150,15 +151,15 @@ def _getvm(driver_info):
except sdk.Error as e:
LOG.error("Could not fetch information about VM vm %(name)s, "
"got error: %(error)s", {'name': name, 'error': e})
raise staging_exception.oVirtError(err=e)
raise staging_exception.OVirtError(err=e)
if vmsearch:
return vms_service.vm_service(vmsearch[0].id)
else:
raise staging_exception.oVirtError(_("VM with name "
raise staging_exception.OVirtError(_("VM with name "
"%s was not found") % name)
class oVirtPower(base.PowerInterface):
class OVirtPower(base.PowerInterface):
def get_properties(self):
return PROPERTIES
@ -230,7 +231,7 @@ class oVirtPower(base.PowerInterface):
except sdk.Error as e:
LOG.error("Could not change status of VM vm %(name)s "
"got error: %(error)s", {'name': vm_name, 'error': e})
raise staging_exception.oVirtError(err=e)
raise staging_exception.OVirtError(err=e)
@task_manager.require_exclusive_lock
def reboot(self, task, timeout=None):
@ -247,7 +248,7 @@ class oVirtPower(base.PowerInterface):
self.set_power_state(task, states.REBOOT, timeout=timeout)
class oVirtManagement(base.ManagementInterface):
class OVirtManagement(base.ManagementInterface):
def get_properties(self):
return PROPERTIES
@ -285,7 +286,7 @@ class oVirtManagement(base.ManagementInterface):
missing in the node's driver_info.
:raises: InvalidParameterValue, if some parameter(s) have invalid
value(s) in the node's driver_info.
:raises: oVirtError, if error encountered from
:raises: OVirtError, if error encountered from
oVirt operation.
"""
driver_info = _parse_driver_info(task.node)
@ -298,8 +299,8 @@ class oVirtManagement(base.ManagementInterface):
msg = _("oVirt returned unknown boot device '%(device)s' "
"for node %(node)s")
LOG.error(msg, {'device': boot_dev, 'node': task.node.uuid})
raise staging_exception.oVirtError(msg.format(device=boot_dev,
node=task.node.uuid))
raise staging_exception.OVirtError(msg.format(device=boot_dev,
node=task.node.uuid))
return {'boot_device': ironic_boot_dev, 'persistent': persistent}
@ -331,7 +332,7 @@ class oVirtManagement(base.ManagementInterface):
LOG.error("Setting boot device failed for node %(node_id)s "
"with error: %(error)s",
{'node_id': task.node.uuid, 'error': e})
raise staging_exception.oVirtError(err=e)
raise staging_exception.OVirtError(err=e)
def get_sensors_data(self, task):
"""Get sensors data.

View File

@ -1,3 +1,4 @@
# Copyright 2017 Red Hat, Inc.
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@ -35,10 +36,10 @@ def _ovirt_info():
@mock.patch.object(time, 'sleep', lambda *_: None)
class oVirtDriverTestCase(db_base.DbTestCase):
class OVirtDriverTestCase(db_base.DbTestCase):
def setUp(self):
super(oVirtDriverTestCase, self).setUp()
super(OVirtDriverTestCase, self).setUp()
self.config(enabled_power_interfaces='staging-ovirt',
enabled_management_interfaces='staging-ovirt',
enabled_hardware_types=['staging-ovirt'])
@ -91,7 +92,7 @@ class oVirtDriverTestCase(db_base.DbTestCase):
if prop in expected]
self.assertEqual(sorted(expected), sorted(driver_properties))
@mock.patch.object(ovirt_power.oVirtPower, 'set_power_state',
@mock.patch.object(ovirt_power.OVirtPower, 'set_power_state',
autospec=True, spec_set=True)
def test_set_power_state_power_on(self, mock_power):
with task_manager.acquire(self.context, self.node.uuid) as task:
@ -99,7 +100,7 @@ class oVirtDriverTestCase(db_base.DbTestCase):
mock_power.assert_called_once_with(task.driver.power, task,
states.POWER_ON)
@mock.patch.object(ovirt_power.oVirtPower, 'set_power_state',
@mock.patch.object(ovirt_power.OVirtPower, 'set_power_state',
autospec=True, spec_set=True)
def test_set_power_state_power_off(self, mock_power):
with task_manager.acquire(self.context, self.node.uuid) as task:
@ -121,14 +122,14 @@ class oVirtDriverTestCase(db_base.DbTestCase):
self.assertEqual([boot_devices.CDROM, boot_devices.DISK,
boot_devices.PXE], bdevices)
@mock.patch.object(ovirt_power.oVirtManagement, 'get_boot_device',
@mock.patch.object(ovirt_power.OVirtManagement, 'get_boot_device',
return_value='hd')
def test_get_boot_device(self, mock_management):
with task_manager.acquire(self.context, self.node.uuid) as task:
boot_dev = task.driver.management.get_boot_device(task)
self.assertEqual('hd', boot_dev)
@mock.patch.object(ovirt_power.oVirtManagement, 'set_boot_device',
@mock.patch.object(ovirt_power.OVirtManagement, 'set_boot_device',
autospec=True, spec_set=True)
def test_set_boot_device(self, mock_power):
with task_manager.acquire(self.context, self.node.uuid) as task:

View File

@ -45,13 +45,13 @@ ironic.hardware.interfaces.deploy =
ironic.hardware.interfaces.management =
staging-amt = ironic_staging_drivers.amt.management:AMTManagement
staging-libvirt = ironic_staging_drivers.libvirt.power:LibvirtManagement
staging-ovirt = ironic_staging_drivers.ovirt.ovirt:oVirtManagement
staging-ovirt = ironic_staging_drivers.ovirt.ovirt:OVirtManagement
ironic.hardware.interfaces.power =
staging-amt = ironic_staging_drivers.amt.power:AMTPower
staging-iboot = ironic_staging_drivers.iboot.power:IBootPower
staging-libvirt = ironic_staging_drivers.libvirt.power:LibvirtPower
staging-ovirt = ironic_staging_drivers.ovirt.ovirt:oVirtPower
staging-ovirt = ironic_staging_drivers.ovirt.ovirt:OVirtPower
staging-wol = ironic_staging_drivers.wol.power:WakeOnLanPower
ironic.hardware.interfaces.vendor =
@ -62,7 +62,7 @@ ironic.hardware.types =
staging-iboot = ironic_staging_drivers.iboot:IBootHardware
staging-nm = ironic_staging_drivers.intel_nm:IntelNMHardware
staging-libvirt = ironic_staging_drivers.libvirt:LibvirtHardware
staging-ovirt = ironic_staging_drivers.ovirt:oVirtHardware
staging-ovirt = ironic_staging_drivers.ovirt:OVirtHardware
staging-wol = ironic_staging_drivers.wol:WOLHardware
[build_sphinx]