You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ch...@apache.org on 2015/12/21 11:53:01 UTC

[1/4] stratos git commit: PCA - Message broker IP and Port config for compatibility

Repository: stratos
Updated Branches:
  refs/heads/master bd32dcd3f -> 932c3286e


PCA - Message broker IP and Port config for compatibility


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

Branch: refs/heads/master
Commit: 258f5b41d2e210e8e2d15e6a075cfcb9996be88b
Parents: bd32dcd
Author: Chamila de Alwis <ch...@apache.org>
Authored: Mon Dec 21 15:34:02 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Mon Dec 21 15:34:02 2015 +0530

----------------------------------------------------------------------
 .../cartridge.agent/cartridge.agent/agent.conf  |   2 +
 .../cartridge.agent/cartridge.agent/config.py   |  29 +++-
 .../cartridge.agent/constants.py                |   2 +
 .../modules/event/eventhandler.py               |   3 +
 .../cartridge.agent/subscriber.py               |   6 +
 .../AgentConfBackwardCompatibilityTestCase.java | 162 +++++++++++++++++++
 .../agent.conf                                  |  48 ++++++
 .../logging.ini                                 |  52 ++++++
 .../payload/launch-params                       |   1 +
 9 files changed, 303 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
index a8c8a19..b2c2f76 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/agent.conf
@@ -16,6 +16,8 @@
 # under the License.
 
 [agent]
+mb.ip                                 =MB-IP
+mb.port                               =MB-PORT
 mb.urls                               =MB-URLS
 mb.username                           =MB-USERNAME
 mb.password                           =MB-PASSWORD

http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
index 72fc5e2..d6a751d 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
@@ -142,6 +142,10 @@ class Config:
     """ :type : bool """
     mb_urls = []
     """ :type : list """
+    mb_ip = None
+    """ :type : str """
+    mb_port = None
+    """ :type : str """
     mb_username = None
     """ :type : str """
     mb_password = None
@@ -363,8 +367,29 @@ class Config:
 
             Config.mb_username = Config.read_property(constants.MB_USERNAME, False)
             Config.mb_password = Config.read_property(constants.MB_PASSWORD, False)
-            Config.mb_urls = Config.read_property(constants.MB_URLS)
-            Config.mb_publisher_timeout = int(Config.read_property(constants.MB_PUBLISHER_TIMEOUT))
+
+            # Check if mb.urls is set, if not get values from mb.ip and mb.port and populate mb.urls.
+            # If both are absent, it's a critical error
+            try:
+                Config.mb_urls = Config.read_property(constants.MB_URLS)
+                first_mb_pair = Config.mb_urls.split(",")[0]
+                Config.mb_ip = first_mb_pair.split(":")[0]
+                Config.mb_port = first_mb_pair.split(":")[1]
+            except ParameterNotFoundException:
+                Config.log.info("Single message broker configuration selected.")
+                try:
+                    Config.mb_ip = Config.read_property(constants.MB_IP)
+                    Config.mb_port = Config.read_property(constants.MB_PORT)
+                    Config.mb_urls = "%s:%s" % (Config.mb_ip, Config.mb_port)
+                except ParameterNotFoundException as ex:
+                    Config.log.exception("Required message broker information missing. "
+                                         "Either \"mb.ip\" and \"mb.port\" or \"mb.urls\" should be provided.")
+                    raise RuntimeError("Required message broker information missing.", ex)
+
+            try:
+                Config.mb_publisher_timeout = int(Config.read_property(constants.MB_PUBLISHER_TIMEOUT))
+            except ParameterNotFoundException:
+                Config.mb_publisher_timeout = 900  # 15 minutes
 
             Config.cep_username = Config.read_property(constants.CEP_SERVER_ADMIN_USERNAME)
             Config.cep_password = Config.read_property(constants.CEP_SERVER_ADMIN_PASSWORD)

http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
index cd2ce36..4799add 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/constants.py
@@ -20,6 +20,8 @@ PLUGINS_DIR = "plugins.dir"
 EXTENSIONS_DIR = "extensions.dir"
 
 MB_URLS = "mb.urls"
+MB_IP = "mb.ip"
+MB_PORT = "mb.port"
 MB_USERNAME = "mb.username"
 MB_PASSWORD = "mb.password"
 MB_PUBLISHER_TIMEOUT = "mb.publisher.timeout"

http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
index 62a125a..4e5bdd8 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
@@ -590,6 +590,9 @@ def add_common_input_values(plugin_values):
     elif type(plugin_values) != dict:
         plugin_values = {"VALUE1": str(plugin_values)}
 
+    # Values for the plugins to use in case they want to connect to the MB.
+    plugin_values["MB_IP"] = Config.mb_ip
+
     plugin_values["APPLICATION_PATH"] = Config.app_path
     plugin_values["PARAM_FILE_PATH"] = Config.read_property(constants.PARAM_FILE_PATH, False)
     plugin_values["PERSISTENCE_MAPPINGS"] = Config.persistence_mappings

http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
index bdee412..aa1c04a 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
@@ -20,6 +20,8 @@ from Queue import Queue
 import threading
 import paho.mqtt.client as mqtt
 
+from config import Config
+
 from modules.util.log import LogFactory
 from modules.util.asyncscheduledtask import *
 from modules.util.cartridgeagentutils import IncrementalCeilingListIterator
@@ -81,6 +83,10 @@ class EventSubscriber(threading.Thread):
             self.__mb_client, connected_mb_ip, connected_mb_port = \
                 EventSubscriber.failover(self.__urls, self.__mb_client)
 
+            # update connected MB details in the config for the plugins to use
+            Config.mb_ip = connected_mb_ip
+            Config.mb_port = connected_mb_port
+
             EventSubscriber.log.info(
                 "Connected to the message broker with address %s:%s" % (connected_mb_ip, connected_mb_port))
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java
new file mode 100644
index 0000000..2d955b5
--- /dev/null
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java
@@ -0,0 +1,162 @@
+/*
+ * 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.
+ */
+
+package org.apache.stratos.python.cartridge.agent.integration.tests;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.messaging.domain.topology.ServiceType;
+import org.apache.stratos.messaging.domain.topology.Topology;
+import org.apache.stratos.messaging.event.instance.notifier.ArtifactUpdatedEvent;
+import org.apache.stratos.messaging.event.topology.CompleteTopologyEvent;
+import org.apache.stratos.messaging.event.topology.MemberInitializedEvent;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Test to verify backward compatibility of the Python Cartridge Agent against
+ * older configuration options.
+ */
+public class AgentConfBackwardCompatibilityTestCase extends PythonAgentIntegrationTest {
+    public AgentConfBackwardCompatibilityTestCase() throws IOException {
+    }
+
+    private static final Log log = LogFactory.getLog(AgentConfBackwardCompatibilityTestCase.class);
+    private static final int TIMEOUT = 5 * 60000;
+    private static final String CLUSTER_ID = "php.php.domain";
+    private static final String APPLICATION_PATH = "/tmp/AgentConfBackwardCompatibilityTestCase";
+    private static final String DEPLOYMENT_POLICY_NAME = "deployment-policy-1";
+    private static final String AUTOSCALING_POLICY_NAME = "autoscaling-policy-1";
+    private static final String APP_ID = "application-1";
+    private static final String MEMBER_ID = "php.member-1";
+    private static final String INSTANCE_ID = "instance-1";
+    private static final String CLUSTER_INSTANCE_ID = "cluster-1-instance-1";
+    private static final String NETWORK_PARTITION_ID = "network-partition-1";
+    private static final String PARTITION_ID = "partition-1";
+    private static final String TENANT_ID = "-1234";
+    private static final String SERVICE_NAME = "php";
+
+    @Override
+    protected String getClassName() {
+        return this.getClass().getSimpleName();
+    }
+
+    @BeforeMethod(alwaysRun = true)
+    public void setupCompatibilityTest() throws Exception {
+        System.setProperty("jndi.properties.dir", getCommonResourcesPath());
+
+        // start Python agent with configurations provided in resource path
+        super.setup(TIMEOUT);
+
+        // Simulate server socket
+        startServerSocket(8080);
+    }
+
+    @AfterMethod(alwaysRun = true)
+    public void tearDownCompatibilityTest(){
+        tearDown(APPLICATION_PATH);
+    }
+
+    @Test(timeOut = TIMEOUT, groups = { "smoke" })
+    public void testConfigCompatibility(){
+        startCommunicatorThread();
+        assertAgentActivation();
+    }
+
+    private void assertAgentActivation() {
+        Thread startupTestThread = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                while (!eventReceiverInitialized) {
+                    sleep(1000);
+                }
+                List<String> outputLines = new ArrayList<>();
+                while (!outputStream.isClosed()) {
+                    List<String> newLines = getNewLines(outputLines, outputStream.toString());
+                    if (newLines.size() > 0) {
+                        for (String line : newLines) {
+                            if (line.contains("Subscribed to 'topology/#'")) {
+                                sleep(2000);
+                                // Send complete topology event
+                                log.info("Publishing complete topology event...");
+                                Topology topology = PythonAgentIntegrationTest.createTestTopology(
+                                        SERVICE_NAME,
+                                        CLUSTER_ID,
+                                        DEPLOYMENT_POLICY_NAME,
+                                        AUTOSCALING_POLICY_NAME,
+                                        APP_ID,
+                                        MEMBER_ID,
+                                        CLUSTER_INSTANCE_ID,
+                                        NETWORK_PARTITION_ID,
+                                        PARTITION_ID,
+                                        ServiceType.SingleTenant);
+                                CompleteTopologyEvent completeTopologyEvent = new CompleteTopologyEvent(topology);
+                                publishEvent(completeTopologyEvent);
+                                log.info("Complete topology event published");
+
+                                // Publish member initialized event
+                                log.info("Publishing member initialized event...");
+                                MemberInitializedEvent memberInitializedEvent = new MemberInitializedEvent(SERVICE_NAME,
+                                        CLUSTER_ID, CLUSTER_INSTANCE_ID, MEMBER_ID, NETWORK_PARTITION_ID, PARTITION_ID,
+                                        INSTANCE_ID);
+                                publishEvent(memberInitializedEvent);
+                                log.info("Member initialized event published");
+                            }
+
+                            // Send artifact updated event to activate the instance first
+                            if (line.contains("Artifact repository found")) {
+                                publishEvent(getArtifactUpdatedEventForPrivateRepo());
+                                log.info("Artifact updated event published");
+                            }
+                        }
+                    }
+                    sleep(1000);
+                }
+            }
+        });
+        startupTestThread.start();
+
+        while (!instanceStarted || !instanceActivated) {
+            // wait until the instance activated event is received.
+            // this will assert whether instance got activated within timeout period; no need for explicit assertions
+            sleep(2000);
+        }
+    }
+
+    public static ArtifactUpdatedEvent getArtifactUpdatedEventForPrivateRepo() {
+        ArtifactUpdatedEvent privateRepoEvent = createTestArtifactUpdatedEvent();
+        privateRepoEvent.setRepoURL("https://bitbucket.org/testapache2211/testrepo.git");
+        privateRepoEvent.setRepoUserName("testapache2211");
+//        privateRepoEvent.setRepoPassword("+to2qVW16jzy+Xb/zuafQQ==");
+        privateRepoEvent.setRepoPassword("iF7qT+BKKPE3PGV1TeDsJA==");
+        return privateRepoEvent;
+    }
+
+    private static ArtifactUpdatedEvent createTestArtifactUpdatedEvent() {
+        ArtifactUpdatedEvent artifactUpdatedEvent = new ArtifactUpdatedEvent();
+        artifactUpdatedEvent.setClusterId(CLUSTER_ID);
+        artifactUpdatedEvent.setTenantId(TENANT_ID);
+        return artifactUpdatedEvent;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/agent.conf
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/agent.conf b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/agent.conf
new file mode 100644
index 0000000..9a12680
--- /dev/null
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/agent.conf
@@ -0,0 +1,48 @@
+# 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.
+
+[agent]
+mb.ip                                 =localhost
+mb.port                               =1885
+mb.urls                               =
+mb.username                           =system
+mb.password                           =manager
+mb.publisher.timeout                  =200
+listen.address                        =localhost
+thrift.receiver.urls                  =localhost:7712
+thrift.server.admin.username          =admin
+thrift.server.admin.password          =admin
+cep.stats.publisher.enabled           =true
+lb.private.ip                         =
+lb.public.ip                          =
+enable.artifact.update                =true
+auto.commit                           =false
+auto.checkout                         =false
+artifact.update.interval              =15
+artifact.clone.retries                =5
+artifact.clone.interval               =10
+port.check.timeout                    =600000
+enable.data.publisher                 =false
+monitoring.server.ip                  =localhost
+monitoring.server.port                =7612
+monitoring.server.secure.port         =7712
+monitoring.server.admin.username      =admin
+monitoring.server.admin.password      =admin
+log.file.paths                        =/tmp/agent.screen-mb-ha-test.log
+metadata.service.url                  =https://localhost:9443
+super.tenant.repository.path          =
+tenant.repository.path                =

http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/logging.ini
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/logging.ini b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/logging.ini
new file mode 100644
index 0000000..15cad9b
--- /dev/null
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/logging.ini
@@ -0,0 +1,52 @@
+# 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.
+
+
+[formatters]
+keys=default
+
+[formatter_default]
+format=[%(asctime)s] %(levelname)s {%(filename)s:%(funcName)s} - %(message)s
+class=logging.Formatter
+
+[handlers]
+keys=console, error_file, log_file
+
+[handler_console]
+class=logging.StreamHandler
+formatter=default
+args=tuple()
+
+[handler_log_file]
+class=logging.FileHandler
+level=DEBUG
+formatter=default
+args=("agent.log", "w")
+
+[handler_error_file]
+class=logging.FileHandler
+level=ERROR
+formatter=default
+args=("error.log", "w")
+
+[loggers]
+keys=root
+
+[logger_root]
+level=DEBUG
+formatter=default
+handlers=console,error_file,log_file
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/stratos/blob/258f5b41/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/payload/launch-params
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/payload/launch-params b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/payload/launch-params
new file mode 100644
index 0000000..377baff
--- /dev/null
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/resources/AgentConfBackwardCompatibilityTestCase/payload/launch-params
@@ -0,0 +1 @@
+APPLICATION_ID=application-1,APPLICATION_PATH=/tmp/AgentConfBackwardCompatibilityTestCase,BASH=/bin/bash,BASHOPTS=cmdhist:complete_fullquote:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath,BASH_ALIASES=(),BASH_ARGC=(),BASH_ARGV=(),BASH_CMDS=(),BASH_LINENO=([0]="0"),BASH_SOURCE=([0]="/usr/local/bin/populate-user-data.sh"),BASH_VERSINFO=([0]="4" [1]="3" [2]="30" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu"),BASH_VERSION='4.3.30(1)-release',CARTRIDGE_ALIAS=mytomcat,CARTRIDGE_KEY=PUjpXCLujDhYr5A6,CATALINA_HOME=/opt/tomcat,CEP_IP=54.179.197.243,CEP_PORT=7711,CLUSTER_ID=php.php.domain,CLUSTER_INSTANCE_ID=cluster-1-instance-1,DEPENDENCY_CLUSTER_IDS=myphp.php.domain,DEPLOYMENT=default,DIRSTACK=(),EUID=0,GROUPS=(),GROUP_NAME=null,HOME=/root,HOSTNAME=mytomcat-tomcat-domain3bd3cd47-b95d-475a-aa11-3e3ddc089d49,HOSTTYPE=x86_64,HOST_NAME=mytomcat.tomcat.stratos.org,IFS=' 	,',INSTANCE_ID=null,INTERNAL=false,JAVA_HOME=/opt/jdk1.7.0_67,KUBERNETES_CLUSTER_ID
 =kubernetes-cluster-1,KUBERNETES_PORT=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP=tcp://10.100.0.2:443,KUBERNETES_PORT_443_TCP_ADDR=10.100.0.2,KUBERNETES_PORT_443_TCP_PORT=443,KUBERNETES_PORT_443_TCP_PROTO=tcp,KUBERNETES_RO_PORT=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP=tcp://10.100.0.1:80,KUBERNETES_RO_PORT_80_TCP_ADDR=10.100.0.1,KUBERNETES_RO_PORT_80_TCP_PORT=80,KUBERNETES_RO_PORT_80_TCP_PROTO=tcp,KUBERNETES_RO_SERVICE_HOST=10.100.0.1,KUBERNETES_RO_SERVICE_PORT=80,KUBERNETES_SERVICE_HOST=10.100.0.2,KUBERNETES_SERVICE_PORT=443,LB_CLUSTER_ID=null,LOG_LEVEL=DEBUG,MACHTYPE=x86_64-pc-linux-gnu,MB_IP=54.179.197.243,MB_PORT=1883,MEMBER_ID=php.member-1,MIN_COUNT=1,MULTITENANT=false,MYPHP_PHP_DOMAIN_1_PORT=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP=tcp://10.100.171.218:4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.171.218,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYPHP_PHP_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYPHP_PHP_DOMAIN_1_SERVICE_HOST=10.100.171.218,MYPHP_PHP_DO
 MAIN_1_SERVICE_PORT=4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP=tcp://10.100.16.250:4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_ADDR=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PORT=4500,MYTOMCAT_TOMCAT_DOMAIN_1_PORT_4500_TCP_PROTO=tcp,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_HOST=10.100.16.250,MYTOMCAT_TOMCAT_DOMAIN_1_SERVICE_PORT=4500,NETWORK_PARTITION_ID=network-partition-1,OPTERR=1,OPTIND=1,OSTYPE=linux-gnu,PARTITION_ID=partition-1,PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin,PIPESTATUS=([0]="0"),PORTS=8080,POSIXLY_CORRECT=y,PPID=14,PRIMARY=false,PROVIDER=apache,PS4='+ ',PUPPET_DNS_AVAILABLE=null,PUPPET_ENV=false,PUPPET_HOSTNAME=puppet.apache.stratos.org,PUPPET_IP=127.0.0.1,PWD=/opt,SERVICE_NAME=php,SHELL=/bin/bash,SHELLOPTS=braceexpand:hashall:interactive-comments:posix,SHLVL=2,TENANT_ID=-1234,TENANT_RANGE='*',TERM=dumb,TOKEN=eyJhbGciOiJSUzI1NiJ9.eyJleHAiOi04NzI0ODEyNDEsInN1YiI6ImFkbWluIiwiYXpwIjoid3I5
 SllVaDNtTXd6bVhHVllqWmVIWnhCV2xFYSIsImFwcElkIjoic2luZ2xlX2dyb3VwX3YxIiwiYXVkIjpbIndyOUpZVWgzbU13em1YR1ZZalplSFp4QldsRWEiXSwiaXNzIjoiaHR0cHM6XC9cL2xvY2FsaG9zdDo5NDQzXC9vYXV0aDJlbmRwb2ludHNcL3Rva2VuIiwiaWF0IjotODcyNDgwMjQwfQ.OSa1gIXUT9amhk1YEU02Yc3JtUYqanzrXh5K1YyvRXcpSiY2Ccn2BfJO0hILF5UooRcGBihzfX3979NRcvGwcUDUvOUJ0eaGPmxFZYbu0nr3xD8lhAO3fa1QYsKAvMnMdwyu2uSgSp6R6EUdVleiwlabUoDsuEcKGkIAn_VQvG0,UID=0,_=posix,LVS_VIRTUAL_IP=192.168.0.40|255.255.255.0


[2/4] stratos git commit: PCA - Fix log entries for MB connectivity

Posted by ch...@apache.org.
PCA - Fix log entries for MB connectivity


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

Branch: refs/heads/master
Commit: 4664e6a67690cb5e70fdf1325e092f6f094fc5bf
Parents: 258f5b4
Author: Chamila de Alwis <ch...@apache.org>
Authored: Mon Dec 21 15:50:50 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Mon Dec 21 15:50:50 2015 +0530

----------------------------------------------------------------------
 .../cartridge.agent/cartridge.agent/config.py   |  6 +++---
 .../modules/event/eventhandler.py               |  2 +-
 .../cartridge.agent/subscriber.py               |  4 ++--
 .../AgentConfBackwardCompatibilityTestCase.java | 22 --------------------
 4 files changed, 6 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4664e6a6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
index d6a751d..23283cb 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/config.py
@@ -257,10 +257,10 @@ class Config:
         return value_string
 
     @staticmethod
-    def read_property(property_key, critical=True):
+    def read_property(property_key, mandatory=True):
         """
         Returns the value of the provided property
-        :param critical: If absence of this value should throw an error
+        :param mandatory: If absence of this value should throw an error
         :param str property_key: the name of the property to be read
         :return: Value of the property
         :exception: ParameterNotFoundException if the provided property cannot be found
@@ -280,7 +280,7 @@ class Config:
                 return real_value
 
         # real value is None
-        if critical:
+        if mandatory:
             raise ParameterNotFoundException("Cannot find the value of required parameter: %r" % property_key)
         else:
             return None

http://git-wip-us.apache.org/repos/asf/stratos/blob/4664e6a6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
index 4e5bdd8..4e55bad 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py
@@ -197,7 +197,7 @@ def on_complete_topology_event(complete_topology_event):
                 "Member initialized [member id] %s, [cluster-id] %s, [service] %s"
                 % (member_id_in_payload, cluster_id_in_payload, service_name_in_payload))
         else:
-            log.info("Member not initialized in topology.......")
+            log.info("Member not initialized in topology.")
 
     topology = complete_topology_event.get_topology()
     service = topology.get_service(service_name_in_payload)

http://git-wip-us.apache.org/repos/asf/stratos/blob/4664e6a6/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
index aa1c04a..165cd5b 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/subscriber.py
@@ -168,9 +168,9 @@ class EventSubscriber(threading.Thread):
                     return mb_client, mb_ip, mb_port
                 except:
                     # The message broker didn't respond well
-                    EventSubscriber.log.debug("Could not connect to the message broker at %s:%s." % (mb_ip, mb_port))
+                    EventSubscriber.log.info("Could not connect to the message broker at %s:%s." % (mb_ip, mb_port))
 
-            EventSubscriber.log.debug(
+            EventSubscriber.log.error(
                 "Could not connect to any of the message brokers provided. Retrying in %s seconds." % retry_interval)
 
             time.sleep(retry_interval)

http://git-wip-us.apache.org/repos/asf/stratos/blob/4664e6a6/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java
----------------------------------------------------------------------
diff --git a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java
index 2d955b5..c390449 100644
--- a/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java
+++ b/products/python-cartridge-agent/modules/integration/test-integration/src/test/java/org/apache/stratos/python/cartridge/agent/integration/tests/AgentConfBackwardCompatibilityTestCase.java
@@ -123,12 +123,6 @@ public class AgentConfBackwardCompatibilityTestCase extends PythonAgentIntegrati
                                 publishEvent(memberInitializedEvent);
                                 log.info("Member initialized event published");
                             }
-
-                            // Send artifact updated event to activate the instance first
-                            if (line.contains("Artifact repository found")) {
-                                publishEvent(getArtifactUpdatedEventForPrivateRepo());
-                                log.info("Artifact updated event published");
-                            }
                         }
                     }
                     sleep(1000);
@@ -143,20 +137,4 @@ public class AgentConfBackwardCompatibilityTestCase extends PythonAgentIntegrati
             sleep(2000);
         }
     }
-
-    public static ArtifactUpdatedEvent getArtifactUpdatedEventForPrivateRepo() {
-        ArtifactUpdatedEvent privateRepoEvent = createTestArtifactUpdatedEvent();
-        privateRepoEvent.setRepoURL("https://bitbucket.org/testapache2211/testrepo.git");
-        privateRepoEvent.setRepoUserName("testapache2211");
-//        privateRepoEvent.setRepoPassword("+to2qVW16jzy+Xb/zuafQQ==");
-        privateRepoEvent.setRepoPassword("iF7qT+BKKPE3PGV1TeDsJA==");
-        return privateRepoEvent;
-    }
-
-    private static ArtifactUpdatedEvent createTestArtifactUpdatedEvent() {
-        ArtifactUpdatedEvent artifactUpdatedEvent = new ArtifactUpdatedEvent();
-        artifactUpdatedEvent.setClusterId(CLUSTER_ID);
-        artifactUpdatedEvent.setTenantId(TENANT_ID);
-        return artifactUpdatedEvent;
-    }
 }


[3/4] stratos git commit: PCA - Added more informtation in the README

Posted by ch...@apache.org.
PCA - Added more informtation in the README


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

Branch: refs/heads/master
Commit: 4e948ddd4d75de7c1888b81e5b5c30a659d0df37
Parents: 4664e6a
Author: Chamila de Alwis <ch...@apache.org>
Authored: Mon Dec 21 16:09:47 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Mon Dec 21 16:09:47 2015 +0530

----------------------------------------------------------------------
 .../README.md                                   | 53 +++++++++++++++++++-
 1 file changed, 51 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/4e948ddd/components/org.apache.stratos.python.cartridge.agent/README.md
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/README.md b/components/org.apache.stratos.python.cartridge.agent/README.md
index 92066bf..40a2ec8 100644
--- a/components/org.apache.stratos.python.cartridge.agent/README.md
+++ b/components/org.apache.stratos.python.cartridge.agent/README.md
@@ -5,8 +5,57 @@ Cartridge agent manages cartridge instance lifecycle and publishes its health st
 to Complex Event Processor (CEP). It provides a set of extension points for implementing
 logic required for configuring the server.
 
-How to run Live Tests
----------------------
+# Configuration
+The PCA depends on a few mandatory configurations.
+
+1. Message broker configuration
+2. CEP configuration
+3. Application Path configuration
+
+## Message broker configuration
+The PCA conducts communication with the rest of the Stratos Components mainly via the message broker. Therefore, without the message broker configuration the PCA wouldn't start properly. Following are the configurations related to message broker communication in the PCA.
+
+1. mb.port
+2. mb.ip
+3. mb.urls
+4. mb.username
+5. mb.password
+6. mb.publisher.timeout
+
+The first two options allow to define a single message broker host and a port. The third option `mb.urls` allows to define a comma separated list of message broker urls, out of which the PCA will failover until a successful connection is made. It should be noted that `mb.urls` has precedence over `mb.ip` and `mb.ip` pair. `mb.ip` and `mb.port` will only be taken in to consideration if only `mb.urls` is empty. If none of the two options are specified, the PCA will not start.
+ 
+Also, when using a list of message brokers, the PCA only allows to specify a single pair of `mb.username` and `mb.password`.
+
+`mb.publisher.timeout` specifies the maximum timeout value (in seconds) for the message publisher to retry publishing an event, before giving up and dropping the event. 
+
+```ini
+mb.port = 1883
+mb.host = 10.100.4.33
+mb.urls = 10.100.4.21:1883,10.100.4.22:1883,10.100.4.23:1885
+mb.username = system
+mb.password = manager
+```
+
+## CEP configuration
+The PCA publishes health statistics to a CEP via Thrift. For this, the list of Thrift receivers should be specified using the following configuration options. 
+
+1. thrift.receiver.urls
+2. thrift.server.admin.username
+3. thrift.server.admin.password
+4. cep.stats.publisher.enabled
+
+```ini
+thrift.receiver.urls = 10.100.4.21:7711,10.100.4.22:7711,10.100.4.23:7711
+thrift.server.admin.username = admin
+thrift.server.admin.password = admin
+cep.stats.publisher.enabled = true
+```
+
+## Application Path configuration
+
+`APPLICATION_PATH` refers to the document root of the application service that is running in the specific instance which the PCA manages. For example, in a PHP instance this would be `/var/www`. This has to be either passed through the IaaS metadata service or passed in via the `agent.conf` configuration file.
+
+# How to run Live Tests
 1. Install following packages
 
    apt-get install -y git python python-pip python-dev gcc zip 


[4/4] stratos git commit: PCA - Update LVS create dummy interface extension

Posted by ch...@apache.org.
PCA - Update LVS create dummy interface extension


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

Branch: refs/heads/master
Commit: 932c3286eebe1defdb22f64b14ab8ff3a4a88c60
Parents: 4e948dd
Author: Chamila de Alwis <ch...@apache.org>
Authored: Mon Dec 21 16:13:35 2015 +0530
Committer: Chamila de Alwis <ch...@apache.org>
Committed: Mon Dec 21 16:13:35 2015 +0530

----------------------------------------------------------------------
 .../cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/932c3286/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
index 0bdd6b0..ee9ded9 100644
--- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
+++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/extensions/bash/CreateLVSDummyInterface.sh
@@ -23,4 +23,8 @@
 # event is received by the cartridge agent.
 # --------------------------------------------------------------
 #
-echo `date`": Create LVS dummy interface shell extension executed"
+
+modprobe dummy numdummies=1
+ifconfig dummy0 ${STRATOS_LVS_DUMMY_VIRTUAL_IP} netmask ${STRATOS_LVS_SUBNET_MASK}
+
+echo "update the dummy interface with ${STRATOS_LVS_DUMMY_VIRTUAL_IP} and ${STRATOS_LVS_SUBNET_MASK}"
\ No newline at end of file