|
@@ -56,7 +56,6 @@ STOP_ACTION = "stop"
|
|
|
RESET_ACTION = "reset"
|
|
|
UPGRADE_ACTION = "upgrade"
|
|
|
UPGRADE_STACK_ACTION = "upgradestack"
|
|
|
-UPDATE_METAINFO_ACTION = "update-metainfo"
|
|
|
STATUS_ACTION = "status"
|
|
|
SETUP_HTTPS_ACTION = "setup-https"
|
|
|
LDAP_SETUP_ACTION = "setup-ldap"
|
|
@@ -224,7 +223,6 @@ SETUP_DB_CMD = ['su', '-', 'postgres',
|
|
|
'--command=psql -f {0} -v username=\'"{1}"\' -v password="\'{2}\'" -v dbname="{3}"']
|
|
|
UPGRADE_STACK_CMD = ['su', 'postgres',
|
|
|
'--command=psql -f {0} -v stack_name="\'{1}\'" -v stack_version="\'{2}\'" -v dbname="{3}"']
|
|
|
-UPDATE_METAINFO_CMD = 'curl -X PUT "http://{0}:{1}/api/v1/stacks2" -u "{2}":"{3}"'
|
|
|
|
|
|
|
|
|
PG_ERROR_BLOCKED = "is being accessed by other users"
|
|
@@ -569,66 +567,6 @@ def run_os_command(cmd):
|
|
|
(stdoutdata, stderrdata) = process.communicate()
|
|
|
return process.returncode, stdoutdata, stderrdata
|
|
|
|
|
|
-#
|
|
|
-# Updates metainfo information from stack root. Re-cache information from
|
|
|
-# repoinfo.xml , metainfo.xml files , etc.
|
|
|
-#
|
|
|
-def update_metainfo(args):
|
|
|
- configure_update_metainfo_args(args)
|
|
|
-
|
|
|
- hostname = args.hostname
|
|
|
- port = args.port
|
|
|
- username = args.username
|
|
|
- password = args.password
|
|
|
-
|
|
|
- command = UPDATE_METAINFO_CMD
|
|
|
- command = command.format(hostname, port, username, password)
|
|
|
- retcode, outdata, errdata = run_os_command(command)
|
|
|
-
|
|
|
- if outdata.find("Bad credentials") > 0:
|
|
|
- print 'Incorrect credential provided. Please try again.'
|
|
|
-
|
|
|
- if not retcode == 0:
|
|
|
- print errdata
|
|
|
- return retcode
|
|
|
-
|
|
|
-def configure_update_metainfo_args(args):
|
|
|
- conf_file = search_file(AMBARI_PROPERTIES_FILE, get_conf_dir())
|
|
|
- properties = Properties()
|
|
|
-
|
|
|
- try:
|
|
|
- properties.load(open(conf_file))
|
|
|
- except Exception, e:
|
|
|
- print 'Could not read ambari config file "%s": %s' % (conf_file, e)
|
|
|
- return -1
|
|
|
-
|
|
|
-
|
|
|
- default_username = "admin"
|
|
|
-
|
|
|
- username_prompt = 'Username [' + default_username + ']: '
|
|
|
- password_prompt = 'Password: '
|
|
|
- input_pattern = "^[a-zA-Z_][a-zA-Z0-9_\-]*$"
|
|
|
-
|
|
|
- hostname = socket.gethostname()
|
|
|
- port = properties[CLIENT_API_PORT_PROPERTY]
|
|
|
-
|
|
|
- if not port:
|
|
|
- port = CLIENT_API_PORT
|
|
|
-
|
|
|
- input_descr = "Invalid characters in received. Start with _ or alpha "\
|
|
|
- "followed by alphanumeric or _ or - characters"
|
|
|
-
|
|
|
- print 'Full authentication is required to access the Ambari API'
|
|
|
- username = get_validated_string_input(username_prompt, default_username,
|
|
|
- input_pattern, input_descr, False)
|
|
|
- password = get_validated_string_input(password_prompt, "", input_pattern,
|
|
|
- input_descr, True)
|
|
|
-
|
|
|
- args.hostname = hostname
|
|
|
- args.port = port
|
|
|
- args.username = username
|
|
|
- args.password = password
|
|
|
-
|
|
|
#
|
|
|
# Checks SELinux
|
|
|
#
|
|
@@ -4028,8 +3966,6 @@ def main():
|
|
|
upgrade_stack(options, stack_id)
|
|
|
elif action == LDAP_SETUP_ACTION:
|
|
|
setup_ldap()
|
|
|
- elif action == UPDATE_METAINFO_ACTION:
|
|
|
- update_metainfo(options)
|
|
|
elif action == SETUP_SECURITY_ACTION:
|
|
|
need_restart = setup_security(options)
|
|
|
else:
|