summaryrefslogtreecommitdiffstats
path: root/utils/lab-reconfiguration
diff options
context:
space:
mode:
authorPeter Bandzi <pbandzi@cisco.com>2015-07-24 15:27:45 +0200
committerPeter Bandzi <pbandzi@cisco.com>2015-07-24 16:59:15 +0200
commit6c9f2202e0aaad59d80aa43f62e169009f8a8a2d (patch)
tree66297f10e99e0bd00e61c6ba835f7213682f30ff /utils/lab-reconfiguration
parent0e3af9d49a9249a59ec85c9a57b63804bca6facc (diff)
Add acknowledgment of reboot if needed
add MAC list which is used for NICs JIRA: OCTO-109 Change-Id: I803c3dd4ff7a860efdbae0954502c1e5a833dd9a Signed-off-by: Peter Bandzi <pbandzi@cisco.com>
Diffstat (limited to 'utils/lab-reconfiguration')
-rw-r--r--utils/lab-reconfiguration/foreman.yaml28
-rw-r--r--utils/lab-reconfiguration/fuel.yaml14
-rwxr-xr-xutils/lab-reconfiguration/reconfigUcsNet.py47
3 files changed, 83 insertions, 6 deletions
diff --git a/utils/lab-reconfiguration/foreman.yaml b/utils/lab-reconfiguration/foreman.yaml
index ad91ba911..584a86845 100644
--- a/utils/lab-reconfiguration/foreman.yaml
+++ b/utils/lab-reconfiguration/foreman.yaml
@@ -3,12 +3,40 @@
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'
diff --git a/utils/lab-reconfiguration/fuel.yaml b/utils/lab-reconfiguration/fuel.yaml
index 3f31939e9..744dba959 100644
--- a/utils/lab-reconfiguration/fuel.yaml
+++ b/utils/lab-reconfiguration/fuel.yaml
@@ -3,6 +3,20 @@
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'
diff --git a/utils/lab-reconfiguration/reconfigUcsNet.py b/utils/lab-reconfiguration/reconfigUcsNet.py
index 8adace00b..282eca0cf 100755
--- a/utils/lab-reconfiguration/reconfigUcsNet.py
+++ b/utils/lab-reconfiguration/reconfigUcsNet.py
@@ -30,6 +30,7 @@ import getpass
import optparse
import platform
import yaml
+import time
from UcsSdk import *
from collections import defaultdict
@@ -53,6 +54,14 @@ def get_servers(handle=None):
if server.Type == 'instance' and "POD-2" in server.Dn:
yield server
+
+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)
+
+
def get_vnics(handle=None, server=None):
"""
Return list of vnics for given server
@@ -66,6 +75,7 @@ def get_network_config(handle=None):
Print current network config
"""
print "\nCURRENT NETWORK CONFIG:"
+ print " d - default, t - tagged"
for server in get_servers(handle):
print ' {}'.format(server.Name)
for vnic in get_vnics(handle, server):
@@ -73,10 +83,13 @@ def get_network_config(handle=None):
print ' {}'.format(vnic.Addr)
vnicIfs = handle.ConfigResolveChildren(VnicEtherIf.ClassId(), vnic.Dn, None, YesOrNo.TRUE)
for vnicIf in vnicIfs.OutConfigs.GetChild():
- print ' Vlan: {}'.format(vnicIf.Vnet)
+ if vnicIf.DefaultNet == 'yes':
+ print ' Vlan: {}d'.format(vnicIf.Vnet)
+ else:
+ print ' Vlan: {}t'.format(vnicIf.Vnet)
-def add_interface(handle=None, lsServerDn=None, vnicEther=None, templName=None, order=None):
+def add_interface(handle=None, lsServerDn=None, vnicEther=None, templName=None, order=None, macAddr=None):
"""
Add interface to server specified by server.DN name
"""
@@ -91,6 +104,7 @@ def add_interface(handle=None, lsServerDn=None, vnicEther=None, templName=None,
VnicEther.ORDER: order,
"adminHostPort": "ANY",
VnicEther.ADMIN_VCON: "any",
+ VnicEther.ADDR: macAddr,
VnicEther.NW_TEMPL_NAME: templName,
VnicEther.MTU: "1500"}
handle.AddManagedObject(obj, VnicEther.ClassId(), params, True)
@@ -119,12 +133,11 @@ def set_network(handle=None, yamlFile=None):
Configure VLANs on POD according specified network
"""
# add interfaces and bind them with vNIC templates
- # TODO: make sure MAC address for admin is still same
print "\nRECONFIGURING VNICs..."
network = read_yaml_file(yamlFile)
- for server in get_servers(handle):
+ for index, server in enumerate(get_servers(handle)):
for iface, data in network.iteritems():
- add_interface(handle, server.Dn, iface, data['template'], data['order'])
+ 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:
@@ -164,9 +177,31 @@ if __name__ == "__main__":
handle.Login(options.ip, options.userName, options.password)
+ # Change vnic template if specified in cli option
if (options.yamlFile != None):
- print options.yamlFile
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."
+
+ print "\nWait until Overall Status of all nodes is OK..."
+ timeout = time.time() + 60*5 #5 minutes timeout
+ while True:
+ list_of_states = []
+ for server in get_servers(handle):
+ 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:
+ break
+ time.sleep(2)
+
+ # Show current vnic MACs and VLANs
get_network_config(handle)
handle.Logout()