當前位置: 首頁>>代碼示例>>Python>>正文


Python ApiSession.get_object_by_name方法代碼示例

本文整理匯總了Python中avi.sdk.avi_api.ApiSession.get_object_by_name方法的典型用法代碼示例。如果您正苦於以下問題:Python ApiSession.get_object_by_name方法的具體用法?Python ApiSession.get_object_by_name怎麽用?Python ApiSession.get_object_by_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在avi.sdk.avi_api.ApiSession的用法示例。


在下文中一共展示了ApiSession.get_object_by_name方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_multiple_tenants

# 需要導入模塊: from avi.sdk.avi_api import ApiSession [as 別名]
# 或者: from avi.sdk.avi_api.ApiSession import get_object_by_name [as 別名]
 def test_multiple_tenants(self):
     """
     Tests api with multiple tenants to make sure object is only returned
     for the right tenant.
     """
     tobj = {'name': 'test-tenant'}
     resp = api.post('tenant', data=tobj)
     assert resp.status_code in (200, 201)
     tapi = ApiSession(api.controller_ip, api.username, api.password,
                       tenant=tobj['name'], verify=False)
     t_obj = tapi.get_object_by_name('tenant', tobj['name'])
     # created pool.
     log.info('tenant %s', t_obj)
     basic_vs_cfg = gSAMPLE_CONFIG["BasicVS"]
     pool_cfg = copy.deepcopy(basic_vs_cfg["pool_obj"])
     pool_cfg['name'] = pool_cfg['name'] + '-test-tenant'
     resp = tapi.post('pool', data=pool_cfg)
     assert resp.status_code in (200, 201)
     # check pool was not created in tenant admin
     pname = pool_cfg['name']
     resp = api.get_object_by_name('pool', pname)
     assert resp is None
     resp = tapi.get_object_by_name('pool', pname)
     assert resp
     resp = api.get_object_by_name('pool', pname, tenant_uuid=t_obj['uuid'])
     assert resp
     resp = api.get_object_by_name('pool', pname, tenant='test-tenant')
     assert resp
     resp = tapi.delete_by_name("pool", pname)
     assert resp.status_code in (200, 204)
     resp = api.get_object_by_name('pool', pname, tenant='test-tenant')
     assert resp is None
     resp = tapi.delete_by_name('tenant', 'test-tenant', tenant='admin')
     assert resp.status_code in (200, 204)
開發者ID:DanGreenwell,項目名稱:sdk,代碼行數:36,代碼來源:test_avi_api.py

示例2: ApiSession

# 需要導入模塊: from avi.sdk.avi_api import ApiSession [as 別名]
# 或者: from avi.sdk.avi_api.ApiSession import get_object_by_name [as 別名]
    parser.add_argument('-u', '--username',
                        help='user name', default='admin')
    parser.add_argument('-p', '--password',
                        help='password', default='admin')


    args = parser.parse_args()
    #print('parsed args', args)

    api_ssn = ApiSession(args.controller, args.username, args.password,
                         args.tenant)
    api_utils = ApiUtils(api_ssn)

    entity_uuid = '*'
    if args.vs_name != '*':
        vs_obj = api_ssn.get_object_by_name('virtualservice', args.vs_name)
        entity_uuid = vs_obj['uuid']

    mq = {
        'metric_id': (args.metrics if args.metrics else 'l4_client.avg_bandwidth,l4_client.avg_complete_conns,l7_client.avg_complete_responses,l7_client.sum_get_reqs, l7_client.sum_post_reqs'),
        'tenant': (args.tenant if args.tenant else 'admin'),
        'step': args.step,
        'limit': args.limit,
        'entity_uuid': entity_uuid,
        'pad_missing_data': False
    }

    rsp = api_utils.get_metrics_collection(tenant=args.tenant,
                                           metric_requests=[mq])
    #print 'metrics query', mq
    print json.dumps(rsp, indent=2)
開發者ID:avinetworks,項目名稱:sdk,代碼行數:33,代碼來源:vs_metrics.py


注:本文中的avi.sdk.avi_api.ApiSession.get_object_by_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。