def _configure_swift_to_inst(instance): cluster = instance.node_group.cluster with instance.remote() as r: r.execute_command('sudo curl %s -o %s/hadoop-openstack.jar' % ( c_helper.get_swift_lib_url(cluster), HADOOP_LIB_DIR)) core_site = r.read_file_from(PATH_TO_CORE_SITE_XML) configs = xmlutils.parse_hadoop_xml_with_name_and_value(core_site) configs.extend(swift_helper.get_swift_configs()) confs = dict((c['name'], c['value']) for c in configs) new_core_site = xmlutils.create_hadoop_xml(confs) r.write_file_to(PATH_TO_CORE_SITE_XML, new_core_site, run_as_root=True)
def _configure_swift_to_inst(instance): cluster = instance.node_group.cluster with instance.remote() as r: r.execute_command( 'sudo curl %s -o %s/hadoop-openstack.jar' % (c_helper.get_swift_lib_url(cluster), HADOOP_LIB_DIR)) core_site = r.read_file_from(PATH_TO_CORE_SITE_XML) configs = xmlutils.parse_hadoop_xml_with_name_and_value(core_site) configs.extend(swift_helper.get_swift_configs()) confs = dict((c['name'], c['value']) for c in configs) new_core_site = xmlutils.create_hadoop_xml(confs) r.write_file_to(PATH_TO_CORE_SITE_XML, new_core_site, run_as_root=True)
def test_parse_xml_with_name_and_value(self): file_name = 'tests/unit/resources/test-default.xml' fname = pkg.resource_filename( version.version_info.package, file_name) with open(fname, "r") as f: doc = "".join(line.strip() for line in f) self.assertEqual( [{'name': u'name1', 'value': u'value1'}, {'name': u'name2', 'value': u'value2'}, {'name': u'name3', 'value': ''}, {'name': u'name4', 'value': ''}, {'name': u'name5', 'value': u'value5'}], x.parse_hadoop_xml_with_name_and_value(doc) )
def parse(self, content): configs = xml.parse_hadoop_xml_with_name_and_value(content) for cfg in configs: self.add_property(cfg["name"], cfg["value"])
def parse(self, content): configs = xml.parse_hadoop_xml_with_name_and_value(content) map(lambda i: self.add_property(i['name'], i['value']), configs)
def parse_hadoop_xml_with_name_and_value(data, **kwargs): return xmlutils.parse_hadoop_xml_with_name_and_value(data)