• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python nfvo.check_tenant函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nfvo.check_tenant函数的典型用法代码示例。如果您正苦于以下问题:Python check_tenant函数的具体用法?Python check_tenant怎么用?Python check_tenant使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_tenant函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: http_get_datacenter_id

def http_get_datacenter_id(tenant_id, datacenter_id):
    """get datacenter details, can use both uuid or name"""
    # check valid tenant_id
    if tenant_id != "any":
        if not nfvo.check_tenant(mydb, tenant_id):
            print "httpserver.http_get_datacenter_id () tenant %s not found" % tenant_id
            bottle.abort(HTTP_Not_Found, "Tenant %s not found" % tenant_id)
            return
    # obtain data
    what = "uuid" if af.check_valid_uuid(datacenter_id) else "name"
    where_ = {}
    where_[what] = datacenter_id
    select_ = ("uuid", "name", "vim_url", "vim_url_admin", "type", "config", "d.created_at as created_at")
    if tenant_id != "any":
        where_["td.nfvo_tenant_id"] = tenant_id
        from_ = "datacenters as d join tenants_datacenters as td on d.uuid=td.datacenter_id"
    else:
        from_ = "datacenters as d"
    result, content = mydb.get_table(SELECT=select_, FROM=from_, WHERE=where_)

    if result < 0:
        print "http_get_datacenter_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    elif result == 0:
        bottle.abort(HTTP_Not_Found, "No datacenter found for tenant with %s '%s'" % (what, datacenter_id))
    elif result > 1:
        bottle.abort(HTTP_Bad_Request, "More than one datacenter found for tenant with %s '%s'" % (what, datacenter_id))

    print content
    if content[0]["config"] != None:
        try:
            config_dict = json.loads(content[0]["config"])
            content[0]["config"] = config_dict
        except Exception, e:
            print "Exception '%s' while trying to load config information" % str(e)
开发者ID:312v,项目名称:playnet,代码行数:35,代码来源:httpserver.py


示例2: http_post_instance_scenario_action

def http_post_instance_scenario_action(tenant_id, instance_id):
    """take an action over a scenario instance"""
    # check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id):
        print "httpserver.http_post_instance_scenario_action() tenant %s not found" % tenant_id
        bottle.abort(HTTP_Not_Found, "Tenant %s not found" % tenant_id)
        return
    # parse input data
    http_content = format_in(instance_scenario_action_schema)
    r = af.remove_extra_items(http_content, instance_scenario_action_schema)
    if r is not None:
        print "http_post_instance_scenario_action: Warning: remove extra items ", r
    print "http_post_instance_scenario_action input: ", http_content
    # obtain data
    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)

    result, data = nfvo.instance_action(mydb, tenant_id, instance_id, http_content)
    if result < 0:
        print "http_post_scenario_action error %d: %s" % (-result, data)
        bottle.abort(-result, data)
    else:
        return format_out(data)
开发者ID:312v,项目名称:playnet,代码行数:25,代码来源:httpserver.py


示例3: http_get_datacenters

def http_get_datacenters(tenant_id):
    # check valid tenant_id
    if tenant_id != "any":
        if not nfvo.check_tenant(mydb, tenant_id):
            print "httpserver.http_get_datacenters () tenant %s not found" % tenant_id
            bottle.abort(HTTP_Not_Found, "Tenant %s not found" % tenant_id)
            return
    select_, where_, limit_ = filter_query_string(
        bottle.request.query, None, ("uuid", "name", "vim_url", "type", "created_at")
    )
    if tenant_id != "any":
        where_["nfvo_tenant_id"] = tenant_id
        if "created_at" in select_:
            select_[select_.index("created_at")] = "d.created_at as created_at"
        if "created_at" in where_:
            where_["d.created_at"] = where_.pop("created_at")
        result, content = mydb.get_table(
            FROM="datacenters as d join tenants_datacenters as td on d.uuid=td.datacenter_id",
            SELECT=select_,
            WHERE=where_,
            LIMIT=limit_,
        )
    else:
        result, content = mydb.get_table(FROM="datacenters", SELECT=select_, WHERE=where_, LIMIT=limit_)
    if result < 0:
        print "http_get_datacenters Error", content
        bottle.abort(-result, content)
    else:
        # change_keys_http2db(content, http2db_tenant, reverse=True)
        convert_datetime2str(content)
        data = {"datacenters": content}
        return format_out(data)
开发者ID:312v,项目名称:playnet,代码行数:32,代码来源:httpserver.py


示例4: http_get_instance_id

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)
开发者ID:antoniorafaelbraga,项目名称:openmano,代码行数:27,代码来源:httpserver.py


示例5: http_get_datacenters

def http_get_datacenters(tenant_id):
    #check valid tenant_id
    if tenant_id != 'any':
        if not nfvo.check_tenant(mydb, tenant_id): 
            print 'httpserver.http_get_datacenters () tenant %s not found' % tenant_id
            bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
            return
    select_,where_,limit_ = filter_query_string(bottle.request.query, None,
            ('uuid','name','vim_url','type','created_at') )
    if tenant_id != 'any':
        where_['nfvo_tenant_id'] = tenant_id
        if 'created_at' in select_:
            select_[ select_.index('created_at') ] = 'd.created_at as created_at'
        if 'created_at' in where_:
            where_['d.created_at'] = where_.pop('created_at')
        result, content = mydb.get_table(FROM='datacenters as d join tenants_datacenters as td on d.uuid=td.datacenter_id',
                                      SELECT=select_,WHERE=where_,LIMIT=limit_)
    else:
        result, content = mydb.get_table(FROM='datacenters',
                                      SELECT=select_,WHERE=where_,LIMIT=limit_)
    if result < 0:
        print "http_get_datacenters Error", content
        bottle.abort(-result, content)
    else:
        #change_keys_http2db(content, http2db_tenant, reverse=True)
        convert_datetime2str(content)
        data={'datacenters' : content}
        return format_out(data)
开发者ID:bbandaru,项目名称:openmano,代码行数:28,代码来源:httpserver.py


示例6: http_get_instance_id

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_instances() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return

    #obtain data
    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
    
#     print "Query: %s", bottle.request.query
#     refresh=True
#     if refresh:
#         r,c = nfvo.refresh_instance(mydb, tenant_id, data, datacenter=None, vim_tenant=None)
#         if r<0:
#             print "WARNING: nfvo.refresh_instance had a problem: %s" %c
#         #obtain data
#         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
            
    print json.dumps(data, indent=4)
    return format_out(data)
开发者ID:biddyweb,项目名称:openmano,代码行数:30,代码来源:httpserver.py


示例7: http_post_scenario_action

def http_post_scenario_action(tenant_id, scenario_id):
    '''take an action over a scenario'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_post_scenario_action() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    #parse input data
    http_content,_ = format_in( scenario_action_schema )
    r = af.remove_extra_items(http_content, scenario_action_schema)
    if r is not None: print "http_post_scenario_action: Warning: remove extra items ", r
    
    if "start" in http_content:
        result, data = nfvo.start_scenario(mydb, tenant_id, scenario_id, http_content['start']['instance_name'], \
                    http_content['start'].get('description',http_content['start']['instance_name']),
                    http_content['start'].get('datacenter') )
        if result < 0:
            print "http_post_scenario_action start error %d: %s" % (-result, data)
            bottle.abort(-result, data)
        else:
            return format_out(data)
    elif "deploy" in http_content:   #Equivalent to start
        result, data = nfvo.start_scenario(mydb, tenant_id, scenario_id, http_content['deploy']['instance_name'],
                    http_content['deploy'].get('description',http_content['deploy']['instance_name']),
                    http_content['deploy'].get('datacenter') )
        if result < 0:
            print "http_post_scenario_action deploy error %d: %s" % (-result, data)
            bottle.abort(-result, data)
        else:
            return format_out(data)
    elif "reserve" in http_content:   #Reserve resources
        result, data = nfvo.start_scenario(mydb, tenant_id, scenario_id, http_content['reserve']['instance_name'],
                    http_content['reserve'].get('description',http_content['reserve']['instance_name']),
                    http_content['reserve'].get('datacenter'),  startvms=False )
        if result < 0:
            print "http_post_scenario_action reserve error %d: %s" % (-result, data)
            bottle.abort(-result, data)
        else:
            return format_out(data)
    elif "verify" in http_content:   #Equivalent to start and then delete
        result, data = nfvo.start_scenario(mydb, tenant_id, scenario_id, http_content['verify']['instance_name'],
                    http_content['verify'].get('description',http_content['verify']['instance_name']),
                    http_content['verify'].get('datacenter'), startvms=False )
        if result < 0 or result!=1:
            print "http_post_scenario_action verify error during start %d: %s" % (-result, data)
            bottle.abort(-result, data)
        instance_id = data['uuid']
        result, message = nfvo.delete_instance(mydb, tenant_id,instance_id)
        if result < 0:
            print "http_post_scenario_action verify error during start delete_instance_id %d %s" % (-result, message)
            bottle.abort(-result, message)
        else:
            #print json.dumps(data, indent=4)
            return format_out({"result":"Verify OK"})
开发者ID:bbandaru,项目名称:openmano,代码行数:54,代码来源:httpserver.py


示例8: http_get_datacenter_id

def http_get_datacenter_id(tenant_id, datacenter_id):
    '''get datacenter details, can use both uuid or name'''
    #check valid tenant_id
    if tenant_id != 'any':
        if not nfvo.check_tenant(mydb, tenant_id): 
            print 'httpserver.http_get_datacenter_id () tenant %s not found' % tenant_id
            bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
            return
    #obtain data
    what = 'uuid' if af.check_valid_uuid(datacenter_id) else 'name'
    where_={}
    where_[what] = datacenter_id
    select_=['uuid', 'name','vim_url', 'vim_url_admin', 'type', 'config', 'description', 'd.created_at as created_at']
    if tenant_id != 'any':
        select_.append("datacenter_tenant_id")
        where_['td.nfvo_tenant_id']= tenant_id
        from_='datacenters as d join tenants_datacenters as td on d.uuid=td.datacenter_id'
    else:
        from_='datacenters as d'
    result, content = mydb.get_table(
                SELECT=select_,
                FROM=from_,
                WHERE=where_)

    if result < 0:
        print "http_get_datacenter_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    elif result==0:
        bottle.abort( HTTP_Not_Found, "No datacenter found for tenant with %s '%s'" %(what, datacenter_id) )
    elif result>1: 
        bottle.abort( HTTP_Bad_Request, "More than one datacenter found for tenant with %s '%s'" %(what, datacenter_id) )

    if tenant_id != 'any':
        #get vim tenant info
        result, content2 = mydb.get_table(
                SELECT=("vim_tenant_name", "vim_tenant_id", "user"),
                FROM="datacenter_tenants",
                WHERE={"uuid": content[0]["datacenter_tenant_id"]},
                ORDER_BY=("created", ) )
        del content[0]["datacenter_tenant_id"]
        if result < 0:
            print "http_get_datacenter_id vim_tenant_info error %d %s" % (result, content2)
            bottle.abort(-result, content2)
        content[0]["vim_tenants"] = content2

    print content
    if content[0]['config'] != None:
        try:
            config_dict = yaml.load(content[0]['config'])
            content[0]['config'] = config_dict
        except Exception, e:
            print "Exception '%s' while trying to load config information" % str(e)
开发者ID:DorChen,项目名称:openmano,代码行数:52,代码来源:httpserver.py


示例9: http_delete_instance_id

def http_delete_instance_id(tenant_id, instance_id):
    '''delete instance from VIM and from database, can use both uuid or name'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_delete_instance_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    #obtain data
    result, message = nfvo.delete_instance(mydb, tenant_id,instance_id)
    if result < 0:
        print "http_delete_instance_id error %d %s" % (-result, message)
        bottle.abort(-result, message)
    else:
        #print json.dumps(data, indent=4)
        return format_out({"result":message})
开发者ID:bbandaru,项目名称:openmano,代码行数:15,代码来源:httpserver.py


示例10: http_delete_scenario_id

def http_delete_scenario_id(tenant_id, scenario_id):
    '''delete a scenario from database, can use both uuid or name'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_delete_scenario_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    #obtain data
    result, data = mydb.delete_scenario(scenario_id, tenant_id)
    if result < 0:
        print "http_delete_scenario_id error %d %s" % (-result, data)
        bottle.abort(-result, data)
    else:
        #print json.dumps(data, indent=4)
        return format_out({"result":"Scenario " + data + " deleted"})
开发者ID:bbandaru,项目名称:openmano,代码行数:15,代码来源:httpserver.py


示例11: http_get_scenario_id

def http_get_scenario_id(tenant_id, scenario_id):
    '''get scenario details, can use both uuid or name'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_get_scenario_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    #obtain data
    result, content = mydb.get_scenario(scenario_id, tenant_id)
    if result < 0:
        print "http_get_scenario_id error %d %s" % (-result, content)
        bottle.abort(-result, content)
    else:
        #print json.dumps(content, indent=4)
        data={'scenario' : content}
        return format_out(data)
开发者ID:bbandaru,项目名称:openmano,代码行数:16,代码来源:httpserver.py


示例12: http_post_instances

def http_post_instances(tenant_id):
    '''take an action over a scenario'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_post_scenario_action() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    #parse input data
    http_content,used_schema = format_in( instance_scenario_create_schema)
    r = af.remove_extra_items(http_content, used_schema)
    if r is not None: print "http_post_instances: Warning: remove extra items ", r
    result, data = nfvo.create_instance(mydb, tenant_id, http_content["instance"])
    if result < 0:
        print "http_post_instances start error %d: %s" % (-result, data)
        bottle.abort(-result, data)
    else:
        return format_out(data)
开发者ID:antoniorafaelbraga,项目名称:openmano,代码行数:17,代码来源:httpserver.py


示例13: http_get_vnfs

def http_get_vnfs(tenant_id):
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_get_vnf_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    select_,where_,limit_ = filter_query_string(bottle.request.query, None,
            ('uuid','name','description','path','physical','public', "created_at") )
    result, content = mydb.get_table(FROM='vnfs', SELECT=select_,WHERE=where_,LIMIT=limit_)
    if result < 0:
        print "http_get_vnfs Error", content
        bottle.abort(-result, content)
    else:
        #change_keys_http2db(content, http2db_vnf, reverse=True)
        af.convert_str2boolean(content, ('physical','public',))
        convert_datetime2str(content)
        data={'vnfs' : content}
        return format_out(data)
开发者ID:bbandaru,项目名称:openmano,代码行数:18,代码来源:httpserver.py


示例14: http_get_instances

def http_get_instances(tenant_id):
    '''get instance list'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_get_instances() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    #obtain data
    s,w,l=filter_query_string(bottle.request.query, None, ('uuid', 'name', 'scenario_id', 'description', 'created_at'))
    w['nfvo_tenant_id'] = tenant_id
    result, data = mydb.get_table(SELECT=s, WHERE=w, LIMIT=l, FROM='instance_scenarios')
    if result < 0:
        print "http_get_instances error %d %s" % (-result, data)
        bottle.abort(-result, data)
    else:
        af.convert_datetime2str(data)
        af.convert_str2boolean(data, ('public',) )
        instances={'instances':data}
        print json.dumps(instances, indent=4)
        return format_out(instances)
开发者ID:bbandaru,项目名称:openmano,代码行数:20,代码来源:httpserver.py


示例15: http_get_scenarios

def http_get_scenarios(tenant_id):
    """get scenarios list"""
    # check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id):
        print "httpserver.http_get_scenarios() tenant %s not found" % tenant_id
        bottle.abort(HTTP_Not_Found, "Tenant %s not found" % tenant_id)
        return
    # obtain data
    s, w, l = filter_query_string(bottle.request.query, None, ("uuid", "name", "description", "created_at", "public"))
    w["nfvo_tenant_id"] = tenant_id
    result, data = mydb.get_table(SELECT=s, WHERE=w, LIMIT=l, FROM="scenarios")
    if result < 0:
        print "http_get_scenarios error %d %s" % (-result, data)
        bottle.abort(-result, data)
    else:
        af.convert_datetime2str(data)
        af.convert_str2boolean(data, ("public",))
        scenarios = {"scenarios": data}
        print json.dumps(scenarios, indent=4)
        return format_out(scenarios)
开发者ID:312v,项目名称:playnet,代码行数:20,代码来源:httpserver.py


示例16: http_get_network_id

def http_get_network_id(tenant_id, network_id):
    '''get network details, can use both uuid or name'''
    #check valid tenant_id
    if tenant_id != 'any':
        if not nfvo.check_tenant(mydb, tenant_id): 
            print 'httpserver.http_get_network_id () tenant %s not found' % tenant_id
            bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
            return
    #obtain data
    what = 'uuid' if af.check_valid_uuid(network_id) else 'name'
    where_={}
    where_[what] = network_id
    select_=('uuid', 'name','vim_url', 'vim_url_admin', 'type', 'config', 'description', 'd.created_at as created_at')
    if tenant_id != 'any':
        where_['td.nfvo_tenant_id']= tenant_id
        from_='networks as d join tenants_networks as td on d.uuid=td.network_id'
    else:
        from_='networks as d'
    result, content = mydb.get_table(
                SELECT=select_,
                FROM=from_,
                WHERE=where_)

    if result < 0:
        print "http_get_network_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    elif result==0:
        bottle.abort( HTTP_Not_Found, "No network found for tenant with %s '%s'" %(what, network_id) )
    elif result>1: 
        bottle.abort( HTTP_Bad_Request, "More than one network found for tenant with %s '%s'" %(what, network_id) )


    print content
    if content[0]['config'] != None:
        try:
            config_dict = yaml.load(content[0]['config'])
            content[0]['config'] = config_dict
        except Exception, e:
            print "Exception '%s' while trying to load config information" % str(e)
开发者ID:312v,项目名称:playnetmanotest,代码行数:39,代码来源:httpserver.py


示例17: http_get_datacenter_id

def http_get_datacenter_id(tenant_id, datacenter_id):
    '''get datacenter details, can use both uuid or name'''
    #check valid tenant_id
    if tenant_id != 'any':
        if not nfvo.check_tenant(mydb, tenant_id): 
            print 'httpserver.http_get_datacenter_id () tenant %s not found' % tenant_id
            bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
            return
    #obtain data
    what = 'uuid' if af.check_valid_uuid(datacenter_id) else 'name'
    where={}
    where[what] = datacenter_id
    if tenant_id != 'any':
        where['td.nfvo_tenant_id']= tenant_id
        result, content = mydb.get_table(
                SELECT=('uuid', 'name','vim_url', 'vim_url_admin', 'd.created_at as created_at'),
                FROM='datacenters as d join tenants_datacenters as td on d.uuid=td.datacenter_id',
                WHERE=where)
    else:
        result, content = mydb.get_table(
                SELECT=('uuid', 'name','vim_url', 'vim_url_admin', 'created_at'),
                FROM='datacenters',
                WHERE=where)

    if result < 0:
        print "http_get_datacenter_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    elif result==0:
        bottle.abort( HTTP_Not_Found, "No datacenter found for tenant with %s '%s'" %(what, datacenter_id) )
    elif result>1: 
        bottle.abort( HTTP_Bad_Request, "More than one datacenter found for tenant with %s '%s'" %(what, datacenter_id) )


    print content
    #change_keys_http2db(content, http2db_datacenter, reverse=True)
    convert_datetime2str(content[0])
    data={'datacenter' : content[0]}
    return format_out(data)
开发者ID:biddyweb,项目名称:openmano,代码行数:38,代码来源:httpserver.py


示例18: http_get_scenarios

def http_get_scenarios(tenant_id):
    '''get scenarios list'''
    #check valid tenant_id
    if tenant_id != "any" and not nfvo.check_tenant(mydb, tenant_id): 
        print "httpserver.http_get_scenarios() tenant '%s' not found" % tenant_id
        bottle.abort(HTTP_Not_Found, "Tenant '%s' not found" % tenant_id)
        return
    #obtain data
    s,w,l=filter_query_string(bottle.request.query, None, ('uuid', 'name', 'description', 'tenant_id', 'created_at', 'public'))
    where_or={}
    if tenant_id != "any":
        where_or["tenant_id"] = tenant_id
        where_or["public"] = True
    result, data = mydb.get_table(SELECT=s, WHERE=w, WHERE_OR=where_or, WHERE_AND_OR="AND", LIMIT=l, FROM='scenarios')
    if result < 0:
        print "http_get_scenarios error %d %s" % (-result, data)
        bottle.abort(-result, data)
    else:
        convert_datetime2str(data)
        af.convert_str2boolean(data, ('public',) )
        scenarios={'scenarios':data}
        #print json.dumps(scenarios, indent=4)
        return format_out(scenarios)
开发者ID:DorChen,项目名称:openmano,代码行数:23,代码来源:httpserver.py


示例19: http_get_instance_id

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)
开发者ID:bbandaru,项目名称:openmano,代码行数:36,代码来源:httpserver.py


示例20: http_get_vnf_id

def http_get_vnf_id(tenant_id,vnf_id):
    '''get vnf details, can use both uuid or name'''
    #check valid tenant_id
    if not nfvo.check_tenant(mydb, tenant_id): 
        print 'httpserver.http_get_vnf_id() tenant %s not found' % tenant_id
        bottle.abort(HTTP_Not_Found, 'Tenant %s not found' % tenant_id)
        return
    #obtain data
    result, content = mydb.get_table_by_uuid_name('vnfs', vnf_id, "VNF") 
    if result < 0:
        print "http_get_vnf_id error %d %s" % (result, content)
        bottle.abort(-result, content)

    
    vnf_id=content["uuid"]
    filter_keys = ('uuid','name','description','path','physical','public', "created_at")
    filtered_content = dict( (k,v) for k,v in content.iteritems() if k in filter_keys )
    #change_keys_http2db(filtered_content, http2db_vnf, reverse=True)
    af.convert_str2boolean(filtered_content, ('physical','public',))
    convert_datetime2str(filtered_content)
    data={'vnf' : filtered_content}
    #GET VM
    result,content = mydb.get_table(FROM='vnfs join vms on vnfs.uuid=vms.vnf_id',
            SELECT=('vms.uuid as uuid','vms.name as name', 'vms.description as description'), 
            WHERE={'vnfs.uuid': vnf_id} )
    if result < 0:
        print "http_get_vnf_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    elif result==0:
        print "http_get_vnf_id vnf '%s' not found" % vnf_id
        bottle.abort(HTTP_Not_Found, "vnf %s not found" % vnf_id)

    data['vnf']['VNFC'] = content
    #GET NET
    result,content = mydb.get_table(FROM='vnfs join nets on vnfs.uuid=nets.vnf_id', 
                                    SELECT=('nets.uuid as uuid','nets.name as name','nets.description as description', 'nets.type as type', 'nets.multipoint as multipoint'),
                                    WHERE={'vnfs.uuid': vnf_id} )
    print content
    if result < 0:
        print "http_get_vnf_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    else:
        if result==0:
            data['vnf']['nets'] = []
        else:
            data['vnf']['nets'] = content
    #GET Interfaces
    result,content = mydb.get_table(FROM='vnfs join vms on vnfs.uuid=vms.vnf_id join interfaces on vms.uuid=interfaces.vm_id',\
                                    SELECT=('interfaces.uuid as uuid','interfaces.external_name as external_name', 'vms.name as vm_name', 'interfaces.vm_id as vm_id', \
                                            'interfaces.internal_name as internal_name', 'interfaces.type as type', 'interfaces.vpci as vpci','interfaces.bw as bw'),\
                                    WHERE={'vnfs.uuid': vnf_id}, 
                                    WHERE_NOTNULL=('interfaces.external_name',) )
    print content
    if result < 0:
        print "http_get_vnf_id error %d %s" % (result, content)
        bottle.abort(-result, content)
    else:
        if result==0:
            data['vnf']['external-connections'] = []
        else:
            data['vnf']['external-connections'] = content
    return format_out(data)
开发者ID:bbandaru,项目名称:openmano,代码行数:62,代码来源:httpserver.py



注:本文中的nfvo.check_tenant函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python layerDataModel.LayerDataModel类代码示例发布时间:2022-05-27
下一篇:
Python nfs4lib.test_equal函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap