diff options
author | Peter Bandzi <pbandzi@cisco.com> | 2015-08-18 10:19:41 +0200 |
---|---|---|
committer | Peter Bandzi <pbandzi@cisco.com> | 2015-08-18 10:34:38 +0200 |
commit | 09ee57139a397f16bd772541b8ac1a8d023dd55b (patch) | |
tree | a1c81e3e3701ea19cedf322f42828af10f8ac673 | |
parent | 05644e2e1f088214be22e272d3e0d1e1ed7ed1df (diff) |
Reboot servers if they are in power-off state
Also sleep value increased to 10. We don't need so many cycles.
JIRA: OCTO-109
Change-Id: Ia956c77328bc12943e4bd0c4a0d4979ff500c2a2
Signed-off-by: Peter Bandzi <pbandzi@cisco.com>
-rwxr-xr-x | utils/lab-reconfiguration/reconfigUcsNet.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/utils/lab-reconfiguration/reconfigUcsNet.py b/utils/lab-reconfiguration/reconfigUcsNet.py index 90c292bcd..ac7376eda 100755 --- a/utils/lab-reconfiguration/reconfigUcsNet.py +++ b/utils/lab-reconfiguration/reconfigUcsNet.py @@ -82,6 +82,17 @@ def ack_pending(handle=None, server=None): print " Pending-reboot -> Acknowledged." +def boot_server(handle=None, server=None): + """ + Boot server (when is in power-off state) + """ + obj = handle.GetManagedObject(None, LsServer.ClassId(), {LsServer.DN: server.Dn}) + handle.AddManagedObject(obj, LsPower.ClassId(), { + LsPower.DN: server.Dn + "/power", + LsPower.STATE:"admin-up"}, True) + print " Booting." + + def get_vnics(handle=None, server=None): """ Return list of vnics for given server @@ -216,6 +227,8 @@ if __name__ == "__main__": while True: list_of_states = [] for server in get_servers(handle): + if server.OperState == "power-off": + boot_server(handle,server) if server.OperState == "pending-reboot": ack_pending(handle,server) list_of_states.append(server.OperState) @@ -224,7 +237,7 @@ if __name__ == "__main__": break if time.time() > timeout: raise Exception("Timeout reached while waiting for OK status.") - time.sleep(5) + time.sleep(10) # Show current vnic MACs and VLANs get_network_config(handle) |