Don't assume Ironic is installed
During "overcloud node provision", pre-provisioned nodes can be specified with managed:false, in which case the node provision is just a data transformation process to prepare the inputs for Heat. The ansible modules should not assume that Ironic is installed in this case, as the enable_ironic option has existed for many releases already. Signed-off-by: James Slagle <jslagle@redhat.com> Depends-On: I3657169a3b519869f7f3594c8c6a6072a058e0c8 Change-Id: I2bc8f3d8090b2753f636832600d3bd51424ba7e7
This commit is contained in:
parent
8fbb53d01c
commit
9a09036197
|
@ -406,11 +406,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