Support json type for the ironic_node config_drive parameter

Since patch[0], ironic config_drive parameter support json type.

[0] https://review.opendev.org/639050

Change-Id: Ieecb9e6125a182a3da41002aea26233a98aecc8c
This commit is contained in:
Jeffrey Zhang
2020-02-08 18:25:53 +08:00
parent 1a597c2b03
commit bcfa2aa095

View File

@@ -97,19 +97,35 @@ extends_documentation_fragment:
EXAMPLES = '''
# Activate a node by booting an image with a configdrive attached
os_ironic_node:
cloud: "openstack"
uuid: "d44666e1-35b3-4f6b-acb0-88ab7052da69"
state: present
power: present
deploy: True
maintenance: False
config_drive: "http://192.168.1.1/host-configdrive.iso"
instance_info:
image_source: "http://192.168.1.1/deploy_image.img"
image_checksum: "356a6b55ecc511a20c33c946c4e678af"
image_disk_format: "qcow"
delegate_to: localhost
- os_ironic_node:
cloud: "openstack"
uuid: "d44666e1-35b3-4f6b-acb0-88ab7052da69"
state: present
power: present
deploy: True
maintenance: False
config_drive: "http://192.168.1.1/host-configdrive.iso"
instance_info:
image_source: "http://192.168.1.1/deploy_image.img"
image_checksum: "356a6b55ecc511a20c33c946c4e678af"
image_disk_format: "qcow"
delegate_to: localhost
# Activate a node by booting an image with a configdrive json object
- os_ironic_node:
uuid: "d44666e1-35b3-4f6b-acb0-88ab7052da69"
auth_type: None
ironic_url: "http://192.168.1.1:6385/"
config_drive:
meta_data:
hostname: node1
public_keys:
default: ssh-rsa AAA...BBB==
instance_info:
image_source: "http://192.168.1.1/deploy_image.img"
image_checksum: "356a6b55ecc511a20c33c946c4e678af"
image_disk_format: "qcow"
delegate_to: localhost
'''
from ansible.module_utils.basic import AnsibleModule
@@ -205,7 +221,7 @@ def main():
uuid=dict(required=False),
name=dict(required=False),
instance_info=dict(type='dict', required=False),
config_drive=dict(required=False),
config_drive=dict(type='raw', required=False),
ironic_url=dict(required=False),
state=dict(required=False, default='present'),
maintenance=dict(required=False),
@@ -229,6 +245,13 @@ def main():
endpoint=module.params['ironic_url']
)
if (module.params['config_drive'] and
not isinstance(module.params['config_drive'], (str, dict))):
config_drive_type = type(module.params['config_drive'])
msg = ('argument config_drive is of type %s and we expected'
' str or dict') % config_drive_type
module.fail_json(msg=msg)
node_id = _choose_id_value(module)
if not node_id: