stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [2/4] stratos git commit: Updated Member object on the Python cartridge agent to include clusterInstanceId and status Updated MemberStatus enum
Date Thu, 05 Feb 2015 03:34:43 GMT
Updated Member object on the Python cartridge agent to include clusterInstanceId and status
Updated MemberStatus enum


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

Branch: refs/heads/master
Commit: e2eaa8ae98f6c173d33fd12d0e3bb2554b8660ae
Parents: 844f0e9
Author: Chamila de Alwis <chamilad@wso2.com>
Authored: Sat Jan 31 16:56:00 2015 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Thu Feb 5 09:04:37 2015 +0530

----------------------------------------------------------------------
 .../modules/event/topology/events.py            | 22 ++++++++++++-------
 .../modules/topology/topologycontext.py         | 23 +++++++++++---------
 .../modules/util/extensionutils.py              |  3 ++-
 3 files changed, 29 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/e2eaa8ae/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/event/topology/events.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/event/topology/events.py
b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/event/topology/events.py
index acbd914..607c9f9 100644
--- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/event/topology/events.py
+++ b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/event/topology/events.py
@@ -197,23 +197,29 @@ class CompleteTopologyEvent:
                     cluster_obj.properties = cluster_str["properties"] if "properties" in
cluster_str else None
                     cluster_obj.member_list_json = cluster_str["memberMap"]
 
-                    #add member map
+                    # add member map
                     for member_id in cluster_str["memberMap"]:
                         member_str = cluster_str["memberMap"][member_id]
                         mm_service_name = member_str["serviceName"]
                         mm_cluster_id = member_str["clusterId"]
-                        mm_network_partition_id = member_str["networkPartitionId"] if "networkPartitionId"
in member_str else None
+                        mm_network_partition_id = member_str["networkPartitionId"] if "networkPartitionId"
in member_str \
+                            else None
                         mm_partition_id = member_str["partitionId"] if "partitionId" in member_str
else None
-
-                        member_obj = Member(mm_service_name, mm_cluster_id, mm_network_partition_id,
mm_partition_id, member_id)
-                        member_obj.member_public_ips = member_str["memberPublicIPs"] if "memberPublicIPs"
in member_str else None
-                        member_obj.status = member_str["status"] if "status" in member_str
else None
-                        member_obj.member_private_ips = member_str["memberPrivateIPs"] if
"memberPrivateIPs" in json_obj else None
+                        mm_cluster_instance_id = member_str["clusterInstanceId"] if "clusterInstanceId"
in member_str \
+                            else None
+
+                        member_obj = Member(mm_service_name, mm_cluster_id, mm_network_partition_id,
+                                            mm_partition_id, member_id, mm_cluster_instance_id)
+                        member_obj.member_public_ips = member_str["memberPublicIPs"] if "memberPublicIPs"
in member_str \
+                            else None
+                        member_obj.status = member_str["memberStateManager"]["stateStack"][-1]
+                        member_obj.member_private_ips = member_str["memberPrivateIPs"] if
"memberPrivateIPs" in json_obj \
+                            else None
                         member_obj.properties = member_str["properties"] if "properties"
in member_str else None
                         member_obj.lb_cluster_id = member_str["lbClusterId"] if "lbClusterId"
in member_str else None
                         member_obj.json_str = member_str
 
-                        #add port map
+                        # add port map
                         for mm_port_proxy in member_str["portMap"]:
                             mm_port_str = member_str["portMap"][mm_port_proxy]
                             mm_port_obj = Port(mm_port_str["protocol"], mm_port_str["value"],
mm_port_proxy)

http://git-wip-us.apache.org/repos/asf/stratos/blob/e2eaa8ae/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/topology/topologycontext.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/topology/topologycontext.py
b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/topology/topologycontext.py
index ba6daf4..4c7617c 100644
--- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/topology/topologycontext.py
+++ b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/topology/topologycontext.py
@@ -323,13 +323,16 @@ class Member:
     Represents a member on a particular cluster
     """
 
-    def __init__(self, service_name="", cluster_id="", network_partition_id="", parition_id="",
member_id=""):
+    def __init__(self, service_name="", cluster_id="", network_partition_id="", parition_id="",
member_id="",
+                 cluster_instance_id=""):
         self.service_name = service_name
         """ :type : str  """
         self.cluster_id = cluster_id
         """ :type : str  """
         self.network_partition_id = network_partition_id
         """ :type : str  """
+        self.cluster_instance_id = cluster_instance_id
+        """ :type : str  """
         self.partition_id = parition_id
         """ :type : str  """
         self.member_id = member_id
@@ -360,7 +363,7 @@ class Member:
         :return: True if active, False if otherwise
         :rtype: bool
         """
-        return self.status == MemberStatus.Activated
+        return self.status == MemberStatus.Active
 
     def get_ports(self):
         """
@@ -428,14 +431,14 @@ class MemberStatus:
     """
     MemberStatus enum
     """
-    Created = 1
-    Starting = 2
-    Activated = 3
-    In_Maintenance = 4
-    ReadyToShutDown = 5
-    Terminated = 6
-    Suspended = 0
-    ShuttingDown = 0
+    Created = "Created"
+    Initialized = "Initialized"
+    Starting = "Starting"
+    Active = "Active"
+    In_Maintenance = "In_Maintenance"
+    ReadyToShutDown = "ReadyToShutDown"
+    Suspended = "Suspended"
+    Terminated = "Terminated"
 
 
 class TopologyContext:

http://git-wip-us.apache.org/repos/asf/stratos/blob/e2eaa8ae/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/extensionutils.py
b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/extensionutils.py
index 4090228..a075cf7 100644
--- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/extensionutils.py
+++ b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/util/extensionutils.py
@@ -270,7 +270,8 @@ def check_topology_consistency(service_name, cluster_id, member_id):
     if activated_member is None:
         log.error("Member id not found in topology [member] %r" % member_id)
         return False
-    if activated_member.status != "Initialized":
+
+    if activated_member.status != MemberStatus.Initialized:
         return False
 
     return True


Mime
View raw message