summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--utils/lab-reconfiguration/foreman.yaml83
-rw-r--r--utils/lab-reconfiguration/fuel.yaml43
-rwxr-xr-xutils/lab-reconfiguration/reconfigUcsNet.py56
3 files changed, 106 insertions, 76 deletions
diff --git a/utils/lab-reconfiguration/foreman.yaml b/utils/lab-reconfiguration/foreman.yaml
index 584a86845..48ab9ab6e 100644
--- a/utils/lab-reconfiguration/foreman.yaml
+++ b/utils/lab-reconfiguration/foreman.yaml
@@ -1,42 +1,45 @@
# Vnic configuration for foreman deploy
-eth0:
- order: 1
- template: foreman-control
- mac-list:
- - '00:25:b5:a0:00:1a'
- - '00:25:b5:a0:00:2a'
- - '00:25:b5:a0:00:3a'
- - '00:25:b5:a0:00:4a'
- - '00:25:b5:a0:00:5a'
- - '00:25:b5:a0:00:6a'
-eth1:
- order: 2
- template: foreman-private
- mac-list:
- - '00:25:b5:a0:00:1b'
- - '00:25:b5:a0:00:2b'
- - '00:25:b5:a0:00:3b'
- - '00:25:b5:a0:00:4b'
- - '00:25:b5:a0:00:5b'
- - '00:25:b5:a0:00:6b'
-eth2:
- order: 3
- template: foreman-public
- mac-list:
- - '00:25:b5:a0:00:1c'
- - '00:25:b5:a0:00:2c'
- - '00:25:b5:a0:00:3c'
- - '00:25:b5:a0:00:4c'
- - '00:25:b5:a0:00:5c'
- - '00:25:b5:a0:00:6c'
-eth3:
- order: 4
- template: foreman-storage
- mac-list:
- - '00:25:b5:a0:00:1d'
- - '00:25:b5:a0:00:2d'
- - '00:25:b5:a0:00:3d'
- - '00:25:b5:a0:00:4d'
- - '00:25:b5:a0:00:5d'
- - '00:25:b5:a0:00:6d'
+network:
+ eth0:
+ order: 1
+ template: foreman-control
+ mac-list:
+ - '00:25:b5:a0:00:1a'
+ - '00:25:b5:a0:00:2a'
+ - '00:25:b5:a0:00:3a'
+ - '00:25:b5:a0:00:4a'
+ - '00:25:b5:a0:00:5a'
+ - '00:25:b5:a0:00:6a'
+ eth1:
+ order: 2
+ template: foreman-private
+ mac-list:
+ - '00:25:b5:a0:00:1b'
+ - '00:25:b5:a0:00:2b'
+ - '00:25:b5:a0:00:3b'
+ - '00:25:b5:a0:00:4b'
+ - '00:25:b5:a0:00:5b'
+ - '00:25:b5:a0:00:6b'
+ eth2:
+ order: 3
+ template: foreman-public
+ mac-list:
+ - '00:25:b5:a0:00:1c'
+ - '00:25:b5:a0:00:2c'
+ - '00:25:b5:a0:00:3c'
+ - '00:25:b5:a0:00:4c'
+ - '00:25:b5:a0:00:5c'
+ - '00:25:b5:a0:00:6c'
+ eth3:
+ order: 4
+ template: foreman-storage
+ mac-list:
+ - '00:25:b5:a0:00:1d'
+ - '00:25:b5:a0:00:2d'
+ - '00:25:b5:a0:00:3d'
+ - '00:25:b5:a0:00:4d'
+ - '00:25:b5:a0:00:5d'
+ - '00:25:b5:a0:00:6d'
+
+boot-policy: foreman-PXE
diff --git a/utils/lab-reconfiguration/fuel.yaml b/utils/lab-reconfiguration/fuel.yaml
index 744dba959..eb9028b2c 100644
--- a/utils/lab-reconfiguration/fuel.yaml
+++ b/utils/lab-reconfiguration/fuel.yaml
@@ -1,22 +1,25 @@
# Vnic configuration for fuel deploy
-eth0:
- order: 1
- template: fuel-public
- mac-list:
- - '00:25:b5:a0:00:1a'
- - '00:25:b5:a0:00:2a'
- - '00:25:b5:a0:00:3a'
- - '00:25:b5:a0:00:4a'
- - '00:25:b5:a0:00:5a'
- - '00:25:b5:a0:00:6a'
-eth1:
- order: 2
- template: fuel-tagged
- mac-list:
- - '00:25:b5:a0:00:1b'
- - '00:25:b5:a0:00:2b'
- - '00:25:b5:a0:00:3b'
- - '00:25:b5:a0:00:4b'
- - '00:25:b5:a0:00:5b'
- - '00:25:b5:a0:00:6b'
+network:
+ eth0:
+ order: 1
+ template: fuel-public
+ mac-list:
+ - '00:25:b5:a0:00:1a'
+ - '00:25:b5:a0:00:2a'
+ - '00:25:b5:a0:00:3a'
+ - '00:25:b5:a0:00:4a'
+ - '00:25:b5:a0:00:5a'
+ - '00:25:b5:a0:00:6a'
+ eth1:
+ order: 2
+ template: fuel-tagged
+ mac-list:
+ - '00:25:b5:a0:00:1b'
+ - '00:25:b5:a0:00:2b'
+ - '00:25:b5:a0:00:3b'
+ - '00:25:b5:a0:00:4b'
+ - '00:25:b5:a0:00:5b'
+ - '00:25:b5:a0:00:6b'
+
+boot-policy: fuel-PXE
diff --git a/utils/lab-reconfiguration/reconfigUcsNet.py b/utils/lab-reconfiguration/reconfigUcsNet.py
index 282eca0cf..01c4b8340 100755
--- a/utils/lab-reconfiguration/reconfigUcsNet.py
+++ b/utils/lab-reconfiguration/reconfigUcsNet.py
@@ -34,6 +34,8 @@ import time
from UcsSdk import *
from collections import defaultdict
+POD_PREFIX = "POD-2"
+INSTALLER = "POD-21"
def getpassword(prompt):
if platform.system() == "Linux":
@@ -51,15 +53,32 @@ def get_servers(handle=None):
orgObj = handle.GetManagedObject(None, OrgOrg.ClassId(), {OrgOrg.DN : "org-root"})[0]
servers = handle.GetManagedObject(orgObj, LsServer.ClassId())
for server in servers:
- if server.Type == 'instance' and "POD-2" in server.Dn:
+ if server.Type == 'instance' and POD_PREFIX in server.Dn:
yield server
+def set_boot_policy(handle=None, server=None, policy=None):
+ """
+ Modify Boot policy of server
+ """
+ obj = handle.GetManagedObject(None, LsServer.ClassId(), {
+ LsServer.DN: server.Dn})
+ handle.SetManagedObject(obj, LsServer.ClassId(), {
+ LsServer.BOOT_POLICY_NAME: policy} )
+ print " Configured boot policy: {}".format(policy)
+
+
def ack_pending(handle=None, server=None):
"""
Acknowledge pending state of server
"""
- handle.AddManagedObject(server, LsmaintAck.ClassId(), {LsmaintAck.DN: server.Dn + "/ack", LsmaintAck.DESCR:"", LsmaintAck.ADMIN_STATE:"trigger-immediate", LsmaintAck.SCHEDULER:"", LsmaintAck.POLICY_OWNER:"local"}, True)
+ handle.AddManagedObject(server, LsmaintAck.ClassId(), {
+ LsmaintAck.DN: server.Dn + "/ack",
+ LsmaintAck.DESCR:"",
+ LsmaintAck.ADMIN_STATE:"trigger-immediate",
+ LsmaintAck.SCHEDULER:"",
+ LsmaintAck.POLICY_OWNER:"local"}, True)
+ print " Pending-reboot -> Acknowledged."
def get_vnics(handle=None, server=None):
@@ -78,6 +97,7 @@ def get_network_config(handle=None):
print " d - default, t - tagged"
for server in get_servers(handle):
print ' {}'.format(server.Name)
+ print ' Boot policy: {}'.format(server.OperBootPolicyName)
for vnic in get_vnics(handle, server):
print ' {}'.format(vnic.Name)
print ' {}'.format(vnic.Addr)
@@ -134,10 +154,14 @@ def set_network(handle=None, yamlFile=None):
"""
# add interfaces and bind them with vNIC templates
print "\nRECONFIGURING VNICs..."
- network = read_yaml_file(yamlFile)
+ pod_data = read_yaml_file(yamlFile)
+ network = pod_data['network']
+
for index, server in enumerate(get_servers(handle)):
+ # Assign template to interface
for iface, data in network.iteritems():
add_interface(handle, server.Dn, iface, data['template'], data['order'], data['mac-list'][index])
+
# Remove other interfaces which have not assigned required vnic template
vnics = get_vnics(handle, server)
for vnic in vnics:
@@ -145,6 +169,10 @@ def set_network(handle=None, yamlFile=None):
remove_interface(handle, vnic.Dn)
print " {} removed, template: {}".format(vnic.Name, vnic.OperNwTemplName)
+ # Set boot policy template
+ if not INSTALLER in server.Dn:
+ set_boot_policy(handle, server, pod_data['boot-policy'])
+
if __name__ == "__main__":
# Latest urllib2 validate certs by default
@@ -180,26 +208,22 @@ if __name__ == "__main__":
# Change vnic template if specified in cli option
if (options.yamlFile != None):
set_network(handle, options.yamlFile)
-
- time.sleep(3)
-
- print "\nCheck if acknowledge is needed..."
- for server in get_servers(handle):
- print " {}: {}".format(server.Dn, server.OperState)
- if server.OperState == "pending-reboot":
- ack_pending(handle,server)
- print " Acknowledged."
+ time.sleep(5)
print "\nWait until Overall Status of all nodes is OK..."
- timeout = time.time() + 60*5 #5 minutes timeout
+ timeout = time.time() + 60*10 #10 minutes timeout
while True:
list_of_states = []
for server in get_servers(handle):
+ if server.OperState == "pending-reboot":
+ ack_pending(handle,server)
list_of_states.append(server.OperState)
- print " {}".format(list_of_states)
- if all(state == "ok" for state in list_of_states) or time.time() > timeout:
+ print " {}, {} seconds remains.".format(list_of_states, round(timeout-time.time()))
+ if all(state == "ok" for state in list_of_states):
break
- time.sleep(2)
+ if time.time() > timeout:
+ raise Exception("Timeout reached while waiting for OK status.")
+ time.sleep(5)
# Show current vnic MACs and VLANs
get_network_config(handle)