def pre_start(self): super(KafkaStandalone, self).pre_start() self.log_path = os.path.join(self.runpath, "log") self.etc_path = os.path.join(self.runpath, "etc") for directory in (self.log_path, self.etc_path): if self.cfg.path_cleanup is False: makedirs(directory) else: makeemptydirs(directory) self.config = os.path.join(self.runpath, "etc", "server.properties") instantiate(self.cfg.cfg_template, self.context_input(), self.config)
def _install_files(self): for install_file in self.cfg.install_files: if isinstance(install_file, str): if not os.path.isfile(install_file): raise ValueError("{} is not a file".format(install_file)) instantiate(install_file, self.context_input(), self._install_target()) elif isinstance(install_file, tuple): if len(install_file) != 2: raise ValueError( "Expected the the source filepath, or a (source, " "destination) pair; got {}".format(install_file)) src, dst = install_file if not os.path.isabs(dst): dst = os.path.join(self._install_target(), dst) instantiate(src, self.context_input(), dst)
def pre_start(self): """ Create mandatory directories and install files from given templates using the drivers context before starting zookeeper. """ super(ZookeeperStandalone, self).pre_start() self.zkdata_path = os.path.join(self.runpath, "zkdata") self.zklog_path = os.path.join(self.runpath, "zklog") self.etc_path = os.path.join(self.runpath, "etc") self.env["ZOO_LOG_DIR"] = self.zklog_path for directory in (self.zkdata_path, self.zklog_path, self.etc_path): if self.cfg.path_cleanup is False: makedirs(directory) else: makeemptydirs(directory) self.config = os.path.join(self.runpath, "etc", "zookeeper.cfg") if self.port == 0: raise RuntimeError("Zookeeper doesn't support random port") instantiate(self.cfg.cfg_template, self.context_input(), self.config)
def _install_files(self): for template in self.cfg.install_files: instantiate(template, self.context_input(), self._install_target())