def install(self, es_home_path, plugin_url=None): installer_binary_path = os.path.join(es_home_path, "bin", "elasticsearch-plugin") if plugin_url: logger.info("Installing [%s] into [%s] from [%s]" % (self.plugin_name, es_home_path, plugin_url)) install_cmd = '%s install --batch "%s"' % (installer_binary_path, plugin_url) else: logger.info("Installing [%s] into [%s]" % (self.plugin_name, es_home_path)) install_cmd = '%s install --batch "%s"' % (installer_binary_path, self.plugin_name) return_code = process.run_subprocess_with_logging(install_cmd) # see: https://www.elastic.co/guide/en/elasticsearch/plugins/current/_other_command_line_parameters.html if return_code == 0: logger.info("Successfully installed [%s]." % self.plugin_name) elif return_code == 64: # most likely this is an unknown plugin raise exceptions.SystemSetupError("Unknown plugin [%s]" % self.plugin_name) elif return_code == 74: raise exceptions.SupplyError( "I/O error while trying to install [%s]" % self.plugin_name) else: raise exceptions.RallyError( "Unknown error while trying to install [%s] (installer return code [%s]). Please check the logs." % (self.plugin_name, str(return_code)))
def clone(src, remote): io.ensure_dir(src) # Don't swallow subprocess output, user might need to enter credentials... if process.run_subprocess_with_logging("git clone %s %s" % (remote, io.escape_path(src))): raise exceptions.SupplyError("Could not clone from [%s] to [%s]" % (remote, src))
def pull_ts(src_dir, ts): fetch(src_dir) clean_src = io.escape_path(src_dir) revision = process.run_subprocess_with_output( "git -C {0} rev-list -n 1 --before=\"{1}\" --date=iso8601 origin/master".format(clean_src, ts))[0].strip() if process.run_subprocess_with_logging("git -C {0} checkout {1}".format(clean_src, revision)): raise exceptions.SupplyError("Could not checkout source tree for timestamped revision [%s]" % ts)
def test_ignores_fetch_errors(self, fetch, is_working_copy): fetch.side_effect = exceptions.SupplyError("Testing error") is_working_copy.return_value = True r = repo.RallyRepository( remote_url="[email protected]/rally-resources", root_dir="/rally-resources", repo_name="unit-test", resource_name="unittest-resources", offline=False) # no exception during the call - we reach this here self.assertTrue(r.remote) fetch.assert_called_with(src="/rally-resources/unit-test")
def rebase(src_dir, remote="origin", branch="master"): checkout(src_dir, branch) if process.run_subprocess_with_logging("git -C {0} rebase {1}/{2}".format( io.escape_path(src_dir), remote, branch)): raise exceptions.SupplyError("Could not rebase on branch [%s]" % branch)
def checkout(src_dir, branch="master"): if process.run_subprocess_with_logging("git -C {0} checkout {1}".format( io.escape_path(src_dir), branch)): raise exceptions.SupplyError( "Could not checkout [%s]. Do you have uncommitted changes?" % branch)
def fetch(src, remote="origin"): if process.run_subprocess_with_logging( "git -C {0} fetch --prune --tags {1}".format( io.escape_path(src), remote)): raise exceptions.SupplyError("Could not fetch source tree from [%s]" % remote)
def pull_revision(src_dir, revision): fetch(src_dir) if process.run_subprocess_with_logging("git -C {0} checkout {1}".format( io.escape_path(src_dir), revision)): raise exceptions.SupplyError( "Could not checkout source tree for revision [%s]" % revision)
def pull_revision(src_dir, revision): if process.run_subprocess( "git -C {0} fetch --quiet origin && git -C {0} checkout --quiet {1}" .format(src_dir, revision)): raise exceptions.SupplyError( "Could not fetch source tree for revision %s" % revision)
def pull_ts(src_dir, ts): if process.run_subprocess( "git -C {0} fetch --quiet origin && git -C {0} checkout --quiet `git -C {0} rev-list -n 1 --before=\"{1}\" " "--date=iso8601 origin/master`".format(src_dir, ts)): raise exceptions.SupplyError( "Could not fetch source tree for timestamped revision %s" % ts)
def rebase(src_dir, remote="origin", branch="master"): checkout(src_dir, branch) if process.run_subprocess("git -C {0} rebase --quiet {1}/{2}".format( src_dir, remote, branch)): raise exceptions.SupplyError("Could not rebase on '%s'" % branch)
def checkout(src_dir, branch="master"): if process.run_subprocess("git -C {0} checkout --quiet {1}".format( src_dir, branch)): raise exceptions.SupplyError("Could not checkout '%s'" % branch)
def fetch(src, remote="origin"): # Don't swallow output but silence git at least a bit... (--quiet) if process.run_subprocess("git -C {0} fetch --prune --quiet {1}".format( src, remote)): raise exceptions.SupplyError("Could not fetch source tree from '%s'" % remote)
def clone(src, remote): io.ensure_dir(src) # Don't swallow subprocess output, user might need to enter credentials... if process.run_subprocess("git clone %s %s" % (remote, src)): raise exceptions.SupplyError("Could not clone from '%s' to '%s'" % (remote, src))
def checkout(src_dir, branch="master"): if process.run_subprocess("git -C {0} checkout --quiet {1}".format( src_dir, branch)): raise exceptions.SupplyError( "Could not checkout branch [%s]. Do you have uncommitted changes?" % branch)
def pull_revision(src_dir, revision): fetch(src_dir) if process.run_subprocess("git -C {0} checkout --quiet {1}".format(src_dir, revision)): raise exceptions.SupplyError("Could not checkout source tree for revision [%s]" % revision)