From 22d007796b9944457a820ed01212309cb8bb9c1c Mon Sep 17 00:00:00 2001 From: ting wu Date: Thu, 31 May 2018 04:23:38 +0200 Subject: [PATCH] To extend the wait_for states with timeout parameter To extend the wait_for states with timeout parameter. The timeout value is taken from reclass pillar data if defined. Oterwise, the states use the default value. wait_for_deployed.sls wait_for_ready.sls Signed-off-by: ting wu --- README.rst | 10 ++++++++-- maas/machines/wait_for_deployed.sls | 3 +++ maas/machines/wait_for_ready.sls | 4 ++++ tests/pillar/maas_region.sls | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index d08ec42..fb3983d 100644 --- a/README.rst +++ b/README.rst @@ -497,12 +497,16 @@ Module function's example: machines: - kvm01 - kvm02 - timeout: 1200 # in seconds + {%- if region.timeout is defined and region.timeout.ready is defined %} + timeout: {{ region.timeout.ready }} + {%- endif %} 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 those case, will be usefull to skip some machines: .. code-block:: bash @@ -515,7 +519,9 @@ If module run w/\o any extra paremeters - `wait_for_machines_ready` will wait fo module.run: - name: maas.wait_for_machine_status - kwargs: - timeout: 1200 # in seconds + {%- if region.timeout is defined and region.timeout.deployed is defined %} + timeout: {{ region.timeout.deployed }} + {%- endif %} req_status: "Deployed" ignore_machines: - kvm01 # in case it's broken or whatever diff --git a/maas/machines/wait_for_deployed.sls b/maas/machines/wait_for_deployed.sls index ebeedac..c84942b 100644 --- a/maas/machines/wait_for_deployed.sls +++ b/maas/machines/wait_for_deployed.sls @@ -9,5 +9,8 @@ wait_for_machines_deployed: - name: maas.wait_for_machine_status - kwargs: req_status: "Deployed" + {%- if region.timeout is defined and region.timeout.deployed is defined %} + timeout: {{ region.timeout.deployed }} + {%- endif %} - require: - cmd: maas_login_admin diff --git a/maas/machines/wait_for_ready.sls b/maas/machines/wait_for_ready.sls index c5d3c28..9aa55b7 100644 --- a/maas/machines/wait_for_ready.sls +++ b/maas/machines/wait_for_ready.sls @@ -7,5 +7,9 @@ maas_login_admin: wait_for_machines_ready: module.run: - name: maas.wait_for_machine_status + - kwargs: + {%- if region.timeout is defined and region.timeout.ready is defined %} + timeout: {{ region.timeout.ready }} + {%- endif %} - require: - cmd: maas_login_admin diff --git a/tests/pillar/maas_region.sls b/tests/pillar/maas_region.sls index 607b472..85fa64d 100644 --- a/tests/pillar/maas_region.sls +++ b/tests/pillar/maas_region.sls @@ -22,3 +22,6 @@ maas: username: maas enabled: true salt_master_ip: 127.0.0.1 + timeout: + deployed: 900 + ready: 900