You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2015/12/14 17:07:13 UTC
ambari git commit: AMBARI-14369. Make messages about user or group
not found more understandable (aonishuk)
Repository: ambari
Updated Branches:
refs/heads/trunk 77cf8477b -> 9cb0e457c
AMBARI-14369. Make messages about user or group not found more understandable (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9cb0e457
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9cb0e457
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9cb0e457
Branch: refs/heads/trunk
Commit: 9cb0e457c9960114bd6a892852616784f1755c28
Parents: 77cf847
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Dec 14 18:07:04 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Dec 14 18:07:04 2015 +0200
----------------------------------------------------------------------
.../python/resource_management/core/providers/system.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9cb0e457/ambari-common/src/main/python/resource_management/core/providers/system.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/system.py b/ambari-common/src/main/python/resource_management/core/providers/system.py
index 4e6a122..4feacee 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/system.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/system.py
@@ -41,14 +41,22 @@ def _ensure_metadata(path, user, group, mode=None, cd_access=None):
stat = sudo.stat(path)
if user:
- _user_entity = pwd.getpwnam(user)
+ try:
+ _user_entity = pwd.getpwnam(user)
+ except KeyError:
+ raise Fail("User '{0}' doesn't exist".format(user))
+
if stat.st_uid != _user_entity.pw_uid:
user_entity = _user_entity
Logger.info(
"Changing owner for %s from %d to %s" % (path, stat.st_uid, user))
if group:
- _group_entity = grp.getgrnam(group)
+ try:
+ _group_entity = grp.getgrnam(group)
+ except KeyError:
+ raise Fail("Group '{0}' doesn't exist".format(group))
+
if stat.st_gid != _group_entity.gr_gid:
group_entity = _group_entity
Logger.info(