Esempio n. 1
0
def GetNetworks():

    res = ValuesXCP()
    res.Status = StatusVLAB()
    res.Values = []
    res.Status.Messages = []
    res.Status.StatusOK = True

    xcp = XCPMethods(logging=res.Status, conf=config)
    resOK = xcp.ConnectXCP()
    if not resOK:
        return res

    objs = xcp.GetNetworks()
    if not objs:
        res.Status.StatusOK = False
        return res

    for obj in objs:
        valueXCP = ValueXCP()
        valueXCP.Ref = obj
        valueXCP.Value = xcp.xapi.network.get_name_label(obj)
        res.Values.append(valueXCP)

    return res
Esempio n. 2
0
def GetNetworks():

    res = ValuesXCP()
    res.Status = StatusVLAB()
    res.Values = []
    res.Status.Messages = []
    res.Status.StatusOK = True

    xcp = XCPMethods(logging=res.Status, conf=config)
    resOK = xcp.ConnectXCP()
    if not resOK:
        return res

    objs = xcp.GetNetworks()
    if not objs:
        res.Status.StatusOK = False
        return res

    for obj in objs:
        valueXCP = ValueXCP()
        valueXCP.Ref = obj
        valueXCP.Value = xcp.xapi.network.get_name_label(obj)
        res.Values.append(valueXCP)

    return res
Esempio n. 3
0
def GetVMsUsers(strUser):
    res = ValuesXCP()
    res.Status = StatusVLAB()
    res.Values = []
    res.Status.Messages = []
    res.Status.StatusOK = True

    xcp = XCPMethods(logging=res.Status, conf=config)
    resOK = xcp.ConnectXCP()
    if not resOK:
        return res

    xvp = XVPMethods(logging=res.Status, conf=config)
    xvp.ConnectDB()
    if not xvp.SQLConnect:
        return
    xvp.sqlCur = xvp.SQLConnect.cursor()

    pool = xcp.GetPoolName()
    uuids = xvp.GetVMUUIDByUser(pool, strUser)
    if len(uuids) > 0:
        if uuids[0] == '*':
            return GetAllVM()

    for obj in uuids:
        vm = xcp.FindVMbyUUID(obj)

        if not res.Status.StatusOK:
            return res

        if not vm:
            continue

        valueXCP = ValueXCP()
        valueXCP.Ref = obj
        valueXCP.Value = xcp.xapi.VM.get_name_label(vm)
        res.Values.append(valueXCP)

    for group in xvp.GetVMGroupByUser(pool, strUser):
        for obj in xcp.GetVMByGroup(group):
            valueXCP = ValueXCP()
            valueXCP.Ref = xcp.xapi.VM.get_uuid(obj)
            valueXCP.Value = xcp.xapi.VM.get_name_label(obj)
            res.Values.append(valueXCP)

    return res
Esempio n. 4
0
def GetLabs():
    res = ValuesXCP()
    res.Status = StatusVLAB()
    res.Values = []
    res.Status.Messages = []
    res.Status.StatusOK = True

    xcp = XCPMethods(logging=res.Status, conf=config)
    resOK = xcp.ConnectXCP()
    if not resOK:
        return res
    xcp.ReadConfs()
    for obj in xcp.GetLabs():
        valueXCP = ValueXCP()
        valueXCP.Value = obj
        res.Values.append(valueXCP)
    return res
Esempio n. 5
0
def GetVMsUsers(strUser):
    res = ValuesXCP()
    res.Status = StatusVLAB()
    res.Values = []
    res.Status.Messages = []
    res.Status.StatusOK = True

    xcp = XCPMethods(logging=res.Status, conf=config)
    resOK = xcp.ConnectXCP()
    if not resOK:
        return res

    xvp = XVPMethods(logging=res.Status, conf=config)
    xvp.ConnectDB()
    if not xvp.SQLConnect:
        return
    xvp.sqlCur = xvp.SQLConnect.cursor()

    pool = xcp.GetPoolName()
    uuids = xvp.GetVMUUIDByUser(pool, strUser)
    if len(uuids) > 0:
        if uuids[0] == "*":
            return GetAllVM()

    for obj in uuids:
        vm = xcp.FindVMbyUUID(obj)

        if not res.Status.StatusOK:
            return res

        if not vm:
            continue

        valueXCP = ValueXCP()
        valueXCP.Ref = obj
        valueXCP.Value = xcp.xapi.VM.get_name_label(vm)
        res.Values.append(valueXCP)

    for group in xvp.GetVMGroupByUser(pool, strUser):
        for obj in xcp.GetVMByGroup(group):
            valueXCP = ValueXCP()
            valueXCP.Ref = xcp.xapi.VM.get_uuid(obj)
            valueXCP.Value = xcp.xapi.VM.get_name_label(obj)
            res.Values.append(valueXCP)

    return res
Esempio n. 6
0
def GetLabs():
    res = ValuesXCP()
    res.Status = StatusVLAB()
    res.Values = []
    res.Status.Messages = []
    res.Status.StatusOK = True

    xcp = XCPMethods(logging=res.Status, conf=config)
    resOK = xcp.ConnectXCP()
    if not resOK:
        return res
    xcp.ReadConfs()
    for obj in xcp.GetLabs():
        valueXCP = ValueXCP()
        valueXCP.Value = obj
        res.Values.append(valueXCP)
    return res
Esempio n. 7
0
def GetVMsByLab(strLab):
    res = ValuesXCP()
    res.Status = StatusVLAB()
    res.Values = []
    res.Status.Messages = []
    res.Status.StatusOK = True

    xcp = XCPMethods(logging=res.Status, conf=config)
    resOK = xcp.ConnectXCP()
    if not resOK:
        return res

    xcp.ReadConfs()

    for obj in xcp.GetVMsByLab(strLab):
        valueXCP = ValueXCP()
        valueXCP.Ref = obj['uuid']
        valueXCP.Value = obj['name_label']
        res.Values.append(valueXCP)

    return res
Esempio n. 8
0
def GetVMsByLab(strLab):
    res = ValuesXCP()
    res.Status = StatusVLAB()
    res.Values = []
    res.Status.Messages = []
    res.Status.StatusOK = True

    xcp = XCPMethods(logging=res.Status, conf=config)
    resOK = xcp.ConnectXCP()
    if not resOK:
        return res

    xcp.ReadConfs()

    for obj in xcp.GetVMsByLab(strLab):
        valueXCP = ValueXCP()
        valueXCP.Ref = obj["uuid"]
        valueXCP.Value = obj["name_label"]
        res.Values.append(valueXCP)

    return res