Stop depending on oslo.utils

We use it only in one place, which can be easily replaced.

Change-Id: Ic878e890de68c087eef1a791938ecfc8275c30bc
This commit is contained in:
Dmitry Tantsur 2018-05-17 16:10:23 +02:00
parent 1037276d61
commit 86ef953d49
2 changed files with 11 additions and 11 deletions

View File

@ -16,8 +16,9 @@
import collections import collections
import logging import logging
import random import random
import sys
from oslo_utils import excutils import six
from metalsmith import _exceptions from metalsmith import _exceptions
from metalsmith import _os_api from metalsmith import _os_api
@ -138,10 +139,17 @@ class Provisioner(object):
# Update the node to return it's latest state # Update the node to return it's latest state
node = self._api.get_node(node) node = self._api.get_node(node)
except Exception: except Exception:
with excutils.save_and_reraise_exception(): exc_info = sys.exc_info()
try:
LOG.error('Deploy attempt failed on node %s, cleaning up', LOG.error('Deploy attempt failed on node %s, cleaning up',
_utils.log_node(node)) _utils.log_node(node))
self._clean_up(node, created_ports, attached_ports) self._delete_ports(node, created_ports, attached_ports)
self._api.release_node(node)
except Exception:
LOG.exception('Clean up failed')
six.reraise(*exc_info)
if wait is not None: if wait is not None:
LOG.info('Deploy succeeded on node %s', _utils.log_node(node)) LOG.info('Deploy succeeded on node %s', _utils.log_node(node))
@ -164,13 +172,6 @@ class Provisioner(object):
else: else:
LOG.warning('No IPs for node %s', _utils.log_node(node)) LOG.warning('No IPs for node %s', _utils.log_node(node))
def _clean_up(self, node, created_ports, attached_ports):
try:
self._delete_ports(node, created_ports, attached_ports)
self._api.release_node(node)
except Exception:
LOG.exception('Clean up failed')
def _get_nics(self, nics): def _get_nics(self, nics):
"""Validate and get the NICs.""" """Validate and get the NICs."""
result = [] result = []

View File

@ -3,6 +3,5 @@
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
pbr!=2.1.0,>=2.0.0 # Apache-2.0 pbr!=2.1.0,>=2.0.0 # Apache-2.0
openstacksdk>=0.11.0 # Apache-2.0 openstacksdk>=0.11.0 # Apache-2.0
oslo.utils>=3.20.0 # Apache-2.0
python-ironicclient>=1.14.0 # Apache-2.0 python-ironicclient>=1.14.0 # Apache-2.0
six>=1.10.0 # MIT six>=1.10.0 # MIT