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


Python ClcPublicIp.ensure_public_ip_present方法代码示例

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


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

示例1: test_ensure_server_publicip_present_w_mock_server

# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import ensure_public_ip_present [as 别名]
 def test_ensure_server_publicip_present_w_mock_server(self,mock_get_servers):
     server_ids = ['TESTSVR1']
     mock_get_servers.return_value=[mock.MagicMock()]
     protocol = 'TCP'
     ports = [80]
     self.module.check_mode = False
     under_test = ClcPublicIp(self.module)
     under_test.ensure_public_ip_present(server_ids, protocol, ports)
     self.assertFalse(self.module.fail_json.called)
开发者ID:cgeers,项目名称:clc-ansible-module,代码行数:11,代码来源:test_clc_publicip.py

示例2: test_ensure_server_publicip_present_w_mock_server

# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import ensure_public_ip_present [as 别名]
 def test_ensure_server_publicip_present_w_mock_server(self,mock_get_server):
     server_id = 'TESTSVR1'
     mock_get_server.return_value=mock.MagicMock()
     ports = [
         {'port': 80},
         {'port': 90, 'protocol': 'TCP'}
     ]
     self.module.check_mode = False
     under_test = ClcPublicIp(self.module)
     under_test.ensure_public_ip_present(server_id, ports)
     self.assertFalse(self.module.fail_json.called)
开发者ID:bjfelton,项目名称:clc-ansible-module,代码行数:13,代码来源:test_clc_publicip.py

示例3: test_ensure_server_publicip_present_w_mock_server_restrictions

# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import ensure_public_ip_present [as 别名]
 def test_ensure_server_publicip_present_w_mock_server_restrictions(self,mock_get_servers):
     server_ids = ['TESTSVR1']
     mock_get_servers.return_value=[mock.MagicMock()]
     protocol = 'TCP'
     ports = [80]
     restrictions = ['1.1.1.1/24', '2.2.2.0/36']
     self.module.check_mode = False
     under_test = ClcPublicIp(self.module)
     under_test.ensure_public_ip_present(server_ids=server_ids,
                                         protocol=protocol,
                                         ports=ports,
                                         source_restrictions=restrictions)
     self.assertFalse(self.module.fail_json.called)
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:15,代码来源:test_clc_publicip.py

示例4: test_ensure_server_publicip_present_w_mock_server_restrictions

# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import ensure_public_ip_present [as 别名]
 def test_ensure_server_publicip_present_w_mock_server_restrictions(self,mock_get_server):
     server_id = 'TESTSVR1'
     mock_get_server.return_value=mock.MagicMock()
     ports = [
         {'port': 80},
         {'port': 1290, 'protocol': 'UDP'}
     ]
     restrictions = ['1.1.1.1/24', '2.2.2.0/36']
     self.module.check_mode = False
     under_test = ClcPublicIp(self.module)
     under_test.ensure_public_ip_present(server_id=server_id,
                                         ports=ports,
                                         source_restrictions=restrictions)
     self.assertFalse(self.module.fail_json.called)
开发者ID:bjfelton,项目名称:clc-ansible-module,代码行数:16,代码来源:test_clc_publicip.py

示例5: test_ensure_server_publicip_present_calls_private_helper_with_expected_args

# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import ensure_public_ip_present [as 别名]
 def test_ensure_server_publicip_present_calls_private_helper_with_expected_args(self,mock_get_server,mock_add_ip):
     server_id = 'TESTSVR1'
     mock_server = mock.MagicMock()
     mock_get_server.return_value=mock_server
     private_ip = '2.4.6.01'
     ports = [
         {'port': 80},
         {'port': 1290, 'protocol': 'UDP'}
     ]
     restrictions = ['not now']
     self.module.check_mode = False
     under_test = ClcPublicIp(self.module)
     under_test.ensure_public_ip_present(server_id=server_id,
                                         private_ip=private_ip,
                                         ports=ports,
                                         source_restrictions=restrictions)
     mock_add_ip.assert_called_once_with(
         mock_server
         , ports
         , private_ip=private_ip
         , source_restrictions=[{'cidr': restrictions[0]}]
     )
开发者ID:bjfelton,项目名称:clc-ansible-module,代码行数:24,代码来源:test_clc_publicip.py

示例6: test_ensure_server_publicip_present_returns_expected_data

# 需要导入模块: from clc_ansible_module.clc_publicip import ClcPublicIp [as 别名]
# 或者: from clc_ansible_module.clc_publicip.ClcPublicIp import ensure_public_ip_present [as 别名]
    def test_ensure_server_publicip_present_returns_expected_data(self,mock_get_server):
        server_id = 'TESTSVR1'
        mock_server = mock.MagicMock()
        mock_server.id = server_id
        mock_server.PublicIPs().Add.return_value = 'Awesome Result'
        mock_get_server.return_value=mock_server
        ports = [
            {'port': 80},
            {'port': 1290, 'protocol': 'UDP'}
        ]

        self.module.check_mode = False
        under_test = ClcPublicIp(self.module)

        changed, changed_server_id, result = under_test.ensure_public_ip_present(server_id, ports)

        self.assertEqual(True, changed)
        self.assertEqual(server_id, changed_server_id)
        self.assertEqual('Awesome Result', result)
开发者ID:bjfelton,项目名称:clc-ansible-module,代码行数:21,代码来源:test_clc_publicip.py


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