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


Python clc_loadbalancer.ClcLoadBalancer类代码示例

本文整理汇总了Python中clc_ansible_module.clc_loadbalancer.ClcLoadBalancer的典型用法代码示例。如果您正苦于以下问题:Python ClcLoadBalancer类的具体用法?Python ClcLoadBalancer怎么用?Python ClcLoadBalancer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_ensure_loadbalancerpool_present_no_lb_id

 def test_ensure_loadbalancerpool_present_no_lb_id(self):
     under_test = ClcLoadBalancer(self.module)
     changed, result, pool_id = under_test.ensure_loadbalancerpool_present(
         None, 'alias', 'location', 'method', 'persistence', 'port')
     self.assertEqual(changed, False)
     self.assertEqual(result, None)
     self.assertEqual(pool_id, None)
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:7,代码来源:test_clc_loadbalancer.py

示例2: test_process_request_state_present

    def test_process_request_state_present(self,
                                           mock_set_clc_credentials,
                                           mock_clc_sdk):

        # Setup
        self.module.params = {
            'name': 'test',
            'port': 80,
            'nodes':[{ 'ipAddress': '10.82.152.15', 'privatePort': 80 }],
            'state': 'present'
        }
        mock_loadbalancer_response = [{'name': 'TEST_LB'}]

        mock_clc_sdk.v2.API.Call.side_effect = [
            [{'name': 'test'}],
            {'id': 'test', 'name': 'test'},
            [],
            {'id': 'test', 'name': 'test'},
            []
        ]
        # TODO: Mock a response to API.Call('POST')
        self.module.check_mode = False
        # Under Test
        under_test = ClcLoadBalancer(self.module)
        under_test.process_request()

        # Assert
        self.module.exit_json.assert_called_once_with(changed=False, loadbalancer = {'id': 'test', 'name': 'test'})
        self.assertFalse(self.module.fail_json.called)
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:29,代码来源:test_clc_loadbalancer.py

示例3: test_set_loadbalancernodes_exception

 def test_set_loadbalancernodes_exception(self, mock_clc_sdk):
     error = APIFailedResponse('Failed')
     error.response_text = 'Mock failure response'
     mock_clc_sdk.v2.API.Call.side_effect = error
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     result = test.set_loadbalancernodes('alias', 'location', 'lb_id', 'pool_id', [1,2,3])
     self.module.fail_json.assert_called_with(msg='Unable to set nodes for the load balancer pool id "pool_id". Mock failure response')
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:8,代码来源:test_clc_loadbalancer.py

示例4: test_create_loadbalancerpool_exception

 def test_create_loadbalancerpool_exception(self, mock_clc_sdk):
     error = APIFailedResponse('Failed')
     error.response_text = 'Mock failure response'
     mock_clc_sdk.v2.API.Call.side_effect = error
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     result = test.create_loadbalancerpool('alias', 'location', 'lb_id', 'method', 'persistance', 'port')
     self.module.fail_json.assert_called_with(msg='Unable to create pool for load balancer id "lb_id". Mock failure response')
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:8,代码来源:test_clc_loadbalancer.py

示例5: test_create_loadbalancer_exception

 def test_create_loadbalancer_exception(self, mock_clc_sdk):
     error = APIFailedResponse('Failed')
     error.response_text = 'Mock failure response'
     mock_clc_sdk.v2.API.Call.side_effect = error
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     result = test.create_loadbalancer('name', 'alias', 'location', 'description', 'status')
     self.module.fail_json.assert_called_with(msg='Unable to create load balancer "name". Mock failure response')
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:8,代码来源:test_clc_loadbalancer.py

示例6: test_loadbalancerpool_exists_exception

 def test_loadbalancerpool_exists_exception(self, mock_clc_sdk):
     error = APIFailedResponse('Failed')
     error.response_text = 'Mock failure response'
     mock_clc_sdk.v2.API.Call.side_effect = error
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     test._loadbalancerpool_exists('alias', 'location', 90, 'lb_id')
     self.module.fail_json.assert_called_with(msg='Unable to fetch the load balancer pools for for load balancer id: lb_id. Mock failure response')
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:8,代码来源:test_clc_loadbalancer.py

示例7: test_ensure_lbpool_nodes_set_no_lb_pool

 def test_ensure_lbpool_nodes_set_no_lb_pool(self, mock_lb_exists, mock_get_lb, mock_lb_pool_exists):
     mock_lb_exists.return_value = True
     mock_get_lb.return_value = 'lb name'
     mock_lb_pool_exists.return_value = False
     under_test = ClcLoadBalancer(self.module)
     changed, result = under_test.ensure_lbpool_nodes_set('alias', 'location', 'name', 'port', [1,2,3])
     self.assertEqual(changed, False)
     self.assertEqual(result, 'Pool doesn\'t exist')
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:8,代码来源:test_clc_loadbalancer.py

示例8: test_set_clc_credentials_from_env

 def test_set_clc_credentials_from_env(self, mock_clc_sdk):
     with patch.dict('os.environ', {'CLC_V2_API_TOKEN': 'dummyToken',
                                    'CLC_ACCT_ALIAS': 'TEST'}):
         under_test = ClcLoadBalancer(self.module)
         under_test._set_clc_credentials_from_env()
     self.assertEqual(under_test.clc._LOGIN_TOKEN_V2, 'dummyToken')
     self.assertFalse(mock_clc_sdk.v2.SetCredentials.called)
     self.assertEqual(self.module.fail_json.called, False)
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:8,代码来源:test_clc_loadbalancer.py

示例9: test_get_loadbalancer_list_exception

 def test_get_loadbalancer_list_exception(self, mock_clc_sdk):
     error = APIFailedResponse('Failed')
     error.response_text = 'Mock failure response'
     mock_clc_sdk.v2.API.Call.side_effect = error
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     test._get_loadbalancer_list('alias', 'location')
     self.module.fail_json.assert_called_with(msg='Unable to fetch load balancers for account: alias. Mock failure response')
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:8,代码来源:test_clc_loadbalancer.py

示例10: test_get_lbpool_nodes_exception

 def test_get_lbpool_nodes_exception(self, mock_clc_sdk):
     error = APIFailedResponse('Failed')
     error.response_text = 'Mock failure response'
     mock_clc_sdk.v2.API.Call.side_effect = error
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     result = test._get_lbpool_nodes('alias', 'location', 'lb_id', 'pool_id')
     self.module.fail_json.assert_called_with(msg='Unable to fetch list of available nodes for load balancer pool id: pool_id. Mock failure response')
     self.assertEqual(result, None)
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:9,代码来源:test_clc_loadbalancer.py

示例11: test_delete_loadbalancer_exception

 def test_delete_loadbalancer_exception(self, mock_clc_sdk, mock_get):
     error = APIFailedResponse('Failed')
     error.response_text = 'Mock failure response'
     mock_clc_sdk.v2.API.Call.side_effect = error
     mock_get.return_value = 'lb_id'
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     result = test.delete_loadbalancer('alias', 'location', 'name')
     self.module.fail_json.assert_called_with(msg='Unable to delete load balancer "name". Mock failure response')
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:9,代码来源:test_clc_loadbalancer.py

示例12: test_ensure_lbpool_nodes_set

 def test_ensure_lbpool_nodes_set(self, set_lb_nodes, lbpool_nodes_exists, lbpool_exists, get_lb_id, lb_exists, mock_clc_sdk):
     lb_exists.return_value = True
     get_lb_id.return_value = '123'
     lbpool_exists.retrun_value = True
     lbpool_nodes_exists.return_value = False
     set_lb_nodes.return_value = 'success'
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     result = test.ensure_lbpool_nodes_set('alias', 'location', 'name', 80, [1,2,3])
     self.assertEqual(result, (True, 'success'))
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:10,代码来源:test_clc_loadbalancer.py

示例13: test_set_loadbalancernodes_lb_id_none

    def test_set_loadbalancernodes_lb_id_none(self, mock_clc_sdk):

        mock_clc_sdk.v2.API.Call.side_effect = [
            [{'id': 'test', 'name': 'test'}],
            [{'port': '80', 'id':'test'}],
            [{ 'ipAddress': '10.82.152.15', 'privatePort': 81, 'status': 'enabled' }]
        ]
        self.module.check_mode = False
        test = ClcLoadBalancer(self.module)
        result = test.set_loadbalancernodes('alias', 'location', None, 'pool_id', [1,2,3])
        self.assertIsNone(result)
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:11,代码来源:test_clc_loadbalancer.py

示例14: test_loadbalancerpool_nodes_exists_false

 def test_loadbalancerpool_nodes_exists_false(self, mock_get_pool_nodes, mock_clc_sdk):
     #Setup
     self.module.params = {
         'name': 'test',
         'port': 80,
         'nodes':[{ 'ipAddress': '10.82.152.15', 'privatePort': 80, 'status': 'enabled' }],
         'state': 'nodes_absent'
     }
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     mock_get_pool_nodes.return_value = [{ 'ipAddress': '10.82.152.15', 'privatePort': 80, 'status': 'enabled' }]
     result = test._loadbalancerpool_nodes_exists('alias','location','lb_id','pool_id',
                                    [{ 'ipAddress': '10.82.152.15', 'privatePort': 90}])
     self.assertEqual(result, False)
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:14,代码来源:test_clc_loadbalancer.py

示例15: test_remove_lbpool_nodes

 def test_remove_lbpool_nodes(self, mock_set_pool_nodes, mock_get_pool_nodes, mock_clc_sdk):
     #Setup
     self.module.params = {
         'name': 'test',
         'port': 80,
         'nodes':[{ 'ipAddress': '10.82.152.15', 'privatePort': 80, 'status': 'enabled' }],
         'state': 'nodes_absent'
     }
     self.module.check_mode = False
     test = ClcLoadBalancer(self.module)
     mock_get_pool_nodes.return_value = [{ 'ipAddress': '10.82.152.15', 'privatePort': 80, 'status': 'enabled' }]
     mock_set_pool_nodes.return_value = 'success'
     result = test.remove_lbpool_nodes('alias','location','lb_id','pool_id',
                                    [{ 'ipAddress': '10.82.152.15', 'privatePort': 80}])
     self.assertFalse(self.module.fail_json.called)
     self.assertEqual(result, (True, 'success'))
开发者ID:Tier3,项目名称:clc-ansible-module,代码行数:16,代码来源:test_clc_loadbalancer.py


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