コード例 #1
0
    def test_cleanup_config_groups(self, client_delete, client_get, get_instance):
        def response(data):
            fake = mock.Mock()
            fake.text = jsonutils.dumps(data)
            fake.raise_for_status.return_value = True
            return fake

        fake_config_groups = {"items": [{"ConfigGroup": {"id": "1"}}, {"ConfigGroup": {"id": "2"}}]}

        config_group1 = {"ConfigGroup": {"id": "1", "group_name": "test:fakename"}}
        config_group2 = {"ConfigGroup": {"id": "2", "group_name": "test:toremove"}}

        fake_ambari = mock.Mock()
        fake_ambari.management_ip = "127.0.0.1"
        get_instance.return_value = fake_ambari

        inst1 = mock.Mock()
        inst1.instance_name = "toremove"

        cl = mock.Mock(extra={"ambari_password": "******"})
        cl.name = "test"

        client_get.side_effect = [response(fake_config_groups), response(config_group1), response(config_group2)]
        client_delete.side_effect = [response({})]

        deploy.cleanup_config_groups(cl, [inst1])
        get_calls = [
            mock.call("http://127.0.0.1:8080/api/v1/clusters/test/config_groups"),
            mock.call("http://127.0.0.1:8080/api/v1/clusters/test/config_groups/1"),
            mock.call("http://127.0.0.1:8080/api/v1/clusters/test/config_groups/2"),
        ]

        self.assertEqual(get_calls, client_get.call_args_list)

        delete_calls = [mock.call("http://127.0.0.1:8080/api/v1/clusters/test/config_groups/2")]

        self.assertEqual(delete_calls, client_delete.call_args_list)
コード例 #2
0
 def decommission_nodes(self, cluster, instances):
     deploy.decommission_hosts(cluster, instances)
     deploy.remove_services_from_hosts(cluster, instances)
     deploy.restart_nns_and_rms(cluster)
     deploy.cleanup_config_groups(cluster, instances)
コード例 #3
0
    def test_cleanup_config_groups(self, client_delete, client_get,
                                   get_instance, check_cluster_exists,
                                   add_provisioning_step):
        def response(data):
            fake = mock.Mock()
            fake.text = jsonutils.dumps(data)
            fake.raise_for_status.return_value = True
            return fake

        fake_config_groups = {
            'items': [{
                'ConfigGroup': {
                    'id': "1"
                }
            }, {
                'ConfigGroup': {
                    'id': "2"
                }
            }]
        }

        config_group1 = {
            'ConfigGroup': {
                'id': '1',
                'group_name': "test:fakename"
            }
        }
        config_group2 = {
            'ConfigGroup': {
                'id': '2',
                'group_name': "test:toremove"
            }
        }

        fake_ambari = mock.Mock()
        fake_ambari.management_ip = "127.0.0.1"
        get_instance.return_value = fake_ambari

        inst1 = mock.Mock()
        inst1.instance_name = "toremove"

        cl = mock.Mock(extra={'ambari_password': "******"})
        cl.name = "test"

        client_get.side_effect = [
            response(fake_config_groups),
            response(config_group1),
            response(config_group2)
        ]
        client_delete.side_effect = [response({})]

        check_cluster_exists.return_value = True

        deploy.cleanup_config_groups(cl, [inst1])
        get_calls = [
            mock.call(
                'http://127.0.0.1:8080/api/v1/clusters/test/config_groups'),
            mock.call(
                'http://127.0.0.1:8080/api/v1/clusters/test/config_groups/1'),
            mock.call(
                'http://127.0.0.1:8080/api/v1/clusters/test/config_groups/2')
        ]

        self.assertEqual(get_calls, client_get.call_args_list)

        delete_calls = [
            mock.call(
                'http://127.0.0.1:8080/api/v1/clusters/test/config_groups/2')
        ]

        self.assertEqual(delete_calls, client_delete.call_args_list)
コード例 #4
0
ファイル: plugin.py プロジェクト: Imperat/sahara
 def decommission_nodes(self, cluster, instances):
     deploy.decommission_hosts(cluster, instances)
     deploy.remove_services_from_hosts(cluster, instances)
     deploy.restart_nns_and_rms(cluster)
     deploy.cleanup_config_groups(cluster, instances)