Repository: ambari Updated Branches: refs/heads/trunk 4102d919a -> 93687a299
AMBARI-10781 [WinTP2] Ambari agent: Ensure the default set of users declared in the host data can be domain accounts Redesigned the users filter to include all the possible hadoop users, local or domain. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/93687a29 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/93687a29 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/93687a29 Branch: refs/heads/trunk Commit: 93687a29934f7bd0608c14849e36e3ae74860a8e Parents: 4102d91 Author: Florian Barca <fba...@hortonworks.com> Authored: Thu Apr 30 09:17:02 2015 -0700 Committer: Florian Barca <fba...@hortonworks.com> Committed: Thu Apr 30 09:17:02 2015 -0700 ---------------------------------------------------------------------- .../src/main/python/ambari_agent/HostInfo.py | 21 ++++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/93687a29/ambari-agent/src/main/python/ambari_agent/HostInfo.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/main/python/ambari_agent/HostInfo.py b/ambari-agent/src/main/python/ambari_agent/HostInfo.py index 1d1e853..98c8045 100644 --- a/ambari-agent/src/main/python/ambari_agent/HostInfo.py +++ b/ambari-agent/src/main/python/ambari_agent/HostInfo.py @@ -32,7 +32,6 @@ from ambari_commons import OSCheck, OSConst from ambari_commons.firewall import Firewall from ambari_commons.os_family_impl import OsFamilyImpl -from resource_management.libraries.functions import packages_analyzer from ambari_agent.Hardware import Hardware from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler @@ -326,26 +325,26 @@ class HostInfoLinux(HostInfo): @OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY) class HostInfoWindows(HostInfo): SERVICE_STATUS_CMD = 'If ((Get-Service | Where-Object {{$_.Name -eq \'{0}\'}}).Status -eq \'Running\') {{echo "Running"; $host.SetShouldExit(0)}} Else {{echo "Stopped"; $host.SetShouldExit(1)}}' - GET_USERS_CMD = '$accounts=(Get-WmiObject -Class Win32_UserAccount -Namespace "root\cimv2" -Filter "LocalAccount=\'$True\'" -ComputerName "LocalHost" -ErrorAction Stop); foreach ($acc in $accounts) {echo $acc.Name}' - GET_JAVA_PROC_CMD = 'foreach ($process in (gwmi Win32_Process -Filter "name = \'java.exe\'")){echo $process.ProcessId;echo $process.CommandLine; echo $process.GetOwner().User}' + GET_USERS_CMD = '$accounts=(Get-WmiObject -Class Win32_UserAccount -Namespace "root\cimv2" -Filter "name = \'{0}\' and Disabled=\'False\'" -ErrorAction Stop); foreach ($acc in $accounts) {{Write-Host ($acc.Domain + "\\" + $acc.Name)}}' + GET_JAVA_PROC_CMD = 'foreach ($process in (gwmi Win32_Process -Filter "name = \'java.exe\'")){{echo $process.ProcessId;echo $process.CommandLine; echo $process.GetOwner().User}}' DEFAULT_LIVE_SERVICES = [ "W32Time" ] - DEFAULT_USERS = ["hadoop"] + DEFAULT_USERS = "hadoop" - def checkUsers(self, users, results): - get_users_cmd = ["powershell", '-noProfile', '-NonInteractive', '-nologo', "-Command", self.GET_USERS_CMD] + def checkUsers(self, user_mask, results): + get_users_cmd = ["powershell", '-noProfile', '-NonInteractive', '-nologo', "-Command", self.GET_USERS_CMD.format(user_mask)] try: osStat = subprocess.Popen(get_users_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = osStat.communicate() except: raise Exception("Failed to get users.") for user in out.split(os.linesep): - if user in users: - result = {} - result['name'] = user - result['status'] = "Available" - results.append(result) + result = {} + result['name'] = user + result['homeDir'] = "" + result['status'] = "Available" + results.append(result) def createAlerts(self, alerts): # TODO AMBARI-7849 Implement createAlerts for Windows