Merge "Don't assume Ironic is installed"
This commit is contained in:
commit
33709771b9
|
@ -422,11 +422,18 @@ def check_existing(instances, provisioner, baremetal):
|
|||
found = []
|
||||
unmanaged = []
|
||||
for request in instances:
|
||||
|
||||
ident = request.get('name', request['hostname'])
|
||||
|
||||
if not request.get('managed', True):
|
||||
unmanaged.append(request)
|
||||
continue
|
||||
|
||||
ident = request.get('name', request['hostname'])
|
||||
elif not baremetal:
|
||||
message = ('Instance %s is not specified as pre-provisioned '
|
||||
'(managed: False), and no connection to '
|
||||
'the baremetal service was provided.'
|
||||
% ident)
|
||||
raise BaremetalDeployException(message)
|
||||
|
||||
try:
|
||||
instance = provisioner.show_instance(ident)
|
||||
|
|
|
@ -21,6 +21,7 @@ from ansible.module_utils.openstack import openstack_cloud_from_module
|
|||
from ansible.module_utils.openstack import openstack_full_argument_spec
|
||||
from ansible.module_utils.openstack import openstack_module_kwargs
|
||||
|
||||
import keystoneauth1
|
||||
import metalsmith
|
||||
|
||||
import yaml
|
||||
|
@ -114,12 +115,19 @@ def main():
|
|||
provisioner = metalsmith.Provisioner(cloud_region=cloud.config)
|
||||
|
||||
try:
|
||||
msg = ''
|
||||
|
||||
try:
|
||||
baremetal = cloud.baremetal
|
||||
except keystoneauth1.exceptions.catalog.EndpointNotFound as exc:
|
||||
msg += str(exc)
|
||||
baremetal = None
|
||||
|
||||
found, not_found, pre_provisioned = bd.check_existing(
|
||||
instances=module.params['instances'],
|
||||
provisioner=provisioner,
|
||||
baremetal=cloud.baremetal
|
||||
baremetal=baremetal
|
||||
)
|
||||
msg = ''
|
||||
if found:
|
||||
msg += ('Found existing instances: %s. '
|
||||
% ', '.join([i.uuid for i in found]))
|
||||
|
|
|
@ -1109,6 +1109,19 @@ class TestCheckExistingInstances(base.TestCase):
|
|||
self.assertIn("hostname host1 was not found", str(exc))
|
||||
pr.show_instance.assert_called_once_with('host1')
|
||||
|
||||
def test_check_existing_no_ironic(self):
|
||||
pr = mock.Mock()
|
||||
instances = [
|
||||
{'hostname': 'host1',
|
||||
'image': {'href': 'overcloud-full'}},
|
||||
]
|
||||
exc = self.assertRaises(
|
||||
bd.BaremetalDeployException, bd.check_existing,
|
||||
instances, pr, None)
|
||||
|
||||
self.assertIn(
|
||||
"Instance host1 is not specified as pre-provisioned", str(exc))
|
||||
|
||||
def test_unexpected_error(self):
|
||||
pr = mock.Mock()
|
||||
instances = [
|
||||
|
|
Loading…
Reference in New Issue