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


Python ProfitBricksService.delete_loadbalancer方法代碼示例

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


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

示例1: TestLoadBalancer

# 需要導入模塊: from profitbricks.client import ProfitBricksService [as 別名]
# 或者: from profitbricks.client.ProfitBricksService import delete_loadbalancer [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)
開發者ID:grandvizier,項目名稱:profitbricks-sdk-python,代碼行數:101,代碼來源:test_loadbalancer.py


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