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 11:09:32 UTC
[07/50] [abbrv] Restructured modules to suit relative imports
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py b/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py
new file mode 100644
index 0000000..7395f7e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/event/tenant/events.py
@@ -0,0 +1,98 @@
+import json
+
+
+class SubscriptionDomainAddedEvent():
+
+ def __init__(self):
+ self.tenant_id = None
+ self.service_name = None
+ self.cluster_ids = None
+ self.domain_name = None
+ self.application_context = None
+
+ @staticmethod
+ def create_from_json(json_str):
+ json_obj = json.loads(json_str)
+ instance = SubscriptionDomainAddedEvent()
+
+ instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
+ instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+ instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+ instance.domain_name = json_obj["domainName"] if "domainName" in json_obj else None
+ instance.application_context = json_obj["applicationContext"] if "applicationContext" in json_obj else None
+
+ return instance
+
+
+class SubscriptionDomainRemovedEvent:
+
+ def __init__(self, tenant_id, service_name, cluster_ids, domain_name):
+ self.tenant_id = tenant_id
+ self.service_name = service_name
+ self.cluster_ids = cluster_ids
+ self.domain_name = domain_name
+
+ @staticmethod
+ def create_from_json(json_str):
+ json_obj = json.loads(json_str)
+ instance = SubscriptionDomainRemovedEvent()
+
+ instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
+ instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+ instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+ instance.domain_name = json_obj["domainName"] if "domainName" in json_obj else None
+
+ return instance
+
+
+class CompleteTenantEvent:
+
+ def __init__(self):
+ self.tenants = None
+
+ @staticmethod
+ def create_from_json(json_str):
+ json_obj = json.loads(json_str)
+ instance = CompleteTenantEvent()
+
+ instance.tenants = json_obj["tenants"] if "tenants" in json_obj else None
+
+ return instance
+
+
+class TenantSubscribedEvent:
+
+ def __init__(self):
+ self.tenant_id = None
+ self.service_name = None
+ self.cluster_ids = None
+
+ @staticmethod
+ def create_from_json(json_str):
+ json_obj = json.loads(json_str)
+ instance = TenantSubscribedEvent()
+
+ instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+ instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+ instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
+
+ return instance
+
+
+class TenantUnsubscribedEvent:
+
+ def __init__(self):
+ self.tenant_id = None
+ self.service_name = None
+ self.cluster_ids = None
+
+ @staticmethod
+ def create_from_json(json_str):
+ json_obj = json.loads(json_str)
+ instance = TenantUnsubscribedEvent()
+
+ instance.tenant_id = json_obj["tenantId"] if "tenantId" in json_obj else None
+ instance.service_name = json_obj["serviceName"] if "serviceName" in json_obj else None
+ instance.cluster_ids = json_obj["clusterIds"] if "clusterIds" in json_obj else None
+
+ return instance
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
new file mode 100644
index 0000000..7f59666
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.py
@@ -0,0 +1 @@
+__all__ = ['parameternotfoundexception']
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.pyc
new file mode 100644
index 0000000..d1603b5
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/exception/__init__.pyc differ
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
new file mode 100644
index 0000000..a9a776e
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.py
@@ -0,0 +1,9 @@
+class ParameterNotFoundException(Exception):
+ __message = None
+
+ def __init__(self, message):
+ Exception.__init__(self, message)
+ self.__message = message
+
+ def get_message(self):
+ return self.__message
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.pyc
new file mode 100644
index 0000000..7a4c42c
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/exception/parameternotfoundexception.pyc differ
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
new file mode 100644
index 0000000..33da048
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/__init__.py
@@ -0,0 +1 @@
+__all__=['defaultextensionhandler']
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/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
new file mode 100644
index 0000000..15e79bc
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/extensions/defaultextensionhandler.py
@@ -0,0 +1,148 @@
+import logging
+
+from ..artifactmgt.git.agentgithandler import AgentGitHandler
+from ..artifactmgt.repositoryinformation import RepositoryInformation
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from .. util import extensionutils, cartridgeagentconstants, cartridgeagentutils
+from .. publisher import cartridgeagentpublisher
+
+
+class DefaultExtensionHandler:
+ log = None
+ cartridge_agent_config = None
+
+ def __init__(self):
+ logging.basicConfig(level=logging.DEBUG)
+ self.log = logging.getLogger(__name__)
+
+ self.cartridge_agent_config = CartridgeAgentConfiguration()
+
+ pass
+
+ def on_instance_started_event(self):
+ try:
+ self.log.debug("Processing instance started event...")
+ if self.cartridge_agent_config.is_multitenant():
+ artifact_source = "%r/repository/deployment/server/" % self.cartridge_agent_config.get_app_path()
+ artifact_dest = cartridgeagentconstants.SUPERTENANT_TEMP_PATH
+ extensionutils.execute_copy_artifact_extension(artifact_source, artifact_dest)
+
+ env_params = {}
+ extensionutils.execute_instance_started_extention(env_params)
+
+ except Exception:
+ self.log.exception("Error processing instance started event")
+
+ def on_instance_activated_event(self):
+ extensionutils.execute_instance_activated_extension()
+
+ def on_artifact_updated_event(self, event):
+ self.log.info("Artifact update event received: [tenant] %r [cluster] %r [status] %r" %
+ (event.tenant_id, event.cluster_id, event.status))
+
+ cluster_id_event = str(event.cluster_id).strip()
+ cluster_id_payload = self.cartridge_agent_config.get_cluster_id()
+ repo_url = str(event.repo_url).strip()
+
+ if (repo_url != "") and (cluster_id_payload is not None) and (cluster_id_payload == cluster_id_event):
+ local_repo_path = self.cartridge_agent_config.get_app_path()
+
+ secret = self.cartridge_agent_config.get_cartridge_key()
+ repo_password = cartridgeagentutils.decrypt_password(event.repo_password, secret)
+
+ repo_username = event.repo_username
+ tenant_id = event.tenant_id
+ is_multitenant = self.cartridge_agent_config.is_multitenant()
+ commit_enabled = event.commit_enabled
+
+ self.log.info("Executing git checkout")
+
+ # create repo object
+ repo_info = RepositoryInformation(repo_url, repo_username, repo_password, local_repo_path, tenant_id,
+ is_multitenant, commit_enabled)
+
+ #checkout code
+ checkout_result = AgentGitHandler.checkout(repo_info)
+ #execute artifact updated extension
+ env_params = {"STRATOS_ARTIFACT_UPDATED_CLUSTER_ID": event.cluster_id,
+ "STRATOS_ARTIFACT_UPDATED_TENANT_ID": event.tenant_id,
+ "STRATOS_ARTIFACT_UPDATED_REPO_URL": event.repo_url,
+ "STRATOS_ARTIFACT_UPDATED_REPO_PASSWORD": event.repo_password,
+ "STRATOS_ARTIFACT_UPDATED_REPO_USERNAME": event.repo_username,
+ "STRATOS_ARTIFACT_UPDATED_STATUS": event.status}
+
+ extensionutils.execute_artifacts_updated_extension(env_params)
+
+ #if !cloneExists publish instanceActivatedEvent
+ if not checkout_result["cloned"]:
+ #publish instanceActivated
+ cartridgeagentpublisher.publish_instance_activated_event()
+
+ #TODO: set artifact update task
+
+ def on_artifact_update_scheduler_event(self, tenantId):
+ pass
+
+ def on_instance_cleanup_cluster_event(self, instanceCleanupClusterEvent):
+ pass
+
+ def onInstanceCleanupMemberEvent(self, instanceCleanupMemberEvent):
+ pass
+
+ def onMemberActivatedEvent(self, memberActivatedEvent):
+ pass
+
+ def onCompleteTopologyEvent(self, completeTopologyEvent):
+ pass
+
+ def onCompleteTenantEvent(self, completeTenantEvent):
+ pass
+
+ def onMemberTerminatedEvent(self, memberTerminatedEvent):
+ pass
+
+ def onMemberSuspendedEvent(self, memberSuspendedEvent):
+ pass
+
+ def onMemberStartedEvent(self, memberStartedEvent):
+ pass
+
+ def start_server_extension(self):
+ raise NotImplementedError
+ # extensionutils.wait_for_complete_topology()
+ # self.log.info("[start server extension] complete topology event received")
+ #
+ # service_name_in_payload = self.cartridge_agent_config.get_service_name()
+ # cluster_id_in_payload = self.cartridge_agent_config.get_cluster_id()
+ # member_id_in_payload = self.cartridge_agent_config.get_member_id()
+ #
+ # try:
+ # consistant = extensionutils.check_topology_consistency(service_name_in_payload, cluster_id_in_payload, member_id_in_payload)
+ #
+ # if not consistant:
+ # self.log.error("Topology is inconsistent...failed to execute start server event")
+ # return
+ #
+ #
+ # except:
+ # self.log.exception("Error processing start servers event")
+ # finally:
+ # pass
+
+ def volume_mount_extension(self, persistence_mappings_payload):
+ extensionutils.execute_volume_mount_extension(persistence_mappings_payload)
+
+ def onSubscriptionDomainAddedEvent(self, subscriptionDomainAddedEvent):
+ pass
+
+ def onSubscriptionDomainRemovedEvent(self, subscriptionDomainRemovedEvent):
+ pass
+
+ def onCopyArtifactsExtension(self, src, des):
+ pass
+
+ def onTenantSubscribedEvent(self, tenantSubscribedEvent):
+ pass
+
+ def onTenantUnSubscribedEvent(self, tenantUnSubscribedEvent):
+ pass
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
new file mode 100644
index 0000000..923c1de
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/__init__.py
@@ -0,0 +1 @@
+__all__=['cartridgeagentpublisher']
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
new file mode 100644
index 0000000..959920d
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/publisher/cartridgeagentpublisher.py
@@ -0,0 +1,90 @@
+import logging
+
+import paho.mqtt.publish as publish
+
+from .. event.instance.status.events import *
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+from .. util import cartridgeagentconstants
+
+
+logging.basicConfig(level=logging.DEBUG)
+log = logging.getLogger(__name__)
+
+started = False
+activated = False
+ready_to_shutdown = False
+maintenance = False
+
+cartridge_agent_config = CartridgeAgentConfiguration()
+
+publishers = {}
+
+
+def publish_instance_started_event():
+ global started, log, cartridge_agent_config
+ if not started:
+ log.info("Publishing instance started event")
+ service_name = cartridge_agent_config.get_service_name()
+ cluster_id = cartridge_agent_config.get_cluster_id()
+ network_partition_id = cartridge_agent_config.get_network_partition_id()
+ parition_id = cartridge_agent_config.get_partition_id()
+ member_id = cartridge_agent_config.get_member_id()
+
+ instance_started_event = InstanceStartedEvent(service_name, cluster_id, network_partition_id, parition_id,
+ member_id)
+ publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+ publisher.publish(instance_started_event)
+ started = True
+ log.info("Instance started event published")
+ else:
+ log.warn("Instance already started")
+
+
+def publish_instance_activated_event():
+ global activated, log, cartridge_agent_config
+ if not activated:
+ log.info("Publishing instance activated event")
+ service_name = cartridge_agent_config.get_service_name()
+ cluster_id = cartridge_agent_config.get_cluster_id()
+ network_partition_id = cartridge_agent_config.get_network_partition_id()
+ parition_id = cartridge_agent_config.get_partition_id()
+ member_id = cartridge_agent_config.get_member_id()
+
+ instance_activated_event = InstanceActivatedEvent(service_name, cluster_id, network_partition_id, parition_id,
+ member_id)
+ publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
+ publisher.publish(instance_activated_event)
+
+ log.info("Instance activated event published")
+ log.info("Starting health statistics notifier")
+
+ # TODO: health stat publisher start()
+ activated = True
+ log.info("Health statistics notifier started")
+ else:
+ log.warn("Instance already activated")
+
+
+def get_publisher(topic):
+ if topic not in publishers:
+ publishers[topic] = EventPublisher(topic)
+
+ return publishers[topic]
+
+
+class EventPublisher:
+ def __init__(self, topic):
+ self.__topic = topic
+ self.cartridge_agent_config = CartridgeAgentConfiguration()
+
+ """
+ msgs = [{'topic': "instance/status/InstanceStartedEvent", 'payload': instance_started_event.to_JSON()}]
+ #publish.single("instance", instance_started_event.to_JSON(), hostname="localhost", port=1883)
+ publish.multiple(msgs, "localhost", 1883)
+ """
+
+ def publish(self, event):
+ mb_ip = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_IP)
+ mb_port = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_PORT)
+ payload = event.to_json()
+ publish.single(self.__topic, payload, hostname=mb_ip, port=mb_port)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
new file mode 100644
index 0000000..27483e8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/__init__.py
@@ -0,0 +1 @@
+__all__=['eventsubscriber']
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
new file mode 100644
index 0000000..a8deb77
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/subscriber/eventsubscriber.py
@@ -0,0 +1,62 @@
+import logging
+import threading
+import paho.mqtt.client as mqtt
+
+from .. util import cartridgeagentconstants
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+
+
+class EventSubscriber(threading.Thread):
+
+ def __init__(self, topic):
+ threading.Thread.__init__(self)
+
+ self.cartridge_agent_config = CartridgeAgentConfiguration()
+ #{"ArtifactUpdateEvent" : onArtifactUpdateEvent()}
+ self.__event_handlers = {}
+
+ logging.basicConfig(level=logging.DEBUG)
+ self.log = logging.getLogger(__name__)
+
+ self.__mb_client = None
+
+ self.__topic = topic
+
+ self.__subscribed = False
+
+ def run(self):
+ self.__mb_client = mqtt.Client()
+ self.__mb_client.on_connect = self.on_connect
+ self.__mb_client.on_message = self.on_message
+
+ mb_ip = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_IP)
+ mb_port = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_PORT)
+
+ self.log.debug("Connecting to the message broker with address %r:%r" % (mb_ip, mb_port))
+ self.__mb_client.connect(mb_ip, mb_port, 60)
+ self.__subscribed = True
+ self.__mb_client.loop_forever()
+
+ def register_handler(self, event, handler):
+ self.__event_handlers[event] = handler
+ self.log.debug("Registered handler for event %r" % event)
+
+ def on_connect(self, client, userdata, flags, rc):
+ self.log.debug("Connected to message broker.")
+ self.__mb_client.subscribe(self.__topic)
+ self.log.debug("Subscribed to %r" % self.__topic)
+
+ def on_message(self, client, userdata, msg):
+ self.log.debug("Message received: %r:\n%r" % (msg.topic, msg.payload))
+
+ event = msg.topic.rpartition('/')[2]
+ handler = self.__event_handlers[event]
+
+ try:
+ self.log.debug("Executing handler for event %r" % event)
+ handler(msg)
+ except:
+ self.log.exception("Error processing %r event" % event)
+
+ def is_subscribed(self):
+ return self.__subscribed
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
new file mode 100644
index 0000000..7051a3c
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.py
@@ -0,0 +1 @@
+__all__=['cartridgeagentconstants', 'cartridgeagentutils', 'extensionutils']
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.pyc
new file mode 100644
index 0000000..2c921d6
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/util/__init__.pyc differ
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
new file mode 100644
index 0000000..a2efe80
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.py
@@ -0,0 +1,88 @@
+JNDI_PROPERTIES_DIR = "jndi.properties.dir"
+PARAM_FILE_PATH = "param.file.path"
+EXTENSIONS_DIR = "extensions.dir"
+
+MB_IP = "mb.ip"
+MB_PORT = "mb.port"
+
+INSTANCE_STARTED_SH = "instance-started.sh"
+START_SERVERS_SH = "start-servers.sh"
+INSTANCE_ACTIVATED_SH = "instance-activated.sh"
+ARTIFACTS_UPDATED_SH = "artifacts-updated.sh"
+CLEAN_UP_SH = "clean.sh"
+MOUNT_VOLUMES_SH = "mount_volumes.sh"
+SUBSCRIPTION_DOMAIN_ADDED_SH = "subscription-domain-added.sh"
+SUBSCRIPTION_DOMAIN_REMOVED_SH = "subscription-domain-removed.sh"
+
+CARTRIDGE_KEY = "CARTRIDGE_KEY"
+APP_PATH = "APP_PATH"
+SERVICE_GROUP = "SERIVCE_GROUP"
+SERVICE_NAME = "SERVICE_NAME"
+CLUSTER_ID = "CLUSTER_ID"
+LB_CLUSTER_ID = "LB_CLUSTER_ID"
+NETWORK_PARTITION_ID = "NETWORK_PARTITION_ID"
+PARTITION_ID = "PARTITION_ID"
+MEMBER_ID = "MEMBER_ID"
+TENANT_ID= "TENANT_ID"
+REPO_URL = "REPO_URL"
+PORTS = "PORTS"
+DEPLOYMENT = "DEPLOYMENT"
+MANAGER_SERVICE_TYPE = "MANAGER_SERVICE_TYPE"
+WORKER_SERVICE_TYPE = "WORKER_SERVICE_TYPE"
+
+# stratos.sh environment variables keys
+LOG_FILE_PATHS = "LOG_FILE_PATHS"
+MEMORY_CONSUMPTION = "memory_consumption"
+LOAD_AVERAGE = "load_average"
+PORTS_NOT_OPEN = "ports_not_open"
+MULTITENANT = "MULTITENANT"
+CLUSTERING = "CLUSTERING"
+MIN_INSTANCE_COUNT = "MIN_COUNT"
+ENABLE_ARTIFACT_UPDATE = "enable.artifact.update"
+ARTIFACT_UPDATE_INTERVAL = "artifact.update.interval"
+COMMIT_ENABLED = "COMMIT_ENABLED"
+AUTO_COMMIT = "auto.commit"
+AUTO_CHECKOUT = "auto.checkout"
+LISTEN_ADDRESS = "listen.address"
+PROVIDER = "PROVIDER"
+INTERNAL = "internal"
+LB_PRIVATE_IP = "lb.private.ip"
+LB_PUBLIC_IP = "lb.public.ip"
+
+# stratos.sh extension points shell scripts names keys
+INSTANCE_STARTED_SCRIPT = "extension.instance.started"
+START_SERVERS_SCRIPT = "extension.start.servers"
+INSTANCE_ACTIVATED_SCRIPT = "extension.instance.activated"
+ARTIFACTS_UPDATED_SCRIPT = "extension.artifacts.updated"
+CLEAN_UP_SCRIPT = "extension.clean"
+MOUNT_VOLUMES_SCRIPT = "extension.mount.volumes"
+MEMBER_ACTIVATED_SCRIPT = "extension.member.activated"
+MEMBER_TERMINATED_SCRIPT = "extension.member.terminated"
+MEMBER_SUSPENDED_SCRIPT = "extension.member.suspended"
+MEMBER_STARTED_SCRIPT = "extension.member.started"
+COMPLETE_TOPOLOGY_SCRIPT = "extension.complete.topology"
+COMPLETE_TENANT_SCRIPT = "extension.complete.tenant"
+SUBSCRIPTION_DOMAIN_ADDED_SCRIPT = "extension.subscription.domain.added"
+SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT = "extension.subscription.domain.removed"
+ARTIFACTS_COPY_SCRIPT = "extension.artifacts.copy"
+TENANT_SUBSCRIBED_SCRIPT = "extension.tenant.subscribed"
+TENANT_UNSUBSCRIBED_SCRIPT = "extension.tenant.unsubscribed"
+
+SERVICE_GROUP_TOPOLOGY_KEY = "payload_parameter.SERIVCE_GROUP"
+CLUSTERING_TOPOLOGY_KEY = "payload_parameter.CLUSTERING"
+CLUSTERING_PRIMARY_KEY = "PRIMARY"
+
+SUPERTENANT_TEMP_PATH = "/tmp/-1234/"
+
+DEPLOYMENT_MANAGER = "manager"
+DEPLOYMENT_WORKER = "worker"
+DEPLOYMENT_DEFAULT = "default"
+SUPER_TENANT_REPO_PATH = "super.tenant.repository.path"
+TENANT_REPO_PATH = "tenant.repository.path"
+
+# topic names to subscribe
+INSTANCE_NOTIFIER_TOPIC = "instance/#"
+HEALTH_STAT_TOPIC = "health/#"
+TOPOLOGY_TOPIC = "topology/#"
+TENANT_TOPIC = "tenant/#"
+INSTANCE_STATUS_TOPIC = "instance/#"
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.pyc
new file mode 100644
index 0000000..0b31e3a
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentconstants.pyc differ
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
new file mode 100644
index 0000000..e599ef8
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.py
@@ -0,0 +1,94 @@
+from Crypto.Cipher import AES
+import base64
+import logging
+import os
+import time
+import socket
+
+from .. config.cartridgeagentconfiguration import CartridgeAgentConfiguration
+
+unpad = lambda s : s[0:-ord(s[-1])]
+logging.basicConfig(level=logging.DEBUG)
+log = logging.getLogger(__name__)
+
+cartridge_agent_config = CartridgeAgentConfiguration()
+
+current_milli_time = lambda: int(round(time.time() * 1000))
+
+
+def decrypt_password(pass_str, secret):
+ if pass_str is None:
+ return pass_str
+
+ dec_pass = ""
+
+ try:
+ log.debug("Decrypting password")
+ bdecoded_pass = base64.b64decode(pass_str)
+ #secret length should be 16
+ cipher = AES.new(secret, AES.MODE_ECB)
+ dec_pass = unpad(cipher.decrypt(bdecoded_pass))
+ except:
+ log.exception("Exception occurred while decrypting password")
+
+ log.debug("Decrypted PWD: [%r]" % dec_pass)
+ return dec_pass
+
+
+def create_dir(path):
+ """
+ mkdir the provided path
+ :param path: The path to the directory to be made
+ :return: True if mkdir was successful, False if dir already exists
+ """
+ try:
+ os.mkdir(path)
+ log.info("Successfully created directory [%r]" % path)
+ return True
+ except OSError:
+ log.exception("Directory creating failed in [%r]. Directory already exists. " % path)
+
+ return False
+
+
+def wait_until_ports_active(ip_address, ports):
+ ports_check_timeout = cartridge_agent_config.read_property("port.check.timeout")
+ if ports_check_timeout is None:
+ ports_check_timeout = 1000 * 60 * 10
+
+ log.debug("Port check timeout: %r" % ports_check_timeout)
+
+ active = False
+ start_time = current_milli_time()
+ while not active:
+ log.info("Waiting for ports to be active: [ip] %r [ports] %r" % (ip_address, ports))
+ active = check_ports_active(ip_address, ports)
+ end_time = current_milli_time()
+ duration = end_time - start_time
+ if duration > ports_check_timeout:
+ return
+
+ try:
+ time.sleep(5)
+ except:
+ pass
+
+ log.info("Ports activated: [ip] %r [ports] %r" % (ip_address, ports))
+
+
+def check_ports_active(ip_address, ports):
+ if len(ports) < 1:
+ raise RuntimeError("No ports found")
+
+ for port in ports:
+ s = socket.socket()
+ s.settimeout(5)
+ try:
+ s.connect(ip_address, port)
+ log.debug("Port %r is active" % port)
+ s.close()
+ except socket.error:
+ log.debug("Print %r is not active" % port)
+ return False
+
+ return True
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.pyc
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.pyc b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.pyc
new file mode 100644
index 0000000..729c54b
Binary files /dev/null and b/tools/python-cartridge-agent/cartridge-agent/modules/util/cartridgeagentutils.pyc differ
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
new file mode 100644
index 0000000..c2ecc52
--- /dev/null
+++ b/tools/python-cartridge-agent/cartridge-agent/modules/util/extensionutils.py
@@ -0,0 +1,40 @@
+import logging
+
+logging.basicConfig(level=logging.DEBUG)
+log = logging.getLogger(__name__)
+
+
+def execute_copy_artifact_extension(source, destination):
+ raise NotImplementedError
+
+
+def execute_instance_started_extention(env_params):
+ raise NotImplementedError
+
+
+def execute_instance_activated_extension():
+ raise NotImplementedError
+
+
+def execute_artifacts_updated_extension(env_params):
+ raise NotImplementedError
+
+
+def execute_subscription_domain_added_extension(tenant_id, tenant_domain, domain_name, application_context):
+ raise NotImplementedError
+
+
+def execute_subscription_domain_removed_extension(tenant_id, tenant_domain, domain_name):
+ raise NotImplementedError
+
+
+def wait_for_complete_topology():
+ raise NotImplementedError
+
+
+def check_topology_consistency(service_name, cluster_id, member_id):
+ raise NotImplementedError
+
+
+def execute_volume_mount_extension(persistance_mappings_payload):
+ raise NotImplementedError
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/publisher/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/publisher/__init__.py b/tools/python-cartridge-agent/cartridge-agent/publisher/__init__.py
deleted file mode 100644
index 923c1de..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/publisher/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['cartridgeagentpublisher']
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/publisher/cartridgeagentpublisher.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/publisher/cartridgeagentpublisher.py b/tools/python-cartridge-agent/cartridge-agent/publisher/cartridgeagentpublisher.py
deleted file mode 100644
index a47c1be..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/publisher/cartridgeagentpublisher.py
+++ /dev/null
@@ -1,88 +0,0 @@
-import logging
-from ..event.instance.status.events import *
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-from ..util import cartridgeagentconstants
-import paho.mqtt.publish as publish
-
-
-logging.basicConfig(level=logging.DEBUG)
-log = logging.getLogger(__name__)
-
-started = False
-activated = False
-ready_to_shutdown = False
-maintenance = False
-
-cartridge_agent_config = CartridgeAgentConfiguration()
-
-publishers = {}
-
-
-def publish_instance_started_event():
- global started, log, cartridge_agent_config
- if not started:
- log.info("Publishing instance started event")
- service_name = cartridge_agent_config.get_service_name()
- cluster_id = cartridge_agent_config.get_cluster_id()
- network_partition_id = cartridge_agent_config.get_network_partition_id()
- parition_id = cartridge_agent_config.get_partition_id()
- member_id = cartridge_agent_config.get_member_id()
-
- instance_started_event = InstanceStartedEvent(service_name, cluster_id, network_partition_id, parition_id,
- member_id)
- publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
- publisher.publish(instance_started_event)
- started = True
- log.info("Instance started event published")
- else:
- log.warn("Instance already started")
-
-
-def publish_instance_activated_event():
- global activated, log, cartridge_agent_config
- if not activated:
- log.info("Publishing instance activated event")
- service_name = cartridge_agent_config.get_service_name()
- cluster_id = cartridge_agent_config.get_cluster_id()
- network_partition_id = cartridge_agent_config.get_network_partition_id()
- parition_id = cartridge_agent_config.get_partition_id()
- member_id = cartridge_agent_config.get_member_id()
-
- instance_activated_event = InstanceActivatedEvent(service_name, cluster_id, network_partition_id, parition_id,
- member_id)
- publisher = get_publisher(cartridgeagentconstants.INSTANCE_STATUS_TOPIC)
- publisher.publish(instance_activated_event)
-
- log.info("Instance activated event published")
- log.info("Starting health statistics notifier")
-
- # TODO: health stat publisher start()
- activated = True
- log.info("Health statistics notifier started")
- else:
- log.warn("Instance already activated")
-
-
-def get_publisher(topic):
- if topic not in publishers:
- publishers[topic] = EventPublisher(topic)
-
- return publishers[topic]
-
-
-class EventPublisher:
- def __init__(self, topic):
- self.__topic = topic
- self.cartridge_agent_config = CartridgeAgentConfiguration()
-
- """
- msgs = [{'topic': "instance/status/InstanceStartedEvent", 'payload': instance_started_event.to_JSON()}]
- #publish.single("instance", instance_started_event.to_JSON(), hostname="localhost", port=1883)
- publish.multiple(msgs, "localhost", 1883)
- """
-
- def publish(self, event):
- mb_ip = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_IP)
- mb_port = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_PORT)
- payload = event.to_json()
- publish.single(self.__topic, payload, hostname=mb_ip, port=mb_port)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/readme.txt
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/readme.txt b/tools/python-cartridge-agent/cartridge-agent/readme.txt
deleted file mode 100644
index 65c3e8c..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/readme.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-sudo apt-get install python-setuptools
-easy_install http://stomppy.googlecode.com/files/stomp.py-3.0.2a.tar.gz
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/script.sh
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/script.sh b/tools/python-cartridge-agent/cartridge-agent/script.sh
deleted file mode 100755
index e69de29..0000000
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/subscriber/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/subscriber/__init__.py b/tools/python-cartridge-agent/cartridge-agent/subscriber/__init__.py
deleted file mode 100644
index 27483e8..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/subscriber/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['eventsubscriber']
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/subscriber/eventsubscriber.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/subscriber/eventsubscriber.py b/tools/python-cartridge-agent/cartridge-agent/subscriber/eventsubscriber.py
deleted file mode 100644
index c71fb71..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/subscriber/eventsubscriber.py
+++ /dev/null
@@ -1,62 +0,0 @@
-import logging
-import threading
-import paho.mqtt.client as mqtt
-
-from ..util import cartridgeagentconstants
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-
-
-class EventSubscriber(threading.Thread):
-
- def __init__(self, topic):
- threading.Thread.__init__(self)
-
- self.cartridge_agent_config = CartridgeAgentConfiguration()
- #{"ArtifactUpdateEvent" : onArtifactUpdateEvent()}
- self.__event_handlers = {}
-
- logging.basicConfig(level=logging.DEBUG)
- self.log = logging.getLogger(__name__)
-
- self.__mb_client = None
-
- self.__topic = topic
-
- self.__subscribed = False
-
- def run(self):
- self.__mb_client = mqtt.Client()
- self.__mb_client.on_connect = self.on_connect
- self.__mb_client.on_message = self.on_message
-
- mb_ip = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_IP)
- mb_port = self.cartridge_agent_config.read_property(cartridgeagentconstants.MB_PORT)
-
- self.log.debug("Connecting to the message broker with address %r:%r" % (mb_ip, mb_port))
- self.__mb_client.connect(mb_ip, mb_port, 60)
- self.__subscribed = True
- self.__mb_client.loop_forever()
-
- def register_handler(self, event, handler):
- self.__event_handlers[event] = handler
- self.log.debug("Registered handler for event %r" % event)
-
- def on_connect(self, client, userdata, flags, rc):
- self.log.debug("Connected to message broker.")
- self.__mb_client.subscribe(self.__topic)
- self.log.debug("Subscribed to %r" % self.__topic)
-
- def on_message(self, client, userdata, msg):
- self.log.debug("Message received: %r:\n%r" % (msg.topic, msg.payload))
-
- event = msg.topic.rpartition('/')[2]
- handler = self.__event_handlers[event]
-
- try:
- self.log.debug("Executing handler for event %r" % event)
- handler(msg)
- except:
- self.log.exception("Error processing %r event" % event)
-
- def is_subscribed(self):
- return self.__subscribed
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/util/__init__.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/util/__init__.py b/tools/python-cartridge-agent/cartridge-agent/util/__init__.py
deleted file mode 100644
index 7051a3c..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/util/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-__all__=['cartridgeagentconstants', 'cartridgeagentutils', 'extensionutils']
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentconstants.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentconstants.py b/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentconstants.py
deleted file mode 100644
index a2efe80..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentconstants.py
+++ /dev/null
@@ -1,88 +0,0 @@
-JNDI_PROPERTIES_DIR = "jndi.properties.dir"
-PARAM_FILE_PATH = "param.file.path"
-EXTENSIONS_DIR = "extensions.dir"
-
-MB_IP = "mb.ip"
-MB_PORT = "mb.port"
-
-INSTANCE_STARTED_SH = "instance-started.sh"
-START_SERVERS_SH = "start-servers.sh"
-INSTANCE_ACTIVATED_SH = "instance-activated.sh"
-ARTIFACTS_UPDATED_SH = "artifacts-updated.sh"
-CLEAN_UP_SH = "clean.sh"
-MOUNT_VOLUMES_SH = "mount_volumes.sh"
-SUBSCRIPTION_DOMAIN_ADDED_SH = "subscription-domain-added.sh"
-SUBSCRIPTION_DOMAIN_REMOVED_SH = "subscription-domain-removed.sh"
-
-CARTRIDGE_KEY = "CARTRIDGE_KEY"
-APP_PATH = "APP_PATH"
-SERVICE_GROUP = "SERIVCE_GROUP"
-SERVICE_NAME = "SERVICE_NAME"
-CLUSTER_ID = "CLUSTER_ID"
-LB_CLUSTER_ID = "LB_CLUSTER_ID"
-NETWORK_PARTITION_ID = "NETWORK_PARTITION_ID"
-PARTITION_ID = "PARTITION_ID"
-MEMBER_ID = "MEMBER_ID"
-TENANT_ID= "TENANT_ID"
-REPO_URL = "REPO_URL"
-PORTS = "PORTS"
-DEPLOYMENT = "DEPLOYMENT"
-MANAGER_SERVICE_TYPE = "MANAGER_SERVICE_TYPE"
-WORKER_SERVICE_TYPE = "WORKER_SERVICE_TYPE"
-
-# stratos.sh environment variables keys
-LOG_FILE_PATHS = "LOG_FILE_PATHS"
-MEMORY_CONSUMPTION = "memory_consumption"
-LOAD_AVERAGE = "load_average"
-PORTS_NOT_OPEN = "ports_not_open"
-MULTITENANT = "MULTITENANT"
-CLUSTERING = "CLUSTERING"
-MIN_INSTANCE_COUNT = "MIN_COUNT"
-ENABLE_ARTIFACT_UPDATE = "enable.artifact.update"
-ARTIFACT_UPDATE_INTERVAL = "artifact.update.interval"
-COMMIT_ENABLED = "COMMIT_ENABLED"
-AUTO_COMMIT = "auto.commit"
-AUTO_CHECKOUT = "auto.checkout"
-LISTEN_ADDRESS = "listen.address"
-PROVIDER = "PROVIDER"
-INTERNAL = "internal"
-LB_PRIVATE_IP = "lb.private.ip"
-LB_PUBLIC_IP = "lb.public.ip"
-
-# stratos.sh extension points shell scripts names keys
-INSTANCE_STARTED_SCRIPT = "extension.instance.started"
-START_SERVERS_SCRIPT = "extension.start.servers"
-INSTANCE_ACTIVATED_SCRIPT = "extension.instance.activated"
-ARTIFACTS_UPDATED_SCRIPT = "extension.artifacts.updated"
-CLEAN_UP_SCRIPT = "extension.clean"
-MOUNT_VOLUMES_SCRIPT = "extension.mount.volumes"
-MEMBER_ACTIVATED_SCRIPT = "extension.member.activated"
-MEMBER_TERMINATED_SCRIPT = "extension.member.terminated"
-MEMBER_SUSPENDED_SCRIPT = "extension.member.suspended"
-MEMBER_STARTED_SCRIPT = "extension.member.started"
-COMPLETE_TOPOLOGY_SCRIPT = "extension.complete.topology"
-COMPLETE_TENANT_SCRIPT = "extension.complete.tenant"
-SUBSCRIPTION_DOMAIN_ADDED_SCRIPT = "extension.subscription.domain.added"
-SUBSCRIPTION_DOMAIN_REMOVED_SCRIPT = "extension.subscription.domain.removed"
-ARTIFACTS_COPY_SCRIPT = "extension.artifacts.copy"
-TENANT_SUBSCRIBED_SCRIPT = "extension.tenant.subscribed"
-TENANT_UNSUBSCRIBED_SCRIPT = "extension.tenant.unsubscribed"
-
-SERVICE_GROUP_TOPOLOGY_KEY = "payload_parameter.SERIVCE_GROUP"
-CLUSTERING_TOPOLOGY_KEY = "payload_parameter.CLUSTERING"
-CLUSTERING_PRIMARY_KEY = "PRIMARY"
-
-SUPERTENANT_TEMP_PATH = "/tmp/-1234/"
-
-DEPLOYMENT_MANAGER = "manager"
-DEPLOYMENT_WORKER = "worker"
-DEPLOYMENT_DEFAULT = "default"
-SUPER_TENANT_REPO_PATH = "super.tenant.repository.path"
-TENANT_REPO_PATH = "tenant.repository.path"
-
-# topic names to subscribe
-INSTANCE_NOTIFIER_TOPIC = "instance/#"
-HEALTH_STAT_TOPIC = "health/#"
-TOPOLOGY_TOPIC = "topology/#"
-TENANT_TOPIC = "tenant/#"
-INSTANCE_STATUS_TOPIC = "instance/#"
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentutils.py b/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentutils.py
deleted file mode 100644
index c8d70a3..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/util/cartridgeagentutils.py
+++ /dev/null
@@ -1,94 +0,0 @@
-from Crypto.Cipher import AES
-import base64
-import logging
-import os
-import time
-import socket
-
-from ..config.cartridgeagentconfiguration import CartridgeAgentConfiguration
-
-unpad = lambda s : s[0:-ord(s[-1])]
-logging.basicConfig(level=logging.DEBUG)
-log = logging.getLogger(__name__)
-
-cartridge_agent_config = CartridgeAgentConfiguration()
-
-current_milli_time = lambda: int(round(time.time() * 1000))
-
-
-def decrypt_password(pass_str, secret):
- if pass_str is None:
- return pass_str
-
- dec_pass = ""
-
- try:
- log.debug("Decrypting password")
- bdecoded_pass = base64.b64decode(pass_str)
- #secret length should be 16
- cipher = AES.new(secret, AES.MODE_ECB)
- dec_pass = unpad(cipher.decrypt(bdecoded_pass))
- except:
- log.exception("Exception occurred while decrypting password")
-
- log.debug("Decrypted PWD: [%r]" % dec_pass)
- return dec_pass
-
-
-def create_dir(path):
- """
- mkdir the provided path
- :param path: The path to the directory to be made
- :return: True if mkdir was successful, False if dir already exists
- """
- try:
- os.mkdir(path)
- log.info("Successfully created directory [%r]" % path)
- return True
- except OSError:
- log.exception("Directory creating failed in [%r]. Directory already exists. " % path)
-
- return False
-
-
-def wait_until_ports_active(ip_address, ports):
- ports_check_timeout = cartridge_agent_config.read_property("port.check.timeout")
- if ports_check_timeout is None:
- ports_check_timeout = 1000 * 60 * 10
-
- log.debug("Port check timeout: %r" % ports_check_timeout)
-
- active = False
- start_time = current_milli_time()
- while not active:
- log.info("Waiting for ports to be active: [ip] %r [ports] %r" % (ip_address, ports))
- active = check_ports_active(ip_address, ports)
- end_time = current_milli_time()
- duration = end_time - start_time
- if duration > ports_check_timeout:
- return
-
- try:
- time.sleep(5)
- except:
- pass
-
- log.info("Ports activated: [ip] %r [ports] %r" % (ip_address, ports))
-
-
-def check_ports_active(ip_address, ports):
- if len(ports) < 1:
- raise RuntimeError("No ports found")
-
- for port in ports:
- s = socket.socket()
- s.settimeout(5)
- try:
- s.connect(ip_address, port)
- log.debug("Port %r is active" % port)
- s.close()
- except socket.error:
- log.debug("Print %r is not active" % port)
- return False
-
- return True
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/stratos/blob/ed08e2d3/tools/python-cartridge-agent/cartridge-agent/util/extensionutils.py
----------------------------------------------------------------------
diff --git a/tools/python-cartridge-agent/cartridge-agent/util/extensionutils.py b/tools/python-cartridge-agent/cartridge-agent/util/extensionutils.py
deleted file mode 100644
index c2ecc52..0000000
--- a/tools/python-cartridge-agent/cartridge-agent/util/extensionutils.py
+++ /dev/null
@@ -1,40 +0,0 @@
-import logging
-
-logging.basicConfig(level=logging.DEBUG)
-log = logging.getLogger(__name__)
-
-
-def execute_copy_artifact_extension(source, destination):
- raise NotImplementedError
-
-
-def execute_instance_started_extention(env_params):
- raise NotImplementedError
-
-
-def execute_instance_activated_extension():
- raise NotImplementedError
-
-
-def execute_artifacts_updated_extension(env_params):
- raise NotImplementedError
-
-
-def execute_subscription_domain_added_extension(tenant_id, tenant_domain, domain_name, application_context):
- raise NotImplementedError
-
-
-def execute_subscription_domain_removed_extension(tenant_id, tenant_domain, domain_name):
- raise NotImplementedError
-
-
-def wait_for_complete_topology():
- raise NotImplementedError
-
-
-def check_topology_consistency(service_name, cluster_id, member_id):
- raise NotImplementedError
-
-
-def execute_volume_mount_extension(persistance_mappings_payload):
- raise NotImplementedError
\ No newline at end of file