Exemple #1
0
def status(request):
    session = DBSession()
    thunder = session.query(Thunder).filter(
        Thunder.id == request.matchdict["thunder_id"]).one()

    return Response(
        "Status of thunder{0}:<br>Hypervisor: {1}<br>Status: {2}".format(
            request.matchdict["thunder_id"], thunder.hypervisor,
            thunder.status))
Exemple #2
0
def lock(request):
    session = DBSession()
    tid = request.matchdict["thunder_id"]
    thunder = session.query(Thunder).filter(Thunder.id == tid).one()
    thunder.status = u"locked"
    session.add(thunder)
    session.flush()
    transaction.commit()

    return {
        'project': 'thunders',
        'message': "Locked thunder{0}".format(request.matchdict["thunder_id"])
    }
Exemple #3
0
def check_status(request):
    session = DBSession()
    thunder = session.query(Thunder).filter(
        Thunder.id == request.matchdict["thunder_id"]).one()
    thunder.hypervisor = do_check_hypervisor_by_api(thunder)
    thunder.power = do_check_power(thunder)
    if (thunder.hypervisor != u"unknown"):
        thunder.status = u'ok'
    session.add(thunder)
    session.flush()
    transaction.commit()
    res = "Refreshing Thunder{0}".format(request.matchdict["thunder_id"])
    # thunders = session.query(Thunder).all()
    return {'project': 'thunders', 'message': res}
Exemple #4
0
def reboot(request):
    session = DBSession()
    tid = request.matchdict["thunder_id"]
    thunder = session.query(Thunder).filter(Thunder.id == tid).one()
    if thunder.status != "locked":
        do_reboot(thunder)
        thunder.status = u"rebooting"
        session.add(thunder)
        session.flush()
        transaction.commit()
        res = "Rebooting thunder{0}...".format(request.matchdict["thunder_id"])
    else:
        res = "Thunder{0} locked!".format(request.matchdict["thunder_id"])
    return {'project': 'thunders', 'message': res}
Exemple #5
0
def install(request):
    session = DBSession()
    thunder = session.query(Thunder).filter(
        Thunder.id == request.matchdict["thunder_id"]).one()
    if thunder.status != "locked":
        thunder.status = u"installing"
        thunder.hypervisor = request.matchdict["hypervisor"]
        session.add(thunder)
        session.flush()
        transaction.commit()

        thunder = session.query(Thunder).filter(
            Thunder.id == request.matchdict["thunder_id"]).one()
        do_install(thunder.ipmiip, request.matchdict["hypervisor"])
        res = "Installing hypervisor {0} on thunder {1}...".format(
            request.matchdict["hypervisor"], request.matchdict["thunder_id"])
    else:
        res = "Thunder {0} locked!".format(request.matchdict["thunder_id"])
    return {'project': 'thunders', 'message': res}
Exemple #6
0
def list(request):
    session = DBSession()
    thunders = session.query(Thunder).all()

    return Response(unicode(thunders))
Exemple #7
0
def home(request):
    session = DBSession()
    thunders = session.query(Thunder).all()
    return {'project': 'thunderdome', 'thunders': thunders}