Exemplo n.º 1
0
    def test_update_ambari_admin_password(self):
        processor = bp.BlueprintProcessor(
            json.load(
                open(
                    os.path.join(os.path.realpath('./unit/plugins'), 'hdp',
                                 'resources', 'sample-ambari-blueprint.json'),
                    'r')))
        config_items = [{
            "value": "new-pwd",
            "config": {
                "name": "ambari.admin.password",
                "description": "Ambari admin password",
                "config_type": "string",
                "applicable_target": "AMBARI",
                "is_optional": "true",
                "tag": "ambari-stack",
                "scope": "cluster"
            }
        }]

        configs_list = self.json2obj(json.dumps(config_items))

        # process the input configuration
        processor.process_user_inputs(configs_list)
        services = self._xpath_get(processor.blueprint, '/services')

        self.assertEqual('new-pwd', services[2]['users'][0]['password'])
Exemplo n.º 2
0
 def _get_blueprint_processor(self, cluster):
     processor = bp.BlueprintProcessor(json.load(
         open(os.path.join(os.path.dirname(__file__), 'resources',
                           'default-cluster.template'), "r")))
     processor.process_user_inputs(self._map_to_user_inputs(
         '1.3.0', cluster.cluster_configs))
     processor.process_node_groups(cluster.node_groups)
     return processor
Exemplo n.º 3
0
    def test_existing_config_item_in_top_level_within_blueprint(self):
        processor = bp.BlueprintProcessor(
            json.load(
                open(
                    os.path.join(os.path.realpath('./unit/plugins'), 'hdp',
                                 'resources', 'sample-ambari-blueprint.json'),
                    'r')))
        config_items = [{
            "value": "/some/new/path",
            "config": {
                "name": "dfs_name_dir",
                "description": "blah blah",
                "config_type": "string",
                "is_optional": "true",
                "default_value": "/hadoop/hdfs/namenode",
                "applicable_target": "general",
                "tag": "global",
                "scope": "cluster"
            }
        }]
        # verify this config item already exists in the blueprint
        prop_name = self._xpath_get(processor.blueprint,
                                    '/configurations/0/properties/0/name')
        self.assertEqual('dfs_name_dir', prop_name,
                         'dfs_name_dir not found in bluerpint')

        # convert the json structure into a proper object
        configs_list = self.json2obj(json.dumps(config_items))

        # process the input configuration
        processor.process_user_inputs(configs_list)
        prop_name = self._xpath_get(processor.blueprint,
                                    '/configurations/0/properties/0/name')
        self.assertEqual(
            'dfs_name_dir', prop_name,
            'dfs_name_dir not found in bluerpint post config '
            'processing')
        prop_value = self._xpath_get(processor.blueprint,
                                     '/configurations/0/properties/0/value')
        self.assertEqual('/some/new/path', prop_value,
                         'prop value is wrong post config processing')
Exemplo n.º 4
0
    def test_insert_new_config_item_into_existing_top_level_configuration(
            self):
        processor = bp.BlueprintProcessor(
            json.load(
                open(
                    os.path.join(os.path.realpath('./unit/plugins'), 'hdp',
                                 'resources', 'sample-ambari-blueprint.json'),
                    'r')))
        config_items = [{
            "value": "512m",
            "config": {
                "name": "namenode_heapsize",
                "description": "heap size",
                "default_value": "256m",
                "config_type": "string",
                "is_optional": "true",
                "applicable_target": "general",
                "tag": "global",
                "scope": "cluster"
            }
        }]
        # verify this config section already exists in the blueprint,
        # but doesn't have the given property
        props_for_global = self._xpath_get(processor.blueprint,
                                           '/configurations/0/properties')
        prop_dict = processor._find_blueprint_section(props_for_global, 'name',
                                                      'namenode_heapsize')
        self.assertIsNone(prop_dict, 'no matching property should be found')

        configs_list = self.json2obj(json.dumps(config_items))

        # process the input configuration
        processor.process_user_inputs(configs_list)
        prop_dict = processor._find_blueprint_section(props_for_global, 'name',
                                                      'namenode_heapsize')
        self.assertIsNotNone(prop_dict, 'no matching property should be found')
Exemplo n.º 5
0
    def test_insert_new_config_item_into_newly_created_top_level_configuration(
            self):
        processor = bp.BlueprintProcessor(
            json.load(
                open(
                    os.path.join(os.path.realpath('./unit/plugins'), 'hdp',
                                 'resources', 'sample-ambari-blueprint.json'),
                    'r')))
        config_items = [{
            "value": "50",
            "config": {
                "name": "mapred.job.tracker.handler.count",
                "description": "job tracker handler count",
                "config_type": "integer",
                "applicable_target": "general",
                "is_optional": "true",
                "tag": "mapred-site",
                "scope": "node"
            }
        }]
        # verify the config with this tag does not exist
        configs = self._xpath_get(processor.blueprint, '/configurations')
        self.assertNotEqual('mapred-site', configs[0]['name'],
                            'section should not exist')

        configs_list = self.json2obj(json.dumps(config_items))

        # process the input configuration
        processor.process_user_inputs(configs_list)
        configs = self._xpath_get(processor.blueprint, '/configurations')
        self.assertEqual(2, len(configs), 'no config section added')
        self.assertEqual('mapred-site', configs[1]['name'],
                         'section should exist')
        self.assertEqual('mapred.job.tracker.handler.count',
                         configs[1]['properties'][0]['name'],
                         'property not added')
Exemplo n.º 6
0
    def configure_cluster(self, cluster):
        # take the user inputs from the cluster and node groups and convert
        # to a ambari blueprint

        processor = bp.BlueprintProcessor(
            json.load(
                open(
                    os.path.join(os.path.dirname(__file__), 'resources',
                                 'default-cluster.template'), "r")))
        processor.process_user_inputs(
            self._map_to_user_inputs('1.3.0', cluster.cluster_configs))
        processor.process_node_groups(cluster.node_groups)
        # NOTE: for the time being we are going to ignore the node group
        # level configurations.  we are not currently
        # defining node level configuration items (i.e. scope='cluster' in
        # all cases for returned configs)

        #create a cloud context

        #TODO(jmaron):  is base host name really necessary any longer?
        #cloud_ctx = ClusterContext(None, LOG)
        #self._add_instances_to_cluster_context (cloud_ctx, cluster)

        self.create_cluster(cluster, json.dumps(processor.blueprint))
Exemplo n.º 7
0
    def test_empty_node_processes_specified(self):
        processor = bp.BlueprintProcessor(
            json.load(
                open(
                    os.path.join(os.path.realpath('./unit/plugins'), 'hdp',
                                 'resources', 'sample-ambari-blueprint.json'),
                    'r')))
        node_groups = []
        node_groups.append(
            _create_ng('MASTER', 'master-flavor', [], 1, 'master-img'))
        node_groups.append(
            _create_ng('SLAVE', 'slave-flavor', [], 2, 'slave-img'))

        processor.process_node_groups(node_groups)
        host_mappings = processor.blueprint['host_role_mappings']
        self.assertEqual(2, len(host_mappings),
                         'wrong number of host role mappings')
        expected_master_dict = {
            "name":
            "MASTER",
            "components": [{
                "name": "NAMENODE"
            }, {
                "name": "JOBTRACKER"
            }, {
                "name": "SECONDARY_NAMENODE"
            }, {
                "name": "GANGLIA_SERVER"
            }, {
                "name": "GANGLIA_MONITOR"
            }, {
                "name": "NAGIOS_SERVER"
            }, {
                "name": "AMBARI_SERVER"
            }, {
                "name": "AMBARI_AGENT"
            }],
            "hosts": [{
                "cardinality": "1"
            }]
        }
        self.assertDictEqual(expected_master_dict, host_mappings[0],
                             'first mapping does not match')
        expected_slave_dict = {
            "name":
            "SLAVE",
            "components": [{
                "name": "DATANODE"
            }, {
                "name": "TASKTRACKER"
            }, {
                "name": "GANGLIA_MONITOR"
            }, {
                "name": "HDFS_CLIENT"
            }, {
                "name": "MAPREDUCE_CLIENT"
            }, {
                "name": "AMBARI_AGENT"
            }],
            "hosts": [{
                "cardinality": "1+"
            }]
        }
        self.assertDictEqual(expected_slave_dict, host_mappings[1],
                             'second mapping does not match')
Exemplo n.º 8
0
 def test_leave_existing_host_mapping_alone(self):
     processor = bp.BlueprintProcessor(
         json.load(
             open(
                 os.path.join(os.path.realpath('./unit/plugins'), 'hdp',
                              'resources', 'sample-ambari-blueprint.json'),
                 'r')))
     node_groups = []
     node_groups.append(
         _create_ng('OTHER_MASTER_GROUP', 'master-flavor', [
             "namenode", "jobtracker", "secondary_namenode",
             "ganglia_server", "ganglia_monitor", "nagios_server",
             "ambari_server", "ambari_agent"
         ], 1, 'master-img'))
     processor.process_node_groups(node_groups)
     host_mappings = processor.blueprint['host_role_mappings']
     self.assertEqual(3, len(host_mappings),
                      'wrong number of host role mappings')
     expected_master_dict = {
         "name":
         "MASTER",
         "components": [{
             "name": "NAMENODE"
         }, {
             "name": "JOBTRACKER"
         }, {
             "name": "SECONDARY_NAMENODE"
         }, {
             "name": "GANGLIA_SERVER"
         }, {
             "name": "GANGLIA_MONITOR"
         }, {
             "name": "NAGIOS_SERVER"
         }, {
             "name": "AMBARI_SERVER"
         }, {
             "name": "AMBARI_AGENT"
         }],
         "hosts": [{
             "cardinality": "1"
         }]
     }
     self.assertDictEqual(expected_master_dict, host_mappings[0],
                          'first mapping does not match')
     expected_other_master_dict = {
         "name":
         "OTHER_MASTER_GROUP",
         "components": [{
             "name": "NAMENODE"
         }, {
             "name": "JOBTRACKER"
         }, {
             "name": "SECONDARY_NAMENODE"
         }, {
             "name": "GANGLIA_SERVER"
         }, {
             "name": "GANGLIA_MONITOR"
         }, {
             "name": "NAGIOS_SERVER"
         }, {
             "name": "AMBARI_SERVER"
         }, {
             "name": "AMBARI_AGENT"
         }],
         "hosts": [{
             "cardinality": "1"
         }]
     }
     self.assertDictEqual(expected_other_master_dict, host_mappings[2],
                          'first mapping does not match')