You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2017/12/12 15:59:00 UTC
ambari git commit: AMBARI-22476. Modify bootstrap API to pass Ambari
repo URL from UI and retrieve Host OS types (Sinia Garudi via ncole)
Repository: ambari
Updated Branches:
refs/heads/branch-feature-AMBARI-21674 f1a2b3a1c -> 95164bcce
AMBARI-22476. Modify bootstrap API to pass Ambari repo URL from UI and retrieve Host OS types (Sinia Garudi via ncole)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/95164bcc
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/95164bcc
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/95164bcc
Branch: refs/heads/branch-feature-AMBARI-21674
Commit: 95164bccec30af3ab21382040376b76ac05433b4
Parents: f1a2b3a
Author: Nate Cole <nc...@hortonworks.com>
Authored: Tue Dec 12 10:58:54 2017 -0500
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Tue Dec 12 10:58:54 2017 -0500
----------------------------------------------------------------------
.../ambari/server/bootstrap/BSRunner.java | 3 +-
.../ambari/server/bootstrap/SshHostInfo.java | 11 +++
ambari-server/src/main/python/bootstrap.py | 8 +-
.../ambari/server/bootstrap/BootStrapTest.java | 2 +
ambari-server/src/test/python/TestBootstrap.py | 64 +++++++-------
.../app/controllers/wizard/step3_controller.js | 59 ++++++++++++-
.../test/controllers/wizard/step3_test.js | 91 +++++++++++++++++++-
7 files changed, 198 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/95164bcc/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
index c7976ee..2cd061c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/BSRunner.java
@@ -202,7 +202,7 @@ class BSRunner extends Thread {
sshPort = DEFAULT_SSHPORT;
}
- String command[] = new String[13];
+ String command[] = new String[14];
BSStat stat = BSStat.RUNNING;
String scriptlog = "";
try {
@@ -242,6 +242,7 @@ class BSRunner extends Thread {
command[10] = this.serverPort+"";
command[11] = userRunAs;
command[12] = (this.passwordFile==null) ? "null" : this.passwordFile.toString();
+ command[13] = this.sshHostInfo.getAmbariRepoUrls();
Map<String, String> envVariables = new HashMap<>();
http://git-wip-us.apache.org/repos/asf/ambari/blob/95164bcc/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java
index 86888f4..6218fb6 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/bootstrap/SshHostInfo.java
@@ -57,6 +57,9 @@ public class SshHostInfo {
@XmlElement
private String userRunAs;
+ @XmlElement
+ private String ambariRepoUrls;
+
public String getSshKey() {
return sshKey;
}
@@ -119,4 +122,12 @@ public class SshHostInfo {
}
return ret.toString();
}
+
+ public String getAmbariRepoUrls() {
+ return ambariRepoUrls;
+ }
+
+ public void setAmbariRepoUrls(String ambariRepoUrls) {
+ this.ambariRepoUrls = ambariRepoUrls;
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/95164bcc/ambari-server/src/main/python/bootstrap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/bootstrap.py b/ambari-server/src/main/python/bootstrap.py
index f1c53ce..b949bc0 100755
--- a/ambari-server/src/main/python/bootstrap.py
+++ b/ambari-server/src/main/python/bootstrap.py
@@ -844,7 +844,7 @@ class PBootstrap:
class SharedState:
def __init__(self, user, sshPort, sshkey_file, script_dir, boottmpdir, setup_agent_file,
ambari_server, cluster_os_type, ambari_version, server_port,
- user_run_as, password_file = None):
+ user_run_as, ambariRepoUrls, password_file = None):
self.hostlist_to_remove_password_file = None
self.user = user
self.sshPort = sshPort
@@ -859,6 +859,7 @@ class SharedState:
self.password_file = password_file
self.statuses = None
self.server_port = server_port
+ self.ambariRepoUrls = ambariRepoUrls
self.remote_files = {}
self.ret = {}
pass
@@ -888,6 +889,7 @@ def main(argv=None):
server_port = onlyargs[9]
user_run_as = onlyargs[10]
passwordFile = onlyargs[11]
+ ambariRepoUrls = onlyargs[12]
if not OSCheck.is_windows_family():
# ssh doesn't like open files
@@ -900,10 +902,10 @@ def main(argv=None):
" using " + scriptDir + " cluster primary OS: " + cluster_os_type +
" with user '" + user + "'with ssh Port '" + sshPort + "' sshKey File " + sshkey_file + " password File " + passwordFile +\
" using tmp dir " + bootdir + " ambari: " + ambariServer +"; server_port: " + server_port +\
- "; ambari version: " + ambariVersion+"; user_run_as: " + user_run_as)
+ "; ambari version: " + ambariVersion+"; user_run_as: " + user_run_as +"; ambariRepoUrls: " + ambariRepoUrls)
sharedState = SharedState(user, sshPort, sshkey_file, scriptDir, bootdir, setupAgentFile,
ambariServer, cluster_os_type, ambariVersion,
- server_port, user_run_as, passwordFile)
+ server_port, user_run_as, ambariRepoUrls, passwordFile)
pbootstrap = PBootstrap(hostList, sharedState)
pbootstrap.run()
return 0 # Hack to comply with current usage
http://git-wip-us.apache.org/repos/asf/ambari/blob/95164bcc/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
index b9da013..d4f8708 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/bootstrap/BootStrapTest.java
@@ -92,6 +92,7 @@ public class BootStrapTest extends TestCase {
info.setHosts(hosts);
info.setUser("user");
info.setPassword("passwd");
+ info.setAmbariRepoUrls("null");
BSResponse response = impl.runBootStrap(info);
LOG.info("Response id from bootstrap " + response.getRequestId());
/* do a query */
@@ -168,6 +169,7 @@ public class BootStrapTest extends TestCase {
info.setUser("user");
info.setUserRunAs("root");
info.setPassword("passwd");
+ info.setAmbariRepoUrls("null");
BSResponse response = impl.runBootStrap(info);
long requestId = response.getRequestId();
LOG.info("Response id from bootstrap " + requestId);
http://git-wip-us.apache.org/repos/asf/ambari/blob/95164bcc/ambari-server/src/test/python/TestBootstrap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestBootstrap.py b/ambari-server/src/test/python/TestBootstrap.py
index bea47f4..404d07b 100644
--- a/ambari-server/src/test/python/TestBootstrap.py
+++ b/ambari-server/src/test/python/TestBootstrap.py
@@ -44,7 +44,7 @@ class TestBootstrap(TestCase):
def test_getRemoteName(self):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
- "setupAgentFile", "ambariServer", "centos6", None, "8440", "root")
+ "setupAgentFile", "ambariServer", "centos6", None, "8440", "root", "null")
res = bootstrap_obj = Bootstrap("hostname", shared_state)
utime1 = 1234
utime2 = 12345
@@ -67,7 +67,7 @@ class TestBootstrap(TestCase):
def test_getAmbariPort(self):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
self.assertEquals(bootstrap_obj.getAmbariPort(),"8440")
shared_state.server_port = None
@@ -83,11 +83,11 @@ class TestBootstrap(TestCase):
@patch("os.path.realpath")
def test_bootstrap_main(self, dirname_mock, realpath_mock, run_mock, exit_mock, stderr_mock, subprocess_Popen_mock):
bootstrap.main(["bootstrap.py", "hostname,hostname2", "/tmp/bootstrap", "root", "123", "sshkey_file", "setupAgent.py", "ambariServer", \
- "centos6", "1.1.1", "8440", "root", "passwordfile"])
+ "centos6", "1.1.1", "8440", "root", "null", "passwordfile"])
self.assertTrue(run_mock.called)
run_mock.reset_mock()
bootstrap.main(["bootstrap.py", "hostname,hostname2", "/tmp/bootstrap", "root", "123", "sshkey_file", "setupAgent.py", "ambariServer", \
- "centos6", "1.1.1", "8440", "root", None])
+ "centos6", "1.1.1", "8440", "root", "null", None])
self.assertTrue(run_mock.called)
run_mock.reset_mock()
def side_effect(retcode):
@@ -106,7 +106,7 @@ class TestBootstrap(TestCase):
def test_getRunSetupWithPasswordCommand(self, environ_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
environ_mock.__getitem__.return_value = "TEST_PASSPHRASE"
bootstrap_obj = Bootstrap("hostname", shared_state)
utime = 1234
@@ -120,7 +120,7 @@ class TestBootstrap(TestCase):
def test_generateRandomFileName(self):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
self.assertTrue(bootstrap_obj.generateRandomFileName(None) == bootstrap_obj.getUtime())
@@ -131,7 +131,7 @@ class TestBootstrap(TestCase):
def test_getRepoDir(self, is_suse_family, is_redhat_family):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
# Suse
is_redhat_family.return_value = False
@@ -147,7 +147,7 @@ class TestBootstrap(TestCase):
def test_getSetupScript(self):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
self.assertEquals(bootstrap_obj.shared_state.script_dir, "scriptDir")
@@ -157,7 +157,7 @@ class TestBootstrap(TestCase):
version = "1.1.1"
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- version, "8440", "root")
+ version, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
runSetupCommand = bootstrap_obj.getRunSetupCommand("hostname")
self.assertTrue(runSetupCommand.endswith(version + " 8440"))
@@ -168,7 +168,7 @@ class TestBootstrap(TestCase):
version = None
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- version, "8440", "root")
+ version, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
runSetupCommand = bootstrap_obj.getRunSetupCommand("hostname")
self.assertTrue(runSetupCommand.endswith(" 8440"))
@@ -209,7 +209,7 @@ class TestBootstrap(TestCase):
def test_SCP(self, popenMock):
params = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- "1.2.1", "8440", "root")
+ "1.2.1", "8440", "root", "null")
host_log_mock = MagicMock()
log = {'text': ""}
def write_side_effect(text):
@@ -252,7 +252,7 @@ class TestBootstrap(TestCase):
def test_SSH(self, popenMock):
params = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- "1.2.1", "8440", "root")
+ "1.2.1", "8440", "root", "null")
host_log_mock = MagicMock()
log = {'text': ""}
def write_side_effect(text):
@@ -308,7 +308,7 @@ class TestBootstrap(TestCase):
def test_getOsCheckScript(self):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root" ,"null")
bootstrap_obj = Bootstrap("hostname", shared_state)
ocs = bootstrap_obj.getOsCheckScript()
self.assertEquals(ocs, "scriptDir/os_check_type.py")
@@ -318,7 +318,7 @@ class TestBootstrap(TestCase):
def test_getOsCheckScriptRemoteLocation(self, getRemoteName_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
v = "/tmp/os_check_type1374259902.py"
getRemoteName_mock.return_value = v
@@ -330,7 +330,7 @@ class TestBootstrap(TestCase):
def test_getRepoFile(self, is_suse_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
is_suse_mock.return_value = False
rf = bootstrap_obj.getRepoFile()
@@ -344,7 +344,7 @@ class TestBootstrap(TestCase):
init_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root" ,"null")
bootstrap_obj = Bootstrap("hostname", shared_state)
expected = 42
init_mock.return_value = None
@@ -368,7 +368,7 @@ class TestBootstrap(TestCase):
getOsCheckScriptRemoteLocation_mock, getOsCheckScript_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
getOsCheckScript_mock.return_value = "OsCheckScript"
getOsCheckScriptRemoteLocation_mock.return_value = "OsCheckScriptRemoteLocation"
@@ -391,7 +391,7 @@ class TestBootstrap(TestCase):
def test_getRepoFile(self, is_redhat_family, is_ubuntu_family, is_suse_family, hasPassword_mock, getRemoteName_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
is_redhat_family.return_value = True
is_ubuntu_family.return_value = False
is_suse_family.return_value = False
@@ -439,7 +439,7 @@ class TestBootstrap(TestCase):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
is_redhat_family.return_value = True
is_ubuntu_family.return_value = False
is_suse_family.return_value = False
@@ -509,7 +509,7 @@ class TestBootstrap(TestCase):
init_mock, getOsCheckScriptRemoteLocation_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
getOsCheckScriptRemoteLocation_mock.return_value = "OsCheckScriptRemoteLocation"
expected = 42
@@ -531,7 +531,7 @@ class TestBootstrap(TestCase):
getRunSetupCommand_mock, init_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
getRunSetupCommand_mock.return_value = "RunSetupCommand"
expected = 42
@@ -551,7 +551,7 @@ class TestBootstrap(TestCase):
hasPassword_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
# With password
hasPassword_mock.return_value = True
@@ -570,7 +570,7 @@ class TestBootstrap(TestCase):
tmp_dir = tempfile.gettempdir()
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", tmp_dir,
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
done_file = os.path.join(tmp_dir, "hostname.done")
expected = 42
@@ -589,7 +589,7 @@ class TestBootstrap(TestCase):
def test_checkSudoPackage(self, write_mock, run_mock, init_mock, is_redhat_family, is_ubuntu_family, is_suse_family):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
expected = 42
init_mock.return_value = None
@@ -612,7 +612,7 @@ class TestBootstrap(TestCase):
is_redhat_family, is_ubuntu_family, is_suse_family):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "ubuntu12",
- None, "8440", "root")
+ None, "8440", "root" ,"null")
is_redhat_family.return_value = False
is_ubuntu_family.return_value = True
is_suse_family.return_value = False
@@ -634,7 +634,7 @@ class TestBootstrap(TestCase):
init_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
expected = 42
getPasswordFile_mock.return_value = "PasswordFile"
@@ -657,7 +657,7 @@ class TestBootstrap(TestCase):
scp_init_mock, getPasswordFile_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root", password_file="PasswordFile")
+ None, "8440", "root", "null", password_file="PasswordFile")
bootstrap_obj = Bootstrap("hostname", shared_state)
getPasswordFile_mock.return_value = "PasswordFile"
# Testing max retcode return
@@ -690,7 +690,7 @@ class TestBootstrap(TestCase):
run_mock, init_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
expected = 42
getPasswordFile_mock.return_value = "PasswordFile"
@@ -707,7 +707,7 @@ class TestBootstrap(TestCase):
expected = 43
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
# Normal case
def act_normal_return_int():
@@ -740,7 +740,7 @@ class TestBootstrap(TestCase):
hasPassword_mock, try_to_execute_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
# Testing workflow without password
bootstrap_obj.copied_password_file = False
@@ -812,7 +812,7 @@ class TestBootstrap(TestCase):
def test_interruptBootstrap(self, write_mock, createDoneFile_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
bootstrap_obj = Bootstrap("hostname", shared_state)
bootstrap_obj.interruptBootstrap()
self.assertTrue(createDoneFile_mock.called)
@@ -829,7 +829,7 @@ class TestBootstrap(TestCase):
info_mock, warn_mock, time_mock, sleep_mock):
shared_state = SharedState("root", "123", "sshkey_file", "scriptDir", "bootdir",
"setupAgentFile", "ambariServer", "centos6",
- None, "8440", "root")
+ None, "8440", "root", "null")
n = 180
time = 100500
time_mock.return_value = time
http://git-wip-us.apache.org/repos/asf/ambari/blob/95164bcc/ambari-web/app/controllers/wizard/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js
index 5ff2cdc..6e0988c 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/step3_controller.js
@@ -201,7 +201,8 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, App.Check
'hosts': this.getBootstrapHosts(),
'user': this.get('content.installOptions.sshUser'),
'sshPort': this.get('content.installOptions.sshPort'),
- 'userRunAs': App.get('supports.customizeAgentUserAccount') ? this.get('content.installOptions.agentUser') : 'root'
+ 'userRunAs': App.get('supports.customizeAgentUserAccount') ? this.get('content.installOptions.agentUser') : 'root',
+ 'ambariRepoUrls': "null"
});
App.router.get(this.get('content.controllerName')).launchBootstrap(bootStrapData, function (requestId) {
if (requestId == '0') {
@@ -400,7 +401,8 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, App.Check
'hosts': hosts.mapProperty('name'),
'user': this.get('content.installOptions.sshUser'),
'sshPort': this.get('content.installOptions.sshPort'),
- 'userRunAs': App.get('supports.customizeAgentUserAccount') ? this.get('content.installOptions.agentUser') : 'root'
+ 'userRunAs': App.get('supports.customizeAgentUserAccount') ? this.get('content.installOptions.agentUser') : 'root',
+ 'ambariRepoUrls': "null"
});
this.set('numPolls', 0);
this.set('registrationStartedAt', null);
@@ -662,7 +664,60 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, App.Check
* @method bootstrapWithAmbariRepoUrl
*/
bootstrapWithAmbariRepoUrl : function() {
+ var self = this;
+ var tmpNewAmbariOsTypes = [];
+ var tmpBootstrapHosts = [];
+ self.newAmbariOsTypes.forEach(function(os) {
+ if (os.ambari_repo != "") {
+ tmpNewAmbariOsTypes.pushObject(os);
+ self.newAmbariOsTypes.removeObject(os);
+ }
+ });
+ if (self.newAmbariOsTypes.length <= 0) {
+ this.set('promptAmbariRepoUrl', false);
+ }
+ tmpNewAmbariOsTypes.forEach(function(os) {
+ os.hosts.forEach(function(host) {
+ tmpBootstrapHosts.push(host);
+ });
+ });
+ var bootStrapData = JSON.stringify({
+ 'verbose' : true,
+ 'sshKey' : this.get('content.installOptions.sshKey'),
+ 'hosts' : tmpBootstrapHosts,
+ 'user' : this.get('content.installOptions.sshUser'),
+ 'sshPort' : this.get('content.installOptions.sshPort'),
+ 'userRunAs' : App.get('supports.customizeAgentUserAccount') ? this.get('content.installOptions.agentUser') : 'root',
+ 'ambariRepoUrls' : JSON.stringify(tmpNewAmbariOsTypes)
+ });
+ this.set('numPolls', 0);
+ this.set('registrationStartedAt', null);
+ this.set('isHostsWarningsLoaded', false);
+ this.set('stopChecking', false);
+ this.set('isSubmitDisabled', true);
+ this.set('bootstrapInProgress',true);
+ var selectedHosts = this.get('bootHosts');
+ selectedHosts.forEach(function(_host) {
+ var bootHostName = _host.get('name');
+ for (var i = 0; i < tmpNewAmbariOsTypes.length; i++) {
+ if (tmpNewAmbariOsTypes[i] == bootHostName) {
+ _host.set('bootStatus', 'DONE');
+ _host.set('bootLog', 'Retrying ...');
+ }
+ }
+ }, this);
+ App.router.get(this.get('content.controllerName')).launchBootstrap(bootStrapData,function(requestId) {
+ if (requestId == '0') {
+ self.startBootstrap();
+ } else if (requestId) {
+ self.set('content.installOptions.bootRequestId',
+ requestId);
+ App.router.get(self.get('content.controllerName'))
+ .save('installOptions');
+ self.startBootstrap();
+ }
+ });
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/95164bcc/ambari-web/test/controllers/wizard/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js
index be1affe..a3d5b43 100644
--- a/ambari-web/test/controllers/wizard/step3_test.js
+++ b/ambari-web/test/controllers/wizard/step3_test.js
@@ -542,7 +542,8 @@ describe('App.WizardStep3Controller', function () {
hosts: ['host0', 'host1'],
user: 'root',
sshPort: '123',
- userRunAs: item.userRunAs
+ userRunAs: item.userRunAs,
+ ambariRepoUrls: "null"
}));
});
@@ -2358,7 +2359,8 @@ describe('App.WizardStep3Controller', function () {
hosts: ['host0', 'host1'],
user: 'root',
sshPort: '123',
- userRunAs: item.userRunAs
+ userRunAs: item.userRunAs,
+ ambariRepoUrls: "null"
}));
});
});
@@ -2700,6 +2702,91 @@ describe('App.WizardStep3Controller', function () {
});
+ describe('#bootstrapWithAmbariRepoUrl', function () {
+
+ var customizeAgentUserAccountCases = [
+ {
+ customizeAgentUserAccount: true,
+ userRunAs: 'user',
+ title: 'Ambari Agent user account customize enabled'
+ },
+ {
+ customizeAgentUserAccount: false,
+ userRunAs: 'root',
+ title: 'Ambari Agent user account customize disabled'
+ }
+ ];
+ var controller = App.WizardStep3Controller.create({
+ content: {
+ installOptions: {
+ sshKey: 'key',
+ sshUser: 'root',
+ sshPort: '123',
+ agentUser: 'user'
+ },
+ controllerName: 'installerController'
+ },
+ });
+
+ beforeEach(function () {
+ sinon.stub(App.router.get('installerController'), 'launchBootstrap', Em.K);
+ this.mock = sinon.stub(App, 'get');
+ });
+
+ afterEach(function () {
+ App.router.get('installerController').launchBootstrap.restore();
+ this.mock.restore();
+ });
+
+ customizeAgentUserAccountCases.forEach(function (item) {
+ it(item.title, function () {
+ controller.set('newAmbariOsTypes', [Em.Object.create({os_type : 'os1', ambari_repo : "http://ambari-repo", ambariRepoUIError : "", hasError : false, hosts : ['host1']})]);
+ this.mock.withArgs('supports.customizeAgentUserAccount').returns(item.customizeAgentUserAccount);
+ controller.bootstrapWithAmbariRepoUrl();
+ expect(App.router.get('installerController.launchBootstrap').firstCall.args[0]).to.equal(JSON.stringify({
+ verbose: true,
+ sshKey: 'key',
+ hosts: ['host1'],
+ user: 'root',
+ sshPort: '123',
+ userRunAs: item.userRunAs,
+ ambariRepoUrls: "[{\"os_type\":\"os1\",\"ambariRepoUIError\":\"\",\"hasError\":false,\"hosts\":[\"host1\"],\"ambari_repo\":\"http://ambari-repo\"}]"
+ }));
+ });
+ });
+
+ it('bootstrap hosts with ambari repo url not null', function () {
+ var newAmbariOsTypes = [
+ Em.Object.create({os_type : 'os1', ambari_repo : "http://ambari-repo", ambariRepoUIError: "", hasError : false, hosts : ['host1']}),
+ Em.Object.create({os_type : 'os2', ambari_repo : "", ambariRepoUIError: "", hasError : false, hosts : ['host2']})
+ ];
+ controller.set('newAmbariOsTypes',newAmbariOsTypes);
+ this.mock.withArgs('supports.customizeAgentUserAccount').returns(false);
+ controller.bootstrapWithAmbariRepoUrl();
+ expect(App.router.get('installerController.launchBootstrap').firstCall.args[0]).to.equal(JSON.stringify({
+ verbose: true,
+ sshKey: 'key',
+ hosts: ['host1'],
+ user: 'root',
+ sshPort: '123',
+ userRunAs: 'root',
+ ambariRepoUrls: "[{\"os_type\":\"os1\",\"ambariRepoUIError\":\"\",\"hasError\":false,\"hosts\":[\"host1\"],\"ambari_repo\":\"http://ambari-repo\"}]"
+ }));
+ });
+
+ it('should show ambari repo url prompt for empty textboxes', function () {
+ var newAmbariOsTypes = [
+ Em.Object.create({os_type : 'os1', ambari_repo : "http://ambari-repo", hasError : false, hosts : ['host1']}),
+ Em.Object.create({os_type : 'os2', ambari_repo : "", hasError : false, hosts : ['host2']})
+ ];
+ controller.set('newAmbariOsTypes',newAmbariOsTypes);
+ this.mock.withArgs('supports.customizeAgentUserAccount').returns(false);
+ controller.bootstrapWithAmbariRepoUrl();
+ expect(controller.get('promptAmbariRepoUrl'), true);
+ });
+
+ });
+
describe('#getJDKNameSuccessCallback', function () {
it('should set proper data to controller properties', function () {