def _is_managed_db(db_properties, force_install=False): ''' responds true (returns 0) if this IS intended to be a managed database is expecting the vars: ---- "db_host" ---- "esgf_host" to be set Define: managed - (true|0) this means NOT manipulated by this script but done by external means (hint prepend "externally" before managed to get the meaning - yes I find it confusing but Stephen likes this term :-)) db_managed=no means that it is a LOCAL database. (I have to change this damn verbiage... what I get for following pasco-speak ;-). ''' db_managed_default = None default_selection_output = None db_managed = esg_property_manager.get_property("db_managed") if not force_install: if db_managed == "yes": return True else: return False if not db_managed: esgf_host = esg_property_manager.get_property("esgf_host") logger.debug("esgf_host = %s", esgf_host) logger.debug("db_host = %s", db_properties["db_host"]) # Try to come up with some "sensible" default value for the user... if db_properties["db_host"] == esgf_host or db_properties[ "db_host"] == "localhost" or not db_properties["db_host"]: db_managed_default = "no" default_selection_output = "[y/N]:" else: db_managed_default = "yes" default_selection_output = "[Y/n]:" external_db_input = raw_input( "Is the database external to this node? " + default_selection_output) if not external_db_input: db_managed = db_managed_default esg_property_manager.write_as_property("db_managed", db_managed) else: if external_db_input.lower() == "y" or external_db_input.lower( ) == "yes": db_managed == "yes" else: db_managed == "no" esg_property_manager.write_as_property("db_managed", db_managed) else: logger.info("db_managed = [%s]", db_managed) if db_managed == "yes": print "Set to use externally \"managed\" database on host: {db_host}".format( db_host=db_properties["db_host"]) return True else: logger.debug("(hmm... setting db_host to localhost)") # Note: if not managed and on the local machine... always use # "localhost" db_properties["db_host"] = "localhost" return False
def _get_db_conn_str_questionnaire(db_properties, force_install=False): # postgresql://esgcet@localhost:5432/esgcet user_ = None host_ = None port_ = None dbname_ = None connstring_ = None valid_connection_string = None # Note the values referenced here should have been set by prior get_property *** calls # that sets these values in the script scope. (see the call in # questionnaire function - above) esgf_host = esg_property_manager.get_property("esgf_host") if not db_properties["db_user"] or not db_properties[ "db_host"] or not db_properties["db_port"] or not db_properties[ "db_database"]: if not db_properties["db_host"]: if db_properties["db_host"] == esgf_host or db_properties[ "db_host"] == "localhost": connstring_ = "{db_user}@localhost" else: connstring_ = "{db_user}@{db_host}:{db_port}/{db_database}" while True: print "Please enter the database connection string..." print " (form: postgresql://[username]@[host]:[port]/esgcet)" db_managed = esg_property_manager.get_property("db_managed") #(if it is a not a force install and we are using a LOCAL (NOT MANAGED) database then db_managed == "no") if not connstring_ and db_managed != "yes" and not force_install: connstring_ = "dbsuper@localhost:5432/esgcet" db_connection_input = raw_input( "What is the database connection string? [postgresql://${connstring_}]: postgresql://" .format(connstring_=connstring_)) or connstring_ parsed_db_conn_string = urlparse.urlparse(db_connection_input) # result.path[1:] is database name if not parsed_db_conn_string.username or not parsed_db_conn_string.hostname or parsed_db_conn_string.port or parsed_db_conn_string.result.path[ 1:]: logger.error("ERROR: Incorrect connection string syntax or values") valid_connection_string = False else: valid_connection_string = True break logger.debug("user = %s", user_) logger.debug("host = %s", host_) logger.debug("port = %s", port_) logger.debug("database = %s", dbname_) # write vars to property file esg_property_manager.write_as_property("db_user", user_) esg_property_manager.write_as_property("db_host", host_) esg_property_manager.write_as_property("db_port", port_) esg_property_manager.write_as_property("db_database", dbname_) logger.debug("valid_connection_string: %s", valid_connection_string) return valid_connection_string
def init(): esgf_node_manager_egg_file = "esgf_node_manager-{esgf_node_manager_db_version}-py{python_version}.egg".format( esgf_node_manager_db_version=config["esgf_node_manager_db_version"], python_version=config["python_version"]) # get_property node_use_ssl && [ -z "${node_use_ssl}" ] && write_as_property node_use_ssl true node_use_ssl = esg_property_manager.get_property("node_use_ssl") esg_property_manager.write_as_property("node_use_ssl", True) # get_property node_manager_service_app_home ${tomcat_install_dir}/webapps/${node_manager_app_context_root} # write_as_property node_manager_service_app_home node_manager_service_app_home = esg_property_manager.get_property( "node_manager_service_app_home", "{tomcat_install_dir}/webapps/{node_manager_app_context_root}".format( tomcat_install_dir=config["tomcat_install_dir"], node_manager_app_context_root=node_manager_app_context_root)) esg_property_manager.write_as_property("node_manager_service_app_home", node_manager_service_app_home) # write_as_property node_manager_service_endpoint "http$([ "${node_use_ssl}" = "true" ] && echo "s" || echo "")://${esgf_host}/${node_manager_app_context_root}/node" if node_use_ssl: node_manager_service_endpoint = "https://{esgf_host}/{node_manager_app_context_root}/node".format( esgf_host=esgf_host, node_manager_app_context_root=node_manager_app_context_root) else: node_manager_service_endpoint = "http://{esgf_host}/{node_manager_app_context_root}/node".format( esgf_host=esgf_host, node_manager_app_context_root=node_manager_app_context_root) esg_property_manager.write_as_property("node_manager_service_endpoint", node_manager_service_endpoint) # get_property node_use_ips && [ -z "${node_use_ips}" ] && write_as_property node_use_ips true node_use_ips = esg_property_manager.get_property("node_use_ips") esg_property_manager.write_as_property("node_use_ips", True) # get_property node_poke_timeout && [ -z "${node_poke_timeout}" ] && write_as_property node_poke_timeout 6000 node_poke_timeout = esg_property_manager.get_property("node_poke_timeout") esg_property_manager.write_as_property("node_poke_timeout", 6000) # Database information.... node_db_node_manager_schema_name = "esgf_node_manager" # Notification component information... # mail_smtp_host=${mail_smtp_host:-smtp.`hostname --domain`} #standard guess. # Overwrite mail_smtp_host value if already defined in props file # get_property mail_smtp_host ${mail_smtp_host} config["mail_smtp_host"] = esg_property_manager.get_property( "mail_smtp_host") # Launcher script for the esgf-sh esgf_shell_launcher = "esgf-sh"
def _choose_esgf_index_peer(force_install=False): esgf_index_peer = esg_property_manager.get_property("esgf_index_peer") esgf_default_peer = esg_property_manager.get_property("esgf_default_peer") esgf_host = esg_property_manager.get_property("esgf_host") if not esgf_index_peer or force_install: default_esgf_index_peer = esgf_default_peer or esgf_host or socket.getfqdn( ) esgf_index_peer_input = raw_input( "What is the hostname of the node do you plan to publish to? [{default_esgf_index_peer}]: " .format(default_esgf_index_peer=default_esgf_index_peer )) or default_esgf_index_peer esg_property_manager.write_as_property("esgf_index_peer", esgf_index_peer_input) else: logger.info("esgf_index_peer = [%s]", esgf_index_peer)
def _choose_node_namespace(force_install=False): node_namespace = esg_property_manager.get_property("node_namespace") if not node_namespace or force_install: try: top_level_domain = tld.get_tld("http://" + socket.gethostname(), as_object=True) domain = top_level_domain.domain suffix = top_level_domain.suffix default_node_namespace = suffix + "." + domain except tld.exceptions.TldDomainNotFound, error: top_level_domain = None default_node_namespace = None while True: node_namespace_input = raw_input( "What is the namespace to use for this node? (set to your reverse fqdn - Ex: \"gov.llnl\") [{default_node_namespace}]: " .format(default_node_namespace=default_node_namespace )) or default_node_namespace namespace_pattern_requirement = re.compile("(\w+.{1}\w+)$") if not namespace_pattern_requirement.match(node_namespace_input): print "Namespace entered is not in a valid format. Valid format is [suffix].[domain]. Example: gov.llnl" continue else: esg_property_manager.write_as_property("node_namespace", node_namespace_input) break
def _choose_node_peer_group(force_install=False): node_peer_group = esg_property_manager.get_property("node_peer_group") if node_peer_group: logger.info("node_peer_group = [%s]", node_peer_group) return if not node_peer_group or force_install: try: node_peer_group except NameError: node_peer_group = "esgf-dev" while True: print "Only choose esgf-test for test federation install or esgf-prod for production installation. Otherwise choose esgf-dev." node_peer_group_input = raw_input( "What peer group(s) will this node participate in? (esgf-test|esgf-prod|esgf-dev) [{node_peer_group}]: " .format(node_peer_group=node_peer_group)) or node_peer_group if node_peer_group_input.strip() not in [ "esgf-test", "esgf-prod", "esgf-dev" ]: print "Invalid Selection: {node_peer_group_input}".format( node_peer_group_input=node_peer_group_input) print "Please choose either esgf-test, esgf-dev, or esgf-prod" continue else: esg_property_manager.write_as_property("node_peer_group", node_peer_group_input) break
def test_get_property(self): test_properties_file = "/usr/local/test_properties.ini" esg_property_manager.write_as_property("Black Panther", "T'Challa", test_properties_file) output = esg_property_manager.get_property("Black Panther", test_properties_file) self.assertEqual(output, "T'Challa")
def choose_mail_admin_address(): mail_admin_address = esg_property_manager.get_property( "mail_admin_address") if not mail_admin_address or force_install: mail_admin_address_input = raw_input( "What email address should notifications be sent as? [{mail_admin_address}]: " .format(mail_admin_address=mail_admin_address)) else: logger.info("mail_admin_address = [%s]", mail_admin_address) config["mail_admin_address"] = mail_admin_address
def check_for_my_ip(force_install=False): logger.debug("Checking for IP address(es)...") matched = 0 my_ip_address = None eth0 = netifaces.ifaddresses(netifaces.interfaces()[1]) ip_addresses = [ip["addr"] for ip in eth0[netifaces.AF_INET]] try: esgf_host_ip except NameError: esgf_host_ip = esg_property_manager.get_property("esgf_host_ip") if esgf_host_ip and not force_install: logger.info("Using IP: %s", esgf_host_ip) return 0 # We want to make sure that the IP address we have in our config # matches one of the IPs that are associated with this host for ip in ip_addresses: if ip == esgf_host_ip: matched += 1 if matched == 0: logger.info( "Configured host IP address does not match available IPs...") if not esgf_host_ip or force_install or matched == 0: if len(ip_addresses) > 1: # ask the user to choose... while True: _render_ip_address_menu(ip_addresses) default = 0 choice = _select_ip_address() or default my_ip_address = ip_addresses[choice] logger.info("selected address -> %s", my_ip_address) break else: my_ip_address = ip_addresses[0] esg_property_manager.write_as_property("esgf_host_ip", my_ip_address) esgf_host_ip = esg_property_manager.get_property("esgf_host_ip") return esgf_host_ip
def _choose_node_long_name(force_install=False): node_long_name = esg_property_manager.get_property("node_long_name") if not node_long_name or force_install: while True: node_long_name_input = raw_input( "Please give this node a more descriptive \"long\" name [{node_long_name}]: " .format(node_long_name=node_long_name)) or node_long_name esg_property_manager.write_as_property("node_long_name", node_long_name_input) break else: logger.info("node_long_name = [%s]", node_long_name)
def get_db_properties(): db_properties_dict = { "db_user": None, "db_host": None, "db_port": None, "db_database": None, "db_managed": None } for key, _ in db_properties_dict.items(): db_properties_dict[key] = esg_property_manager.get_property(key) return db_properties_dict
def setup_db_schemas(force_install): '''Load ESGF schemas''' conn = connect_to_db("postgres") conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) cur = conn.cursor() db_user_password = esg_functions.get_publisher_password() if not db_user_password: esg_functions.set_publisher_password() db_user_password = esg_functions.get_publisher_password() # create super user print "Create {db_user} user: "******"postgress_user"]), cur.mogrify("CREATE USER {db_user} with CREATEROLE superuser PASSWORD \'{db_user_password}\';".format(db_user=config["postgress_user"], db_user_password=db_user_password)) cur.execute("CREATE USER {db_user} with CREATEROLE superuser PASSWORD \'{db_user_password}\';".format(db_user=config["postgress_user"], db_user_password=db_user_password)) # create 'esgcet' user publisher_db_user = esg_property_manager.get_property("publisher_db_user") if not publisher_db_user: publisher_db_user = raw_input("What is the (low privilege) db account for publisher? [esgcet]: ") or "esgcet" print "Create {publisher_db_user} user:"******"CREATE USER {publisher_db_user} PASSWORD \'{db_user_password}\';".format(publisher_db_user=publisher_db_user, db_user_password=db_user_password)) cur.execute("CREATE USER {publisher_db_user} PASSWORD \'{db_user_password}\';".format(publisher_db_user=publisher_db_user, db_user_password=db_user_password)) # create CoG database cur.execute("CREATE DATABASE cogdb;") # create ESGF database cur.execute("CREATE DATABASE esgcet;") print list_users(conn=conn) #TODO: close connection here and connection to esgcet; or look up how to switch databases cur.close() conn.close() #TODO: move download_config_files() here # download_config_files(force_install) # esg_functions.replace_string_in_file("/var/lib/pgsql/9.6/data/pg_hba.conf", "ident", "md5") # restart_postgres() conn = connect_to_db("dbsuper", db_name='esgcet', password=db_user_password) cur = conn.cursor() # load ESGF schemas cur.execute(open("sqldata/esgf_esgcet.sql", "r").read()) cur.execute(open("sqldata/esgf_node_manager.sql", "r").read()) cur.execute(open("sqldata/esgf_security.sql", "r").read()) cur.execute(open("sqldata/esgf_dashboard.sql", "r").read()) # # list database users print list_users(conn=conn) load_esgf_data(cur) list_tables(conn) # IMPORTANT: change connections to require encrypted password esg_functions.replace_string_in_file("/var/lib/pgsql/9.6/data/pg_hba.conf", "ident", "md5")
def _choose_node_short_name(force_install=False): node_short_name = esg_property_manager.get_property("node_short_name") if not node_short_name or force_install: while True: node_short_name_input = raw_input( "Please give this node a \"short\" name [{node_short_name}]: ". format(node_short_name=node_short_name)) or node_short_name node_short_name_input.replace("", "_") esg_property_manager.write_as_property("node_short_name", node_short_name_input) break else: logger.info("node_short_name = [%s]", node_short_name)
def _choose_mail_admin_address(force_install=False): mail_admin_address = esg_property_manager.get_property( "mail_admin_address") if not mail_admin_address or force_install: mail_admin_address_input = raw_input( "What email address should notifications be sent as? [{mail_admin_address}]: " .format(mail_admin_address=mail_admin_address)) if mail_admin_address_input: esg_property_manager.write_as_property("mail_admin_address", mail_admin_address_input) else: print " (The notification system will not be enabled without an email address)" else: logger.info("mail_admin_address = [%s]", mail_admin_address)
def _choose_publisher_db_user(force_install=False): default_publisher_db_user = None publisher_db_user = esg_property_manager.get_property("publisher_db_user") if publisher_db_user: print "Found existing value for property publisher_db_user: {publisher_db_user}".format( publisher_db_user=publisher_db_user) logger.info("publisher_db_user: %s", publisher_db_user) return if not publisher_db_user or force_install: default_publisher_db_user = publisher_db_user or "esgcet" publisher_db_user_input = raw_input( "What is the (low privilege) db account for publisher? [{default_publisher_db_user}]: " .format(default_publisher_db_user=default_publisher_db_user )) or default_publisher_db_user esg_property_manager.write_as_property("publisher_db_user", publisher_db_user_input)
def check_shmmax(min_shmmax = 48): ''' NOTE: This is another **RedHat/CentOS** specialty thing (sort of) arg1 - min value of shmmax in MB (see: /etc/sysctl.conf) ''' kernel_shmmax = esg_property_manager.get_property("kernel_shmmax") set_value_mb = min_shmmax set_value_bytes = set_value_mb *1024*1024 cur_value_bytes = call_subprocess("sysctl -q kernel.shmmax")["stdout"].split("=")[1] print "cur_value_bytes:", cur_value_bytes cur_value_bytes = cur_value_bytes.strip() if cur_value_bytes < set_value_bytes: print "Current system shared mem value too low [{cur_value_bytes} bytes] changing to [{set_value_bytes} bytes]".format(cur_value_bytes = cur_value_bytes, set_value_bytes = set_value_bytes) call_subprocess("sysctl -w kernel.shmmax={set_value_bytes}".format(set_value_bytes = set_value_bytes)) #TODO: replace with Python to update file call_subprocess("sed -i.bak 's/\(^[^# ]*[ ]*kernel.shmmax[ ]*=[ ]*\)\(.*\)/\1'${set_value_bytes}'/g' /etc/sysctl.conf") esg_property_manager.write_as_property("kernal_shmmax", set_value_mb)
def _choose_publisher_db_user_passwd(force_install=False): if config[ "publisher_db_user_passwd"] or esg_functions.get_publisher_password( ): print "Using previously configured publisher DB password" return if force_install: publisher_db_user = esg_property_manager.get_property( "publisher_db_user") or "esgcet" publisher_db_user_passwd_input = getpass.getpass( "What is the db password for publisher user ({publisher_db_user})?: " .format(publisher_db_user=publisher_db_user)) password_input_confirmation = getpass.getpass( "Please re-enter password to confirm: ") if esg_functions.confirm_password(publisher_db_user_passwd_input, password_input_confirmation): esg_functions.set_publisher_password( publisher_db_user_passwd_input)
def _choose_organization_name(force_install=False): esg_root_id = esg_property_manager.get_property("esg_root_id") if esg_root_id: logger.info("esg_root_id = [%s]", esg_root_id) return elif force_install: try: default_org_name = tld.get_tld("http://" + socket.gethostname(), as_object=True).domain except tld.exceptions.TldDomainNotFound, error: logger.exception("Could not find top level domain for %s.", socket.gethostname()) default_org_name = "llnl" while True: org_name_input = raw_input( "What is the name of your organization? [{default_org_name}]: " .format(default_org_name=default_org_name)) or default_org_name org_name_input.replace("", "_") esg_property_manager.write_as_property("esg_root_id", org_name_input) break
def generate_esgsetup_options(recommended_setup=1): '''Generate the string that will pass arguments to esgsetup to initialize the database''' publisher_db_user = None try: publisher_db_user = config["publisher_db_user"] except KeyError: publisher_db_user = esg_property_manager.get_property( "publisher_db_user") security_admin_password = esg_functions.get_security_admin_password() generate_esg_ini_command = "esgsetup --db" if recommended_setup == 1: generate_esg_ini_command += " --minimal-setup" if config["db_database"]: generate_esg_ini_command += " --db-name %s" % (config["db_database"]) if config["postgress_user"]: generate_esg_ini_command += " --db-admin %s" % ( config["postgress_user"]) if security_admin_password: generate_esg_ini_command += " --db-admin-password %s" % ( security_admin_password) if publisher_db_user: generate_esg_ini_command += " --db-user %s" % (publisher_db_user) if config["publisher_db_user_passwd"]: generate_esg_ini_command += " --db-user-password %s" % ( config["publisher_db_user_passwd"]) if config["postgress_host"]: generate_esg_ini_command += " --db-host %s" % ( config["postgress_host"]) if config["postgress_port"]: generate_esg_ini_command += " --db-port %s" % ( config["postgress_port"]) logger.info("generate_esg_ini_command in function: %s", generate_esg_ini_command) print "generate_esg_ini_command in function: %s" % generate_esg_ini_command return generate_esg_ini_command
def setup_node_manager(mode="install"): ##### # Install The Node Manager ##### # - Takes boolean arg: 0 = setup / install mode (default) # 1 = updated mode # # In setup mode it is an idempotent install (default) # In update mode it will always pull down latest after archiving old # print "Checking for node manager {esgf_node_manager_version}".format( esgf_node_manager_version=config["esgf_node_manager_version"]) if esg_version_manager.check_webapp_version( "esgf-node-manager", config["esgf_node_manager_version"]) == 0 and not force_install: print "\n Found existing version of the node-manager [OK]" return True init() print "*******************************" print "Setting up The ESGF Node Manager..." print "*******************************" # local upgrade=${1:-0} db_set = 0 if force_install: default_answer = "N" else: default_answer = "Y" # local dosetup node_manager_service_app_home = esg_property_manager.get_property( "node_manager_service_app_home") if os.path.isdir(node_manager_service_app_home): db_set = 1 print "Detected an existing node manager installation..." if default_answer == "Y": installation_answer = raw_input( "Do you want to continue with node manager installation and setup? [Y/n]" ) or default_answer else: installation_answer = raw_input( "Do you want to continue with node manager installation and setup? [y/N]" ) or default_answer if installation_answer.lower() not in ["y", "yes"]: print "Skipping node manager installation and setup - will assume it's setup properly" # resetting node manager version to what it is already, not what we prescribed in the script # this way downstream processes will use the *actual* version in play, namely the (access logging) filter(s) esgf_node_manager_version = esg_version_manager.get_current_webapp_version( "esgf_node_manager") return True backup_default_answer = "Y" backup_answer = raw_input( "Do you want to make a back up of the existing distribution [{node_manager_app_context_root}]? [Y/n] " .format(node_manager_app_context_root=node_manager_app_context_root )) or backup_default_answer if backup_answer.lower in ["yes", "y"]: print "Creating a backup archive of this web application [{node_manager_service_app_home}]".format( node_manager_service_app_home=node_manager_service_app_home) esg_functions.backup(node_manager_service_app_home) backup_db_default_answer = "Y" backup_db_answer = raw_input( "Do you want to make a back up of the existing database [{node_db_name}:esgf_node_manager]?? [Y/n] " .format(node_db_name=config["node_db_name"] )) or backup_db_default_answer if backup_db_answer.lower() in ["yes", "y"]: print "Creating a backup archive of the manager database schema [{node_db_name}:esgf_node_manager]".format( node_db_name=config["node_db_name"]) # TODO: Implement this # esg_postgres.backup_db() -db ${node_db_name} -s node_manager esg_bash2py.mkdir_p(config["workdir"]) with esg_bash2py.pushd(config["workdir"]): logger.debug("changed directory to : %s", os.getcwd()) # strip off .tar.gz at the end #(Ex: esgf-node-manager-0.9.0.tar.gz -> esgf-node-manager-0.9.0) node_dist_file = esg_bash2py.trim_string_from_head(node_dist_url) logger.debug("node_dist_file: %s", node_dist_file) # Should just be esgf-node-manager-x.x.x node_dist_dir = node_dist_file # checked_get ${node_dist_file} ${node_dist_url} $((force_install)) if not esg_functions.download_update( node_dist_file, node_dist_url, force_download=force_install): print "ERROR: Could not download {node_dist_url} :-(".format( node_dist_url=node_dist_url) esg_functions.exit_with_error(1) # make room for new install if force_install: print "Removing Previous Installation of the ESGF Node Manager... ({node_dist_dir})".format( node_dist_dir=node_dist_dir) try: shutil.rmtree(node_dist_dir) logger.info("Deleted directory: %s", node_dist_dir) except IOError, error: logger.error(error) logger.error("Could not delete directory: %s", node_dist_dir) esg_functions.exit_with_error(1) clean_node_manager_webapp_subsystem() print "\nunpacking {node_dist_file}...".format( node_dist_file=node_dist_file) # This probably won't work, because the extension has already been stripped, no idea how this even worked in the bash code smh try: tar = tarfile.open(node_dist_file) tar.extractall() tar.close() except Exception, error: logger.error(error) print "ERROR: Could not extract the ESG Node: {node_dist_file}".format( node_dist_file=node_dist_file) esg_functions.exit_with_error(1)
def get_esg_root_id(): try: esg_root_id = config["esg_root_id"] except KeyError: esg_root_id = esg_property_manager.get_property("esg_root_id") return esg_root_id
def done_remark(): '''Prints info to denote that the installation has completed''' print "\nFinished!..." print "In order to see if this node has been installed properly you may direct your browser to:" if "DATA" in node_type_list or "INSTALL" in node_type_list: esgf_host = esg_functions.get_esgf_host() print "http://{esgf_host}/thredds".format(esgf_host=esgf_host) print "http://{esgf_host}/esg-orp".format(esgf_host=esgf_host) if "INDEX" in node_type_list: print "http://${esgf_host}/" if "COMPUTE" in node_type_list: print "http://${esgf_host}/las" print "Your peer group membership -- : [{node_peer_group}]".format(node_peer_group=esg_property_manager.get_property("node_peer_group")) print "Your specified \"index\" peer - :[{esgf_index_peer}]) (url = http://{esgf_index_peer}/)".format(esgf_index_peer=esg_property_manager.get_property("esgf_index_peer")) # if [ -d "${thredds_content_dir}/thredds" ]; then # echo # echo "[Note: Use UNIX group permissions on ${thredds_content_dir}/thredds/esgcet to enable users to be able to publish thredds catalogs from data therein]" # echo " %> chgrp -R <appropriate unix group for publishing users> ${thredds_content_dir}/thredds" # fi # print '''
def initial_setup_questionnaire(force_install=False): print "-------------------------------------------------------" print 'Welcome to the ESGF Node installation program! :-)' print "-------------------------------------------------------" esg_bash2py.mkdir_p(config['esg_config_dir']) starting_directory = os.getcwd() os.chdir(config['esg_config_dir']) esgf_host = esg_property_manager.get_property("esgf_host") _choose_fqdn(esgf_host) if not esg_functions.get_security_admin_password() or force_install: _choose_admin_password() else: logger.info("Previously set password found.") _choose_organization_name() _choose_node_short_name() _choose_node_long_name() _choose_node_namespace() _choose_node_peer_group() _choose_esgf_index_peer() _choose_mail_admin_address() #TODO:Extract constructring DB string into separate function db_properties = get_db_properties() if not all(db_properties) or force_install: _is_managed_db(db_properties) _get_db_conn_str_questionnaire(db_properties) else: if db_properties["db_host"] == esgf_host or db_properties[ "db_host"] == "localhost": print "db_connection_string = {db_user}@localhost".format( db_user=db_properties["db_user"]) else: connstring_ = "{db_user}@{db_host}:{db_port}/{db_database} [external = ${db_managed}]".format( db_user=db_properties["db_user"], db_host=db_properties["db_host"], db_port=db_properties["db_port"], db_database=db_properties["db_database"], db_managed=db_properties["db_managed"]) _choose_publisher_db_user() _choose_publisher_db_user_passwd() os.chmod(config['pub_secret_file'], 0640) if "tomcat" not in esg_functions.get_group_list(): esg_functions.add_unix_group(config["tomcat_group"]) os.chown(config['esgf_secret_file'], config["installer_uid"], esg_functions.get_tomcat_group_id()) if db_properties["db_host"] == esgf_host or db_properties[ "db_host"] == "localhost": logger.info("db publisher connection string %s@localhost", db_properties["db_user"]) else: logger.info("db publisher connection string %s@%s:%s/%s", db_properties["db_user"], db_properties["db_host"], db_properties["db_port"], db_properties["db_database"]) os.chdir(starting_directory) return True