当前位置: 首页>>代码示例>>Python>>正文


Python ProfitBricksService.remove_loadbalanced_nic方法代码示例

本文整理汇总了Python中profitbricks.client.ProfitBricksService.remove_loadbalanced_nic方法的典型用法代码示例。如果您正苦于以下问题:Python ProfitBricksService.remove_loadbalanced_nic方法的具体用法?Python ProfitBricksService.remove_loadbalanced_nic怎么用?Python ProfitBricksService.remove_loadbalanced_nic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在profitbricks.client.ProfitBricksService的用法示例。


在下文中一共展示了ProfitBricksService.remove_loadbalanced_nic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestLoadBalancer

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import remove_loadbalanced_nic [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.remove_loadbalanced_nic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。