示例#1
0
def CreateLab(configLab):
    res = StatusVLAB()
    res.Messages = []
    res.StatusOK = True

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

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

    if configLab.Action.lower() == "create":
        _createLab(xcp, xvp, configLab)
    elif configLab.Action.lower() == "delete":
        _deleteLab(xcp, xvp, configLab)
    else:
        res.Messages.append("ERROR: Action is wrong!!! Action is 'create' or 'delete'")
        res.StatusOK = False

    xvp.SQLConnect.commit()
    xvp.SQLConnect.close()
    xcp.xapi.logout()

    return res
示例#2
0
def CreateLab(configLab):
    res = StatusVLAB()
    res.Messages = []
    res.StatusOK = True

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

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

    if configLab.Action.lower() == "create":
        _createLab(xcp, xvp, configLab)
    elif configLab.Action.lower() == "delete":
        _deleteLab(xcp, xvp, configLab)
    else:
        res.Messages.append(
            "ERROR: Action is wrong!!! Action is 'create' or 'delete'")
        res.StatusOK = False

    xvp.SQLConnect.commit()
    xvp.SQLConnect.close()
    xcp.xapi.logout()

    return res
示例#3
0
def ChangeStateVM(uuid, state):
    res = StatusVLAB()
    res.Messages = []
    res.StatusOK = True

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

    if not xcp.ChangeStateVM(uuid, state):
        res.StatusOK = False

    return res
示例#4
0
def ChangeStateVM(uuid, state):
    res = StatusVLAB()
    res.Messages = []
    res.StatusOK = True

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

    if not xcp.ChangeStateVM(uuid, state):
        res.StatusOK = False

    return res