Browse Source

Merge "Don't assume Ironic is installed"

changes/48/789548/1
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
33709771b9
3 changed files with 32 additions and 4 deletions
  1. +9
    -2
      tripleo_ansible/ansible_plugins/module_utils/baremetal_deploy.py
  2. +10
    -2
      tripleo_ansible/ansible_plugins/modules/tripleo_baremetal_check_existing.py
  3. +13
    -0
      tripleo_ansible/tests/plugins/module_utils/test_baremetal_deploy.py

+ 9
- 2
tripleo_ansible/ansible_plugins/module_utils/baremetal_deploy.py View File

@ -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)


+ 10
- 2
tripleo_ansible/ansible_plugins/modules/tripleo_baremetal_check_existing.py View File

@ -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]))


+ 13
- 0
tripleo_ansible/tests/plugins/module_utils/test_baremetal_deploy.py View File

@ -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…
Cancel
Save