stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [45/50] [abbrv] git commit: Fixed issues in git artifact management Git clone Git pull
Date Mon, 27 Oct 2014 14:16:49 GMT
Fixed issues in git artifact management
	Git clone
	Git pull

Improved logging format
Removed duplicated parameter APP_PATH


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

Branch: refs/heads/master
Commit: 514a7e38dc5f559ac8024139dbb12ed721682366
Parents: 55e7ea0
Author: Chamila de Alwis <chamilad@wso2.com>
Authored: Fri Oct 24 04:14:23 2014 +0530
Committer: Chamila de Alwis <chamilad@wso2.com>
Committed: Fri Oct 24 04:14:23 2014 +0530

----------------------------------------------------------------------
 .../cartridgeagent/agent.conf                   |  1 -
 .../cartridgeagent/logging.ini                  |  2 +-
 .../modules/artifactmgt/git/agentgithandler.py  | 21 ++++++++++-----
 .../modules/event/instance/notifier/events.py   |  2 +-
 .../extensions/defaultextensionhandler.py       | 15 ++++++-----
 .../cartridgeagent/testgit.py                   | 27 ++++++++++++++++++++
 6 files changed, 52 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/514a7e38/tools/python_cartridgeagent/cartridgeagent/agent.conf
----------------------------------------------------------------------
diff --git a/tools/python_cartridgeagent/cartridgeagent/agent.conf b/tools/python_cartridgeagent/cartridgeagent/agent.conf
index dff3cd7..f3e2afb 100644
--- a/tools/python_cartridgeagent/cartridgeagent/agent.conf
+++ b/tools/python_cartridgeagent/cartridgeagent/agent.conf
@@ -40,7 +40,6 @@ monitoring.server.secure.port         =MONITORING-SERVER-SECURE-PORT
 monitoring.server.admin.username      =MONITORING-SERVER-ADMIN-USERNAME
 monitoring.server.admin.password      =MONITORING-SERVER-ADMIN-PASSWORD
 log.file.paths                        =LOG_FILE_PATHS
-APP_PATH                              =APP-PATH
 super.tenant.repository.path          =/repository/deployment/server/
 tenant.repository.path                =/repository/tenants/
 extension.instance.started            =instance-started.sh

http://git-wip-us.apache.org/repos/asf/stratos/blob/514a7e38/tools/python_cartridgeagent/cartridgeagent/logging.ini
----------------------------------------------------------------------
diff --git a/tools/python_cartridgeagent/cartridgeagent/logging.ini b/tools/python_cartridgeagent/cartridgeagent/logging.ini
index 3e49a96..d71b541 100644
--- a/tools/python_cartridgeagent/cartridgeagent/logging.ini
+++ b/tools/python_cartridgeagent/cartridgeagent/logging.ini
@@ -20,7 +20,7 @@
 keys=default
 
 [formatter_default]
-format=%(asctime)s:%(levelname)s:%(message)s
+format=[%(asctime)s] %(levelname)s {%(filename)s:%(funcName)s} - %(message)s
 class=logging.Formatter
 
 [handlers]

http://git-wip-us.apache.org/repos/asf/stratos/blob/514a7e38/tools/python_cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
----------------------------------------------------------------------
diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
b/tools/python_cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
index 6da9c58..d6381a0 100644
--- a/tools/python_cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
+++ b/tools/python_cartridgeagent/cartridgeagent/modules/artifactmgt/git/agentgithandler.py
@@ -19,6 +19,7 @@ from threading import current_thread, Thread
 from git import *
 from gittle import Gittle, GittleAuth  # GitPython and Gittle are both used at the time being
for pros and cons of both
 import urllib2
+import os
 
 from ... util.log import LogFactory
 from ... util import cartridgeagentutils, extensionutils, cartridgeagentconstants
@@ -27,6 +28,7 @@ from ... config import cartridgeagentconfiguration
 from ... util.asyncscheduledtask import AbstractAsyncScheduledTask, ScheduledExecutor
 from ... artifactmgt.repositoryinformation import RepositoryInformation
 
+
 class AgentGitHandler:
     """
     Handles all the git artifact management tasks related to a cartridge
@@ -81,7 +83,7 @@ class AgentGitHandler:
         else:
             #subscribing run.. need to clone
             subscribe_run = True
-            repo_context = AgentGitHandler.clone(repo_context)
+            repo_context = AgentGitHandler.clone(repo_info)
 
         return subscribe_run, repo_context
 
@@ -133,13 +135,15 @@ class AgentGitHandler:
     @staticmethod
     def pull(repo_context):
         repo = Repo(repo_context.local_repo_path)
-        from ....agent import CartridgeAgent
-        AgentGitHandler.extension_handler = CartridgeAgent.extension_handler
+        import agent
+        AgentGitHandler.extension_handler = agent.CartridgeAgent.extension_handler
         try:
             repo.git.checkout("master")
             pull_output = repo.git.pull()
             if "Already up-to-date." not in pull_output:
                 AgentGitHandler.log.debug("Artifacts were updated as a result of the pull
operation, thread: %r - %r" % (current_thread().getName(), current_thread().ident))
+            else:
+                AgentGitHandler.log.debug("Pull operation: Already up-to-date, thread: %r
- %r" % (current_thread().getName(), current_thread().ident))
 
             AgentGitHandler.extension_handler.on_artifact_update_scheduler_event(repo_context.tenant_id)
         except GitCommandError as ex:
@@ -235,9 +239,10 @@ class AgentGitHandler:
         :rtype: GittleAuth
         """
         if repo_context.key_based_auth:
-            pkey = AgentGitHandler.get_private_key()
-            auth = GittleAuth(pkey=pkey)
-        elif repo_context.repo_username.strip() != "" and repo_context.repo_password.strip()
!= "":
+            private_key = AgentGitHandler.get_private_key()
+            auth = GittleAuth(pkey=private_key)
+        elif repo_context.repo_username is not None and repo_context.repo_username.strip()
!= "" and \
+                        repo_context.repo_password is not None and repo_context.repo_password.strip()
!= "":
             auth = GittleAuth(username=repo_context.repo_username, password=repo_context.repo_password)
         else:
             auth = None
@@ -349,7 +354,7 @@ class AgentGitHandler:
                 #"app_path"
                 repo_path += git_local_repo_path
 
-                if super_tenant_repo_path is not None  and super_tenant_repo_path != "":
+                if super_tenant_repo_path is not None and super_tenant_repo_path != "":
                     super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.startswith("/")
else "/" + super_tenant_repo_path
                     super_tenant_repo_path = super_tenant_repo_path if super_tenant_repo_path.endswith("/")
else  super_tenant_repo_path + "/"
                     #"app_path/repository/deploy/server/"
@@ -495,9 +500,11 @@ class ArtifactUpdateTask(AbstractAsyncScheduledTask):
     def execute_task(self):
         try:
             if self.auto_checkout:
+                self.log.debug("Running checkout job")
                 AgentGitHandler.checkout(self.repo_info)
         except:
             self.log.exception("Auto checkout task failed")
 
         if self.auto_commit:
+            self.log.debug("Running commit job")
             AgentGitHandler.commit(self.repo_info)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/514a7e38/tools/python_cartridgeagent/cartridgeagent/modules/event/instance/notifier/events.py
----------------------------------------------------------------------
diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/event/instance/notifier/events.py
b/tools/python_cartridgeagent/cartridgeagent/modules/event/instance/notifier/events.py
index 024e1e4..eb7be55 100644
--- a/tools/python_cartridgeagent/cartridgeagent/modules/event/instance/notifier/events.py
+++ b/tools/python_cartridgeagent/cartridgeagent/modules/event/instance/notifier/events.py
@@ -45,7 +45,7 @@ class ArtifactUpdatedEvent:
         instance.repo_username = json_obj["repoUserName"] if "repoUserName" in json_obj else
None
         instance.repo_password = json_obj["repoPassword"] if "repoPassword" in json_obj else
None
         instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
-        instance.repo_url = json_obj["repoUrl"] if "repoUrl" in json_obj else ""
+        instance.repo_url = json_obj["repoURL"] if "repoURL" in json_obj else ""
         instance.commit_enabled = json_obj["commitEnabled"] if "commitEnabled" in json_obj
else None
 
         return instance

http://git-wip-us.apache.org/repos/asf/stratos/blob/514a7e38/tools/python_cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python_cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
b/tools/python_cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
index 8a7ccc0..07107da 100644
--- a/tools/python_cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python_cartridgeagent/cartridgeagent/modules/extensions/defaultextensionhandler.py
@@ -99,7 +99,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
                 auto_checkout = self.cartridge_agent_config.is_checkout_enabled
 
                 try:
-                    update_interval = len(
+                    update_interval = int(
                         self.cartridge_agent_config.read_property(cartridgeagentconstants.ARTIFACT_UPDATE_INTERVAL,
False))
                 except ParameterNotFoundException:
                     self.log.exception("Invalid artifact sync interval specified ")
@@ -110,14 +110,17 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
 
                 self.log.info("Artifact updating task enabled, update interval: %r seconds"
% update_interval)
 
-                self.log.info("Auto Commit is turned %r " % "on" if auto_commit else "off")
-                self.log.info("Auto Checkout is turned %r " % "on" if auto_checkout else
"off")
+                self.log.info("Auto Commit is turned %r " % ("on" if auto_commit else "off"))
+                self.log.info("Auto Checkout is turned %r " % ("on" if auto_checkout else
"off"))
 
-                agentgithandler.AgentGitHandler.schedule_artifact_update_scheduled_task(repo_info,
auto_checkout, auto_commit,
-                                                                        update_interval)
+                agentgithandler.AgentGitHandler.schedule_artifact_update_scheduled_task(
+                    repo_info,
+                    auto_checkout,
+                    auto_commit,
+                    update_interval)
 
     def on_artifact_update_scheduler_event(self, tenant_id):
-        env_params = {"STRATOS_ARTIFACT_UPDATED_TENANT_ID": tenant_id, "STRATOS_ARTIFACT_UPDATED_SCHEDULER":
True}
+        env_params = {"STRATOS_ARTIFACT_UPDATED_TENANT_ID": str(tenant_id), "STRATOS_ARTIFACT_UPDATED_SCHEDULER":
str(True)}
 
         extensionutils.execute_artifacts_updated_extension(env_params)
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/514a7e38/tools/python_cartridgeagent/cartridgeagent/testgit.py
----------------------------------------------------------------------
diff --git a/tools/python_cartridgeagent/cartridgeagent/testgit.py b/tools/python_cartridgeagent/cartridgeagent/testgit.py
new file mode 100644
index 0000000..c683b56
--- /dev/null
+++ b/tools/python_cartridgeagent/cartridgeagent/testgit.py
@@ -0,0 +1,27 @@
+# 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.
+
+
+from modules.extensions.defaultextensionhandler import *
+from modules.event.instance.notifier.events import ArtifactUpdatedEvent
+
+event_msg = '{"clusterId":"php.php.domain","repoPassword":"","repoURL":"https://github.com/chamilad/NeWoice","tenantId":"-1234","commitEnabled":false}'
+event = ArtifactUpdatedEvent.create_from_json(event_msg)
+
+extension_handler = DefaultExtensionHandler()
+extension_handler.on_artifact_updated_event(event)
+


Mime
View raw message