You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ni...@apache.org on 2014/10/11 20:47:07 UTC
[43/50] [abbrv] git commit: Fixed syntax errors in obtaining json
strings of events
Fixed syntax errors in obtaining json strings of events
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/b6a871d1
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/b6a871d1
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/b6a871d1
Branch: refs/heads/master
Commit: b6a871d1e99fecc7f34de4b157ce3bcf961554ce
Parents: 4139b16
Author: Chamila de Alwis <ch...@wso2.com>
Authored: Sat Oct 11 20:30:19 2014 +0530
Committer: Chamila de Alwis <ch...@wso2.com>
Committed: Sat Oct 11 20:30:19 2014 +0530
----------------------------------------------------------------------
.../modules/event/topology/events.py | 5 +---
.../extensions/defaultextensionhandler.py | 27 ++++++++++----------
2 files changed, 15 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/b6a871d1/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
index 18580c2..72c4a99 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/topology/events.py
@@ -166,7 +166,7 @@ class CompleteTopologyEvent:
cluster_obj.status = cluster_str["status"]
cluster_obj.load_balancer_algorithm_name = cluster_str["loadBalanceAlgorithmName"] if "loadBalanceAlgorithmName" in cluster_str else None
cluster_obj.properties = cluster_str["properties"]
- cluster_obj.member_list_json = "["
+ cluster_obj.member_list_json = cluster_str["memberMap"]
#add member map
for member_id in cluster_str["memberMap"]:
@@ -183,7 +183,6 @@ class CompleteTopologyEvent:
member_obj.properties = member_str["properties"]
member_obj.lb_cluster_id = member_str["lbClusterId"] if "lbClusterId" in member_str else None
member_obj.json_str = member_str
- cluster_obj.member_list_json += member_str + ","
#add port map
for mm_port_proxy in member_str["portMap"]:
@@ -191,8 +190,6 @@ class CompleteTopologyEvent:
mm_port_obj = Port(mm_port_str["protocol"], mm_port_str["value"], mm_port_proxy)
member_obj.add_port(mm_port_obj)
cluster_obj.add_member(member_obj)
- #remove final comma and close the square bracker of the json array
- cluster_obj.member_list_json = cluster_obj.member_list_json[:-1] + "]"
service_obj.add_cluster(cluster_obj)
topology_obj.add_service(service_obj)
instance.topology = topology_obj
http://git-wip-us.apache.org/repos/asf/stratos/blob/b6a871d1/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
index 4c36e55..8ee3cd6 100644
--- a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -16,6 +16,7 @@
# under the License.
import time
+import json
from abstractextensionhandler import AbstractExtensionHandler
from ..util import extensionutils, cartridgeagentutils
@@ -162,14 +163,14 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
env_params["STRATOS_MEMBER_ACTIVATED_PORTS"] = ports_str
- env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = cluster.member_list_json
+ env_params["STRATOS_MEMBER_ACTIVATED_MEMBER_LIST_JSON"] = json.dumps(cluster.member_list_json)
member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
if member_ips is not None and len(member_ips) > 1:
env_params["STRATOS_MEMBER_ACTIVATED_LB_IP"] = member_ips[0]
env_params["STRATOS_MEMBER_ACTIVATED_LB_PUBLIC_IP"] = member_ips[1]
- env_params["STRATOS_TOPOLOGY_JSON"] = topology.json_str
+ env_params["STRATOS_TOPOLOGY_JSON"] = json.dumps(topology.json_str)
extensionutils.add_properties(service.properties, env_params, "MEMBER_ACTIVATED_SERVICE_PROPERTY")
extensionutils.add_properties(cluster.properties, env_params, "MEMBER_ACTIVATED_CLUSTER_PROPERTY")
@@ -219,7 +220,7 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
service = topology.get_service(service_name_in_payload)
cluster = service.get_cluster(cluster_id_in_payload)
- env_params = {"STRATOS_TOPOLOGY_JSON": topology.json_str, "STRATOS_MEMBER_LIST_JSON": cluster.member_list_json}
+ env_params = {"STRATOS_TOPOLOGY_JSON": json.dumps(topology.json_str), "STRATOS_MEMBER_LIST_JSON": json.dumps(cluster.member_list_json)}
extensionutils.execute_complete_topology_extension(env_params)
@@ -227,9 +228,9 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
self.log.debug("Complete tenant event received")
tenant_list_json = complete_tenant_event.tenant_list_json
- self.log.debug("Complete tenants:" + ','.join(tenant_list_json))
+ self.log.debug("Complete tenants:" + json.dumps(tenant_list_json))
- env_params = {"STRATOS_TENANT_LIST_JSON": ','.join(tenant_list_json)}
+ env_params = {"STRATOS_TENANT_LIST_JSON": json.dumps(tenant_list_json)}
extensionutils.execute_complete_tenant_extension(env_params)
@@ -266,8 +267,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
"STRATOS_MEMBER_TERMINATED_LB_CLUSTER_ID": lb_cluster_id,
"STRATOS_MEMBER_TERMINATED_NETWORK_PARTITION_ID": member_terminated_event.network_partition_id,
"STRATOS_MEMBER_TERMINATED_SERVICE_NAME": member_terminated_event.service_name,
- "STRATOS_MEMBER_TERMINATED_MEMBER_LIST_JSON": cluster.member_list_json,
- "STRATOS_TOPOLOGY_JSON": topology.json_str}
+ "STRATOS_MEMBER_TERMINATED_MEMBER_LIST_JSON": json.dumps(cluster.member_list_json),
+ "STRATOS_TOPOLOGY_JSON": json.dumps(topology.json_str)}
member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
if member_ips is not None and len(member_ips) > 1:
@@ -315,8 +316,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
"STRATOS_MEMBER_SUSPENDED_LB_CLUSTER_ID": lb_cluster_id,
"STRATOS_MEMBER_SUSPENDED_NETWORK_PARTITION_ID": member_suspended_event.network_partition_id,
"STRATOS_MEMBER_SUSPENDED_SERVICE_NAME": member_suspended_event.service_name,
- "STRATOS_MEMBER_SUSPENDED_MEMBER_LIST_JSON": cluster.member_list_json,
- "STRATOS_TOPOLOGY_JSON": topology.json_str}
+ "STRATOS_MEMBER_SUSPENDED_MEMBER_LIST_JSON": json.dumps(cluster.member_list_json),
+ "STRATOS_TOPOLOGY_JSON": json.dumps(topology.json_str)}
member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
if member_ips is not None and len(member_ips) > 1:
@@ -364,8 +365,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
"STRATOS_MEMBER_STARTED_LB_CLUSTER_ID": lb_cluster_id,
"STRATOS_MEMBER_STARTED_NETWORK_PARTITION_ID": member_started_event.network_partition_id,
"STRATOS_MEMBER_STARTED_SERVICE_NAME": member_started_event.service_name,
- "STRATOS_MEMBER_STARTED_MEMBER_LIST_JSON": cluster.member_list_json,
- "STRATOS_TOPOLOGY_JSON": topology.json_str}
+ "STRATOS_MEMBER_STARTED_MEMBER_LIST_JSON": json.dumps(cluster.member_list_json),
+ "STRATOS_TOPOLOGY_JSON": json.dumps(topology.json_str)}
member_ips = extensionutils.get_lb_member_ip(lb_cluster_id)
if member_ips is not None and len(member_ips) > 1:
@@ -415,8 +416,8 @@ class DefaultExtensionHandler(AbstractExtensionHandler):
self.wait_for_wk_members(env_params)
self.log.info("All well known members have started! Resuming start server extension...")
- env_params["STRATOS_TOPOLOGY_JSON"] = topology.json_str
- env_params["STRATOS_MEMBER_LIST_JSON"] = cluster.member_list_json
+ env_params["STRATOS_TOPOLOGY_JSON"] = json.dumps(topology.json_str)
+ env_params["STRATOS_MEMBER_LIST_JSON"] = json.dumps(cluster.member_list_json)
extensionutils.execute_start_servers_extension(env_params)