You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2015/10/29 09:35:30 UTC

[2/3] git commit: updated refs/heads/master to eabf11c

CLOUDSTACK-8957 - Implement password server in configure.py


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

Branch: refs/heads/master
Commit: b2aa1f8417138797dddf3813fcaed9b5ea4ba611
Parents: 1f6781b
Author: Wilder Rodrigues <wr...@schubergphilis.com>
Authored: Tue Oct 27 13:31:31 2015 +0100
Committer: Wilder Rodrigues <wr...@schubergphilis.com>
Committed: Thu Oct 29 07:14:51 2015 +0100

----------------------------------------------------------------------
 .../debian/config/opt/cloud/bin/configure.py    | 36 +++++++++++++-------
 1 file changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b2aa1f84/systemvm/patches/debian/config/opt/cloud/bin/configure.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/configure.py b/systemvm/patches/debian/config/opt/cloud/bin/configure.py
index 8c39f75..2047744 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/configure.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/configure.py
@@ -41,27 +41,37 @@ from cs.CsApp import CsApache, CsDnsmasq
 from cs.CsMonitor import CsMonitor
 from cs.CsLoadBalancer import CsLoadBalancer
 from cs.CsConfig import CsConfig
+from cs.CsProcess import CsProcess
 
 
 class CsPassword(CsDataBag):
-    """
-      Update the password cache
-
-      A stupid step really as we should just rewrite the password server to
-      use the databag
-    """
-    cache = "/var/cache/cloud/passwords"
-
+    
+    TOKEN_FILE="/tmp/passwdsrvrtoken"
+    
     def process(self):
-        file = CsFile(self.cache)
         for item in self.dbag:
             if item == "id":
                 continue
-            self.__update(file, item, self.dbag[item])
-        file.commit()
+            self.__update(item, self.dbag[item])
 
-    def __update(self, file, ip, password):
-        file.search("%s=" % ip, "%s=%s" % (ip, password))
+    def __update(self, vm_ip, password):
+        token = ""
+        try:
+            tokenFile = open(self.TOKEN_FILE)
+            token = tokenFile.read()
+        except IOError:
+            logging.debug("File %s does not exist" % self.TOKEN_FILE)
+
+        ips_cmd = "ip addr show | grep inet | awk '{print $2}'"
+        ips = CsHelper.execute(ips_cmd)
+        for ip in ips:
+            server_ip = ip.split('/')[0]
+            proc = CsProcess(['/opt/cloud/bin/passwd_server_ip.py', server_ip])
+            if proc.find():
+                update_command = 'curl --header "DomU_Request: save_password" "http://{SERVER_IP}:8080/" -F "ip={VM_IP}" -F "password={PASSWORD}" ' \
+                '-F "token={TOKEN}" >/dev/null 2>/dev/null &'.format(SERVER_IP=server_ip, VM_IP=vm_ip, PASSWORD=password, TOKEN=token)
+                result = CsHelper.execute(update_command)
+                logging.debug("Update password server result ==> %s" % result)
 
 
 class CsAcl(CsDataBag):