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


Python ProfitBricksService.delete_firewall_rule方法代码示例

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


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

示例1: TestFirewall

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import delete_firewall_rule [as 别名]
class TestFirewall(unittest.TestCase):
    def setUp(self):
        self.firewall = ProfitBricksService(username='username', password='password')

    def test_get_all(self):
        firewalls = self.firewall.get_firewall_rules(
            datacenter_id=datacenter_id,
            server_id=server_id,
            nic_id=nic_id)

        self.assertEqual(len(firewalls), 4)
        self.assertEqual(firewalls['items'][0]['id'], firewall_rule_id)
        self.assertEqual(firewalls['items'][0]['properties']['name'], 'Open SSH port')
        self.assertEqual(firewalls['items'][0]['properties']['portRangeStart'], 22)

    def test_get(self):
        firewall = self.firewall.get_firewall_rule(
            datacenter_id=datacenter_id,
            server_id=server_id,
            nic_id=nic_id,
            firewall_rule_id=firewall_rule_id)

        self.assertEqual(firewall['id'], firewall_rule_id)
        self.assertEqual(firewall['properties']['name'], 'Open SSH port')
        self.assertEqual(firewall['properties']['portRangeStart'], 22)

    def test_delete(self):
        firewall = self.firewall.delete_firewall_rule(
            datacenter_id=datacenter_id,
            server_id=server_id,
            nic_id=nic_id,
            firewall_rule_id=firewall_rule_id)

        self.assertTrue(firewall)

    def test_update(self):
        firewall = self.firewall.update_firewall_rule(
            datacenter_id=datacenter_id,
            server_id=server_id,
            nic_id=nic_id,
            firewall_rule_id=firewall_rule_id,
            source_mac='01:98:22:22:44:22',
            target_ip='123.100.101.102')

        self.assertEqual(firewall['id'], firewall_rule_id)
        self.assertEqual(firewall['properties']['name'], 'Open SSH port')
        self.assertEqual(firewall['properties']['portRangeStart'], 22)
        self.assertEqual(
            firewall['properties']['sourceMac'], '01:98:22:22:44:22')
        self.assertEqual(
            firewall['properties']['targetIp'], '123.100.101.102')

    def test_create(self):
        i = FirewallRule(
            name='Open SSH port',
            protocol='TCP'
            )

        response = self.firewall.create_firewall_rule(
            datacenter_id=datacenter_id,
            server_id=server_id,
            nic_id=nic_id,
            firewall_rule=i)

        self.assertEqual(response['id'], firewall_rule_id)
        self.assertEqual(response['properties']['name'], 'Open SSH port')
        self.assertEqual(response['properties']['portRangeStart'], 22)
        self.assertEqual(response['properties']['protocol'], 'TCP')
        self.assertEqual(
            response['properties']['sourceMac'], '01:23:45:67:89:00')

    def test_create_optional_value(self):
        i = FirewallRule(
            name='Open SSH port',
            protocol='TCP',
            source_mac='01:23:45:67:89:00',
            source_ip='12.2.11.22',
            port_range_start=22,
            port_range_end=1000
            )

        response = self.firewall.create_firewall_rule(
            datacenter_id=datacenter_id,
            server_id=server_id,
            nic_id=nic_id,
            firewall_rule=i)

        self.assertEqual(response['id'], firewall_rule_id)
        self.assertEqual(response['properties']['name'], 'Open SSH port')
        self.assertEqual(response['properties']['portRangeStart'], 22)
        self.assertEqual(response['properties']['protocol'], 'TCP')
开发者ID:grandvizier,项目名称:profitbricks-sdk-python,代码行数:93,代码来源:test_firewall.py


注:本文中的profitbricks.client.ProfitBricksService.delete_firewall_rule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。