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 2014/12/29 17:23:20 UTC

ambari git commit: AMBARI-8940. Ambari overrides user/groups settings configured by cluster admins (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/trunk a0ea540ce -> dc097d18d


AMBARI-8940. Ambari overrides user/groups settings configured by cluster admins (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/dc097d18
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/dc097d18
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/dc097d18

Branch: refs/heads/trunk
Commit: dc097d18d458bcdaab7de77af3f2ccffe81e86b1
Parents: a0ea540
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Dec 29 18:23:14 2014 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Dec 29 18:23:14 2014 +0200

----------------------------------------------------------------------
 .../core/providers/accounts.py                  | 12 ++++++++--
 .../core/providers/system.py                    |  1 +
 .../core/resources/accounts.py                  |  3 +++
 .../libraries/functions/get_namenode_states.py  | 24 +++++++++++++++++++-
 .../dependency-reduced-pom.xml                  | 16 +++++++++++++
 5 files changed, 53 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/dc097d18/ambari-common/src/main/python/resource_management/core/providers/accounts.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/providers/accounts.py b/ambari-common/src/main/python/resource_management/core/providers/accounts.py
index c99b775..12dcffe 100644
--- a/ambari-common/src/main/python/resource_management/core/providers/accounts.py
+++ b/ambari-common/src/main/python/resource_management/core/providers/accounts.py
@@ -51,7 +51,12 @@ class UserProvider(Provider):
       command.append("--system")
 
     if self.resource.groups:
-      command += ["-G", ",".join(self.resource.groups)]
+      
+      groups = self.resource.groups
+      if self.user and self.user_groups:
+        groups += self.user_groups
+      
+      command += ["-G", ",".join(groups)]
 
     for option_name, option_flag in options.items():
       option_value = getattr(self.resource, option_name)
@@ -74,7 +79,10 @@ class UserProvider(Provider):
       return pwd.getpwnam(self.resource.username)
     except KeyError:
       return None
-
+    
+  @property
+  def user_groups(self):
+    return [g.gr_name for g in grp.getgrall() if self.resource.username in g.gr_mem]
 
 class GroupProvider(Provider):
   def action_create(self):

http://git-wip-us.apache.org/repos/asf/ambari/blob/dc097d18/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 1c4313c..d293a31 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
@@ -244,6 +244,7 @@ class ExecuteProvider(Provider):
   def action_run(self):
     if self.resource.creates:
       if os.path.exists(self.resource.creates):
+        Logger.info("Skipping %s due to creates" % self.resource)
         return
       
     env = self.resource.environment

http://git-wip-us.apache.org/repos/asf/ambari/blob/dc097d18/ambari-common/src/main/python/resource_management/core/resources/accounts.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/resources/accounts.py b/ambari-common/src/main/python/resource_management/core/resources/accounts.py
index b6200fa..a75b723 100644
--- a/ambari-common/src/main/python/resource_management/core/resources/accounts.py
+++ b/ambari-common/src/main/python/resource_management/core/resources/accounts.py
@@ -39,6 +39,9 @@ class User(Resource):
   comment = ResourceArgument()
   uid = ResourceArgument()
   gid = ResourceArgument()
+  """
+  If the user exists, and there are some groups, appends to existant
+  """
   groups = ForcedListArgument(default=[]) # supplementary groups
   home = ResourceArgument()
   shell = ResourceArgument()

http://git-wip-us.apache.org/repos/asf/ambari/blob/dc097d18/ambari-common/src/main/python/resource_management/libraries/functions/get_namenode_states.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/libraries/functions/get_namenode_states.py b/ambari-common/src/main/python/resource_management/libraries/functions/get_namenode_states.py
index f1dcaa2..826c045 100644
--- a/ambari-common/src/main/python/resource_management/libraries/functions/get_namenode_states.py
+++ b/ambari-common/src/main/python/resource_management/libraries/functions/get_namenode_states.py
@@ -1,3 +1,25 @@
+#!/usr/bin/env python
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+Ambari Agent
+
+"""
+
 from resource_management.libraries.script import UnknownConfiguration
 
 __all__ = ["get_namenode_states", "get_active_namenode"]
@@ -47,4 +69,4 @@ def get_active_namenode(hdfs_site):
   if active_namenodes:
     return active_namenodes[0]
   else:
-    return UnknownConfiguration('fs_root')
\ No newline at end of file
+    return UnknownConfiguration('fs_root')

http://git-wip-us.apache.org/repos/asf/ambari/blob/dc097d18/contrib/fast-hdfs-resource/dependency-reduced-pom.xml
----------------------------------------------------------------------
diff --git a/contrib/fast-hdfs-resource/dependency-reduced-pom.xml b/contrib/fast-hdfs-resource/dependency-reduced-pom.xml
index c252f2e..1f48496 100644
--- a/contrib/fast-hdfs-resource/dependency-reduced-pom.xml
+++ b/contrib/fast-hdfs-resource/dependency-reduced-pom.xml
@@ -1,3 +1,19 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>