def set_path(self, options): failover_file = os.path.join(options.chorus_path, ".failover") if os.path.exists(failover_file): os.remove(failover_file) self.options = options self.io = InstallerIO(self.options.silent) self.executor = ChorusExecutor(self.options.chorus_path) self.chorus_version = get_version(self.options.chorus_path) self.alpine_version = None self.release_path = os.path.join(self.options.chorus_path, 'releases/%s' % self.chorus_version) self.shared = os.path.join(self.options.chorus_path, "shared")
def config(self, options, is_upgrade): self.options = options self.io = InstallerIO(options.silent) self._version_detect() print "*" * 60 header = "" if self.chorus_version is None: print text.get("status_msg", "no_chorus") else: print text.get("status_msg", "chorus_status") % ( self.chorus_version, self.get_chorus_state()) if self.alpine_version is None: print text.get("status_msg", "no_alpine") else: print text.get("status_msg", "alpine_status") % ( self.alpine_version, self.get_alpine_state()) print "CHORUS_HOME:\t%s" % os.getenv("CHORUS_HOME", "not set in ~/.bashrc") print "*" * 60 if self.chorus_version is None: return self.method = self._load_configure_func() not_experiment_method = [ "enable_alpine_agent", "role_permission_migrate" ] while True: menu = "" lens = len(self.method) + 1 for e in self.method.keys(): if self.method[e][0] not in not_experiment_method: menu += str( e) + ". " + self.method[e][0] + " (experimental) \n" else: menu += str(e) + ". " + self.method[e][0] + "\n" menu += "%d. exit" % lens selection = self.io.require_menu( text.get("interview_question", "configuration_menu") % menu, range(1, lens + 1), default=lens) if selection == lens: break self.method[selection][1](options) if self.io.require_confirmation(text.get("interview_question", "back_to_menu"), default="no"): continue else: break print "*" * 60 print text.get("status_msg", "configure_post_step") print "*" * 60
def configure_default_port(options): from log import logger from installer_io import InstallerIO from configParser import ConfigParser from text import text io = InstallerIO(options.silent) config_file = os.path.join(options.chorus_path, "shared/chorus.properties") chorus_config = ConfigParser(config_file) alpine_config_file = os.path.join( options.chorus_path, "shared/ALPINE_DATA_REPOSITORY/configuration/deploy.properties") alpine_config = ConfigParser(alpine_config_file) ports = ["server_port", "solr_port"] menu = "\n".join( str(i + 1) + ". %s: [default: %s]" % (ports[i], chorus_config[ports[i]]) for i in xrange(0, len(ports))) menu += "\n" alpine_ports = ["alpine_port"] menu += "\n".join(str(len(ports)+i+1) + ". %s: [default: %s]" % (alpine_ports[i], alpine_config[alpine_ports[i].replace("_", ".")]) \ for i in xrange(0, len(alpine_ports))) menu += "\n%d. exit" % (len(ports) + len(alpine_ports) + 1) num = io.require_menu(text.get("interview_question", "port_menu") % menu, range(1, len(ports) + len(alpine_ports) + 2), default=len(ports) + len(alpine_ports) + 1) if num in range(1, len(ports) + 1): new_port = io.prompt_int( text.get("interview_question", "change_port") % ports[num - 1], default=int(chorus_config[ports[num - 1]])) chorus_config[ports[num - 1]] = new_port chorus_config.write(config_file) logger.info("%s has successfully changed to %d" % (ports[num - 1], new_port)) elif num in range(len(ports) + 1, len(ports) + 1 + len(alpine_ports)): new_port = io.prompt_int( text.get("interview_question", "change_port") % alpine_ports[num - len(ports) - 1], default=int(alpine_config[alpine_ports[num - len(ports) - 1].replace("_", ".")])) alpine_config[alpine_ports[num - len(ports) - 1].replace( "_", ".")] = new_port alpine_config.write(alpine_config_file) chorus_config["workflow.url"] = "http://%s:%d" % ( alpine_config["alpine.host"], new_port) chorus_config.write(config_file) logger.info("%s has successfully changed to %d" % (alpine_ports[num - len(ports) - 1], new_port))
def enable_alpine_agent(options): from log import logger from installer_io import InstallerIO from text import text from helper import get_agents io = InstallerIO(options.silent) alpine_conf = os.path.join( options.chorus_path, "shared/ALPINE_DATA_REPOSITORY/configuration/alpine.conf") agent_dic = get_agents(alpine_conf) with open(alpine_conf, "r") as f: contents = f.read() agents_str = "\n".join( str(key + 1) + ". " + agent_dic[key][1] + " " + agent_dic[key][2] for key in range(3, len(agent_dic))) agents_str += "\n%d. exit" % (len(agent_dic) + 1) agents = io.require_selection( text.get("interview_question", "alpine_agent_menu") % agents_str, range(4, len(agent_dic) + 2), default=[4]) if (len(agent_dic) + 1) in agents: return for i in range(1, len(agent_dic) + 1): contents = re.sub("hadoop.version.%s.agents.%s.enabled=[a-z]+" % (agent_dic[i-1][1], agent_dic[i-1][0]),\ "hadoop.version.%s.agents.%s.enabled=%s" % (agent_dic[i-1][1], agent_dic[i-1][0], str(i in agents).lower()), contents) with open(alpine_conf, "w") as f: f.write(contents) logger.info( str([agent_dic[agent - 1][1] for agent in agents]) + " is enabled.") logger.info(text.get("status_msg", "enable_agent_post_step") % alpine_conf)