X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Flab-reconfiguration%2FreconfigUcsNet.py;h=4c08f3dc9d62de904c1d27737c36caa05d4e6e73;hb=b2be8319a7a293737f8f2b5f258ecc754f20a97b;hp=01c4b834096104033eb6f5ac114a20ca318a245b;hpb=c00c4b8be0eea24591b32d35d1b50b042b8e7d7b;p=releng.git diff --git a/utils/lab-reconfiguration/reconfigUcsNet.py b/utils/lab-reconfiguration/reconfigUcsNet.py index 01c4b8340..4c08f3dc9 100755 --- a/utils/lab-reconfiguration/reconfigUcsNet.py +++ b/utils/lab-reconfiguration/reconfigUcsNet.py @@ -31,6 +31,7 @@ import optparse import platform import yaml import time +import sys from UcsSdk import * from collections import defaultdict @@ -81,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 @@ -145,7 +157,7 @@ def read_yaml_file(yamlFile): """ # TODO: add check if vnic templates specified in file exist on UCS with open(yamlFile, 'r') as stream: - return yaml.load(stream) + return yaml.safe_load(stream) def set_network(handle=None, yamlFile=None): @@ -175,6 +187,8 @@ def set_network(handle=None, yamlFile=None): if __name__ == "__main__": + print "\n*** SKIPING RECONFIGURATION.***\n" + sys.exit(0) # Latest urllib2 validate certs by default # The process wide "revert to the old behaviour" hook is to monkeypatch the ssl module # https://bugs.python.org/issue22417 @@ -215,6 +229,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) @@ -223,7 +239,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) @@ -237,3 +253,4 @@ if __name__ == "__main__": print '-'*60 traceback.print_exc(file=sys.stdout) print '-'*60 + sys.exit(1)