예제 #1
0
 def list_ucsc(handle, wanted):
     """
     Get all the drives of the servers listed and print them out. 
     """
     try:
         all_servers = UCSCServer.list_servers(handle)
         ucs_servers = UCSCUtil.servers_to_objects(all_servers, wanted)
     except KubamError as e:
         UCSCUtil.ucsc_logout(handle)
         return {"error": str(e)}, Const.HTTP_BAD_REQUEST
     disks = {} 
     from ucscsdk.mometa.storage.StorageLocalDisk import StorageLocalDisk
     for i in ucs_servers:
         try:
             server_disks = UCSCServer.list_disks(handle, i)
             disks[i['dn']] = []
             for d in server_disks:
                 # d.__dict__ flattens the object to a dictionary. 
                 kv = d.__dict__
                 kv = dict((key, value) for key, value in kv.iteritems() if not key.startswith('_') )
                 disks[i['dn']].append( kv)
         except KubamError as e:
             UCSUtil.ucs_logout(handle)
             return {"error": str(e)}, Const.HTTP_BAD_REQUEST
     
     out = UCSCUtil.dn_hash_to_out(disks)
     UCSCUtil.ucsc_logout(handle)
     return out, Const.HTTP_OK
예제 #2
0
파일: monitor.py 프로젝트: madpabz/KUBaM
def get_server_status_ucsc(sg, wanted):
    try:
        handle = UCSCUtil.ucsc_login(sg)
    except KubamError as e:
        return jsonify({"error": str(e)}), Const.HTTP_BAD_REQUEST

    try:
        all_servers = UCSCServer.list_servers(handle)
        if not wanted == "all":
            all_servers = UCSCUtil.servers_to_objects(all_servers, wanted)
        # put in dn name format
        status = {}
        for i in all_servers:
            status[i['dn']] = i
        out = UCSCUtil.dn_hash_to_out(status)
    except KubamError as e:
        UCSCUtil.ucsc_logout(handle)
        return jsonify({"error": str(e)}), Const.HTTP_BAD_REQUEST

    UCSCUtil.ucsc_logout(handle)
    return jsonify({"servers": out}), Const.HTTP_OK
예제 #3
0
파일: monitor.py 프로젝트: madpabz/KUBaM
def ucsc_fsm(sg, wanted):
    """
    Get the FSM of the servers in UCS Central
    """
    try:
        handle = UCSCUtil.ucsc_login(sg)
    except KubamError as e:
        return jsonify({"error": str(e)}), Const.HTTP_BAD_REQUEST

    try:
        all_servers = UCSCServer.list_servers(handle)
        if not wanted == "all":
            all_servers = UCSCUtil.servers_to_objects(all_servers, wanted)
        # put in dn name format
        status = {}
        for i in all_servers:
            status[i['dn']] = UCSCMonitor.get_fsm(handle, i)
        out = UCSCUtil.dn_hash_to_out(status)
    except KubamError as e:
        UCSCUtil.ucsc_logout(handle)
        return jsonify({"error": str(e)}), Const.HTTP_BAD_REQUEST

    UCSCUtil.ucsc_logout(handle)
    return jsonify({"servers": out}), Const.HTTP_OK