Merge "create merge job for genesis master and stable/arno"
authorAric Gardner <agardner@linuxfoundation.org>
Fri, 31 Jul 2015 20:51:08 +0000 (20:51 +0000)
committerGerrit Code Review <gerrit@172.30.200.206>
Fri, 31 Jul 2015 20:51:08 +0000 (20:51 +0000)
utils/lab-reconfiguration/foreman.yaml
utils/lab-reconfiguration/fuel.yaml
utils/lab-reconfiguration/reconfigUcsNet.py

index ad91ba9..584a868 100644 (file)
@@ -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'
index 3f31939..744dba9 100644 (file)
@@ -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'
index 8adace0..282eca0 100755 (executable)
@@ -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()