Ejemplo n.º 1
0
def WriteCacheAttach():
    Failflag=False
    origsetting=dict()
    tolog("Verify original write cache setting")
    origsetting=WriteCacheinfo()
    if origsetting:
        tolog(str(origsetting))
    else:
        tolog("There's no write cache, and write cache will be added.")
        pdlist=getavailpd()

        body={"pd_list":pdlist}
        urlpara="attach"
        server.webapiurlbody("post","wcache",urlpara,body)

        modifiedsetting=WriteCacheinfo()
        if modifiedsetting:
            tolog(str(modifiedsetting))
        else:
            Failflag
            tolog("Write cache cannot be created.")


    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 2
0
def Iscsitrunk_delete():
    Failflag = False
    Faillist = list()
    tolog("Delete iscsitrunk by api")

    res = server.webapiurlbody("get", "linkaggr")
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    if "200" in str(res["response"]):

        for each in view:
            res1=server.webapiurlbody("delete", "linkaggr",urlparameter=str(each["id"]))
            # view = json.loads(res1["text"])
            if "200" in str(res1["response"]):
                tolog("Delete iscsitrunk %d  succesfully." % each["id"])
            else:
                tolog("Delete iscsitrunk %d  failed." % each["id"])
                Failflaglist.append(True)
    else:
        Failflaglist.append(True)
        tolog("Get iscsitrunk info failed." )


    for flag in Faillist:
        if flag:
            Failflag=True
            break

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 3
0
def SetDate():

    Failflag = False
    date = Dateinfo()
    # view=dict()
    # view = {'hour': 13, 'min': 56, 'month': 5, 'sec': 52, 'year': 2016, 'day': 18}
    view = date[0].copy()
    view['year'] = date[0]['year'] - 1

    view = convert(view)

    server.webapiurlbody("post", "date", body=view)

    newview = Dateinfo()

    if view['year'] != newview[0]['year']:
        Failflag = True
        tolog("Change year failed")
    else:
        tolog("Change year from %s to %s" %
              (date[0]['year'], newview[0]['year']))

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 4
0
def cleanpool():
    res = server.webapiurlbody("get", "pool")
    poollist = list()
    cleanrestext = json.loads(res["text"])

    for eachpool in cleanrestext:
        urlpara=str(eachpool["id"])+"?force=1"
        res=server.webapiurlbody("delete","pool",urlparameter=urlpara)
        print str((res["text"]))
Ejemplo n.º 5
0
def EnclDiagPSUinfo():
    Failflag = False
    tolog("Get EnclDiagPSUinfo by api")
    Failflag, enclousreinfo = ExternalEnclosureinfo()
    for enc in enclousreinfo:
        print enc["id"]

        tolog("Enclosure %d " % (enc["id"]))

        urlpara = str(enc['id']) + "/psu"

        res = server.webapiurlbody("get", "encldiag", urlparameter=urlpara)
        tolog(str(res["response"]))
        view = json.loads(res["text"])
        if view:
            tolog("Get psu is succesfully.")

            tolog(str(view))
        else:
            Failflag = True
            tolog("Get psu failed.")

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 6
0
def Factorydefaults():
    Failflag = False

    tolog("Factory defaults restore by api")
    # type 	1 : db, 2 : event, 3 : servicereport, 4 : config
    body = {"type": "bga"}
    tolog("Check original BGA setting info")
    orires = BGAapi.BGAinfo()
    tolog(str(orires))
    tolog("Restore BGA setting to factory default ")
    res = server.webapiurlbody("post", "factorydefaults", body=body)

    tolog(str(res["response"]))
    tolog("Check default BGA setting info")
    defaultres = BGAapi.BGAinfo()
    tolog(str(defaultres))

    tolog("Check modified BGA setting info")
    Failflag = BGAapi.BGAset()
    modifiedres = BGAapi.BGAinfo()
    tolog(str(modifiedres))

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 7
0
def Iscsiportal_add_trunk():
    Failflag=False
    Faillist=list()
    tolog("Add portal by api")
    # max portal number 32

    bodypara_trunk = {"if_type": "Trunk", "tcp_port": 3260, "ip_type": "IPv4", "dhcp": 1, "trunk_id": 1}
    for i in range(32):

        res=server.webapiurlbody("post","iscsiportal",body=bodypara_trunk)
        tolog(str(res["response"]))
        #view = json.loads(res["text"])
        if "200" in str(res["response"]):
            tolog("Add portal succesfully.")
            #tolog(str(view))
        else:
            Faillist.append(True)
            tolog("Add portal failed." + str(para))

    for flag in Faillist:
        if flag:
            Failflag=True
            break

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 8
0
def Useradd():
    Failflag = False

    tolog("Add user by api")
    bodypara = {
        "id": "testabc",
        "email": "*****@*****.**",
        "status": 1,
        "privilege": "View",
        "passwd": "1234"
    }
    res = server.webapiurlbody("post", "user", body=bodypara)
    tolog(str(res["response"]))
    #view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Get user info is succesfully.")

        #tolog(str(view))
    else:
        Failflag = True
        tolog("Get user info failed.")

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 9
0
def Iscsiportal_add_phyvlan():
    Failflag=False
    Faillist=list()
    tolog("Add portal by api")
    # max portal number 32
    bodypara_phy = {"if_type": "Physical", "tcp_port": 3260, "ip_type": "IPv4", "dhcp": 1, "port_id": 1, "ctrl_id": 2}

    bodypara_vlan = {"if_type": "Vlan", "tcp_port": 3260, "ip_type": "IPv4", "dhcp": 1, "port_id": 2, "ctrl_id": 2,"vlan_tag":1}
    bodypara=(bodypara_phy,bodypara_vlan)
    #bodypara_trunk = {"if_type": "Trunk", "tcp_port": 3260, "ip_type": "IPv4", "dhcp": 1, "trunk_id": 1}
    for i in range(32):
        para=random.choice(bodypara)
        res=server.webapiurlbody("post","iscsiportal",body=para)
        tolog(str(res["response"]))
        #view = json.loads(res["text"])
        if "200" in str(res["response"]):
            tolog("Add portal succesfully.")
            #tolog(str(view))
        else:
            Faillist.append(True)
            tolog("Add portal failed." + str(para))

    for flag in Faillist:
        if flag:
            Failflag=True
            break

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 10
0
def Passwordset():
    Failflag=False

    tolog("Get Password set info by api")
    Useradd()
    Failflag,userinfo=extUsergetinfo()
    for user in userinfo:
        if "testabc" in user['id']:
            userid=user["id"]
            urlpara=str(userid)
            bodypara={"new_passwd":"abcd"}

            res = server.webapiurlbody("put", "password",urlparameter=urlpara,body=bodypara)
            tolog(str(res["response"]))
            #view = json.loads(res["text"])
            if "200" in str(res["response"]):
                tolog("Get password set  is succesfully.")

                #tolog(str(view))
            else:
                Failflag = True
                tolog("Get password set  info failed.")


    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 11
0
def Iscsisetnode(id):
    Failflag = False

    tolog("Set iscsinode info by api")
    urlpara = str(id)
    bodypara={"alias":"test","header_digest":1,"data_digest":1,"bi_chap_auth":0,"uni_chap_auth":0,"assn_portal_ids":"1,2"}
    res = server.webapiurlbody("put", "iscsinode", urlparameter=urlpara,body=bodypara)
    Iscsinodegetbyidinfo(id)
Ejemplo n.º 12
0
def deleteobj(obj,objid):
    Failflag = False
    urlpara=str(objid)+"?force=1"
    res = server.webapiurlbody("delete", obj, urlparameter=urlpara)
    if res["text"] != "":
        tolog("Deleting %s %s failed" % (obj,str(objid)))
        Failflag = True
    else:
        tolog("Deleting %s %s successfully" % (obj, str(objid)))

    return Failflag
Ejemplo n.º 13
0
def createobj(obj,setting):
    Failflag=False
    createres = server.webapiurlbody("post", obj, body=setting)

    if createres["text"] != "":
        tolog("Creating %s with %s failed" % (obj,str(setting)))
        Failflag = True
    else:
        tolog("Creating %s with %s successfully" % (obj, str(setting)))

    return Failflag
Ejemplo n.º 14
0
def getusedpd():
    res = server.webapiurlbody("get", "phydrv")
    pdlist = list()
    cleanrestext = json.loads(res["text"])

    for eachpd in cleanrestext:

        if eachpd["op_status"] == "OK" and ("Pool" in eachpd["cfg_status"] or  "Spare" in eachpd["cfg_status"] ) and eachpd["type"] == "SAS HDD":
            pdlist.append(eachpd["id"])

    return pdlist
Ejemplo n.º 15
0
def getavailpd():
    res = server.webapiurlbody("get", "phydrv")
    pdlist = list()
    cleanrestext = json.loads(res["text"])

    for eachpd in cleanrestext:

        if eachpd["op_status"] == "OK" and eachpd["cfg_status"] == "Unconfigured" and eachpd["type"] == "SAS HDD":
            pdlist.append(eachpd["id"])

    return pdlist
Ejemplo n.º 16
0
def PerfStatsgetinfo():
    Failflag = False

    tolog("Get perfstats info by api")
    server.webapiurlbody("post", "perfstatsstart")
    time.sleep(10)
    res = server.webapiurlbody("get", "perfstats")
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Get perfstats info is succesfully.")

        tolog(str(view))
    else:
        Failflag = True
        tolog("Get perfstats info failed.")

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 17
0
def ReadCacheAttach():
    Failflag=False
    origsetting=dict()
    tolog("Verify original read cache setting")
    origsetting=ReadCacheinfo()
    tolog(str(origsetting))

    pdlist=getavailpd()


    body={"pd_list":pdlist}
    urlpara="attach"
    server.webapiurlbody("post","rcache",urlpara,body)
    modifiedsetting=ReadCacheinfo()
    tolog(str(modifiedsetting))


    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 18
0
def Iscsiportal_delete(id):
    Failflag = False
    tolog("Delete portal by api")
    urlpara=str(id)
    res=server.webapiurlbody("delete","iscsiportal",urlparameter=urlpara)
    tolog(str(res["response"]))
    #view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Delete portal %d succesfully." %id)
        #tolog(str(view))
    else:
        Failflag=True

    return Failflag
Ejemplo n.º 19
0
def Iscsinodegetbyidinfo(id):
    Failflag = False

    tolog("Get iscsinode info by id")
    urlpara=str(id)
    res = server.webapiurlbody("get", "iscsinode",urlparameter=urlpara)
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Get iscsinode info by id is succesfully.")
        tolog(str(view))
    else:
        Failflag=True

    return Failflag
Ejemplo n.º 20
0
def Iscsiportal_getanddelete():
    Failflag=False
    Failflaglist=list()
    tolog("Get portals info by api")
    res = server.webapiurlbody("get", "iscsiportal")
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    portalnum=len(view)
    if "200" in str(res["response"]):
        tolog("Get portals info succesfully.")
        tolog(str(view))
        # print "type of view is ", type(view)
        for each in view:
            newres = server.webapiurlbody("get", "iscsiportal")
            newview= json.loads(newres["text"])
            num=len(newview)


            if num!=portalnum:
                Failflaglist.append(True)
                tolog("Returned portal number is %d, and it should be %d" % (num, portalnum))
            Failflaglist.append(Iscsiportal_delete(each['id']))
            portalnum-=1
    else:
        Failflaglist.append(True)
        tolog("Delete portal failed.")

    for flag in Failflaglist:
        if flag:
            Failflag=True
            break

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 21
0
def ExternalEnclosureinfo():
    Failflag = False

    # urlpara="?usercache=1"

    res = server.webapiurlbody("get", "enclosure")
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    if view:
        tolog("Get enclosure is succesfully.")

        tolog(str(view))
    else:
        Failflag = True
        tolog("Get enclosure failed.")

    return Failflag, view
Ejemplo n.º 22
0
def extUsergetinfo():
    Failflag = False

    tolog("Get user info by api")

    res = server.webapiurlbody("get", "user")
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Get user info is succesfully.")

        tolog(str(view))
    else:
        Failflag = True
        tolog("Get user info failed.")

    return Failflag, view
Ejemplo n.º 23
0
def Dashboardinfo():
    Failflag = False

    urlpara = "pool"

    res = server.webapiurlbody("get", "dashboard", urlparameter=urlpara)
    view = json.loads(res["text"])
    if view:
        tolog("Dashboard get pool status succesfully.")
        tolog(str(view))
    else:
        Failflag = True
        tolog("Dashboard get pool status failed.")

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 24
0
def Iscsitrunk_create():
    Failflag=False
    tolog("Add iscsitrunk by api")
    bodypara={"ctrl_id":2,"master_port":1,"trunk_type":"balance_xor","slave_ports":[2]}
    res=server.webapiurlbody("post","linkaggr",body=bodypara)
    tolog(str(res["response"]))
        #view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Add trunk succesfully.")
            #tolog(str(view))
    else:
        Failflag = True
        tolog("Add portal failed." + str(bodypara))

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 25
0
def BuzzerTurnOff():
    Failflag = False
    tolog("Verify buzzer turn off by api")
    body = {"onoff": 0}
    res = server.webapiurlbody("post", "buzzer", "status", body)

    buzzer, Failflag = Buzzerinfo()
    if buzzer["status"] == "Silent":

        tolog("Buzzer turn off sucessfully.")
    else:
        Failflag = True
        tolog("Buzzer turn off failed.")

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 26
0
def Iscsitrunk_getinfo():
    Failflag = False

    tolog("Get iscsitrunk info by api")
    # bodypara = {"ctrl_id": 2, "master_port": 1, "trunk_type": "balance_xor", "slave_ports": [1]}
    res = server.webapiurlbody("get", "linkaggr")
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Get iscsitrunk info succesfully.")
        tolog(str(view))
    else:
        Failflag = True
        tolog("Get iscsitrunk info failed." + str(para))

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 27
0
def Discoveryinfo():
    Failflag=False

    urlpara="?usercache=1"

    res = server.webapiurlbody("get", "discovery",urlparameter=urlpara)
    view = json.loads(res["text"])
    if view:
        tolog("Discovery %s succesfully."%view['hosts'])
        tolog(str(view))
    else:
        Failflag=True
        tolog("Discovery failed.")


    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 28
0
def Netgetinfo():
    Failflag = False

    tolog("Get net info by api")

    res = server.webapiurlbody("get", "net")
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Get net info is succesfully.")

        tolog(str(view))
    else:
        Failflag = True
        tolog("Get net info failed.")

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 29
0
def UPSgetinfo():
    Failflag = False

    tolog("Get UPS by api")
    # urlpara="Administrator"
    res = server.webapiurlbody("get", "ups")
    tolog(str(res["response"]))
    view = json.loads(res["text"])

    if "200" in str(res["response"]):
        tolog("Get UPS is succesfully.")

        tolog(str(view))
    else:
        Failflag = True
        tolog("Get UPS info failed.")

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)
Ejemplo n.º 30
0
def ProtocolAFPgetinfo():
    Failflag = False

    tolog("Get Protocol AFP info by api")

    urlpara = "afp"
    res = server.webapiurlbody("get", "protocol", urlparameter=urlpara)
    tolog(str(res["response"]))
    view = json.loads(res["text"])
    if "200" in str(res["response"]):
        tolog("Get Protocol AFP info is succesfully.")

        tolog(str(view))
    else:
        Failflag = True
        tolog("Get Protocol AFP info failed.")

    if Failflag:
        tolog(Fail)
    else:
        tolog(Pass)