Repository: ambari Updated Branches: refs/heads/branch-1.7.0 40d892858 -> c14ab1d80 refs/heads/trunk 4862ae3b3 -> 9c27eaf0e
AMBARI-7752. HostCleanup.py not compatible with Ubuntu (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9c27eaf0 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9c27eaf0 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9c27eaf0 Branch: refs/heads/trunk Commit: 9c27eaf0e83068f33be8163526236858e34b41ad Parents: 4862ae3 Author: Andrew Onishuk <[email protected]> Authored: Sun Oct 12 15:16:50 2014 +0300 Committer: Andrew Onishuk <[email protected]> Committed: Sun Oct 12 15:16:50 2014 +0300 ---------------------------------------------------------------------- .../src/main/python/ambari_agent/HostCleanup.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9c27eaf0/ambari-agent/src/main/python/ambari_agent/HostCleanup.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/HostCleanup.py b/ambari-agent/src/main/python/ambari_agent/HostCleanup.py index a7283a1..0840378 100644 --- a/ambari-agent/src/main/python/ambari_agent/HostCleanup.py +++ b/ambari-agent/src/main/python/ambari_agent/HostCleanup.py @@ -38,8 +38,12 @@ from ambari_commons import OSCheck logger = logging.getLogger() configFile = "/etc/ambari-agent/conf/ambari-agent.ini" -PACKAGE_ERASE_CMD_RHEL = "yum erase -y {0}" -PACKAGE_ERASE_CMD_SUSE = "zypper -n -q remove {0}" +PACKAGE_ERASE_CMD = { + "redhat": "yum erase -y {0}", + "suse": "zypper -n -q remove {0}", + "ubuntu": "/usr/bin/apt-get -y -q remove {0}" +} + USER_ERASE_CMD = "userdel -rf {0}" GROUP_ERASE_CMD = "groupdel {0}" PROC_KILL_CMD = "kill -9 {0}" @@ -324,10 +328,8 @@ class HostCleanup: if packageStr is not None and packageStr: os_name = OSCheck.get_os_family() command = '' - if os_name == 'suse': - command = PACKAGE_ERASE_CMD_SUSE.format(packageStr) - elif os_name == 'redhat': - command = PACKAGE_ERASE_CMD_RHEL.format(packageStr) + if os_name in PACKAGE_ERASE_CMD: + command = PACKAGE_ERASE_CMD[os_name].format(packageStr) else: logger.warn("Unsupported OS type, cannot remove package.")
