stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [7/7] stratos git commit: Introducing KubernetesIaas class, MemberContext.clusterInstanceId, removing Cartridge.deployerType
Date Sat, 20 Dec 2014 21:56:45 GMT
Introducing KubernetesIaas class, MemberContext.clusterInstanceId, removing Cartridge.deployerType


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

Branch: refs/heads/master
Commit: b575c7d68669527c6f130bf1d1cb34fbdb9913b2
Parents: 4e6bebe
Author: Imesh Gunaratne <imesh@apache.org>
Authored: Sun Dec 21 03:20:36 2014 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Sun Dec 21 03:25:27 2014 +0530

----------------------------------------------------------------------
 .../applications/topic/ApplicationBuilder.java  |  11 +-
 .../client/CloudControllerClient.java           | 183 +----
 .../context/cluster/ClusterContext.java         |   3 +-
 .../autoscaler/monitor/MonitorFactory.java      |   2 +-
 .../monitor/cluster/ClusterMonitor.java         |  14 +-
 .../component/ParentComponentMonitor.java       |  12 +-
 .../autoscaler/rule/RuleTasksDelegator.java     | 149 +---
 .../cluster/ClusterStatusProcessorChain.java    |   3 -
 .../config/CartridgeAgentConfiguration.java     |  24 +-
 .../publisher/CartridgeAgentEventPublisher.java |  24 +-
 .../context/CloudControllerContext.java         |   4 +-
 .../cloud/controller/domain/Cartridge.java      |  13 +-
 .../controller/domain/InstanceContext.java      | 100 +++
 .../controller/domain/InstanceMetadata.java     | 107 +++
 .../cloud/controller/domain/MemberContext.java  |  87 ++-
 .../exception/CartridgeNotFoundException.java   |  44 ++
 .../UnregisteredCartridgeException.java         |  44 --
 ...inerClusterContextToKubernetesContainer.java |  13 +-
 ...tainerClusterContextToKubernetesService.java |   5 +-
 ...erClusterContextToReplicationController.java |  19 +-
 .../stratos/cloud/controller/iaases/Iaas.java   |  20 +-
 .../cloud/controller/iaases/JcloudsIaas.java    |  75 +-
 .../cloud/controller/iaases/KubernetesIaas.java | 651 ++++++++++++++++
 .../cloud/controller/iaases/MockIaas.java       |  11 +-
 .../controller/iaases/mock/MockIaasService.java |  27 +-
 .../iaases/mock/MockMemberContext.java          |  22 +-
 .../iaases/mock/MockMemberEventPublisher.java   |  28 +-
 .../iaases/mock/MockNodeMetadata.java           | 143 ----
 .../iaases/mock/MockPartitionValidator.java     |   3 +-
 .../validators/AWSEC2PartitionValidator.java    |   2 +-
 .../CloudstackPartitionValidator.java           |   5 +-
 .../validators/DockerPartitionValidator.java    |   5 +-
 .../validators/GCEPartitionValidator.java       |  10 +-
 .../validators/IaasBasedPartitionValidator.java |  47 --
 .../KubernetesBasedPartitionValidator.java      |  67 --
 .../KubernetesPartitionValidator.java           |  72 ++
 .../OpenstackNovaPartitionValidator.java        |   3 +-
 .../iaases/validators/PartitionValidator.java   |  18 +-
 .../validators/VCloudPartitionValidator.java    |   2 +-
 .../publisher/StatisticsDataPublisher.java      |  18 +-
 .../publisher/TopologyEventPublisher.java       | 323 ++++++++
 .../publisher/TopologySynchronizerTask.java     |  69 ++
 .../TopologySynchronizerTaskScheduler.java      |   2 -
 .../messaging/topology/TopologyBuilder.java     |  84 +-
 .../topology/TopologyEventPublisher.java        | 321 --------
 .../topology/TopologySynchronizerTask.java      |  68 --
 .../services/CloudControllerService.java        |  79 +-
 .../impl/CloudControllerServiceImpl.java        | 774 +++----------------
 .../impl/CloudControllerServiceUtil.java        |   8 +-
 .../services/impl/InstanceCreator.java          |  58 +-
 .../controller/util/CloudControllerUtil.java    |   1 -
 .../controller/util/PodActivationWatcher.java   |  41 +-
 .../definition/CartridgeDefinitionBean.java     |  10 -
 .../stratos/common/beans/topology/Member.java   |  43 +-
 .../kubernetes/client/KubernetesApiClient.java  |  17 +-
 .../KubernetesAPIClientInterface.java           |   2 +-
 .../live/KubernetesApiClientLiveTest.java       |  12 +-
 .../conf/LoadBalancerConfiguration.java         |   3 +-
 .../client/CloudControllerServiceClient.java    |   4 +-
 .../cartridge/CartridgeDeploymentManager.java   |  13 +-
 .../service/ServiceDeploymentManager.java       |   4 +-
 .../deployer/DefaultServiceGroupDeployer.java   |   4 +-
 .../grouping/deployer/ServiceGroupDeployer.java |   4 +-
 .../manager/ServiceGroupingManager.java         |   4 +-
 .../manager/CartridgeSubscriptionManager.java   |   6 +-
 .../utils/ApplicationManagementUtil.java        |   4 +-
 .../messaging/domain/topology/Member.java       |  41 +-
 .../instance/status/InstanceActivatedEvent.java |  18 +-
 .../status/InstanceMaintenanceModeEvent.java    |  18 +-
 .../status/InstanceReadyToShutdownEvent.java    |  19 +-
 .../instance/status/InstanceStartedEvent.java   |  17 +-
 .../instance/status/InstanceStatusEvent.java    |   2 +
 .../event/topology/InstanceSpawnedEvent.java    |  18 +-
 .../event/topology/MemberActivatedEvent.java    |  19 +-
 .../topology/MemberMaintenanceModeEvent.java    |  23 +-
 .../topology/MemberReadyToShutdownEvent.java    |  20 +-
 .../event/topology/MemberStartedEvent.java      |  15 +-
 .../event/topology/MemberTerminatedEvent.java   |  22 +-
 .../InstanceSpawnedMessageProcessor.java        |  13 +-
 .../cartridgeagent/cartridgeagent/agent.py      |  10 +-
 .../config/cartridgeagentconfiguration.py       |  22 +-
 .../modules/event/instance/status/events.py     |  47 +-
 .../modules/event/topology/events.py            |  60 +-
 .../publisher/cartridgeagentpublisher.py        |  47 +-
 .../modules/util/cartridgeagentconstants.py     |   3 +-
 .../rest/endpoint/api/StratosApiV41Utils.java   |   4 +-
 .../util/converter/ObjectConverter.java         | 371 ++++-----
 .../src/main/resources/AutoScalerService.wsdl   |  20 +-
 .../main/resources/CloudControllerService.wsdl  | 516 ++++---------
 89 files changed, 2588 insertions(+), 2805 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
index a07f5c6..7968acb 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/applications/topic/ApplicationBuilder.java
@@ -477,7 +477,6 @@ public class ApplicationBuilder {
                                                                 String parentId,
                                                                 String networkPartitionId,
                                                                 String partitionId) {
-        GroupInstance groupInstance = null;
         ApplicationHolder.acquireWriteLock();
         try {
             if (log.isDebugEnabled()) {
@@ -490,14 +489,14 @@ public class ApplicationBuilder {
             if (application == null) {
                 log.warn(String.format("Application %s does not exist",
                         appId));
-                return groupInstance;
+                return null;
             }
 
             Group group = application.getGroupRecursively(groupId);
             if (group == null) {
                 log.warn(String.format("Group %s does not exist when creating group",
                         groupId));
-                return groupInstance;
+                return null;
             }
 
             GroupStatus status = GroupStatus.Created;
@@ -514,6 +513,7 @@ public class ApplicationBuilder {
 
             if (!group.containsInstanceContext(instanceId)) {
                 //setting the status, persist and publish
+                GroupInstance groupInstance = null;
                 groupInstance = new GroupInstance(groupId, instanceId);
                 groupInstance.setParentId(parentId);
                 groupInstance.setPartitionId(partitionId);
@@ -523,6 +523,7 @@ public class ApplicationBuilder {
                 //updateGroupMonitor(appId, groupId, status);
                 ApplicationHolder.persistApplication(application);
                 ApplicationsEventPublisher.sendGroupInstanceCreatedEvent(appId, groupId, groupInstance);
+                return groupInstance;
             } else {
                 log.warn("Group Instance Context already exists: [group-id] " + groupId +
                         " [Group-Instance-Id] " + instanceId);
@@ -530,9 +531,7 @@ public class ApplicationBuilder {
         } finally {
             ApplicationHolder.releaseWriteLock();
         }
-
-
-        return groupInstance;
+        return null;
     }
 
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
index 210f5e1..430dd97 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/client/CloudControllerClient.java
@@ -28,25 +28,20 @@ import org.apache.stratos.autoscaler.applications.pojo.ApplicationClusterContext
 import org.apache.stratos.autoscaler.exception.cartridge.CartridgeInformationException;
 import org.apache.stratos.autoscaler.exception.cartridge.SpawningException;
 import org.apache.stratos.autoscaler.exception.cartridge.TerminationException;
-import org.apache.stratos.autoscaler.exception.kubernetes.NonExistingKubernetesGroupException;
 import org.apache.stratos.autoscaler.exception.partition.PartitionValidationException;
-import org.apache.stratos.autoscaler.pojo.policy.deployment.DeploymentPolicy;
-import org.apache.stratos.autoscaler.kubernetes.KubernetesManager;
-import org.apache.stratos.autoscaler.pojo.policy.deployment.partition.network.*;
 import org.apache.stratos.autoscaler.util.AutoscalerUtil;
 import org.apache.stratos.autoscaler.util.ConfUtil;
 import org.apache.stratos.cloud.controller.stub.*;
-import org.apache.stratos.cloud.controller.stub.domain.*;
+import org.apache.stratos.cloud.controller.stub.domain.CartridgeInfo;
+import org.apache.stratos.cloud.controller.stub.domain.InstanceContext;
+import org.apache.stratos.cloud.controller.stub.domain.MemberContext;
 import org.apache.stratos.cloud.controller.stub.domain.Partition;
 import org.apache.stratos.common.Properties;
 import org.apache.stratos.common.Property;
 import org.apache.stratos.common.constants.StratosConstants;
-import org.apache.stratos.common.kubernetes.KubernetesGroup;
-import org.apache.stratos.common.kubernetes.KubernetesMaster;
 
 import java.rmi.RemoteException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
 
@@ -137,9 +132,6 @@ public class CloudControllerClient {
         return partition1;
     }
 
-
-
-
     /*
      * Calls the CC to validate the partition.
      */
@@ -166,10 +158,10 @@ public class CloudControllerClient {
 
     }
 
-    public synchronized MemberContext spawnAnInstance(Partition partition,
-                                                      String clusterId,
-                                                      String networkPartitionId,String instanceID, boolean isPrimary,
-                                                      int minMemberCount) throws SpawningException {
+    public synchronized MemberContext startInstance(Partition partition,
+                                                    String clusterId, String clusterInstanceId,
+                                                    String networkPartitionId, boolean isPrimary,
+                                                    int minMemberCount) throws SpawningException {
         try {
             if (log.isInfoEnabled()) {
                 log.info(String.format("Trying to spawn an instance via cloud controller: " +
@@ -183,14 +175,14 @@ public class CloudControllerClient {
                 log.debug("Member Obsolete Expiry Time is set to: " + expiryTime);
             }
 
-            MemberContext member = new MemberContext();
-            member.setClusterId(clusterId);
-            member.setPartition(partition);
-	        member.setInstanceId(instanceID);
-//            member.setLbClusterId(lbClusterId);
-            member.setObsoleteExpiryTime(expiryTime);
-            member.setInitTime(System.currentTimeMillis());
-            member.setNetworkPartitionId(networkPartitionId);
+            InstanceContext instanceContext = new InstanceContext();
+            instanceContext.setClusterId(clusterId);
+            instanceContext.setClusterInstanceId(clusterInstanceId);
+            instanceContext.setPartition(partition);
+            instanceContext.setInitTime(System.currentTimeMillis());
+            instanceContext.setObsoleteExpiryTime(expiryTime);
+            instanceContext.setNetworkPartitionId(networkPartitionId);
+
             Properties memberContextProps = new Properties();
             Property isPrimaryProp = new Property();
             isPrimaryProp.setName("PRIMARY");
@@ -202,18 +194,17 @@ public class CloudControllerClient {
 
             memberContextProps.addProperty(isPrimaryProp);
             memberContextProps.addProperty(minCountProp);
-            member.setProperties(AutoscalerUtil.toStubProperties(memberContextProps));
-
+            instanceContext.setProperties(AutoscalerUtil.toStubProperties(memberContextProps));
 
             long startTime = System.currentTimeMillis();
-            MemberContext memberContext = stub.startInstance(member);
+            MemberContext memberContext = stub.startInstance(instanceContext);
             if (log.isDebugEnabled()) {
                 long endTime = System.currentTimeMillis();
                 log.debug(String.format("Service call startInstance() returned in %dms", (endTime - startTime)));
             }
             return memberContext;
-        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
-            String message = e.getFaultMessage().getUnregisteredCartridgeException().getMessage();
+        } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
+            String message = e.getFaultMessage().getCartridgeNotFoundException().getMessage();
             log.error(message, e);
             throw new SpawningException(message, e);
         } catch (RemoteException e) {
@@ -337,144 +328,10 @@ public class CloudControllerClient {
             String msg = e.getMessage();
             log.error(msg, e);
             throw new CartridgeInformationException(msg, e);
-        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
+        } catch (CloudControllerServiceCartridgeNotFoundExceptionException e) {
             String msg = e.getMessage();
             log.error(msg, e);
             throw new CartridgeInformationException(msg, e);
         }
     }
-
-    /**
-     * @param kubernetesClusterId
-     * 				kubernetes cluster id in which the cluster needs be created
-     * @param clusterId
-     * 				service cluster id
-     * @return the {@link MemberContext}
-     * @throws SpawningException
-     * 				if client can't connect to cloud controller service, if
-     * 				cartridge not found for the given cluster id, or if the given
-     * 				kubernetes cluster id is not valid
-     */
-    public synchronized MemberContext[] startContainers(Partition partition,
-            String clusterId,
-            String networkPartitionId,String instanceID, boolean isPrimary,
-            int minMemberCount) throws SpawningException {
-        try {
-
-//            KubernetesManager kubernetesManager = KubernetesManager.getInstance();
-//            KubernetesMaster kubernetesMaster = kubernetesManager.getKubernetesMasterInGroup(kubernetesClusterId);
-//            String kubernetesMasterIP = kubernetesMaster.getHostIpAddress();
-//            KubernetesGroup kubernetesGroup = kubernetesManager.getKubernetesGroup(kubernetesClusterId);
-//            int lower = kubernetesGroup.getPortRange().getLower();
-//            int upper = kubernetesGroup.getPortRange().getUpper();
-//            String portRange = Integer.toString(lower) + "-" + Integer.toString(upper);
-
-            ContainerClusterContext context = new ContainerClusterContext();
-            context.setClusterId(clusterId);
-            context.setPartition(partition);
-            context.setNetworkPartitionId(networkPartitionId);
-            context.setInstanceId(instanceID);
-            
-            Properties memberContextProps = new Properties();
-            Property isPrimaryProp = new Property();
-            isPrimaryProp.setName("PRIMARY");
-            isPrimaryProp.setValue(String.valueOf(isPrimary));
-
-            Property minCountProp = new Property();
-            minCountProp.setName(StratosConstants.MIN_COUNT);
-            minCountProp.setValue(String.valueOf(minMemberCount));
-
-            memberContextProps.addProperty(isPrimaryProp);
-            memberContextProps.addProperty(minCountProp);
-            context.setProperties(AutoscalerUtil.toStubProperties(memberContextProps));
-            
-//            Properties memberContextProps = new Properties();
-//            Property kubernetesClusterMasterIPProps = new Property();
-//            kubernetesClusterMasterIPProps.setName(StratosConstants.KUBERNETES_MASTER_IP);
-//            kubernetesClusterMasterIPProps.setValue(kubernetesMasterIP);
-//            memberContextProps.addProperty(kubernetesClusterMasterIPProps);
-//            Property kubernetesClusterPortRangeProps = new Property();
-//            kubernetesClusterPortRangeProps.setName(StratosConstants.KUBERNETES_PORT_RANGE);
-//            kubernetesClusterPortRangeProps.setValue(portRange);
-//            memberContextProps.addProperty(kubernetesClusterPortRangeProps);
-//            context.setProperties(AutoscalerUtil.toStubProperties(memberContextProps));
-            long startTime = System.currentTimeMillis();
-            MemberContext[] memberContexts = stub.startContainers(context);
-
-            if (log.isDebugEnabled()) {
-                long endTime = System.currentTimeMillis();
-                log.debug(String.format("Service call startContainer() returned in %dms", (endTime - startTime)));
-            }
-            return memberContexts;
-        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
-            String msg = String.format("Error while creating containers. Cartridge not found for cluster [%s] ", clusterId);
-            log.error(msg, e);
-            throw new SpawningException(msg, e);
-        } catch (RemoteException e) {
-        	String msg = "Error while creating containers, couldn't communicate with cloud controller service";
-        	log.error(msg, e);
-        	throw new SpawningException(msg, e);
-        } 
-//        catch (NonExistingKubernetesGroupException e) {
-//        	String msg = String.format("Error while creating containers, invalid kubernetes group [%s] ", kubernetesClusterId);
-//        	log.error(msg, e);
-//        	throw new SpawningException(msg, e);
-//        }
-    }
-
-    public synchronized void terminateContainers(String clusterId) throws TerminationException {
-        try {
-            if (log.isInfoEnabled()) {
-                log.info(String.format("Terminating containers via cloud controller: [cluster] %s", clusterId));
-            }
-            long startTime = System.currentTimeMillis();
-            stub.terminateContainers(clusterId);
-            if (log.isDebugEnabled()) {
-                long endTime = System.currentTimeMillis();
-                log.debug(String.format("Service call terminateContainer() returned in %dms", (endTime - startTime)));
-            }
-        } catch (RemoteException e) {
-        	String msg = "Error while creating containers, couldn't communicate with cloud controller service";
-            log.error(msg, e);
-            throw new TerminationException(msg, e);
-        } catch (CloudControllerServiceInvalidClusterExceptionException e) {
-        	String msg = "Invalid Cluster [clusterId] " + clusterId;
-            log.error(msg, e);
-            throw new TerminationException(msg, e);
-        }
-    }
-
-    public synchronized MemberContext[] updateContainers(String clusterId, int replicas)
-            throws SpawningException {
-        try {
-            log.info(String.format("Updating kubernetes replication controller via cloud controller: " +
-                    "[cluster] %s [replicas] %s", clusterId, replicas));
-            MemberContext[] memberContexts = stub.updateContainers(clusterId, replicas);
-            return memberContexts;
-        } catch (CloudControllerServiceUnregisteredCartridgeExceptionException e) {
-            String msg = "Error while updating kubernetes controller, cartridge not found for [cluster] " + clusterId;
-            log.error(msg, e);
-            throw new SpawningException(msg, e);
-        } catch (RemoteException e) {
-            String msg = "Error while updating kubernetes controller, cannot communicate with " +
-                    "cloud controller service";
-            log.error(msg, e);
-            throw new SpawningException(msg, e);
-        }
-    }
-
-    public synchronized void terminateContainer(String memberId) throws TerminationException {
-        try {
-            stub.terminateContainer(memberId);
-        } catch (RemoteException e) {
-            String msg = "Error while updating kubernetes controller, cannot communicate with " +
-                    "cloud controller service";
-            log.error(msg, e);
-            throw new TerminationException(msg, e);
-        } catch (CloudControllerServiceMemberTerminationFailedExceptionException e) {
-            String msg = "Error while terminating container, member not valid for member id : " + memberId;
-            log.error(msg, e);
-            throw new TerminationException(msg, e);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java
index b680fd1..ef7068a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/context/cluster/ClusterContext.java
@@ -127,8 +127,7 @@ public class ClusterContext extends AbstractClusterContext {
         ClusterLevelNetworkPartitionContext networkPartitionContext = null;
         ClusterInstance clusterInstance = cluster.getInstanceContexts(instanceId);
         ChildPolicy policy = this.deploymentPolicy.
-                getChildPolicy(
-                        AutoscalerUtil.getAliasFromClusterId(clusterId));
+                getChildPolicy(AutoscalerUtil.getAliasFromClusterId(clusterId));
         if (networkPartitionCtxts.containsKey(clusterInstance.getNetworkPartitionId())) {
             networkPartitionContext = this.networkPartitionCtxts.get(
                     clusterInstance.getNetworkPartitionId());

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
index b5b1614..7ad7bed 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/MonitorFactory.java
@@ -270,7 +270,7 @@ public class MonitorFactory {
             }
 
             //Creating the instance of the cluster
-            ((ClusterMonitor) clusterMonitor).createClusterInstance(parentInstanceIds, cluster);
+            ((ClusterMonitor) clusterMonitor).createClusterInstances(parentInstanceIds, cluster);
             //add it to autoscaler context
             AutoscalerContext.getInstance().addClusterMonitor(clusterMonitor);
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
index 24b8f3a..d99fd55 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/cluster/ClusterMonitor.java
@@ -859,14 +859,15 @@ public class ClusterMonitor extends AbstractClusterMonitor {
     public void handleMemberActivatedEvent(
             MemberActivatedEvent memberActivatedEvent) {
 
-        String instanceId = memberActivatedEvent.getInstanceId();
         String clusterId = memberActivatedEvent.getClusterId();
+        String clusterInstanceId = memberActivatedEvent.getClusterInstanceId();
+        String memberId = memberActivatedEvent.getMemberId();
         String networkPartitionId = memberActivatedEvent.getNetworkPartitionId();
         String partitionId = memberActivatedEvent.getPartitionId();
-        String memberId = memberActivatedEvent.getMemberId();
-        ClusterInstanceContext networkPartitionCtxt = getClusterInstanceContext(networkPartitionId, instanceId);
+
+        ClusterInstanceContext clusterInstanceContext = getClusterInstanceContext(networkPartitionId, clusterInstanceId);
         ClusterLevelPartitionContext clusterLevelPartitionContext;
-        clusterLevelPartitionContext = networkPartitionCtxt.getPartitionCtxt(partitionId);
+        clusterLevelPartitionContext = clusterInstanceContext.getPartitionCtxt(partitionId);
         clusterLevelPartitionContext.addMemberStatsContext(new MemberStatsContext(memberId));
         if (log.isDebugEnabled()) {
             log.debug(String.format("Member stat context has been added successfully: "
@@ -874,7 +875,7 @@ public class ClusterMonitor extends AbstractClusterMonitor {
         }
         clusterLevelPartitionContext.movePendingMemberToActiveMembers(memberId);
         ServiceReferenceHolder.getInstance().getClusterStatusProcessorChain().process(
-                ClusterStatusActiveProcessor.class.getName(), clusterId, instanceId);
+                ClusterStatusActiveProcessor.class.getName(), clusterId, clusterInstanceId);
     }
 
     @Override
@@ -1117,12 +1118,11 @@ public class ClusterMonitor extends AbstractClusterMonitor {
         return ((ClusterContext) this.clusterContext).getNetworkPartitionCtxts().values();
     }
 
-    public void createClusterInstance(List<String> parentInstanceIds, Cluster cluster)
+    public void createClusterInstances(List<String> parentInstanceIds, Cluster cluster)
             throws PolicyValidationException, PartitionValidationException {
         for (String parentInstanceId : parentInstanceIds) {
             createInstance(parentInstanceId, cluster);
         }
-
     }
 
     public boolean createInstanceOnDemand(String instanceId) {

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
index 8d40397..f4b164a 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/component/ParentComponentMonitor.java
@@ -684,11 +684,11 @@ public abstract class ParentComponentMonitor extends Monitor implements Runnable
 
 
     protected synchronized void startMonitor(ParentComponentMonitor parent,
-                                             ApplicationChildContext context, List<String> instanceId) {
+                                             ApplicationChildContext context, List<String> instanceIds) {
 
         if (!this.aliasToActiveMonitorsMap.containsKey(context.getId())) {
             pendingMonitorsList.add(context.getId());
-            executorService.submit(new MonitorAdder(parent, context, this.appId, instanceId));
+            executorService.submit(new MonitorAdder(parent, context, this.appId, instanceIds));
             if (log.isDebugEnabled()) {
                 log.debug(String.format("Monitor Adder has been added: [cluster] %s ", context.getId()));
             }
@@ -775,14 +775,14 @@ public abstract class ParentComponentMonitor extends Monitor implements Runnable
         private ApplicationChildContext context;
         private ParentComponentMonitor parent;
         private String appId;
-        private List<String> instanceId;
+        private List<String> instanceIds;
 
         public MonitorAdder(ParentComponentMonitor parent, ApplicationChildContext context,
-                            String appId, List<String> instanceId) {
+                            String appId, List<String> instanceIds) {
             this.parent = parent;
             this.context = context;
             this.appId = appId;
-            this.instanceId = instanceId;
+            this.instanceIds = instanceIds;
         }
 
         public void run() {
@@ -801,7 +801,7 @@ public abstract class ParentComponentMonitor extends Monitor implements Runnable
                             + context.getId());
                 }
                 try {
-                    monitor = MonitorFactory.getMonitor(parent, context, appId, instanceId);
+                    monitor = MonitorFactory.getMonitor(parent, context, appId, instanceIds);
                 } catch (DependencyBuilderException e) {
                     String msg = "Monitor creation failed for: " + context.getId();
                     log.warn(msg, e);

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
index d4328ab..9ef332c 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/rule/RuleTasksDelegator.java
@@ -35,7 +35,6 @@ import org.apache.stratos.autoscaler.context.member.MemberStatsContext;
 import org.apache.stratos.autoscaler.context.partition.ClusterLevelPartitionContext;
 import org.apache.stratos.autoscaler.context.partition.network.ClusterLevelNetworkPartitionContext;
 import org.apache.stratos.autoscaler.event.publisher.InstanceNotificationPublisher;
-import org.apache.stratos.autoscaler.exception.cartridge.TerminationException;
 import org.apache.stratos.autoscaler.monitor.cluster.AbstractClusterMonitor;
 import org.apache.stratos.autoscaler.monitor.cluster.ClusterMonitor;
 import org.apache.stratos.cloud.controller.stub.domain.MemberContext;
@@ -137,7 +136,6 @@ public class RuleTasksDelegator {
         //FIXME to not parse for algo when partition is chosen by the parent
 
         if(partitionAlgorithm == null) {
-
             //Send one after another as default
             partitionAlgorithm = Constants.ONE_AFTER_ANOTHER_ALGORITHM_ID;
         }
@@ -145,10 +143,8 @@ public class RuleTasksDelegator {
             log.debug(String.format("Retrieving partition algorithm [Partition algorithm]: ", partitionAlgorithm));
         }
         if (Constants.ROUND_ROBIN_ALGORITHM_ID.equals(partitionAlgorithm)) {
-
             autoscaleAlgorithm = new RoundRobin();
         } else if (Constants.ONE_AFTER_ANOTHER_ALGORITHM_ID.equals(partitionAlgorithm)) {
-
             autoscaleAlgorithm = new OneAfterAnother();
         } else {
             if (log.isErrorEnabled()) {
@@ -159,9 +155,7 @@ public class RuleTasksDelegator {
     }
 
     public void delegateInstanceCleanup(String memberId) {
-
         try {
-
             // send the instance notification event.
             InstanceNotificationPublisher.getInstance().sendInstanceCleanupEventForMember(memberId);
             log.info("Instance clean up event sent for [member] " + memberId);
@@ -171,131 +165,51 @@ public class RuleTasksDelegator {
         }
     }
 
-    public void delegateStartContainers(ClusterLevelPartitionContext clusterMonitorPartitionContext, String clusterId, String instanceId, boolean isPrimary) {
+    /**
+     * Invoked from drools to start an instance.
+     * @param clusterMonitorPartitionContext Cluster monitor partition context
+     * @param clusterId Cluster id
+     * @param clusterInstanceId Instance id
+     * @param isPrimary Is a primary member
+     */
+    public void delegateSpawn(ClusterLevelPartitionContext clusterMonitorPartitionContext, String clusterId,
+                              String clusterInstanceId, boolean isPrimary) {
 
         try {
-
             String nwPartitionId = clusterMonitorPartitionContext.getNetworkPartitionId();
-//            NetworkPartitionLbHolder lbHolder =
-//                    PartitionManager.getInstance()
-//                            .getNetworkPartitionLbHolder(nwPartitionId);
-//            String lbClusterId = getLbClusterId(lbRefType, clusterMonitorPartitionContext, lbHolder);
-            //Calculate accumulation of minimum counts of all the partition of current network partition
+
+            // Calculate accumulation of minimum counts of all the partition of current network partition
             int minimumCountOfNetworkPartition = 0;
-            ClusterMonitor vmClusterMonitor = (ClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId);
-            ClusterContext clusterContext = (ClusterContext) vmClusterMonitor.getClusterContext();
-            ClusterLevelNetworkPartitionContext  clusterLevelNetworkPartitionContext = clusterContext.getNetworkPartitionCtxt(nwPartitionId);
+            ClusterMonitor clusterMonitor = (ClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId);
+            ClusterContext clusterContext = (ClusterContext) clusterMonitor.getClusterContext();
+            ClusterLevelNetworkPartitionContext clusterLevelNetworkPartitionContext = clusterContext.getNetworkPartitionCtxt(nwPartitionId);
             ClusterInstanceContext clusterInstanceContext =
                     (ClusterInstanceContext) clusterLevelNetworkPartitionContext.
-                                getInstanceContext(instanceId);
+                            getInstanceContext(clusterInstanceId);
             minimumCountOfNetworkPartition = clusterInstanceContext.getMinInstanceCount();
-            
-            
-            MemberContext[] memberContexts =
+
+            MemberContext memberContext =
                     CloudControllerClient.getInstance()
-                            .startContainers(clusterMonitorPartitionContext.getPartition(),
+                            .startInstance(clusterMonitorPartitionContext.getPartition(),
                                     clusterId,
-                                    instanceId,
-                                    clusterMonitorPartitionContext.getNetworkPartitionId(),
+                                    clusterInstanceId, clusterMonitorPartitionContext.getNetworkPartitionId(),
                                     isPrimary,
                                     minimumCountOfNetworkPartition);
-            if (null != memberContexts) {
-                for (MemberContext memberContext : memberContexts) {
-                    if (null != memberContext) {
-                        clusterMonitorPartitionContext.addPendingMember(memberContext);
-                        if (log.isDebugEnabled()) {
-                            log.debug(String.format("Pending member added, [member] %s [partition] %s", memberContext.getMemberId(),
-                                    memberContext.getPartition().getId()));
-                        }
-                    } else {
-                        if (log.isDebugEnabled()) {
-                            log.debug("Returned member context is null, did not add any pending members");
-                        }
-                    }
-                }
-            } else {
+            if (memberContext != null) {
+                clusterMonitorPartitionContext.addPendingMember(memberContext);
                 if (log.isDebugEnabled()) {
-                    log.debug("Returned member context is null, did not add to pending members");
+                    log.debug(String.format("Pending member added, [member] %s [partition] %s", memberContext.getMemberId(),
+                            memberContext.getPartition().getId()));
                 }
-            }
 
-        } catch (Throwable e) {
-            String message = "Cannot spawn an instance";
-            log.error(message, e);
-            throw new RuntimeException(message, e);
-        }
-    }
-    
-    public void delegateSpawn(ClusterLevelPartitionContext clusterMonitorPartitionContext, String clusterId, String instanceId, boolean isPrimary) {
-
-        try {
-
-            String nwPartitionId = clusterMonitorPartitionContext.getNetworkPartitionId();
-//            NetworkPartitionLbHolder lbHolder =
-//                    PartitionManager.getInstance()
-//                            .getNetworkPartitionLbHolder(nwPartitionId);
-//            String lbClusterId = getLbClusterId(lbRefType, clusterMonitorPartitionContext, lbHolder);
-            //Calculate accumulation of minimum counts of all the partition of current network partition
-            int minimumCountOfNetworkPartition = 0;
-            ClusterMonitor vmClusterMonitor = (ClusterMonitor) AutoscalerContext.getInstance().getClusterMonitor(clusterId);
-            ClusterContext clusterContext = (ClusterContext) vmClusterMonitor.getClusterContext();
-            ClusterLevelNetworkPartitionContext  clusterLevelNetworkPartitionContext = clusterContext.getNetworkPartitionCtxt(nwPartitionId);
-            ClusterInstanceContext clusterInstanceContext =
-                    (ClusterInstanceContext) clusterLevelNetworkPartitionContext.
-                            getInstanceContext(instanceId);
-            minimumCountOfNetworkPartition = clusterInstanceContext.getMinInstanceCount();
-            
-            if (vmClusterMonitor.getCluster().isKubernetesCluster()) {
-                MemberContext[] memberContexts =
-                        CloudControllerClient.getInstance()
-                                .startContainers(clusterMonitorPartitionContext.getPartition(),
-                                        clusterId,
-                                        instanceId,
-                                        clusterMonitorPartitionContext.getNetworkPartitionId(),
-                                        isPrimary,
-                                        minimumCountOfNetworkPartition);
-                if (null != memberContexts) {
-                    for (MemberContext memberContext : memberContexts) {
-                        if (null != memberContext) {
-                            clusterMonitorPartitionContext.addPendingMember(memberContext);
-                            if (log.isDebugEnabled()) {
-                                log.debug(String.format("Pending member added, [member] %s [partition] %s", memberContext.getMemberId(),
-                                        memberContext.getPartition().getId()));
-                            }
-                        } else {
-                            if (log.isDebugEnabled()) {
-                                log.debug("Returned member context is null, did not add any pending members");
-                            }
-                        }
-                    }
-                } else {
-                    if (log.isDebugEnabled()) {
-                        log.debug("Returned member context is null, did not add to pending members");
-                    }
-                }
             } else {
-                
-                MemberContext memberContext =
-                        CloudControllerClient.getInstance()
-                                .spawnAnInstance(clusterMonitorPartitionContext.getPartition(),
-                                        clusterId,
-                                        clusterMonitorPartitionContext.getNetworkPartitionId(),
-                                        instanceId,
-                                        isPrimary,
-                                        minimumCountOfNetworkPartition);
-                if (memberContext != null) {
-                    clusterMonitorPartitionContext.addPendingMember(memberContext);
-                    if (log.isDebugEnabled()) {
-                        log.debug(String.format("Pending member added, [member] %s [partition] %s", memberContext.getMemberId(),
-                                memberContext.getPartition().getId()));
-                    }
-
-                } else if (log.isDebugEnabled()) {
-                    log.debug("Returned member context is null, did not add to pending members");
+                if (log.isErrorEnabled()) {
+                    log.error("Member context returned from cloud controller is null");
                 }
             }
         } catch (Throwable e) {
-            String message = "Cannot spawn an instance";
+            String message = String.format("Could not start instance: [cluster-id] %s [instance-id] %s",
+                    clusterId, clusterInstanceId);
             log.error(message, e);
             throw new RuntimeException(message, e);
         }
@@ -384,15 +298,6 @@ public class RuleTasksDelegator {
         }
     }
 
-    public void delegateTerminateContainer(String memberId) {
-        try {
-            CloudControllerClient ccClient = CloudControllerClient.getInstance();
-            ccClient.terminateContainer(memberId);
-        } catch (TerminationException e) {
-            log.error("Cannot delete container ", e);
-        }
-    }
-
     public int getPredictedReplicasForStat(int minReplicas, float statUpperLimit, float statPredictedValue) {
         if (statUpperLimit == 0) {
             return 0;

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusProcessorChain.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusProcessorChain.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusProcessorChain.java
index 44ddbde..16dc0aa 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusProcessorChain.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/status/processor/cluster/ClusterStatusProcessorChain.java
@@ -47,8 +47,5 @@ public class ClusterStatusProcessorChain extends StatusProcessorChain {
             throw new RuntimeException("Message processor chain is not initialized");
         }
         return root.process(type, clusterId, instanceId);
-
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
index febbcd3..1326509 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/config/CartridgeAgentConfiguration.java
@@ -71,7 +71,9 @@ public class CartridgeAgentConfiguration {
     private String superTenantRepositoryPath;
     private String tenantRepositoryPath;
     private String kubernetesClusterId;
-        
+    private String instanceId;
+    private String clusterInstanceId;
+
 
     private CartridgeAgentConfiguration() {
         parameters = loadParametersFile();
@@ -582,6 +584,22 @@ public class CartridgeAgentConfiguration {
 	public String getKubernetesClusterId() {
 		return kubernetesClusterId;
 	}
-    
-    
+
+
+    public String getInstanceId() {
+        return instanceId;
+    }
+
+    public void setInstanceId(String instanceId) {
+        this.instanceId = instanceId;
+    }
+
+
+    public String getClusterInstanceId() {
+        return clusterInstanceId;
+    }
+
+    public void setClusterInstanceId(String clusterInstanceId) {
+        this.clusterInstanceId = clusterInstanceId;
+    }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
index b080c20..5b01a4f 100644
--- a/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
+++ b/components/org.apache.stratos.cartridge.agent/src/main/java/org/apache/stratos/cartridge/agent/event/publisher/CartridgeAgentEventPublisher.java
@@ -51,9 +51,11 @@ public class CartridgeAgentEventPublisher {
 			InstanceStartedEvent event = new InstanceStartedEvent(
 					CartridgeAgentConfiguration.getInstance().getServiceName(),
 					CartridgeAgentConfiguration.getInstance().getClusterId(),
+					CartridgeAgentConfiguration.getInstance().getMemberId(),
+					CartridgeAgentConfiguration.getInstance().getInstanceId(),
+					CartridgeAgentConfiguration.getInstance().getClusterInstanceId(),
 					CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(),
-					CartridgeAgentConfiguration.getInstance().getPartitionId(),
-					CartridgeAgentConfiguration.getInstance().getMemberId(), null);
+					CartridgeAgentConfiguration.getInstance().getPartitionId());
 			String topic = Util.getMessageTopicName(event);
 			EventPublisher eventPublisher = EventPublisherPool
 					.getPublisher(topic);
@@ -78,9 +80,11 @@ public class CartridgeAgentEventPublisher {
 			InstanceActivatedEvent event = new InstanceActivatedEvent(
 					CartridgeAgentConfiguration.getInstance().getServiceName(),
 					CartridgeAgentConfiguration.getInstance().getClusterId(),
+					CartridgeAgentConfiguration.getInstance().getMemberId(),
+					CartridgeAgentConfiguration.getInstance().getInstanceId(),
+					CartridgeAgentConfiguration.getInstance().getClusterInstanceId(),
 					CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(),
-					CartridgeAgentConfiguration.getInstance().getPartitionId(),
-					CartridgeAgentConfiguration.getInstance().getMemberId(), null);
+					CartridgeAgentConfiguration.getInstance().getPartitionId());
 
 			// Event publisher connection will
 			String topic = Util.getMessageTopicName(event);
@@ -115,9 +119,11 @@ public class CartridgeAgentEventPublisher {
 			InstanceReadyToShutdownEvent event = new InstanceReadyToShutdownEvent(
 					CartridgeAgentConfiguration.getInstance().getServiceName(),
 					CartridgeAgentConfiguration.getInstance().getClusterId(),
+					CartridgeAgentConfiguration.getInstance().getMemberId(),
+					CartridgeAgentConfiguration.getInstance().getInstanceId(),
+					CartridgeAgentConfiguration.getInstance().getClusterInstanceId(),
 					CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(),
-					CartridgeAgentConfiguration.getInstance().getPartitionId(),
-					CartridgeAgentConfiguration.getInstance().getMemberId(), null);
+					CartridgeAgentConfiguration.getInstance().getPartitionId());
 			String topic = Util.getMessageTopicName(event);
 			EventPublisher eventPublisher = EventPublisherPool
 					.getPublisher(topic);
@@ -141,9 +147,11 @@ public class CartridgeAgentEventPublisher {
 			InstanceMaintenanceModeEvent event = new InstanceMaintenanceModeEvent(
 					CartridgeAgentConfiguration.getInstance().getServiceName(),
 					CartridgeAgentConfiguration.getInstance().getClusterId(),
+					CartridgeAgentConfiguration.getInstance().getMemberId(),
+					CartridgeAgentConfiguration.getInstance().getInstanceId(),
+					CartridgeAgentConfiguration.getInstance().getClusterInstanceId(),
 					CartridgeAgentConfiguration.getInstance().getNetworkPartitionId(),
-					CartridgeAgentConfiguration.getInstance().getPartitionId(),
-					CartridgeAgentConfiguration.getInstance().getMemberId(), null);
+					CartridgeAgentConfiguration.getInstance().getPartitionId());
 			String topic = Util.getMessageTopicName(event);
 			EventPublisher eventPublisher = EventPublisherPool
 					.getPublisher(topic);

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
index 0dfb371..5c19218 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/context/CloudControllerContext.java
@@ -561,13 +561,13 @@ public class CloudControllerContext implements Serializable {
 
     public KubernetesGroup getKubernetesGroup(String groupId) throws NonExistingKubernetesGroupException {
         if (StringUtils.isEmpty(groupId)) {
-            throw new NonExistingKubernetesGroupException("Cannot find for empty group id");
+            throw new NonExistingKubernetesGroupException("Kubernetes group id is empty");
         }
         KubernetesGroup kubernetesGroup = kubernetesGroupsMap.get(groupId);
         if (kubernetesGroup != null) {
             return kubernetesGroup;
         }
-        throw new NonExistingKubernetesGroupException("Kubernetes group not found for id: " + groupId);
+        throw new NonExistingKubernetesGroupException("Kubernetes group not found: [group-id]: " + groupId);
     }
 
     public KubernetesGroup getKubernetesGroupContainingHost(String hostId) throws NonExistingKubernetesGroupException {

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
index 4303fc0..c3d5d03 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/Cartridge.java
@@ -65,9 +65,7 @@ public class Cartridge implements Serializable{
     private List<AppType> appTypeMappings;
     
     private String serviceGroup;
-    
-    private String deployerType;
-    
+
     /**
      * Property map of this Cartridge.
      */
@@ -386,15 +384,6 @@ public class Cartridge implements Serializable{
 		this.container = container;
 	}
 
-	public String getDeployerType() {
-		return deployerType;
-	}
-
-	public void setDeployerType(String deployerType) {
-		this.deployerType = deployerType;
-	}
-
-
     public String[] getExportingProperties() {
         return exportingProperties;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/InstanceContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/InstanceContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/InstanceContext.java
new file mode 100644
index 0000000..8664d5e
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/InstanceContext.java
@@ -0,0 +1,100 @@
+/*
+ * 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.cloud.controller.domain;
+
+import org.apache.stratos.common.Properties;
+
+/**
+ * Instance context defines information required for starting an IaaS instance.
+ */
+public class InstanceContext {
+    private String clusterId;
+    private String clusterInstanceId;
+    private long initTime;
+    private long obsoleteExpiryTime;
+    private String networkPartitionId;
+    private Partition partition;
+    private String cartridgeType;
+    private Properties properties;
+
+    public String getClusterId() {
+        return clusterId;
+    }
+
+    public void setClusterId(String clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public String getNetworkPartitionId() {
+        return networkPartitionId;
+    }
+
+    public void setNetworkPartitionId(String networkPartitionId) {
+        this.networkPartitionId = networkPartitionId;
+    }
+
+    public Partition getPartition() {
+        return partition;
+    }
+
+    public void setPartition(Partition partition) {
+        this.partition = partition;
+    }
+
+    public String getCartridgeType() {
+        return cartridgeType;
+    }
+
+    public void setCartridgeType(String cartridgeType) {
+        this.cartridgeType = cartridgeType;
+    }
+
+    public Properties getProperties() {
+        return properties;
+    }
+
+    public void setProperties(Properties properties) {
+        this.properties = properties;
+    }
+
+    public String getClusterInstanceId() {
+        return clusterInstanceId;
+    }
+
+    public void setClusterInstanceId(String clusterInstanceId) {
+        this.clusterInstanceId = clusterInstanceId;
+    }
+
+    public long getInitTime() {
+        return initTime;
+    }
+
+    public void setInitTime(long initTime) {
+        this.initTime = initTime;
+    }
+
+    public long getObsoleteExpiryTime() {
+        return obsoleteExpiryTime;
+    }
+
+    public void setObsoleteExpiryTime(long obsoleteExpiryTime) {
+        this.obsoleteExpiryTime = obsoleteExpiryTime;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/InstanceMetadata.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/InstanceMetadata.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/InstanceMetadata.java
new file mode 100644
index 0000000..d67c019
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/InstanceMetadata.java
@@ -0,0 +1,107 @@
+/*
+ * 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.cloud.controller.domain;
+
+/**
+ * Instance metadata.
+ */
+public class InstanceMetadata {
+    private String hostname;
+    private String hypervisor;
+    private int ram;
+    private String imageId;
+    private int loginPort;
+    private String operatingSystemName;
+    private String operatingSystemVersion;
+    private String operatingSystemArchitecture;
+    private boolean operatingSystem64bit;
+
+    public String getHostname() {
+        return hostname;
+    }
+
+    public void setHostname(String hostname) {
+        this.hostname = hostname;
+    }
+
+    public String getHypervisor() {
+        return hypervisor;
+    }
+
+    public void setHypervisor(String hypervisor) {
+        this.hypervisor = hypervisor;
+    }
+
+    public int getRam() {
+        return ram;
+    }
+
+    public void setRam(int ram) {
+        this.ram = ram;
+    }
+
+    public String getImageId() {
+        return imageId;
+    }
+
+    public void setImageId(String imageId) {
+        this.imageId = imageId;
+    }
+
+    public int getLoginPort() {
+        return loginPort;
+    }
+
+    public void setLoginPort(int loginPort) {
+        this.loginPort = loginPort;
+    }
+
+    public String getOperatingSystemName() {
+        return operatingSystemName;
+    }
+
+    public void setOperatingSystemName(String operatingSystemName) {
+        this.operatingSystemName = operatingSystemName;
+    }
+
+    public String getOperatingSystemVersion() {
+        return operatingSystemVersion;
+    }
+
+    public void setOperatingSystemVersion(String operatingSystemVersion) {
+        this.operatingSystemVersion = operatingSystemVersion;
+    }
+
+    public String getOperatingSystemArchitecture() {
+        return operatingSystemArchitecture;
+    }
+
+    public void setOperatingSystemArchitecture(String operatingSystemArchitecture) {
+        this.operatingSystemArchitecture = operatingSystemArchitecture;
+    }
+
+    public boolean isOperatingSystem64bit() {
+        return operatingSystem64bit;
+    }
+
+    public void setOperatingSystem64bit(boolean operatingSystem64bit) {
+        this.operatingSystem64bit = operatingSystem64bit;
+    }
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/MemberContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/MemberContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/MemberContext.java
index a5ab367..0201739 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/MemberContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/MemberContext.java
@@ -30,37 +30,41 @@ import java.io.Serializable;
 public class MemberContext implements Serializable {
 
     private static final long serialVersionUID = -388327475844701869L;
-    // id of the member
+
+    // Cartridge type this member belongs to
+    private String cartridgeType;
+    // Cluster id of this member
+    private String clusterId;
+    // Member id generated by cloud controller
     private String memberId;
-    // corresponding jclouds node id
-    private String nodeId;
-    // instance id - derived from nodeId
+    // Instance id generated by the IaaS
     private String instanceId;
-    // cluster id of this member
-    private String clusterId;
-    // partition this member is in.
+    // Instance id of the application hierarchy member belongs to
+    private String clusterInstanceId;
+
+    // Partition this member is in
     private Partition partition;
-    // cartridge type this member belongs to.
-    private String cartridgeType;
-    // private ip
+    // Private ip address
     private String privateIpAddress;
-    // public ip
+    // Public ip address
     private String publicIpAddress;
-    // manually allocated ip
+    // Manually allocated ip
     private String allocatedIpAddress;
-    // member initiated time
+    // Member initiated time
     private long initTime;
-    // lb cluster id of this member
+    // LB cluster id of this member
     private String lbClusterId;
-    //network partition id
+    // Network partition id
     private String networkPartitionId;
-    //member expiry period on the topology
+    // Member expiry period on the topology
     private long obsoleteExpiryTime;
-    //member obsolete init time
+    // Member obsolete init time
     private long obsoleteInitTime;
-
+    // Instance metadata generated by the IaaS
+    private InstanceMetadata instanceMetadata;
+    // Properties
     private Properties properties;
-    
+
     public MemberContext(String id, String clusterId, Partition partition) {
         this.memberId = id;
         this.clusterId = clusterId;
@@ -80,27 +84,27 @@ public class MemberContext implements Serializable {
     public String getMemberId() {
         return memberId;
     }
+
     public void setMemberId(String memberId) {
         this.memberId = memberId;
     }
-    public String getNodeId() {
-        return nodeId;
-    }
-    public void setNodeId(String nodeId) {
-        this.nodeId = nodeId;
-    }
+
     public String getClusterId() {
         return clusterId;
     }
+
     public void setClusterId(String clusterId) {
         this.clusterId = clusterId;
     }
+
     public String getCartridgeType() {
         return cartridgeType;
     }
+
     public void setCartridgeType(String cartridgeType) {
         this.cartridgeType = cartridgeType;
     }
+
     public Partition getPartition() {
         return partition;
     }
@@ -149,7 +153,6 @@ public class MemberContext implements Serializable {
         this.lbClusterId = lbClusterId;
     }
 
-
     public String getNetworkPartitionId() {
         return networkPartitionId;
     }
@@ -166,7 +169,7 @@ public class MemberContext implements Serializable {
 				+ ((clusterId == null) ? 0 : clusterId.hashCode());
 		result = prime * result
 				+ ((memberId == null) ? 0 : memberId.hashCode());
-		result = prime * result + ((nodeId == null) ? 0 : nodeId.hashCode());
+		result = prime * result + ((instanceId == null) ? 0 : instanceId.hashCode());
 		return result;
 	}
 
@@ -189,10 +192,10 @@ public class MemberContext implements Serializable {
 				return false;
 		} else if (!memberId.equals(other.memberId))
 			return false;
-		if (nodeId == null) {
-			if (other.nodeId != null)
+		if (instanceId == null) {
+			if (other.instanceId != null)
 				return false;
-		} else if (!nodeId.equals(other.nodeId))
+		} else if (!instanceId.equals(other.instanceId))
 			return false;
 		return true;
 	}
@@ -229,14 +232,30 @@ public class MemberContext implements Serializable {
         this.properties = properties;
     }
 
+    public InstanceMetadata getInstanceMetadata() {
+        return instanceMetadata;
+    }
+
+    public void setInstanceMetadata(InstanceMetadata instanceMetadata) {
+        this.instanceMetadata = instanceMetadata;
+    }
+
+    public void setClusterInstanceId(String clusterInstanceId) {
+        this.clusterInstanceId = clusterInstanceId;
+    }
+
+    public String getClusterInstanceId() {
+        return clusterInstanceId;
+    }
+
     @Override
     public String toString() {
-        return "MemberContext [memberId=" + memberId + ", nodeId=" + nodeId + ", instanceId="
-                + instanceId + ", clusterId=" + clusterId + ", partition=" + partition
+        return "MemberContext [memberId=" + memberId + ", instanceId=" + instanceId
+                + ", clusterId=" + clusterId + ", partition=" + partition
                 + ", cartridgeType=" + cartridgeType + ", privateIpAddress=" + privateIpAddress
                 + ", publicIpAddress=" + publicIpAddress + ", allocatedIpAddress="
                 + allocatedIpAddress + ", initTime=" + initTime + ", lbClusterId=" + lbClusterId
-                + ", networkPartitionId=" + networkPartitionId + ", properties=" + properties + "]";
+                + ", networkPartitionId=" + networkPartitionId + ", instanceMetadata=" + instanceMetadata +
+                ", properties=" + properties + "]";
     }
-    
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/CartridgeNotFoundException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/CartridgeNotFoundException.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/CartridgeNotFoundException.java
new file mode 100644
index 0000000..899b21f
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/CartridgeNotFoundException.java
@@ -0,0 +1,44 @@
+/*
+ * 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.cloud.controller.exception;
+
+public class CartridgeNotFoundException extends Exception {
+    
+    private static final long serialVersionUID = -6326227079367867222L;
+	private String message;
+
+    public CartridgeNotFoundException(String msg) {
+        super(msg);
+        this.setMessage(msg);
+    }
+    
+    public CartridgeNotFoundException(String msg, Exception ex) {
+        super(msg, ex);
+        this.setMessage(msg);
+    }
+    
+    private void setMessage(String msg) {
+    	this.message = msg;
+	}
+
+	public String getMessage() {
+        return this.message;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/UnregisteredCartridgeException.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/UnregisteredCartridgeException.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/UnregisteredCartridgeException.java
deleted file mode 100644
index af7da00..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/exception/UnregisteredCartridgeException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.cloud.controller.exception;
-
-public class UnregisteredCartridgeException extends Exception {
-    
-    private static final long serialVersionUID = -6326227079367867222L;
-	private String message;
-
-    public UnregisteredCartridgeException(String msg) {
-        super(msg);
-        this.setMessage(msg);
-    }
-    
-    public UnregisteredCartridgeException(String msg, Exception ex) {
-        super(msg, ex);
-        this.setMessage(msg);
-    }
-    
-    private void setMessage(String msg) {
-    	this.message = msg;
-	}
-
-	public String getMessage() {
-        return this.message;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
index 4c80d4f..2a9137a 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesContainer.java
@@ -24,10 +24,7 @@ import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.context.CloudControllerContext;
-import org.apache.stratos.cloud.controller.domain.Cartridge;
-import org.apache.stratos.cloud.controller.domain.ClusterContext;
-import org.apache.stratos.cloud.controller.domain.ContainerClusterContext;
-import org.apache.stratos.cloud.controller.domain.PortMapping;
+import org.apache.stratos.cloud.controller.domain.*;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.common.Properties;
 import org.apache.stratos.common.Property;
@@ -39,15 +36,15 @@ import org.apache.stratos.kubernetes.client.model.Port;
 import com.google.common.base.Function;
 
 /**
- * Is responsible for converting a {@link ContainerClusterContext} object to a Kubernetes
+ * Is responsible for converting a MemberContext object to a Kubernetes
  * {@link Container} Object.
  */
-public class ContainerClusterContextToKubernetesContainer implements Function<ContainerClusterContext, Container> {
+public class ContainerClusterContextToKubernetesContainer implements Function<MemberContext, Container> {
 
     private static final Log log = LogFactory.getLog(ContainerClusterContextToKubernetesContainer.class);
 
     @Override
-    public Container apply(ContainerClusterContext memberContext) {
+    public Container apply(MemberContext memberContext) {
         String clusterId = memberContext.getClusterId();
         ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
 
@@ -93,7 +90,7 @@ public class ContainerClusterContextToKubernetesContainer implements Function<Co
         return portList.toArray(ports);
     }
 
-    private EnvironmentVariable[] getEnvironmentVars(ContainerClusterContext memberCtxt, ClusterContext ctxt) {
+    private EnvironmentVariable[] getEnvironmentVars(MemberContext memberCtxt, ClusterContext ctxt) {
 
         String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(),
                 StratosConstants.KUBERNETES_CLUSTER_ID);

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesService.java
index 50f61bd..d6f0a0f 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesService.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToKubernetesService.java
@@ -22,6 +22,7 @@ import org.apache.stratos.cloud.controller.context.CloudControllerContext;
 import org.apache.stratos.cloud.controller.domain.ClusterContext;
 import org.apache.stratos.cloud.controller.domain.ContainerClusterContext;
 import org.apache.stratos.cloud.controller.domain.KubernetesClusterContext;
+import org.apache.stratos.cloud.controller.domain.MemberContext;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.common.constants.StratosConstants;
 import org.apache.stratos.kubernetes.client.model.Selector;
@@ -33,10 +34,10 @@ import com.google.common.base.Function;
  * Is responsible for converting a {@link ContainerClusterContext} object to a Kubernetes
  * {@link Service} Object.
  */
-public class ContainerClusterContextToKubernetesService implements Function<ContainerClusterContext, Service> {
+public class ContainerClusterContextToKubernetesService implements Function<MemberContext, Service> {
 
     @Override
-    public Service apply(ContainerClusterContext memberContext) {
+    public Service apply(MemberContext memberContext) {
 
         String clusterId = memberContext.getClusterId();
         ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
index e01c474..af63a3f 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/functions/ContainerClusterContextToReplicationController.java
@@ -21,6 +21,7 @@ package org.apache.stratos.cloud.controller.functions;
 import org.apache.stratos.cloud.controller.context.CloudControllerContext;
 import org.apache.stratos.cloud.controller.domain.ClusterContext;
 import org.apache.stratos.cloud.controller.domain.ContainerClusterContext;
+import org.apache.stratos.cloud.controller.domain.MemberContext;
 import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
 import org.apache.stratos.common.constants.StratosConstants;
 import org.apache.stratos.kubernetes.client.model.Container;
@@ -38,18 +39,18 @@ import com.google.common.base.Function;
  * {@link ReplicationController} Object.
  */
 public class ContainerClusterContextToReplicationController implements
-        Function<ContainerClusterContext, ReplicationController> {
+        Function<MemberContext, ReplicationController> {
 
     @Override
-    public ReplicationController apply(ContainerClusterContext memberContext) {
+    public ReplicationController apply(MemberContext memberContext) {
 
         String clusterId = memberContext.getClusterId();
         ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
 
-        ReplicationController contr = new ReplicationController();
-        contr.setId(clusterContext.getClusterId());
-        contr.setKind("ReplicationController");
-        contr.setApiVersion("v1beta1");
+        ReplicationController replicationController = new ReplicationController();
+        replicationController.setId(clusterContext.getClusterId());
+        replicationController.setKind("ReplicationController");
+        replicationController.setApiVersion("v1beta1");
         State desiredState = new State();
         String minReplicas = CloudControllerUtil.getProperty(clusterContext.getProperties(),
                 StratosConstants.KUBERNETES_MIN_REPLICAS);
@@ -76,13 +77,13 @@ public class ContainerClusterContextToReplicationController implements
         podTemplate.setLabels(l1);
 
         desiredState.setPodTemplate(podTemplate);
-        contr.setDesiredState(desiredState);
+        replicationController.setDesiredState(desiredState);
 
         Label l2 = new Label();
         l2.setName(clusterContext.getClusterId());
-        contr.setLabels(l2);
+        replicationController.setLabels(l2);
 
-        return contr;
+        return replicationController;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/b575c7d6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/Iaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/Iaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/Iaas.java
index 341d6f1..4270f19 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/Iaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/Iaas.java
@@ -18,13 +18,9 @@
  */
 package org.apache.stratos.cloud.controller.iaases;
 
-import org.apache.stratos.cloud.controller.domain.ClusterContext;
-import org.apache.stratos.cloud.controller.domain.IaasProvider;
-import org.apache.stratos.cloud.controller.domain.MemberContext;
-import org.apache.stratos.cloud.controller.domain.Partition;
+import org.apache.stratos.cloud.controller.domain.*;
 import org.apache.stratos.cloud.controller.exception.*;
 import org.apache.stratos.cloud.controller.iaases.validators.PartitionValidator;
-import org.jclouds.compute.domain.NodeMetadata;
 
 /**
  * All IaaSes that are going to support by Cloud Controller, should extend this abstract class.
@@ -55,11 +51,10 @@ public abstract class Iaas {
     /**
      * Create vm/container instance.
      *
-     * @param clusterContext
      * @param memberContext
-     * @return
+     * @return updated memberContext
      */
-    public abstract NodeMetadata createInstance(ClusterContext clusterContext, MemberContext memberContext);
+    public abstract MemberContext createInstance(MemberContext memberContext) throws CartridgeNotFoundException;
 
     /**
      * This will deallocate/release the given IP address back to pool.
@@ -147,13 +142,18 @@ public abstract class Iaas {
      */
     public abstract String getIaasDevice(String device);
 
-    public abstract void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition,
-                                           String cartridgeType, NodeMetadata node);
+    public abstract void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition);
 
     /**
      * This method provides a way to set payload.
      */
     public abstract void setDynamicPayload(byte[] payload);
 
+    /**
+     * Terminate an instance.
+     * @param memberContext
+     * @throws InvalidCartridgeTypeException
+     * @throws InvalidMemberException
+     */
     public abstract void terminateInstance(MemberContext memberContext) throws InvalidCartridgeTypeException, InvalidMemberException;
 }


Mime
View raw message