mirror of
https://opendev.org/openstack/ansible-collections-openstack.git
synced 2026-11-21 14:48:41 +00:00
Add target_provision_state option to baremetal_node
Add an option to configure the expected provision state for newly created baremetal nodes. Change-Id: Iafb9206b86ea366d45c6919247847f5f8d221952 Signed-off-by: Jed Preist <jed@stackhpc.com>
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
---
|
||||
minor_changes:
|
||||
- Module ``openstack.cloud.baremetal_node`` gained a
|
||||
``target_provision_state`` option.
|
||||
@@ -75,8 +75,6 @@ options:
|
||||
description:
|
||||
- 'A list of network interface cards, eg, C( - mac: aa:bb:cc:aa:bb:cc)'
|
||||
- This node attribute cannot be updated.
|
||||
- If this option is not set, the target provision state of the node
|
||||
changes from available to enroll.
|
||||
required: false
|
||||
default: []
|
||||
type: list
|
||||
@@ -156,6 +154,17 @@ options:
|
||||
- Interface used for attaching and detaching volumes on this node, e.g.
|
||||
C(cinder).
|
||||
type: str
|
||||
target_provision_state:
|
||||
description:
|
||||
- Indicates desired provision state of the node.
|
||||
- This option is ignored if the node already exists.
|
||||
- If set to available, the node will go through cleaning. This may fail
|
||||
if the nics option has no interfaces specified.
|
||||
- try-available behaves the same as available if the nics option is
|
||||
set, and falls back to enroll if it is not.
|
||||
choices: ['enroll', 'manageable', 'available', 'try-available']
|
||||
default: try-available
|
||||
type: str
|
||||
timeout:
|
||||
description:
|
||||
- Number of seconds to wait for the newly created node to reach the
|
||||
@@ -534,6 +543,10 @@ class BaremetalNodeModule(OpenStackModule):
|
||||
),
|
||||
state=dict(default='present', choices=['present', 'absent']),
|
||||
storage_interface=dict(),
|
||||
target_provision_state=dict(
|
||||
default='try-available',
|
||||
choices=['enroll', 'manageable', 'available', 'try-available']
|
||||
),
|
||||
timeout=dict(default=1800, type='int'), # increased default value
|
||||
vendor_interface=dict(),
|
||||
)
|
||||
@@ -654,12 +667,22 @@ class BaremetalNodeModule(OpenStackModule):
|
||||
if properties:
|
||||
kwargs['properties'] = properties
|
||||
|
||||
provision_state = self.params['target_provision_state']
|
||||
if provision_state == 'available':
|
||||
if len(self.params['nics']) == 0:
|
||||
self.warn('Attempting to make node available with no NICs'
|
||||
' set. Node may fail cleaning.')
|
||||
elif provision_state == 'try-available':
|
||||
if len(self.params['nics']) == 0:
|
||||
provision_state = 'enroll'
|
||||
else:
|
||||
provision_state = 'available'
|
||||
|
||||
node = self.conn.register_machine(
|
||||
nics=self.params['nics'],
|
||||
wait=self.params['wait'],
|
||||
timeout=self.params['timeout'],
|
||||
provision_state=(
|
||||
'available' if len(self.params['nics']) > 0 else 'enroll'),
|
||||
provision_state=provision_state,
|
||||
**kwargs)
|
||||
|
||||
self.exit_json(changed=True, node=node.to_dict(computed=False))
|
||||
|
||||
Reference in New Issue
Block a user