Kaynağa Gözat

AMBARI-2679. An additional .repo file(s) is placed in /etc/yum.repos.d directory after installing hadoop. (smohanty)

Sumit Mohanty 12 yıl önce
ebeveyn
işleme
f79e2f5cde

+ 1 - 30
ambari-server/src/main/python/bootstrap.py

@@ -342,22 +342,6 @@ class BootStrap:
   def hasPassword(self):
     return self.passwordFile is not None and self.passwordFile != 'null'
 
-  def getMoveRepoFileWithPasswordCommand(self, targetDir):
-    return "sudo -S mv " + str(self.getRemoteName(self.AMBARI_REPO_FILENAME))\
-           + " " + str(targetDir) + " < " + str(self.getPasswordFile())
-
-
-  def getMoveRepoFileWithoutPasswordCommand(self, targetDir):
-    return "sudo mv " + str(self.getRemoteName(self.AMBARI_REPO_FILENAME)) +\
-            " " + str(targetDir)
-
-  def getMoveRepoFileCommand(self, targetDir):
-    if self.hasPassword():
-      return self.getMoveRepoFileWithPasswordCommand(targetDir)
-    else:
-      return self.getMoveRepoFileWithoutPasswordCommand(targetDir)
-
-
 
   def copyOsCheckScript(self):
     try:
@@ -390,7 +374,7 @@ class BootStrap:
     try:
       # Copying the files
       fileToCopy = self.getRepoFile()
-      target = self.getRemoteName(self.AMBARI_REPO_FILENAME)
+      target = self.getRepoFile()
       logging.info("Copying repo file to 'tmp' folder...")
       pscp = PSCP(self.successive_hostlist, self.user, self.sshkeyFile, fileToCopy, target, self.bootdir)
       pscp.run()
@@ -405,19 +389,6 @@ class BootStrap:
       self.statuses = unite_statuses(self.statuses, out)
 
       logging.info("Moving repo file...")
-      targetDir = self.getRepoDir()
-      command = self.getMoveRepoFileCommand(targetDir)
-      pssh = PSSH(self.successive_hostlist, self.user, self.sshkeyFile, self.bootdir, command=command)
-      pssh.run()
-      out = pssh.getstatus()
-      # Preparing report about failed hosts
-      failed_current = get_difference(self.successive_hostlist, skip_failed_hosts(out))
-      self.successive_hostlist = skip_failed_hosts(out)
-      failed = get_difference(self.hostlist, self.successive_hostlist)
-      logging.info("Parallel scp returns for moving repo file. All failed hosts are: " + str(failed) +
-                   ". Failed on last step: " + str(failed_current))
-      #updating statuses
-      self.statuses = unite_statuses(self.statuses, out)
 
       target = self.getRemoteName(self.SETUP_SCRIPT_FILENAME)
       pscp = PSCP(self.successive_hostlist, self.user, self.sshkeyFile, self.setupAgentFile, target, self.bootdir)

+ 2 - 17
ambari-server/src/test/python/TestBootstrap.py

@@ -358,9 +358,7 @@ class TestBootstrap(TestCase):
   @patch.object(Popen, "communicate")
   @patch.object(BootStrap, "createDoneFiles")
   @patch.object(BootStrap, "getRunSetupWithPasswordCommand")
-  @patch.object(BootStrap, "getMoveRepoFileWithPasswordCommand")
-  def test_commands_with_password_are_called_for_user_with_password(self, getMoveRepoFileWithPasswordCommand_method,
-                                                                    getRunSetupWithPasswordCommand_method,
+  def test_commands_with_password_are_called_for_user_with_password(self, getRunSetupWithPasswordCommand_method,
                                                                     createDoneFiles_method,
                                                                     communicate_method,
                                                                     SSH_writeLogToFile_method,
@@ -373,7 +371,6 @@ class TestBootstrap(TestCase):
     createDoneFiles_method.return_value = None
 
     getRunSetupWithPasswordCommand_method.return_value = ""
-    getMoveRepoFileWithPasswordCommand_method.return_value = ""
 
     os.environ[AMBARI_PASSPHRASE_VAR_NAME] = ""
     hosts = ["hostname"]
@@ -386,15 +383,11 @@ class TestBootstrap(TestCase):
     bootstrap_obj.successive_hostlist = hosts
     bootstrap_obj.runSetupAgent()
     self.assertTrue(getRunSetupWithPasswordCommand_method.called)
-    self.assertTrue(getMoveRepoFileWithPasswordCommand_method.called)
     getRunSetupWithPasswordCommand_method.reset()
-    getMoveRepoFileWithPasswordCommand_method.reset()
     getRunSetupWithPasswordCommand_method.reset()
-    getMoveRepoFileWithPasswordCommand_method.reset()
     bootstrap_obj.successive_hostlist = None
     bootstrap_obj.copyOsCheckScript()
     self.assertTrue(getRunSetupWithPasswordCommand_method.called)
-    self.assertTrue(getMoveRepoFileWithPasswordCommand_method.called)
 
   @patch.object(bootstrap, "get_difference")
   @patch.object(SCP, "writeLogToFile")
@@ -402,9 +395,7 @@ class TestBootstrap(TestCase):
   @patch.object(Popen, "communicate")
   @patch.object(BootStrap, "createDoneFiles")
   @patch.object(BootStrap, "getRunSetupWithoutPasswordCommand")
-  @patch.object(BootStrap, "getMoveRepoFileWithoutPasswordCommand")
-  def test_commands_without_password_are_called_for_passwordless_user(self, getMoveRepoFileWithoutPasswordCommand_method,
-                                                                      getRunSetupWithoutPasswordCommand_method,
+  def test_commands_without_password_are_called_for_passwordless_user(self, getRunSetupWithoutPasswordCommand_method,
                                                                       createDoneFiles_method,
                                                                       communicate_method,
                                                                       SSH_writeLogToFile_method,
@@ -416,7 +407,6 @@ class TestBootstrap(TestCase):
     createDoneFiles_method.return_value = None
 
     getRunSetupWithoutPasswordCommand_method.return_value = ""
-    getMoveRepoFileWithoutPasswordCommand_method.return_value = ""
 
     os.environ[AMBARI_PASSPHRASE_VAR_NAME] = ""
     hosts = ["hostname"]
@@ -429,21 +419,16 @@ class TestBootstrap(TestCase):
     bootstrap_obj.successive_hostlist = hosts
     bootstrap_obj.runSetupAgent()
     self.assertTrue(getRunSetupWithoutPasswordCommand_method.called)
-    self.assertTrue(getMoveRepoFileWithoutPasswordCommand_method.called)
     getRunSetupWithoutPasswordCommand_method.reset()
-    getMoveRepoFileWithoutPasswordCommand_method.reset()
 
     get_difference_mock.return_value = None
     self.assertTrue(bootstrap_obj.copyNeededFiles() == 0)
     self.assertTrue(getRunSetupWithoutPasswordCommand_method.called)
-    self.assertTrue(getMoveRepoFileWithoutPasswordCommand_method.called)
     getRunSetupWithoutPasswordCommand_method.reset()
-    getMoveRepoFileWithoutPasswordCommand_method.reset()
 
     bootstrap_obj.successive_hostlist = None
     bootstrap_obj.copyNeededFiles()
     self.assertTrue(getRunSetupWithoutPasswordCommand_method.called)
-    self.assertTrue(getMoveRepoFileWithoutPasswordCommand_method.called)
 
   @patch.object(BootStrap, "runSetupAgent")
   @patch.object(BootStrap, "copyNeededFiles")