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


Python ApiSession.post方法代碼示例

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


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

示例1: test_ssl_vs

# 需要導入模塊: from avi.sdk.avi_api import ApiSession [as 別名]
# 或者: from avi.sdk.avi_api.ApiSession import post [as 別名]
 def test_ssl_vs(self):
     papi = ApiSession(api.controller_ip, api.username, api.password,
                       verify=False)
     ssl_vs_cfg = gSAMPLE_CONFIG["SSL-VS"]
     vs_obj = ssl_vs_cfg["vs_obj"]
     pool_name = gSAMPLE_CONFIG["SSL-VS"]["pool_obj"]["name"]
     resp = papi.post('pool', data=json.dumps(ssl_vs_cfg["pool_obj"]))
     pool_ref = papi.get_obj_ref(resp.json())
     cert, key, _, _ = get_sample_ssl_params(folder_path='../samples/')
     api_utils = ApiUtils(papi)
     try:
         resp = api_utils.import_ssl_certificate("ssl-vs-kc", key, cert)
         ssl_kc = resp.json()
     except:
         ssl_kc = api.get_object_by_name('sslkeyandcertificate',
                                         'ssl-vs-kc')
     ssl_key_and_cert_ref = [papi.get_obj_ref(ssl_kc)]
     vs_obj["pool_ref"] = pool_ref
     vs_obj["ssl_key_and_certificate_refs"] = ssl_key_and_cert_ref
     resp = papi.post('virtualservice', data=json.dumps(vs_obj))
     assert resp.status_code < 300
     resp = papi.delete_by_name('virtualservice', vs_obj['name'])
     assert resp.status_code in (200, 204)
     resp = papi.delete_by_name("pool", pool_name)
     assert resp.status_code in (200, 204)
     resp = api.delete_by_name('sslkeyandcertificate', 'ssl-vs-kc')
     assert resp.status_code in (200, 204)
開發者ID:DanGreenwell,項目名稱:sdk,代碼行數:29,代碼來源:test_avi_api.py

示例2: test_multiple_tenants

# 需要導入模塊: from avi.sdk.avi_api import ApiSession [as 別名]
# 或者: from avi.sdk.avi_api.ApiSession import post [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

示例3: test_session_reset

# 需要導入模塊: from avi.sdk.avi_api import ApiSession [as 別名]
# 或者: from avi.sdk.avi_api.ApiSession import post [as 別名]
 def test_session_reset(self):
     papi = ApiSession(api.controller_ip, api.username, api.password,
                       verify=False, api_version=api.api_version)
     res = papi.get('pool', params={'fields': 'name'})
     assert res.status_code == 200
     papi.reset_session()
     res = papi.get('pool', params={'fields': 'name'})
     assert res.status_code == 200
     data = {'name': 'test-reset'}
     res = papi.post('pool', data=data)
     assert res.status_code == 201
     papi.reset_session()
     res = papi.delete_by_name('pool', 'test-reset')
     assert res.status_code == 204
開發者ID:ypraveen,項目名稱:sdk,代碼行數:16,代碼來源:test_avi_api.py


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