Merge "Renaming ironicclient exceptions in nova driver"
This commit is contained in:
commit
d0b14531ce
ironic/nova
@ -184,7 +184,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
icli = cw.IronicClientWrapper()
|
||||
with mock.patch.object(FAKE_CLIENT.node, 'get_by_instance_uuid') \
|
||||
as mock_gbiui:
|
||||
mock_gbiui.side_effect = ironic_exception.HTTPNotFound()
|
||||
mock_gbiui.side_effect = ironic_exception.NotFound()
|
||||
instance_uuid = uuidutils.generate_uuid(),
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
uuid=instance_uuid)
|
||||
@ -308,7 +308,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch.object(cw.IronicClientWrapper, 'call')
|
||||
def test_instance_exists_fail(self, mock_call):
|
||||
mock_call.side_effect = ironic_exception.HTTPNotFound
|
||||
mock_call.side_effect = ironic_exception.NotFound
|
||||
instance_uuid = 'fake-uuid'
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
uuid=instance_uuid)
|
||||
@ -355,7 +355,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
self.assertTrue(self.driver.node_is_available(node.uuid))
|
||||
mock_get.assert_called_with(node.uuid)
|
||||
|
||||
mock_get.side_effect = ironic_exception.HTTPNotFound
|
||||
mock_get.side_effect = ironic_exception.NotFound
|
||||
self.assertFalse(self.driver.node_is_available(node.uuid))
|
||||
|
||||
def test__node_resources_unavailable(self):
|
||||
@ -443,7 +443,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
def test_get_info_http_not_found(self):
|
||||
with mock.patch.object(FAKE_CLIENT.node, 'get_by_instance_uuid') \
|
||||
as mock_gbiu:
|
||||
mock_gbiu.side_effect = ironic_exception.HTTPNotFound()
|
||||
mock_gbiu.side_effect = ironic_exception.NotFound()
|
||||
|
||||
expected = {'state': nova_states.NOSTATE,
|
||||
'max_mem': 0,
|
||||
@ -472,7 +472,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
|
||||
def test_macs_for_instance_http_not_found(self):
|
||||
with mock.patch.object(FAKE_CLIENT.node, 'get') as mock_get:
|
||||
mock_get.side_effect = ironic_exception.HTTPNotFound()
|
||||
mock_get.side_effect = ironic_exception.NotFound()
|
||||
|
||||
instance = fake_instance.fake_instance_obj(
|
||||
self.ctx, node=uuidutils.generate_uuid())
|
||||
@ -534,7 +534,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'update')
|
||||
def test__add_driver_fields_fail(self, mock_update):
|
||||
mock_update.side_effect = ironic_exception.HTTPBadRequest()
|
||||
mock_update.side_effect = ironic_exception.BadRequest()
|
||||
node = ironic_utils.get_test_node(driver='fake')
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
@ -553,7 +553,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
|
||||
@mock.patch.object(FAKE_CLIENT.node, 'update')
|
||||
def test__cleanup_deploy_fail(self, mock_update):
|
||||
mock_update.side_effect = ironic_exception.HTTPBadRequest()
|
||||
mock_update.side_effect = ironic_exception.BadRequest()
|
||||
node = ironic_utils.get_test_node(driver='fake', instance_uuid='fake-id')
|
||||
instance = fake_instance.fake_instance_obj(self.ctx,
|
||||
node=node.uuid)
|
||||
@ -676,7 +676,7 @@ class IronicDriverTestCase(test.NoDBTestCase):
|
||||
|
||||
with mock.patch.object(FAKE_CLIENT.node, 'set_provision_state') \
|
||||
as mock_sps:
|
||||
mock_sps.side_effect = ironic_exception.HTTPBadRequest
|
||||
mock_sps.side_effect = ironic_exception.BadRequest
|
||||
self.assertRaises(exception.InstanceDeployFailure,
|
||||
self.driver.spawn,
|
||||
self.ctx, instance, None, [], None)
|
||||
|
@ -77,8 +77,8 @@ class IronicClientWrapper(object):
|
||||
|
||||
:raises: NovaException if all retries failed.
|
||||
"""
|
||||
retry_excs = (ironic_exception.HTTPServiceUnavailable,
|
||||
ironic_exception.CommunicationError)
|
||||
retry_excs = (ironic_exception.ServiceUnavailable,
|
||||
ironic_exception.ConnectionRefused)
|
||||
num_attempts = CONF.ironic.api_max_retries
|
||||
|
||||
for attempt in range(1, num_attempts + 1):
|
||||
|
@ -114,7 +114,7 @@ def validate_instance_and_node(icli, instance):
|
||||
"""
|
||||
try:
|
||||
return icli.call("node.get_by_instance_uuid", instance['uuid'])
|
||||
except ironic_exception.HTTPNotFound:
|
||||
except ironic_exception.NotFound:
|
||||
raise exception.InstanceNotFound(instance_id=instance['uuid'])
|
||||
|
||||
|
||||
@ -234,7 +234,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
'value': instance['uuid']})
|
||||
try:
|
||||
icli.call('node.update', node.uuid, patch)
|
||||
except ironic_exception.HTTPBadRequest:
|
||||
except ironic_exception.BadRequest:
|
||||
msg = (_("Failed to add deploy parameters on node %(node)s "
|
||||
"when provisioning the instance %(instance)s")
|
||||
% {'node': node.uuid, 'instance': instance['uuid']})
|
||||
@ -250,7 +250,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
patch.append({'op': 'remove', 'path': '/instance_uuid'})
|
||||
try:
|
||||
icli.call('node.update', node.uuid, patch)
|
||||
except ironic_exception.HTTPBadRequest:
|
||||
except ironic_exception.BadRequest:
|
||||
msg = (_("Failed clean up the parameters on node %(node)s "
|
||||
"when unprovisioning the instance %(instance)s")
|
||||
% {'node': node.uuid, 'instance': instance['uuid']})
|
||||
@ -265,7 +265,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
""" Wait for the node to be marked as ACTIVE in Ironic """
|
||||
try:
|
||||
node = icli.call("node.get_by_instance_uuid", instance['uuid'])
|
||||
except ironic_exception.HTTPNotFound:
|
||||
except ironic_exception.NotFound:
|
||||
raise exception.InstanceNotFound(instance_id=instance['uuid'])
|
||||
|
||||
if node.provision_state == ironic_states.ACTIVE:
|
||||
@ -315,7 +315,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
try:
|
||||
icli.call("node.get_by_instance_uuid", instance['uuid'])
|
||||
return True
|
||||
except ironic_exception.HTTPNotFound:
|
||||
except ironic_exception.NotFound:
|
||||
return False
|
||||
|
||||
def list_instances(self):
|
||||
@ -334,7 +334,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
try:
|
||||
icli.call("node.get", nodename)
|
||||
return True
|
||||
except ironic_exception.HTTPNotFound:
|
||||
except ironic_exception.NotFound:
|
||||
return False
|
||||
|
||||
def get_available_nodes(self, refresh=False):
|
||||
@ -362,7 +362,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
icli = client_wrapper.IronicClientWrapper()
|
||||
try:
|
||||
node = icli.call("node.get_by_instance_uuid", instance['uuid'])
|
||||
except ironic_exception.HTTPNotFound:
|
||||
except ironic_exception.NotFound:
|
||||
return {'state': map_power_state(ironic_states.NOSTATE),
|
||||
'max_mem': 0,
|
||||
'mem': 0,
|
||||
@ -381,7 +381,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
icli = client_wrapper.IronicClientWrapper()
|
||||
try:
|
||||
node = icli.call("node.get", instance['node'])
|
||||
except ironic_exception.HTTPNotFound:
|
||||
except ironic_exception.NotFound:
|
||||
return []
|
||||
ports = icli.call("node.list_ports", node.uuid)
|
||||
return [p.address for p in ports]
|
||||
@ -429,9 +429,9 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
try:
|
||||
icli.call("node.set_provision_state", node_uuid,
|
||||
ironic_states.ACTIVE)
|
||||
except (exception.NovaException, # Retry failed
|
||||
ironic_exception.HTTPInternalServerError, # Validations
|
||||
ironic_exception.HTTPBadRequest) as e: # Maintenance
|
||||
except (exception.NovaException, # Retry failed
|
||||
ironic_exception.InternalServerError, # Validations
|
||||
ironic_exception.BadRequest) as e: # Maintenance
|
||||
msg = (_("Failed to request Ironic to provision instance "
|
||||
"%(inst)s: %(reason)s") % {'inst': instance['uuid'],
|
||||
'reason': str(e)})
|
||||
@ -463,7 +463,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
def _wait_for_provision_state():
|
||||
try:
|
||||
node = icli.call("node.get_by_instance_uuid", instance['uuid'])
|
||||
except ironic_exception.HTTPNotFound:
|
||||
except ironic_exception.NotFound:
|
||||
raise exception.InstanceNotFound(instance_id=instance['uuid'])
|
||||
|
||||
if not node.provision_state:
|
||||
@ -597,7 +597,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
patch = [{'op': 'remove', 'path': '/extra/vif_port_id'}]
|
||||
try:
|
||||
icli.call("port.update", pif.uuid, patch)
|
||||
except ironic_exception.HTTPBadRequest:
|
||||
except ironic_exception.BadRequest:
|
||||
pass
|
||||
|
||||
def plug_vifs(self, instance, network_info):
|
||||
@ -638,7 +638,7 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
'op': 'add', 'value': str(preserve_ephemeral)})
|
||||
try:
|
||||
icli.call('node.update', node_uuid, patch)
|
||||
except ironic_exception.HTTPBadRequest:
|
||||
except ironic_exception.BadRequest:
|
||||
msg = (_("Failed to add deploy parameters on node %(node)s "
|
||||
"when rebuilding the instance %(instance)s")
|
||||
% {'node': node_uuid, 'instance': instance['uuid']})
|
||||
@ -648,8 +648,8 @@ class IronicDriver(virt_driver.ComputeDriver):
|
||||
try:
|
||||
icli.call("node.set_provision_state", node_uuid, ironic_states.REBUILD)
|
||||
except (exception.NovaException, # Retry failed
|
||||
ironic_exception.HTTPInternalServerError, # Validations
|
||||
ironic_exception.HTTPBadRequest) as e: # Maintenance
|
||||
ironic_exception.InternalServerError, # Validations
|
||||
ironic_exception.BadRequest) as e: # Maintenance
|
||||
msg = (_("Failed to request Ironic to rebuild instance "
|
||||
"%(inst)s: %(reason)s") % {'inst': instance['uuid'],
|
||||
'reason': str(e)})
|
||||
|
Loading…
x
Reference in New Issue
Block a user