Skip to content

Commit

Permalink
maas.py: Extend wait_for states with timeout param
Browse files Browse the repository at this point in the history
Extend the wait_for states with a timeout parameter.
The timeout value is taken from reclass pillar data if
defined. Oterwise, the states use the default value.

Based on Ting's PR [1], slightly refactored.

[1] salt-formulas#34

Signed-off-by: ting wu <[email protected]>
Signed-off-by: Alexandru Avadanii <[email protected]>
  • Loading branch information
alexandruavadanii committed Sep 23, 2018
1 parent 8f9ba8e commit 00eb6e7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,15 @@ Wait for status of selected machine's:
machines:
- kvm01
- kvm02
timeout: 1200 # in seconds
timeout: {{ region.get('timeout', {}).get('deployed', 1200) }}
req_status: "Ready"
- require:
- cmd: maas_login_admin
...
The timeout setting is taken from the reclass pillar data.
If the pillar data is not defined, it will use the default value.

If module run w/\o any extra paremeters,
``wait_for_machines_ready`` will wait for defined in salt
machines. In this case, it is usefull to skip some machines:
Expand All @@ -559,7 +562,7 @@ machines. In this case, it is usefull to skip some machines:
module.run:
- name: maas.wait_for_machine_status
- kwargs:
timeout: 1200 # in seconds
timeout: {{ region.get('timeout', {}).get('deployed', 7200) }}
req_status: "Deployed"
ignore_machines:
- kvm01 # in case it's broken or whatever
Expand Down
1 change: 1 addition & 0 deletions maas/machines/wait_for_deployed.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ wait_for_machines_deployed:
- name: maas.wait_for_machine_status
- kwargs:
req_status: "Deployed"
timeout: {{ region.get('timeout', {}).get('deployed', 7200) }}
- require:
- cmd: maas_login_admin
2 changes: 2 additions & 0 deletions maas/machines/wait_for_ready.sls
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ maas_login_admin:
wait_for_machines_ready:
module.run:
- name: maas.wait_for_machine_status
- kwargs:
timeout: {{ region.get('timeout', {}).get('deployed', 1200) }}
- require:
- cmd: maas_login_admin
3 changes: 3 additions & 0 deletions tests/pillar/maas_region.sls
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ maas:
password: password
username: maas
salt_master_ip: 127.0.0.1
timeout:
deployed: 900
ready: 900

0 comments on commit 00eb6e7

Please sign in to comment.