Esempio n. 1
0
    def get_client_properties(self):
        from beaver.component.kafka import Kafka
        from beaver.component.ambari import Ambari

        Kafka.alterUser(
            userName=self.client_username,
            config="'SCRAM-SHA-256=[iterations=8192,password=%s],"
            "SCRAM-SHA-512=[password=%s]'" % (self.client_password, self.client_password)
        )

        is_ambari_enc = Ambari.is_ambari_encrypted()
        kafka_jaas_config = Ambari.getConfig(
            "kafka_jaas_conf", webURL=Ambari.getWebUrl(is_hdp=False, is_enc=is_ambari_enc)
        )

        replacement_jaas_entry = self.jaas_entry
        if not Kafka._isSecure:
            replacement_jaas_entry = "\nKafkaServer {%s\n};" % self.jaas_entry

        if self.to_be_replaced + replacement_jaas_entry not in kafka_jaas_config['content']:
            print "old : %s" % kafka_jaas_config['content']
            kafka_jaas_config['content'] = kafka_jaas_config['content'].replace(
                self.to_be_replaced, self.to_be_replaced + replacement_jaas_entry
            )
            print "new : %s" % kafka_jaas_config['content']
        Ambari.setConfig(
            "kafka_jaas_conf", kafka_jaas_config, webURL=Ambari.getWebUrl(is_hdp=False, is_enc=is_ambari_enc)
        )
        Ambari.restart_services_with_stale_configs()
        time.sleep(20)
        return {'sasl.jaas.config': self.jaas_entry.replace("\n", " "), 'sasl.mechanism': 'SCRAM-SHA-256'}
Esempio n. 2
0
 def fix_qe_14910(cls):
     # QE-14190: replace ${hdp.version} in mapreduce.application.classpath because it will case bad substitution error
     config = Ambari.getConfig(type='mapred-site')
     for key in config.keys():
         value = config[key]
         value = value.replace('${hdp.version}', '{{version}}')
         config[key] = value
     Ambari.setConfig(type='mapred-site', config=config)
     Ambari.restart_services_with_stale_configs()
Esempio n. 3
0
 def modifyConfig(cls, changes, env={}, restartService=True):
     logger.info("Current Service Config Version: %s" %
                 cls.getStartingAmbariServiceConfigVersion())
     for key, value in changes.items():
         if cls._ambariConfigMap.has_key(key):
             key = cls._ambariConfigMap[key]
         else:
             logger.warn(
                 "Unknown config \"%s\" change requested, ignoring" % key)
             continue
         Ambari.setConfig(key, value)
     if len(env.keys()) > 0:
         key = cls._ambariConfigMap['oozie-env.sh']
         envProps = Ambari.getConfig(key)
         if envProps.has_key("content"):
             content = envProps['content']
             for envKey, envVal in env.items():
                 content = "export %s=%s\n%s" % (envKey, envVal, content)
             Ambari.setConfig(key, {'content': content})
     if restartService:
         Ambari.restart_services_with_stale_configs()
Esempio n. 4
0
 def restoreConfig(cls):
     resetVersion = cls.getStartingAmbariServiceConfigVersion()
     logger.info("Restoring Service Config Version to: %s" % resetVersion)
     Ambari.resetConfig(cls._ambariServiceName, resetVersion)
     Ambari.restart_services_with_stale_configs()