Пример #1
0
  def test_is_debian_family(self, get_os_family_mock):

    get_os_family_mock.return_value = "debian"
    self.assertEqual(OSCheck.is_debian_family(), True)

    get_os_family_mock.return_value = "troll_os"
    self.assertEqual(OSCheck.is_debian_family(), False)
Пример #2
0
def findNearestAgentPackageVersion(projectVersion):
    if projectVersion == "":
        projectVersion = "  "
    if OSCheck.is_suse_family():
        Command = [
            "bash", "-c",
            "zypper -q search -s --match-exact ambari-agent | grep '" +
            projectVersion +
            "' | cut -d '|' -f 4 | head -n1 | sed -e 's/-\w[^:]*//1' "
        ]
    elif OSCheck.is_debian_family():
        if projectVersion == "  ":
            Command = [
                "bash", "-c",
                "apt-cache -q show ambari-agent |grep 'Version\:'|cut -d ' ' -f 2|tr -d '\\n'|sed -s 's/[-|~][A-Za-z0-9]*//'"
            ]
        else:
            Command = [
                "bash", "-c",
                "apt-cache -q show ambari-agent |grep 'Version\:'|cut -d ' ' -f 2|grep '"
                + projectVersion +
                "'|tr -d '\\n'|sed -s 's/[-|~][A-Za-z\d]*//'"
            ]
    else:
        Command = [
            "bash", "-c",
            "yum -q list all ambari-agent | grep '" + projectVersion +
            "' | sed -re 's/\s+/ /g' | cut -d ' ' -f 2 | head -n1 | sed -e 's/-\w[^:]*//1' "
        ]
    return execOsCommand(Command)
Пример #3
0
def isAgentPackageAlreadyInstalled(projectVersion):
    if OSCheck.is_debian_family():
        Command = [
            "bash", "-c", "dpkg -s ambari-agent  2>&1|grep 'Version\:'|grep " +
            projectVersion
        ]
    else:
        Command = [
            "bash", "-c", "rpm -qa | grep ambari-agent-" + projectVersion
        ]
    ret = execOsCommand(Command)
    res = False
    if ret["exitstatus"] == 0 and ret["log"][0].strip() != "":
        res = True
    return res
Пример #4
0
def installAgent(projectVersion):
    """ Run install and make sure the agent install alright """
    # The command doesn't work with file mask ambari-agent*.rpm, so rename it on agent host
    if OSCheck.is_suse_family():
        Command = ["zypper", "install", "-y", "ambari-agent-" + projectVersion]
    elif OSCheck.is_debian_family():
        # add * to end of version in case of some test releases
        Command = [
            "apt-get", "install", "-y", "--force-yes",
            "ambari-agent=" + projectVersion + "*"
        ]
    else:
        Command = [
            "yum", "-y", "install", "--nogpgcheck",
            "ambari-agent-" + projectVersion
        ]
    return execOsCommand(Command)
Пример #5
0
def getAvaliableAgentPackageVersions():
    if OSCheck.is_suse_family():
        Command = [
            "bash", "-c",
            "zypper -q search -s --match-exact ambari-agent | grep ambari-agent | sed -re 's/\s+/ /g' | cut -d '|' -f 4 | tr '\\n' ', ' | sed -s 's/[-|~][A-Za-z0-9]*//g'"
        ]
    elif OSCheck.is_debian_family():
        Command = [
            "bash", "-c",
            "apt-cache -q show ambari-agent|grep 'Version\:'|cut -d ' ' -f 2| tr '\\n' ', '|sed -s 's/[-|~][A-Za-z0-9]*//g'"
        ]
    else:
        Command = [
            "bash", "-c",
            "yum -q list all ambari-agent | grep -E '^ambari-agent' | sed -re 's/\s+/ /g' | cut -d ' ' -f 2 | tr '\\n' ', ' | sed -s 's/[-|~][A-Za-z0-9]*//g'"
        ]
    return execOsCommand(Command)