示例#1
0
def http_get_instance_id(tenant_id, instance_id):
    '''get instances details, can use both uuid or name'''
    #check valid tenant_id
    if tenant_id != "any" and not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_get_instance_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    if tenant_id == "any":
        tenant_id = None
  
    #obtain data (first time is only to check that the instance exists)
    result, data = mydb.get_instance_scenario(instance_id, tenant_id, verbose=True)
    if result < 0:
        print "http_get_instance_id error %d %s" % (-result, data)
        bottle.abort(-result, data)
        return
    
    r,c = nfvo.refresh_instance(mydb, tenant_id, data)
    if r<0:
        print "WARNING: nfvo.refresh_instance couldn't refresh the status of the instance: %s" %c
    #obtain data with results upated
    result, data = mydb.get_instance_scenario(instance_id, tenant_id)
    if result < 0:
        print "http_get_instance_id error %d %s" % (-result, data)
        bottle.abort(-result, data)
        return
    convert_datetime2str(data)
    print json.dumps(data, indent=4)
    return format_out(data)
示例#2
0
def http_get_instance_id(tenant_id, instance_id):
    '''get instances details, can use both uuid or name'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_get_instance_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
  
    #obtain data (first time is only to check that the instance exists)
    result, data = mydb.get_instance_scenario(instance_id, tenant_id, verbose=True)
    if result < 0:
        print "http_get_instance_id error %d %s" % (-result, data)
        bottle.abort(-result, data)
        return
    
    r,c = nfvo.refresh_instance(mydb, tenant_id, data)
    if r<0:
        print "WARNING: nfvo.refresh_instance couldn't refresh the status of the instance: %s" %c
    #obtain data with results upated
    result, data = mydb.get_instance_scenario(instance_id, tenant_id)
    if result < 0:
        print "http_get_instance_id error %d %s" % (-result, data)
        bottle.abort(-result, data)
        return
    convert_datetime2str(data)
    print json.dumps(data, indent=4)
    return format_out(data)
示例#3
0
def http_get_instance_id(tenant_id, instance_id):
    '''get instances details, can use both uuid or name'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id):
        print 'httpserver.http_get_instance_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return

    #obtain data (first time is only to check that the instance exists)
    result, data = mydb.get_instance_scenario(instance_id, tenant_id)
    if result < 0:
        print "http_get_instance_id error %d %s" % (-result, data)
        bottle.abort(-result, data)
        return


#     OLD:
#     qs = bottle.request.query
#     if type(qs) is not bottle.FormsDict:
#         print '!!!!!!!!!!!!!!invalid query string not a dictionary'
#         bottle.abort(HTTP_Internal_Server_Error, "ttpserver.http_get_instance_id(): unexpected query string")
#     else:
#         print "Query: %s" %qs.dict
#         if 'refresh' in qs and qs.get('refresh')=="yes":
#             print "REFRESH: %s" %qs.get('refresh')
#             #refresh the instance
#             r,c = nfvo.refresh_instance(mydb, tenant_id, data)
#             if r<0:
#                 print "WARNING: nfvo.refresh_instance couldn't refresh the status of the instance: %s" %c
#         else:
#             print "NO REFRESH"

    r, c = nfvo.refresh_instance(mydb, tenant_id, data)
    if r < 0:
        print "WARNING: nfvo.refresh_instance couldn't refresh the status of the instance: %s" % c
    print json.dumps(data, indent=4)
    return format_out(data)
示例#4
0
def http_get_instance_id(tenant_id, instance_id):
    '''get instances details, can use both uuid or name'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_get_instance_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
  
    #obtain data (first time is only to check that the instance exists)
    result, data = mydb.get_instance_scenario(instance_id, tenant_id)
    if result < 0:
        print "http_get_instance_id error %d %s" % (-result, data)
        bottle.abort(-result, data)
        return
    
#     OLD:
#     qs = bottle.request.query
#     if type(qs) is not bottle.FormsDict:
#         print '!!!!!!!!!!!!!!invalid query string not a dictionary'
#         bottle.abort(HTTP_Internal_Server_Error, "ttpserver.http_get_instance_id(): unexpected query string")
#     else:
#         print "Query: %s" %qs.dict
#         if 'refresh' in qs and qs.get('refresh')=="yes":
#             print "REFRESH: %s" %qs.get('refresh')
#             #refresh the instance
#             r,c = nfvo.refresh_instance(mydb, tenant_id, data)
#             if r<0:
#                 print "WARNING: nfvo.refresh_instance couldn't refresh the status of the instance: %s" %c
#         else:
#             print "NO REFRESH"

    r,c = nfvo.refresh_instance(mydb, tenant_id, data)
    if r<0:
        print "WARNING: nfvo.refresh_instance couldn't refresh the status of the instance: %s" %c
    print json.dumps(data, indent=4)
    return format_out(data)