當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。