本文整理匯總了Python中quantumclient.Client.list_networks方法的典型用法代碼示例。如果您正苦於以下問題:Python Client.list_networks方法的具體用法?Python Client.list_networks怎麽用?Python Client.list_networks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類quantumclient.Client
的用法示例。
在下文中一共展示了Client.list_networks方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: APITest
# 需要導入模塊: from quantumclient import Client [as 別名]
# 或者: from quantumclient.Client import list_networks [as 別名]
class APITest(unittest.TestCase):
def setUp(self):
""" Setups a test environment for the API client """
HOST = '127.0.0.1'
PORT = 9696
USE_SSL = False
self.client = Client(HOST, PORT, USE_SSL, TENANT_1, 'json', ServerStub)
def _assert_sanity(self, call, status, method, path, data=[], params={}):
""" Perform common assertions to test the sanity of client requests """
# Handle an error case first
if status != 200:
(self.client.host, self.client.port) = ("10.0.0.1", status)
self.assertRaises(Exception, call, *data, **params)
return
# Make the call, then get the data from the root node and assert it
data = call(*data, **params)['data']
self.assertEqual(data['method'], method)
self.assertEqual(data['format'], params['format'])
self.assertEqual(data['tenant'], params['tenant'])
self.assertEqual(data['path'], path)
return data
def _test_list_networks(self, tenant=TENANT_1, format='json', status=200):
LOG.debug("_test_list_networks - tenant:%s "
"- format:%s - START", format, tenant)
self._assert_sanity(self.client.list_networks,
status,
"GET",
"networks",
data=[],
params={'tenant': tenant, 'format': format})
LOG.debug("_test_list_networks - tenant:%s - format:%s - END",
format, tenant)
def _test_list_networks_details(self,
tenant=TENANT_1, format='json',
status=200):
LOG.debug("_test_list_networks_details - tenant:%s "
"- format:%s - START", format, tenant)
self._assert_sanity(self.client.list_networks_details,
status,
"GET",
"networks/detail",
data=[],
params={'tenant': tenant, 'format': format})
LOG.debug("_test_list_networks_details - tenant:%s "
"- format:%s - END", format, tenant)
def _test_show_network(self,
tenant=TENANT_1, format='json', status=200):
LOG.debug("_test_show_network - tenant:%s "
"- format:%s - START", format, tenant)
self._assert_sanity(self.client.show_network,
status,
"GET",
"networks/001",
data=["001"],
params={'tenant': tenant, 'format': format})
LOG.debug("_test_show_network - tenant:%s "
"- format:%s - END", format, tenant)
def _test_show_network_details(self,
tenant=TENANT_1, format='json', status=200):
LOG.debug("_test_show_network_details - tenant:%s "
"- format:%s - START", format, tenant)
self._assert_sanity(self.client.show_network_details,
status,
"GET",
"networks/001/detail",
data=["001"],
params={'tenant': tenant, 'format': format})
LOG.debug("_test_show_network_details - tenant:%s "
"- format:%s - END", format, tenant)
def _test_create_network(self, tenant=TENANT_1, format='json', status=200):
LOG.debug("_test_create_network - tenant:%s "
"- format:%s - START", format, tenant)
self._assert_sanity(self.client.create_network,
status,
"POST",
"networks",
data=[{'network': {'net-name': 'testNetwork'}}],
params={'tenant': tenant, 'format': format})
#.........這裏部分代碼省略.........