コード例 #1
0
def usermodify(c,username):

    # only status and display name are to be modified.

    Failflag=False
    newdisplayname=random_key(31)

    userdata=SendCmd(c,"user -u "+username)
    if "Enabled" in userdata:

        SendCmd(c,"user -a mod -u "+username+" -s "+"\"status=disable,name="+newdisplayname+"\"")
        res=SendCmd(c,"user -v -u "+username)
        if "Disabled" in res and newdisplayname in res:
            tolog("Modified user %s info successfully." %username)
        else:
            Failflag=True
            tolog("Modified user %s info failed." % username)

    else:
        SendCmd(c, "user -a mod -u " + username + " -s " + "\"status=enable,name=" + newdisplayname + "\"")
        res = SendCmd(c, "user -v -u " + username)
        if "Enabled" in res and newdisplayname in res:
            tolog("Modified user %s info successfully." % username)
        else:
            Failflag = True
            tolog("Modified user %s info failed." % username)

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
コード例 #2
0
ファイル: Net.py プロジェクト: zachpersonal/clitest
def verifyMaintenancemode(c):
    # net -m
    # net -a mod -m -c 1 -f ipv6 -s "primaryip=2001::1"
    # net -a mod -m -c 1 -s "primaryip=10.84.2.145,wol=enable"
    # net -a enable -m -c 1 -f ipv6
    # net -m
    FailFlag = False
    origMresult = SendCmd(c, "net -m")
    ipv4, ipv6 = getnetMinfo(c)
    if ipv6['IP'] == "2001::1":
        ip = "2001::2"
    else:
        ip = "2001::1"

    cmd = "net -a mod -m -c 1 -f ipv6 -s \"primaryip=" + ip + "\""
    result = SendCmd(c, cmd)
    if "Error" in result:
        FailFlag = True

    newMresult = SendCmd(c, "net -m")
    if ip not in newMresult:
        FailFlag = True
        tolog(Failprompt + "changing to maintenance ip addresd " + ip)

    if FailFlag:
        tolog('Verify modifing maintenance mode ip address failed')
        tolog(Fail)
    else:
        tolog('Verify modifing maintenance mode ip address passed')
        tolog(Pass)
コード例 #3
0
ファイル: Net.py プロジェクト: zachpersonal/clitest
def verifyyoption(c):
    # only letters, blank space and underscore are accepted
    # other chars are verified
    # no more than 48 char
    # leading spaces and tailing spaces are removed in the alias
    # length subsys alias = 48 chars
    # length controller alias = 48 chars
    # length array,ld alias =32 cahrs
    result1 = ""
    result2 = ""
    FailFlag = False
    ipv4, ipv6 = getnetinfo(c)
    if "Enabled" in ipv6["ProtocolFamily"]:
        result1 = SendCmd(c, "net -a disable -f ipv6 -y")
    else:
        SendCmd(c, "net -a enable -f ipv6")
        result2 = SendCmd(c, "net -a disable -f ipv6 -y")

    SendCmd(c, "net -a enable -f ipv6")

    result3 = SendCmd(c, "net -a mod -f ipv6 -y -s \"primaryip=2017::12\"")

    if not ("" in result1 and "" in result2 and "" in result3):
        FailFlag = True
        tolog(Failprompt + "sending cmd with -y option.")
    if FailFlag:
        tolog('Modify subsys alias fail')
        tolog(Fail)
    else:
        tolog('Modify subsys alias pass')
        tolog(Pass)
コード例 #4
0
ファイル: Subsys.py プロジェクト: zachpersonal/clitest
def modifyAndVerifyCachemirroring(c):
    # modify the cachemirroring from enabled to disabled
    # modify the cachemirroring from disabled to enabled
    checkResult = ''
    result = tuple()
    FailFlag = False
    # LUN affinity should be disabled before the following execution

    tolog("Modify and Verify Cachemirroring setting: ")

    for i in range(2):

        # determine the original Redundancy type
        OrigResult = SendCmd(c, "subsys -v")
        if "CacheMirroring: Enabled" in OrigResult:
            Cachemirroring = "Enabled"
        else:
            RCachemirroring = "Disabled"

        if Cachemirroring == "Enabled":
            result = SendCmd(c, 'subsys -a mod -s "cachemirroring=disable"')
        else:
            result = SendCmd(c, 'subsys -a mod -s "cachemirroring=enable"')

        checkResult = SendCmd(c, "shutdown -a restart")
        from time import sleep
        from ssh_connect import ssh_conn
        sleep(200)
        cnew, sshnew = ssh_conn()

        RewResult = SendCmd(cnew, "subsys -v")

        if "CacheMirroring: Enabled" in RewResult:
            Cachemirroring = "Enabled"
        else:
            Cachemirroring = "Disabled"

        if not ("Cachemirroring and RedundancyType setting change will take effect on next"
                in result and 'Error' not in checkResult):
            FailFlag = True
        if not (Cachemirroring not in OrigResult):
            tolog(Failprompt + Cachemirroring)
            FailFlag = True
        c = cnew

    if FailFlag:
        tolog('Modify and Verify Cachemirroring setting fail')
        tolog(Fail)
    else:
        tolog('Modify and Verify Cachemirroring setting pass')
        tolog(Pass)
    sshnew.close()
コード例 #5
0
def VerifyTurnonBuzzerDisabled(c):
    checkResult = ''
    result = tuple()
    SendCmd(c, 'buzz -a disable')
    tolog("Turn on buzzer: ")
    result = SendCmd(c, 'buzz -a on')
    verifyBuzzerInfo(c)
    if 'Error' in result and 'Buzzer is disabled' in result:
        tolog('Check turn on buzzer when it is disabled pass')
        tolog(Pass)
    else:
        tolog('Check turn on buzzer when it is disabled fail')
        tolog(Fail)
コード例 #6
0
ファイル: Net.py プロジェクト: zachpersonal/clitest
def verifynetinfo(c):

    Failflag = False
    tolog("Get net info:")
    result = SendCmd(c, "net"), SendCmd(c, "net -v"), SendCmd(
        c, "net -a list"), SendCmd(c, "net -alist")
    for each in result:
        if not ("Error" not in each and "IPv4" in each and "IPv6" in each):
            Failflag = True
    if Failflag:
        tolog('Verify net info fail')
        tolog(Fail)
    else:
        tolog('Verify net info pass')
        tolog(Pass)
コード例 #7
0
ファイル: Subsys.py プロジェクト: zachpersonal/clitest
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
コード例 #8
0
ファイル: Subsys.py プロジェクト: zachpersonal/clitest
def verifySubsysInfo(c):
    result = ""
    FailFlag = False
    tolog("Verify subsys info:")
    result = SendCmd(c, "subsys -v"), SendCmd(c, "subsys")
    for each in result:
        if 'Error' in each:
            FailFlag = True
            tolog(Failprompt + each)

    if FailFlag:
        tolog('Verify subsys info fail')
        tolog(Fail)
    else:
        tolog('Verify subsys info pass')
        tolog(Pass)
コード例 #9
0
def verifyBuzzerInvalidParameter(c):
    checkResult = ''
    result = tuple()
    FailFlag = False
    tolog("Check buzzer Invalid Parameters: ")
    result = SendCmd(c, 'buzz abc'), SendCmd(c, 'buzz 123')

    for each in result:
        if not ('Error' in each and 'Invalid parameter' in each):
            FailFlag = True

    if FailFlag:
        tolog('Check buzzer Invalid Parameters fail')
        tolog(Fail)
    else:
        tolog('Check buzzer Invalid Parameters pass')
        tolog(Pass)
コード例 #10
0
def verifyTurnOnBuzzer(c):
    checkResult = ''
    result = tuple()
    FailFlag = False
    tolog("Turn on buzzer: ")
    result = SendCmd(c, 'buzz -a on'), SendCmd(c, 'buzz -aon')
    checkResult = SendCmd(c, 'buzz')
    for each in result:
        if 'Error' in each or 'Sounding' not in checkResult:
            FailFlag = True

    if FailFlag:
        tolog('Turn on buzzer fail')
        tolog(Fail)
    else:
        tolog('Turn on buzzer pass')
        tolog(Pass)
コード例 #11
0
def verifyDisableBuzzer(c):
    checkResult = ''
    result = tuple()
    tolog("Disable buzzer: ")
    FailFlag = False
    result = SendCmd(c, 'buzz -a disable'), SendCmd(c, 'buzz -adisable')
    checkResult = SendCmd(c, 'buzz')

    for each in result:
        if 'Error' in each or 'No' not in checkResult:
            FailFlag = True

    if FailFlag:
        tolog('Disable buzzer fail')
        tolog(Fail)
    else:
        tolog('Disable buzzer pass')
        tolog(Pass)
コード例 #12
0
ファイル: Net.py プロジェクト: zachpersonal/clitest
def verfiynethelp(c):
    checkResult = ''
    FailFlag = False
    tolog("Verify Net Help: ")
    result = SendCmd(c, 'net -h'), SendCmd(c, 'net -h123')

    for each in result:
        print each
        if not ('net' in each and 'Usage' in each and 'Summary' in each
                and 'to display info page by page' in each):
            FailFlag = True

    if FailFlag:
        tolog('Verify Net Help fail')
        tolog(Fail)
    else:
        tolog('Verify Net Help pass')
        tolog(Pass)
コード例 #13
0
def VerifyBuzzerInvalidActions(c):
    checkResult = ''
    result = tuple()
    FailFlag = False

    result = SendCmd(c, 'buzz -alista'), SendCmd(c, 'buzz -a 123'), SendCmd(
        c, 'buzz -a test'), SendCmd(c, 'buzz -a 你好')
    tolog("Verify Buzzer Invalid Actions: ")
    for each in result:
        if not (('Error' in each) and ('Invalid action' in each)):
            FailFlag = True

    if FailFlag:
        tolog('Check buzzer Invalid Options fail')
        tolog(Fail)
    else:
        tolog('Check buzzer Invalid Options pass')
        tolog(Pass)
コード例 #14
0
def verifyEnableBuzzer(c):
    checkResult = ''
    result = tuple()
    FailFlag = False
    tolog("Enable buzzer: ")
    result = SendCmd(c, 'buzz -a enable'), SendCmd(c, 'buzz -aenable')
    checkResult = SendCmd(c, 'buzz')

    for each in result:
        if 'Error' in each or 'Yes' not in checkResult:
            FailFlag = True

    if FailFlag:
        tolog('Enable buzzer fail')
        tolog(Fail)
    else:
        tolog('Enable buzzer pass')
        tolog(Pass)
コード例 #15
0
def VerifyBuzzerHelp(c):
    checkResult = ''
    result = tuple()
    FailFlag = False
    # buzz -aon should be a misspelled option
    result = SendCmd(c, 'buzz -h'), SendCmd(c, 'buzz -h123')
    tolog("Verify Buzzer Help: ")
    for each in result:
        print each
        if not ('buzz' in each and 'Usage' in each and 'Summary' in each
                and 'to display info page by page' in each):
            FailFlag = True

    if FailFlag:
        tolog('Verify Buzzer Help fail')
        tolog(Fail)
    else:
        tolog('Verify Buzzer Help pass')
        tolog(Pass)
コード例 #16
0
ファイル: Subsys.py プロジェクト: zachpersonal/clitest
def verfiysubsyshelp(c):
    checkResult = ''
    result = tuple()
    FailFlag = False
    tolog("Verify Subsys Help: ")
    result = SendCmd(c, 'subsys -h'), SendCmd(c, 'subsys -h123')

    for each in result:
        print each
        if not ('subsys' in each and 'Usage' in each and 'Summary' in each
                and 'to display info page by page' in each):
            FailFlag = True

    if FailFlag:
        tolog('Verify Subsys Help fail')
        tolog(Fail)
    else:
        tolog('Verify Subsys Help pass')
        tolog(Pass)
コード例 #17
0
def verifyBuzzerInfo(c):
    checkResult = ''
    result = tuple()
    FailFlag = False
    tolog("Check buzzer information: ")
    result = SendCmd(c, 'buzz'), SendCmd(c, 'buzz -a list'), SendCmd(
        c, 'buzz -alist'),
    # checkResult = SendCmd('buzz')
    FailFlag = False
    for each in result:
        if 'Error' in each:
            FailFlag = True

    if FailFlag:
        tolog('Check buzzer info fail')
        tolog(Fail)
    else:
        tolog('Check buzzer info pass')
        tolog(Pass)
コード例 #18
0
ファイル: Subsys.py プロジェクト: zachpersonal/clitest
def modifyAndVerifyRedundancyType(c):
    checkResult = ''
    result = tuple()
    FailFlag = False
    # LUN affinity should be disabled before the following execution
    # in new DS, LUN affinity is enabled and cannot be changed.

    tolog("Modify and Verify RedundancyType setting: ")
    lunaffinityresult = SendCmd(c, "ctrl -v")
    if "LUNAffinity: Enabled" in lunaffinityresult:
        SendCmd(c, "ctrl -a mod -s \"lunaffinity=disable\"")

    for i in range(2):

        # determine the original Redundancy type
        OrigResult = SendCmd(c, "subsys -v")
        if "RedundancyType: Active-Active" in OrigResult:
            OrigRedundancyType = "Active-Active"
        else:
            OrigRedundancyType = "Active-Standby"

        if OrigRedundancyType == "Active-Active":
            result = SendCmd(
                c, 'subsys -a mod -s "redundancytype=active-standby"')
        else:
            result = SendCmd(
                c, 'subsys -a mod -s "redundancytype=active-active"')

        checkResult = SendCmd(c, "shutdown -a restart")
        from time import sleep
        sleep(200)
        from ssh_connect import ssh_conn

        cnew, sshnew = ssh_conn()
        RewResult = SendCmd(cnew, "subsys -v")
        if "RedundancyType: Active-Active" in RewResult:
            NewRedundancyType = "Active-Active"
        else:
            NewRedundancyType = "Active-Standby"

        if not ("Cachemirroring and RedundancyType setting change will take effect on next"
                in result and 'Error' not in checkResult):
            FailFlag = True

        if not (OrigRedundancyType not in RewResult):
            tolog(Failprompt + NewRedundancyType)
            FailFlag = True
        c = cnew

    if FailFlag:
        tolog('Modify and Verify RedundancyType setting fail')
        tolog(Fail)
    else:
        tolog('Modify and Verify RedundancyType setting pass')
        tolog(Pass)
    sshnew.close()
コード例 #19
0
def userverify(c,userinfo):
    FailFlag = False
    briefoutput=(SendCmd(c,"user"),SendCmd(c,"user -a list"),SendCmd(c,"user -a list -u "+userinfo["username"]))

    for op in briefoutput:
        for key,value in userinfo.items():
            if value[:10] not in op:
                tolog("%s created unsucessfully beause %s is not in the list" % userinfo["username"] % value[:10])
                FailFlag = True
                break


    verboseoutput=(SendCmd(c,"user -v"),SendCmd(c,"user -v -a list"),SendCmd(c,"user -v -u "+userinfo["username"]))

    for op in verboseoutput:
        for key,value in userinfo.items():
            if value not in op:
                tolog("%s created unsucessfully beause %s is not in the list" % userinfo["username"] % value)
                FailFlag = True
                break

    if FailFlag:
        tolog(Fail)
    else:
        tolog("User is created successully.")
        tolog(Pass)
コード例 #20
0
def usergetinfo(c):

    import re
    userdata=SendCmd(c,"user -v")
    userslocation=[m.start() for m in re.finditer('Username: '******'Status: ', userdata)]
    userslist=list()
    i = 0
    for userlocation in userslocation:
        print userdata[userlocation+10:usersstatus[i]-1]
        userslist.append((userdata[userlocation+10:usersstatus[i]-1]).rstrip())
        i+=1
    return userslist
コード例 #21
0
ファイル: phydrv.py プロジェクト: zachpersonal/clitest
def phydrvlocate(c):
    FailFlag = False
    pdlist = getpdlist(c)
    res = []
    for key in pdlist:
        res.append(SendCmd(c, "phydrv -a locate -p " + key))
    for eachres in res:
        if "Error" in eachres or "Invalid" in eachres:

            FailFlag = True
            break

    if FailFlag:
        tolog(Fail)
    else:
        tolog(Pass)
コード例 #22
0
ファイル: phydrv.py プロジェクト: zachpersonal/clitest
def getphydrvglobalsettings(c):
    SASsettings = ("WriteCache", "RlaCache", "ReadCache", "CmdQueuing",
                   "TempPollInt", "MediumErrorThreshold", "Glatency")
    pdlist = getpdlist(c)

    # get the pdid randomly
    for key in pdlist:
        pdid = key
        break

    result = SendCmd(c, "phydrv -v -p " + pdid)

    #
    # administrator@cli> phydrv -v -p 2
    #
    # Globle Physical Drives Setting for SATA:
    # -------------------------------------------------------------------------------
    # WriteCache: Enabled                     RlaCache: Enabled
    # DmaMode: UDMA6                          CmdQueuing: Enabled
    # TempPollInt: 30                         MediumErrorThreshold: 64
    # Glatency: 0
    #
    # Globle Physical Drives Setting for SAS:
    # -------------------------------------------------------------------------------
    # WriteCache: Enabled                     RlaCache: Enabled
    # ReadCache: Enabled                      CmdQueuing: Enabled
    # TempPollInt: 30                         MediumErrorThreshold: 64
    # Glatency: 60
    SasSettingsdict = {}
    globalphydrvsetting = result.replace("-", "")
    SasSettingsStr = globalphydrvsetting.split(
        "Globle Physical Drives Setting for SAS:")[1].replace(
            "administrator@cli> ", "")
    # import re
    #
    # userslocation = [m.start() for m in re.finditer('Username: ', userdata)]
    for each in SASsettings:
        if each != "MediumErrorThreshold":
            SasSettingsdict[each] = SasSettingsStr[
                SasSettingsStr.find(each) + len(each) +
                2:SasSettingsStr.find(each) + len(each) + 11].rstrip()
        else:
            SasSettingsdict[each] = SasSettingsStr[
                SasSettingsStr.find(each) + len(each) +
                2:SasSettingsStr.find(each) + len(each) + 4].rstrip()
    return SasSettingsdict
コード例 #23
0
ファイル: Net.py プロジェクト: zachpersonal/clitest
def enable_and_disable_ip_family(c):
    # if we disable the network we are currently connected with
    # the connection will be lost.
    # so, try to disable the network you are not using
    Failflag = False
    ipv4, ipv6 = getnetinfo(c)

    # if "IPv4    Enabled" in origresult:
    #     result=SendCmd(c,"net -a disable -f ipv4")
    #     modifiedresult=SendCmd(c,"net -v")
    #     if not ("IPv4   Disabled" in modifiedresult):
    #         Failflag=True
    #         tolog(Failprompt+"net -a disable -f ipv4")
    # else:
    #     result = SendCmd(c, "net -a enable -f ipv4")
    #     modifiedresult = SendCmd(c, "net -v")
    #     if not ("IPv4   Enabled" in modifiedresult):
    #         Failflag = True
    #         tolog(Failprompt + "net -a enable -f ipv4")

    for i in range(2):
        print ipv6["ProtocolFamily"]
        if "Enabled" in ipv6["ProtocolFamily"]:
            result = SendCmd(c, "net -a disable -f ipv6")
            modifiedresult = SendCmd(c, "net -v")
            if not ("IPv6(Disabled)" in modifiedresult):
                Failflag = True
                tolog(Failprompt + "net -a disable -f ipv6")
        else:
            result = SendCmd(c, "net -a enable -f ipv6")
            modifiedresult = SendCmd(c, "net -v")
            if not ("IPv6(Enabled)" in modifiedresult):
                Failflag = True
                tolog(Failprompt + "net -a enable -f ipv6")
            ipv4, ipv6 = getnetinfo(c)

    # for some invalid parameters, IPv6, iPv6, ads, __
    for each in ("IPv6", "iPv6", "ads", "__"):
        result = SendCmd(c, 'net -a enable -f ' + each), SendCmd(
            c, 'net -a disable -f ' + each)
        for res in result:
            if not ("invalid protocol family" in res
                    and "Error (0x402): Invalid parameter" in res):
                Failflag = True
                tolog(Failprompt + res)

    if Failflag:
        tolog('Enable and Disable ip family fail')
        tolog(Fail)
    else:
        tolog('Enable and Disable ip family pass')
        tolog(Pass)
コード例 #24
0
def usercreate(c,usertype,privilegetype):

    username=random_key(31)
    displayname = random_key(31)
    department=random_key(31)
    phone=random_key(31)
    emailaddress=address_generator()
    privilege=("Super","Power","Maintenance","View")
    type= ("mgmt","snmp","ds")
    auth= ("md5","sha")
    priv=("des", "aes")

    # test 1
    # user type: mgmt
    if usertype=="mgmt":
        if privilegetype!="":

            userinfo = {"username": username, "displayname": displayname, "emailaddress": emailaddress,
                        "privilege": privilegetype}
        else:
            userinfo = {"username": username, "displayname": displayname, "emailaddress": emailaddress,
                        "privilege": random.choice(privilege)}
        settings = " -u " + userinfo["username"] + " -p " + userinfo[
                "privilege"] + " -t " + usertype + " -s " + "\"name=" + userinfo["displayname"] + ",email=" + userinfo[
                           "emailaddress"] + "\""
            # print settings
        # create users
        SendCmd(c, "user -a add " + settings)
        # verify the created users
        userverify(c, userinfo)
        # modify the status and name of the above users
        # and verify the modified users
        usermodify(c,userinfo["username"])
    # test 2
    # user type: snmp
    if usertype=="snmp":
        pass

    # test 2
    # user type: snmp
    if usertype=="ds":
        pass
コード例 #25
0
ファイル: Net.py プロジェクト: zachpersonal/clitest
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
コード例 #26
0
def userdelete(c):
    users=usergetinfo(c)
    print users
    for user in users:
        SendCmd(c,"user -a del -u "+user)
コード例 #27
0
ファイル: Net.py プロジェクト: zachpersonal/clitest
def modifyandverifynetsettings(c):
    result = ""
    FailFlag = False
    origipv4, origipv6 = getnetinfo(c)
    # change ip address
    # newip="10.84.2.145"
    # dns = "10.10.10.10"
    # gateway = "10.84.2.1"
    # mask = "255.255.255.0"
    # if origipv4["WakeOnLAN"] == "Enabled":
    #     wol = "disable"
    # else:
    #     wol = "enable"
    #
    # tolog("Modify and Verify net info:")
    # origresult=SendCmd(c, "net -v")
    # result = SendCmd(c,
    #                  "net -a mod -s \"primaryip=" + newip + ",primaryipmask=" + mask + ",primarydns=" + dns + ",gateway=" + gateway + ",wol=" + wol + "\"")
    # import time
    # time.sleep(2)
    # from ssh_connect_anotherIP import ssh_conn_anotherip
    # cnew, sshnew = ssh_conn_anotherip(newip)
    # #modipv4,modipv6=getnetinfo(cnew)
    # checkresult=SendCmd(cnew,"net -v")
    #
    # if not(origipv4["IP"] in origresult and newip in checkresult):
    #     FailFlag = True
    #     tolog(Failprompt + "modifying ipv4 adress.")
    # # change back to original ip address
    #
    # SendCmd(cnew, "net -a mod -s \"primaryip=" + origipv4['IP'] + ",primaryipmask=" + origipv4[
    #         'IPMask'] + ", primarydns=" + origipv4["DNS"] + ", gateway=" + origipv4["Gateway"] + ",wol=" + origipv4[
    #                 "WakeOnLAN"] + "\"")
    # SendCmd(cnew, "logout")
    # sshnew.close()
    #
    # if not ("" in result):
    #     FailFlag=True
    #     tolog(Failprompt+"sending change settings cmd.")
    # else:
    #     cnew,sshnew=ssh_conn_anotherip(newip)
    #     newipv4,newipv6=getnetinfo(cnew)
    #     if not(dns==newipv4['DNS'] and gateway==newipv4['Gateway'] and  mask==newipv4['IPMask']):
    #         FailFlag = True
    #         tolog(Failprompt+"changed settings are not correct")

    if "Disabled" in origipv6["ProtocolFamily"]:
        SendCmd(c, "net -a enable -f ipv6")

    newipv6 = "2017::2"
    dnsv6 = "2017::3"
    gatewayv6 = "2017::1"
    maskv6 = "ffff::"
    if origipv6["WakeOnLAN"] == "Enabled":
        wol = "disable"
    else:
        wol = "enable"

    tolog("Modify and Verify net info:")
    origresult = SendCmd(c, "net -v")
    p = ", primarydns="
    result = SendCmd(
        c,
        "net -a mod -f ipv6 -s \"primaryip=" + newipv6 + ", primaryipmask=" +
        maskv6 + p + dnsv6 + ", gateway=" + gatewayv6 + ", wol=" + wol + "\"")

    #modipv4,modipv6=getnetinfo(cnew)
    checkresult = SendCmd(c, "net -v")

    if not (newipv6 in checkresult and dnsv6 in checkresult
            and gatewayv6 in checkresult and maskv6 in checkresult):
        FailFlag = True
        tolog(Failprompt + "modifying ipv6 adress.")
    # change back to original ip address
    if origipv6["WakeOnLAN"] == "Enabled":
        wol = 'enable'
    else:
        wol = "disable"

    SendCmd(
        c, "net -a mod -f ipv6 -s \"primaryip=" + origipv6['IP'] +
        ", primaryipmask=" + origipv6['IPMask'] + p + origipv6["DNS"] +
        ", gateway=" + origipv6["Gateway"] + ", wol=" + wol + "\"")

    if not ("" in result):
        FailFlag = True
        tolog(Failprompt + "sending change settings cmd.")
    else:

        newipv4, newipv6 = getnetinfo(c)
        if not (dnsv6 == newipv4['DNS'] and gatewayv6 == newipv4['Gateway']
                and maskv6 == newipv4['IPMask']):
            FailFlag = True
            tolog(Failprompt + "changed settings are not correct")
    #SendCmd(cnew, "net -a mod -s \"primaryip=" + origipv4['IP'] + ",primaryipmask=" + origipv4['IPMask'] +", primarydns=" + origipv4["DNS"]+", gateway="+ origipv4["Gateway"]+",wol=" + origipv4["WakeOnLAN"] + "\"")

    if FailFlag:
        tolog('Verify modify and verify net info fail')
        tolog(Fail)
    else:
        tolog('Verify modify and verify net info pass')
        tolog(Pass)
コード例 #28
0
ファイル: Subsys.py プロジェクト: zachpersonal/clitest
def lockunlockAndVerifySubsys(c):
    # only integer numbers from 1 to 1440 are accepted
    # other chars are also verified
    # use unlock to unlock
    checkResult = ''
    result = ""
    FailFlag = False

    tolog("Lock and verify subsys: ")
    #abnorm_params=['abc', 'Abc',"  ","__","##", "%","*","中文"]
    abnorm_params = ['abc', 'Abc', "  ", "__", "##", "%", "*"]
    tolog("Lock subsym by default")
    result = SendCmd(c, "subsys -a lock")
    if not ("You have owned the lock to the subsystem" in result
            and "The lock will expire in 30 min" in result):
        FailFlag = True
    SendCmd(c, "subsys -a unlock")

    for i in range(1, 1600, 60):

        result = SendCmd(c, "subsys -a lock -t " + str(i))
        checkResult = SendCmd(c, "subsys -a chklock")
        checkunlock = SendCmd(c, "subsys -a unlock")
        # convert the mins to x hr x min
        strtime = ""
        hour = 1
        min = 1
        hour = i / 60
        if i <= 1440:
            if hour > 0:
                strtime += "%d hr " % hour
            min = i % 60
            strtime += "%d min" % min
            # print strtime
            if not ("You have owned the lock to the subsystem" in result and
                    ("The lock will expire in " + strtime + " at") in result
                    and "You have owned the lock to the subsystem"
                    in checkResult
                    and "You have released the lock to the subsystem."
                    in checkunlock):
                FailFlag = True
                tolog(Failprompt + str(i))
        else:
            if not ("Invalid lock time" in result and
                    "You do not own the lock to the subsystem" in checkResult
                    and
                    "Current session does not own the lock to the subsystem"
                    in checkunlock):
                FailFlag = True
                tolog(Failprompt + str(i))

    for each in abnorm_params:
        result = SendCmd(c, "subsys -a lock -t " + each)
        if not ("invalid integer" in result and "Error" in result
                and "Invalid input for integer parameter" in result):
            FailFlag = True
            tolog(Failprompt + each)

    if FailFlag:
        tolog('lock and verify subsys fail')
        tolog(Fail)
    else:
        tolog('lock and verify subsys pass')
        tolog(Pass)
コード例 #29
0
ファイル: Subsys.py プロジェクト: zachpersonal/clitest
def modifyAndVerifyAliasSetting(c):
    # only letters, blank space and underscore are accepted
    # other chars are verified
    # no more than 48 char
    # leading spaces and tailing spaces are removed in the alias
    # length subsys alias = 48 chars
    # length controller alias = 48 chars
    # length array,ld alias =32 cahrs
    result = ""
    FailFlag = False
    stdName = "T st_123"
    norm_params = [
        "alias=" + stdName, "alias=" + stdName * 6, "alias=Test123",
        "alias=Test", "alias=12345678", "alias=__________",
        "alias=           ", "alias=Ted Test", "alias=  Ted Test",
        "alias=Ted Test   ", "alias=__Ted Test"
    ]
    #abnorm_params = ["alias=" + stdName * 7 + "1234567", "alias=" + " " * 60, "alias=Test@123", "alias=#Test",
    #                 "alias=12345678%", "alias=" + "12345678" * 8, "alias=" + "_" * 60 + "", "alias=中文"]
    abnorm_params = [
        "alias=" + stdName * 7 + "1234567", "alias=Test@123", "alias=#Test",
        "alias=12345678%", "alias=" + "12345678" * 8, "alias=" + "_" * 60 + ""
    ]
    for each in norm_params:
        tolog("Modify subsys settings by " + "subsys -a mod -s \"" + each +
              "\"")
        aliasName = string.replace(each, "alias=", "")
        result = SendCmd(c, "subsys -a mod -s \"" + each + "\"")
        checkresult = SendCmd(c, "subsys -v")
        if not ("Error" not in result and
                (aliasName.lstrip()).rstrip() in checkresult):
            tolog("Failed on verifying " + aliasName)
            FailFlag = True
            tolog(Failprompt + each)

    for each in abnorm_params:
        tolog("Modify subsys alias by " + "subsys -a mod -s \"" + each + "\"")
        aliasName = string.replace(each, "alias=", "")
        result = SendCmd(c, "subsys -a mod -s \"" + each + "\"")
        checkresult = SendCmd(c, "subsys -v")
        if not (
                "Error" in result and
            ('alias must contain only alphanumeric characters, blank spaces and underscores'
             in checkresult or "alias must be no longer than 48 characters"
             in result or 'Invalid character in alias' in result)):
            # subsys -a mod -s "alias=local#123"
            # -s: alias must contain only alphanumeric characters, blank spaces and underscores
            # Error (0x2034): Invalid character in alias

            # subsys -a mod -s "alias=111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
            # -s: alias must be no longer than 48 characters
            # Error (0x2014): Setting parameters too long

            # subsys - a mod - s "alias=12345678%"
            # -s: alias must contain only alphanumeric characters, blank spaces and underscores
            # Error(0x2034): Invalid character in alias
            tolog(Failprompt + aliasName)
            FailFlag = True

    if FailFlag:
        tolog('Modify subsys alias fail')
        tolog(Fail)
    else:
        tolog('Modify subsys alias pass')
        tolog(Pass)
コード例 #30
0
ファイル: Subsys.py プロジェクト: zachpersonal/clitest
def renewlockunlockandverifysubsys(c):
    # only integer numbers from 1 to 1440 are accepted
    # other chars are also verified
    # use unlock -f to unlock
    # verify expired lock renew
    checkResult = ''
    result = ""
    FailFlag = False
    #abnorm_params=['abc', 'Abc',"  ","__","##", "%","*","中文"]
    abnorm_params = ['abc', 'Abc', "__", "##", "%", "*"]
    SendCmd(c, "subsys -a unlock")
    tolog("Renew Lock and verify subsys: ")

    for i in range(1, 1600, 60):

        SendCmd(c, "subsys -a lock -t 1")
        result = SendCmd(c, "subsys -a lock -r -t " + str(i))
        checkResult = SendCmd(c, "subsys -a chklock")
        checkunlock = SendCmd(c, "subsys -a unlock -f")
        # convert the mins to x hr x min
        strtime = ""
        hour = 1
        min = 1
        hour = i / 60
        if i <= 1440:
            if hour > 0:
                strtime += "%d hr " % hour
            min = i % 60
            strtime += "%d min" % min
            # print strtime
            if not ("You have owned the lock to the subsystem." in result and
                    ("The lock will expire in " + strtime + " at") in result
                    and "You have owned the lock to the subsystem."
                    in checkResult
                    and "You have released the lock to the subsystem."
                    in checkunlock):
                FailFlag = True
                tolog(Failprompt + str(i))
        else:
            if not ("Invalid lock time" in result
                    and "Error (0x402): Invalid parameter" in result and
                    "You have owned the lock to the subsystem." in checkResult
                    and "You have released the lock to the subsystem"
                    in checkunlock):
                FailFlag = True
                tolog(Failprompt + str(i))

    for each in abnorm_params:
        SendCmd(c, "subsys -a lock -t 1")
        result = SendCmd(c, "subsys -a lock -r -t " + each)
        if not ("invalid integer" in result and "Error" in result
                and "Invalid input for integer parameter" in result):
            FailFlag = True
            tolog(Failprompt + each)

    SendCmd(c, "subsys -a unlock -f")
    SendCmd(c, "subsys -a lock -t 1")
    import time
    time.sleep(60)
    result = SendCmd(c, "subsys -a lock -r -t 2")
    if not ("Error" in result
            and "Error (0x110): The lock has expired" in result):
        tolog(Failprompt + "expired lock")
        FailFlag = True

    if FailFlag:
        tolog('renew lock and verify subsys fail')
        tolog(Fail)
    else:
        tolog('renew lock and verify subsys pass')
        tolog(Pass)