本文整理匯總了Python中profitbricks.client.ProfitBricksService.get_loadbalancer_members方法的典型用法代碼示例。如果您正苦於以下問題:Python ProfitBricksService.get_loadbalancer_members方法的具體用法?Python ProfitBricksService.get_loadbalancer_members怎麽用?Python ProfitBricksService.get_loadbalancer_members使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類profitbricks.client.ProfitBricksService
的用法示例。
在下文中一共展示了ProfitBricksService.get_loadbalancer_members方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestLoadBalancer
# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import get_loadbalancer_members [as 別名]
class TestLoadBalancer(unittest.TestCase):
def setUp(self):
self.loadbalancer = ProfitBricksService(username="username", password="password")
def test_get_all(self):
loadbalancers = self.loadbalancer.list_loadbalancers(datacenter_id=datacenter_id)
self.assertEqual(len(loadbalancers), 4)
self.assertEqual(loadbalancers["items"][0]["id"], loadbalancer_id)
self.assertEqual(loadbalancers["items"][0]["properties"]["name"], "My LB")
def test_get_loadbalancer(self):
loadbalancer = self.loadbalancer.get_loadbalancer(datacenter_id=datacenter_id, loadbalancer_id=loadbalancer_id)
self.assertEqual(loadbalancer["properties"]["name"], "My LB")
self.assertEqual(loadbalancer["properties"]["ip"], "10.2.2.3")
self.assertTrue(loadbalancer["properties"]["dhcp"])
def test_delete_loadbalancer(self):
loadbalancer = self.loadbalancer.delete_loadbalancer(
datacenter_id=datacenter_id, loadbalancer_id=loadbalancer_id
)
self.assertTrue(loadbalancer)
def test_update_loadbalancer(self):
loadbalancer = self.loadbalancer.update_loadbalancer(
datacenter_id=datacenter_id, loadbalancer_id=loadbalancer_id, ip="10.2.2.4"
)
self.assertEqual(loadbalancer["properties"]["name"], "My LB")
self.assertEqual(loadbalancer["properties"]["ip"], "10.2.2.4")
self.assertTrue(loadbalancer["properties"]["dhcp"])
def test_create_loadbalancer(self):
i = LoadBalancer(name="My LB")
response = self.loadbalancer.create_loadbalancer(datacenter_id=datacenter_id, loadbalancer=i)
self.assertEqual(response["properties"]["name"], "My LB")
self.assertEqual(response["properties"]["ip"], "10.2.2.3")
self.assertTrue(response["properties"]["dhcp"])
def test_create_with_balancednics(self):
balancednics = ["<NIC-ID-1>", "<NIC-ID-2>"]
i = LoadBalancer(name="My LB", balancednics=balancednics)
response = self.loadbalancer.create_loadbalancer(datacenter_id=datacenter_id, loadbalancer=i)
self.assertEqual(response["properties"]["name"], "My LB")
self.assertEqual(response["properties"]["ip"], "10.2.2.3")
self.assertTrue(response["properties"]["dhcp"])
def test_create_optional_value(self):
i = LoadBalancer(name="My LB", ip="10.2.2.3", dhcp=True)
response = self.loadbalancer.create_loadbalancer(datacenter_id=datacenter_id, loadbalancer=i)
self.assertEqual(response["properties"]["name"], "My LB")
self.assertEqual(response["properties"]["ip"], "10.2.2.3")
self.assertTrue(response["properties"]["dhcp"])
def test_get_loadbalancer_members(self):
members = self.loadbalancer.get_loadbalancer_members(
datacenter_id=datacenter_id, loadbalancer_id=loadbalancer_id
)
self.assertEqual(len(members), 4)
self.assertEqual(members["items"][0]["id"], "<NIC-ID>")
self.assertEqual(members["items"][0]["properties"]["name"], "nic1")
self.assertEqual(members["items"][0]["properties"]["mac"], "AB:21:23:09:78:C2")
def test_add_loadbalanced_nic(self):
nic = "<NIC-ID-1"
response = self.loadbalancer.add_loadbalanced_nics(
datacenter_id=datacenter_id, loadbalancer_id=loadbalancer_id, nic_id=nic
)
self.assertEqual(response["properties"]["name"], "nic1")
self.assertEqual(response["properties"]["mac"], "AB:21:23:09:78:C2")
self.assertTrue(response["properties"]["dhcp"])
def test_get_balanced_nic(self):
response = self.loadbalancer.get_loadbalanced_nic(
datacenter_id=datacenter_id, loadbalancer_id=loadbalancer_id, nic_id=nic_id
)
self.assertEqual(response["properties"]["name"], "nic1")
self.assertEqual(response["properties"]["mac"], "AB:21:23:09:78:C2")
self.assertTrue(response["properties"]["dhcp"])
def test_remove_balanced_nic(self):
loadbalancer = self.loadbalancer.remove_loadbalanced_nic(
datacenter_id=datacenter_id, loadbalancer_id=loadbalancer_id, nic_id=nic_id
)
self.assertTrue(loadbalancer)