You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ey...@apache.org on 2011/09/27 23:52:41 UTC
svn commit: r1176635 - in
/incubator/ambari/trunk/agent/src/main/python/ambari_agent: Controller.py
main.py
Author: eyang
Date: Tue Sep 27 21:52:40 2011
New Revision: 1176635
URL: http://svn.apache.org/viewvc?rev=1176635&view=rev
Log:
AMBARI-15. Implemented agent side of authentication hooks. (Eric Yang)
Modified:
incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py
incubator/ambari/trunk/agent/src/main/python/ambari_agent/main.py
Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py?rev=1176635&r1=1176634&r2=1176635&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/Controller.py Tue Sep 27 21:52:40 2011
@@ -56,14 +56,15 @@ class Controller(threading.Thread):
def run(self):
id='unknown'
+ if self.credential!=None:
+ auth_handler = urllib2.HTTPBasicAuthHandler()
+ auth_handler.add_password(uri=self.url,
+ user=self.credential['user'],
+ passwd=self.credential['password'])
+ opener = urllib2.build_opener(auth_handler)
+ urllib2.install_openner(opener)
while True:
try:
- '''auth_handler = urllib2.HTTPBasicAuthHandler()
- auth_handler.add_password(uri='',
- user='',
- passwd='')
- opener = urllib2.build_opener(auth_handler)
- urllib2.install_openner(opener) '''
data = json.dumps(self.heartbeat.build(id))
logger.info(data)
req = urllib2.Request(self.url, data, {'Content-Type': 'application/json'})
Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/main.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/main.py?rev=1176635&r1=1176634&r2=1176635&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/main.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/main.py Tue Sep 27 21:52:40 2011
@@ -99,7 +99,9 @@ def main():
config = ConfigParser.RawConfigParser()
config.read('/etc/ambari/ambari.ini')
try:
- credential = config.get('controller', 'user')+":"+config.get('controller', 'password')
+ credential = {}
+ credential['user'] = config.get('controller', 'user')
+ credential['password'] = config.get('controller', 'password')
controllerUrl = config.get('controller', 'url')
except Exception, err:
credential = None
@@ -110,7 +112,7 @@ def main():
logger.info("Connecting to controller at:"+controllerUrl)
# Launch Controller communication
- controller = Controller(controllerUrl)
+ controller = Controller(controllerUrl, credential)
controller.start()
controller.run()
logger.info("finished")