def getSubsysVinfo(c): result = "" tolog("Get Subsystem model name:") result = SendCmd(c, "subsys -v") modelNameValue = (result.split("\\n")[1]).replace( "Vendor: Promise Technology,Inc. Model: ", "") return modelNameValue
def getnetMinfo(c): # the old hyperion net -v # ActiveCtrlId: 1 Port: 1 # MaxSupportedSpeed: 100Mbps LinkStatus: Up # # ProtocolFamily: IPv4(Enabled) DHCP: Disabled # IP: 10.84.2.146 # IPMask: 255.255.255.0 # DNS: 225.0.0.0 # Gateway: 10.84.2.1 # MAC: 00:01:55:59:EA:9D # WakeOnLAN: Enabled # # ProtocolFamily: IPv6(Enabled) DHCP: Disabled # IP: 2017::1 # IPMask: ffff:: # DNS: 2017::3 # Gateway: 2017::9 # MAC: 00:01:55:59:EA:9D # WakeOnLAN: Enabled from ssh_connect import ssh_conn c, ssh = ssh_conn() import json a = SendCmd(c, "net -m") # ------------------------------------------------------------------------------- # CtrlId: 1 Port: 1 # ProtocolFamily: IPv4(Enabled) DHCP: Disabled # IP: 10.0.0.3 # IPMask: 255.0.0.0 # DNS: 0.0.0.0 # Gateway: 0.0.0.0 # MAC: 00:01:55:59:EA:9D # # CtrlId: 1 Port: 1 # ProtocolFamily: IPv6(Enabled) DHCP: Disabled # IP: 2001::1 # IPMask: ffff:: # DNS: :: # Gateway: :: # MAC: 00:01:55:59:EA:9D # # # ------------------------------------------------------------------------------- # Controller 2 information not accessible # b = a.split("\r\n") for i in range(5): for item in b: if not ("ProtocolFamily" in item or "IP" in item or "DNS" in item or "Gateway" in item or "MAC" in item): b.remove(item) net_m_ipv4_list = b[:7] net_m_ipv6_list = b[7:] #net_v_ipv4_list #print "v6 list", net_v_ipv6_list net_m_ipv4_dict = {} net_m_ipv6_dict = {} for each in net_m_ipv4_list: if "ProtocolFamily" in each: lista = each.split(" ") for eacha in lista: key = eacha.split(": ")[0] value = eacha.split(": ")[1] net_m_ipv4_dict[key] = value else: key = each.split(": ")[0] value = each.split(": ")[1] net_m_ipv4_dict[key] = value for each in net_m_ipv6_list: if "ProtocolFamily" in each: lista = each.split(" ") for eacha in lista: key = eacha.split(": ")[0] value = eacha.split(": ")[1] net_m_ipv6_dict[key] = value else: key = each.split(": ")[0] value = each.split(": ")[1] net_m_ipv6_dict[key] = value return net_m_ipv4_dict, net_m_ipv6_dict
def phydrvoffline(c): Failflag = False from pool import poolcreateandlist from pool import poolforceclean from pool import sparedrvcreate from pool import getpdlist import time poolforceclean(c) poolcreateandlist(c, 1) sparedrvcreate(c, 1) spareid = SendCmd(c, "spare -v").split("PdId: ")[1][0:2].strip() # get pdids that are for pool0 # method 1 # pddict=getpdlist(c) # pool0pds=[] # for key,value in pddict.items(): # if "Pool0" in value: # pool0pds.append(key) #method 2 res = SendCmd(c, "pool -v -i 0") pool0pds = res.split("Pds: ")[1].replace("administrator@cli> ", "").strip() # send offline cmd SendCmd(c, "phydrv -a offline -p " + pool0pds[0]) # verify spare drive is rebuilding resbuilding = SendCmd(c, "phydrv") if "Rebuilding" in resbuilding: tolog("spare drive %s is rebuilding." % spareid) else: tolog("Rebuilding does not work on spare drive %s" % spareid) Failflag = True i = 0 while "Rebuilding" in resbuilding and i < 30: tolog("Rebuilding is ongoing, elasped %s" % str(i)) resbuilding = SendCmd(c, "phydrv") time.sleep(1) i += 1 if i == 30: tolog( "Because rebuilding process will take too much time, the script will not record the process any more." ) # else: # tolog("Rebuilding is done.") # verify the original spare drive is in pool0 res = SendCmd(c, "pool -v -i 0") updated_pool0pds = res.split("Pds: ")[1].replace("administrator@cli> ", "").strip() if spareid in updated_pool0pds: tolog("spare drive %s is in pool0" % spareid) else: tolog("NOTE: spare drive %s is not in pool0" % spareid) Failflag = True # verify the offlined drive is Stale, Staleconfig status pddict = getpdlist(c) for key, value in pddict.items(): if "Stale" in value: stalepdid = key break if key == pool0pds[0]: tolog("drive %s is stale" % pool0pds[0]) else: tolog("NOTE: drive %s is not stale" % pool0pds[0]) Failflag = True SendCmd(c, "phydrv -a clear -t staleconfig -p " + pool0pds[0]) updated_pddict = getpdlist(c) staleflag = False for key, value in updated_pddict.items(): if "Stale" in value: tolog("Clear Staleconfig failed") staleflag = True Failflag = True if not staleflag: tolog("Clear Staleconfig successfully.") if Failflag: tolog(Fail) else: tolog(Pass)