diff options
author | Jenkins <jenkins@review.openstack.org> | 2016-08-22 19:23:17 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2016-08-22 19:23:17 +0000 |
commit | 7b3f3ec2f896f32f0bebc363b934edacc5bcb805 (patch) | |
tree | 9ecd3ea753d4421b169001a485551dca41b998f6 /ironic/drivers/modules | |
parent | 04d08f76b13538946dac86ab1998b4180544a48b (diff) | |
parent | e497a32ee09253cde2942a55f6c7c89dad7be831 (diff) | |
download | ironic-7b3f3ec2f896f32f0bebc363b934edacc5bcb805.tar.gz |
Merge "Replace DB API call to object's method in iLO drivers"
Diffstat (limited to 'ironic/drivers/modules')
-rw-r--r-- | ironic/drivers/modules/ilo/inspect.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ironic/drivers/modules/ilo/inspect.py b/ironic/drivers/modules/ilo/inspect.py index e0e174bd5..9ff7a4b79 100644 --- a/ironic/drivers/modules/ilo/inspect.py +++ b/ironic/drivers/modules/ilo/inspect.py @@ -22,9 +22,9 @@ from ironic.common.i18n import _LW from ironic.common import states from ironic.common import utils from ironic.conductor import utils as conductor_utils -from ironic.db import api as dbapi from ironic.drivers import base from ironic.drivers.modules.ilo import common as ilo_common +from ironic import objects ilo_error = importutils.try_import('proliantutils.exception') @@ -35,24 +35,24 @@ CAPABILITIES_KEYS = {'BootMode', 'secure_boot', 'rom_firmware_version', 'pci_gpu_devices', 'sr_iov_devices', 'nic_capacity'} -def _create_ports_if_not_exist(node, macs): +def _create_ports_if_not_exist(task, macs): """Create ironic ports for the mac addresses. Creates ironic ports for the mac addresses returned with inspection or as requested by operator. - :param node: node object. + :param task: a TaskManager instance. :param macs: A dictionary of port numbers to mac addresses returned by node inspection. """ - node_id = node.id - sql_dbapi = dbapi.get_instance() + node = task.node for mac in macs.values(): - port_dict = {'address': mac, 'node_id': node_id} + port_dict = {'address': mac, 'node_id': node.id} + port = objects.Port(task.context, **port_dict) try: - sql_dbapi.create_port(port_dict) + port.create() LOG.info(_LI("Port created for MAC address %(address)s for node " "%(node)s"), {'address': mac, 'node': node.uuid}) except exception.MACAlreadyExists: @@ -237,7 +237,7 @@ class IloInspect(base.InspectInterface): task.node.save() # Create ports for the nics detected. - _create_ports_if_not_exist(task.node, result['macs']) + _create_ports_if_not_exist(task, result['macs']) LOG.debug(("Node properties for %(node)s are updated as " "%(properties)s"), |