stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [6/7] stratos git commit: Introducing KubernetesIaas class, MemberContext.clusterInstanceId, removing Cartridge.deployerType
Date Sat, 20 Dec 2014 21:56:44 GMT
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/JcloudsIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java
index 6c02770..653458a 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/JcloudsIaas.java
@@ -99,12 +99,11 @@ public abstract class JcloudsIaas extends Iaas {
     }
 
     @Override
-    public NodeMetadata createInstance(ClusterContext clusterContext, MemberContext memberContext) {
-        NodeMetadata node = null;
+    public MemberContext createInstance(MemberContext memberContext) {
         // generate the group id from domain name and sub domain name.
         // Should have lower-case ASCII letters, numbers, or dashes.
         // Should have a length between 3-15
-        String clusterId = clusterContext.getClusterId();
+        String clusterId = memberContext.getClusterId();
         String str = clusterId.length() > 10 ? clusterId.substring(0, 10) : clusterId.substring(0, clusterId.length());
         String group = str.replaceAll("[^a-z0-9-]", "");
 
@@ -120,37 +119,60 @@ public abstract class JcloudsIaas extends Iaas {
             }
 
             if (log.isDebugEnabled()) {
-                log.debug("Cloud Controller is delegating request to start an instance for "
-                        + memberContext + " to Jclouds layer.");
+                log.debug("Cloud controller is delegating request to start an instance for "
+                        + memberContext + " to jclouds");
             }
             // create and start a node
-            Set<? extends NodeMetadata> nodes = computeService.createNodesInGroup(group, 1, template);
-            node = nodes.iterator().next();
+            Set<? extends NodeMetadata> nodeMetadataSet = computeService.createNodesInGroup(group, 1, template);
+            NodeMetadata nodeMetadata = nodeMetadataSet.iterator().next();
             if (log.isDebugEnabled()) {
-                log.debug("Cloud Controller received a response for the request to start "
+                log.debug("Cloud controller received a response for the request to start "
                         + memberContext + " from Jclouds layer.");
             }
 
-            if (node == null) {
+            if (nodeMetadata == null) {
                 String msg = "Null response received for instance start-up request to Jclouds.\n"
                         + memberContext.toString();
                 log.error(msg);
                 throw new IllegalStateException(msg);
             }
+            memberContext.setInstanceId(nodeMetadata.getId());
+            memberContext.setInstanceMetadata(createInstanceMetadata(nodeMetadata));
         } catch (Exception e) {
             String msg = "Failed to start an instance. " + memberContext.toString() + " Cause: " + e.getMessage();
             log.error(msg, e);
             throw new IllegalStateException(msg, e);
         }
-        return node;
+        return memberContext;
     }
 
-    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition,
-                                  String cartridgeType, NodeMetadata node) {
+    protected InstanceMetadata createInstanceMetadata(NodeMetadata nodeMetadata) {
+        InstanceMetadata instanceMetadata = new InstanceMetadata();
+        instanceMetadata.setHostname(nodeMetadata.getHostname());
+        instanceMetadata.setImageId(nodeMetadata.getImageId());
+        instanceMetadata.setLoginPort(nodeMetadata.getLoginPort());
+        instanceMetadata.setHypervisor(nodeMetadata.getHardware().getHypervisor());
+        instanceMetadata.setRam(nodeMetadata.getHardware().getRam());
+        instanceMetadata.setOperatingSystemName(nodeMetadata.getOperatingSystem().getName());
+        instanceMetadata.setOperatingSystemVersion(nodeMetadata.getOperatingSystem().getVersion());
+        instanceMetadata.setOperatingSystem64bit(nodeMetadata.getOperatingSystem().is64Bit());
+        return instanceMetadata;
+    }
+
+    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition) {
         try {
             if (log.isDebugEnabled()) {
                 log.debug("IP allocation process started for " + memberContext);
             }
+
+            ComputeService computeService = getIaasProvider().getComputeService();
+            NodeMetadata nodeMetadata = computeService.getNodeMetadata(memberContext.getInstanceId());
+            if(nodeMetadata == null) {
+                String message = "Node metadata not found: [node-id] " + memberContext.getInstanceId();
+                log.error(message);
+                throw new CloudControllerException(message);
+            }
+
             String autoAssignIpProp = getIaasProvider().getProperty(CloudControllerConstants.AUTO_ASSIGN_IP_PROPERTY);
             String preDefinedIp = getIaasProvider().getProperty(CloudControllerConstants.FLOATING_IP_PROPERTY);
             String publicIp = "";
@@ -165,7 +187,7 @@ public abstract class JcloudsIaas extends Iaas {
                         if (log.isDebugEnabled()) {
                             log.debug("CloudControllerServiceImpl:IpAllocator:preDefinedIp: invoking associatePredefinedAddress" + preDefinedIp);
                         }
-                        ip = associatePredefinedAddress(node, preDefinedIp);
+                        ip = associatePredefinedAddress(nodeMetadata, preDefinedIp);
 
                         if (ip == null || "".equals(ip) || !preDefinedIp.equals(ip)) {
                             // throw exception and stop instance creation
@@ -174,7 +196,7 @@ public abstract class JcloudsIaas extends Iaas {
                                     " - terminating node:" + memberContext.toString();
                             log.error(msg);
                             // terminate instance
-                            destroyNode(node.getId(), memberContext);
+                            destroyNode(nodeMetadata.getId(), memberContext);
                             throw new CloudControllerException(msg);
                         }
                     } else {
@@ -182,7 +204,7 @@ public abstract class JcloudsIaas extends Iaas {
                                 " - terminating node:" + memberContext.toString();
                         log.error(msg);
                         // terminate instance
-                        destroyNode(node.getId(), memberContext);
+                        destroyNode(nodeMetadata.getId(), memberContext);
                         throw new CloudControllerException(msg);
                     }
 
@@ -192,7 +214,7 @@ public abstract class JcloudsIaas extends Iaas {
                                 + "selecting available one from pool");
                     }
                     // allocate an IP address - manual IP assigning mode
-                    ip = associateAddress(node);
+                    ip = associateAddress(nodeMetadata);
 
                     if (ip != null) {
                         memberContext.setAllocatedIpAddress(ip);
@@ -213,15 +235,15 @@ public abstract class JcloudsIaas extends Iaas {
                 }
 
                 // build the node with the new ip
-                node = NodeMetadataBuilder.fromNodeMetadata(node)
+                nodeMetadata = NodeMetadataBuilder.fromNodeMetadata(nodeMetadata)
                         .publicAddresses(ImmutableSet.of(ip)).build();
             }
 
 
             // public ip
-            if (node.getPublicAddresses() != null &&
-                    node.getPublicAddresses().iterator().hasNext()) {
-                ip = node.getPublicAddresses().iterator().next();
+            if (nodeMetadata.getPublicAddresses() != null &&
+                    nodeMetadata.getPublicAddresses().iterator().hasNext()) {
+                ip = nodeMetadata.getPublicAddresses().iterator().next();
                 publicIp = ip;
                 memberContext.setPublicIpAddress(ip);
                 if (log.isDebugEnabled()) {
@@ -233,9 +255,9 @@ public abstract class JcloudsIaas extends Iaas {
             }
 
             // private IP
-            if (node.getPrivateAddresses() != null &&
-                    node.getPrivateAddresses().iterator().hasNext()) {
-                ip = node.getPrivateAddresses().iterator().next();
+            if (nodeMetadata.getPrivateAddresses() != null &&
+                    nodeMetadata.getPrivateAddresses().iterator().hasNext()) {
+                ip = nodeMetadata.getPrivateAddresses().iterator().next();
                 memberContext.setPrivateIpAddress(ip);
                 if (log.isDebugEnabled()) {
                     log.debug("Retrieving Private IP Address. " + memberContext.toString());
@@ -264,7 +286,7 @@ public abstract class JcloudsIaas extends Iaas {
     public void terminateInstance(MemberContext memberContext) throws InvalidCartridgeTypeException, InvalidMemberException {
         String memberId = memberContext.getMemberId();
         String cartridgeType = memberContext.getCartridgeType();
-        String nodeId = memberContext.getNodeId();
+        String nodeId = memberContext.getInstanceId();
         Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(cartridgeType);
 
         if(log.isInfoEnabled()) {
@@ -339,4 +361,9 @@ public abstract class JcloudsIaas extends Iaas {
             }
         }
     }
+
+    public NodeMetadata findNodeMetadata(String nodeId) {
+        ComputeService computeService = getIaasProvider().getComputeService();
+        return computeService.getNodeMetadata(nodeId);
+    }
 }

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/KubernetesIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/KubernetesIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/KubernetesIaas.java
new file mode 100644
index 0000000..2b824dc
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/KubernetesIaas.java
@@ -0,0 +1,651 @@
+/*
+ * 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.iaases;
+
+import org.apache.commons.collections.ListUtils;
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.stratos.cloud.controller.concurrent.ScheduledThreadExecutor;
+import org.apache.stratos.cloud.controller.context.CloudControllerContext;
+import org.apache.stratos.cloud.controller.domain.*;
+import org.apache.stratos.cloud.controller.exception.*;
+import org.apache.stratos.cloud.controller.functions.ContainerClusterContextToKubernetesService;
+import org.apache.stratos.cloud.controller.functions.ContainerClusterContextToReplicationController;
+import org.apache.stratos.cloud.controller.functions.PodToMemberContext;
+import org.apache.stratos.cloud.controller.iaases.validators.KubernetesPartitionValidator;
+import org.apache.stratos.cloud.controller.iaases.validators.PartitionValidator;
+import org.apache.stratos.cloud.controller.services.impl.CloudControllerServiceUtil;
+import org.apache.stratos.cloud.controller.util.CloudControllerUtil;
+import org.apache.stratos.cloud.controller.util.PodActivationWatcher;
+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.PortRange;
+import org.apache.stratos.kubernetes.client.KubernetesApiClient;
+import org.apache.stratos.kubernetes.client.exceptions.KubernetesClientException;
+import org.apache.stratos.kubernetes.client.model.Label;
+import org.apache.stratos.kubernetes.client.model.Pod;
+import org.apache.stratos.kubernetes.client.model.ReplicationController;
+import org.apache.stratos.kubernetes.client.model.Service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.locks.Lock;
+
+/**
+ * Kubernetes iaas implementation.
+ */
+public class KubernetesIaas extends Iaas {
+
+    private static final Log log = LogFactory.getLog(KubernetesIaas.class);
+
+    private PartitionValidator partitionValidator;
+
+    public KubernetesIaas(IaasProvider iaasProvider) {
+        super(iaasProvider);
+        partitionValidator = new KubernetesPartitionValidator();
+    }
+
+    @Override
+    public void initialize() {
+
+    }
+
+    @Override
+    public MemberContext createInstance(MemberContext memberContext) throws CartridgeNotFoundException {
+        memberContext = startContainer(memberContext);
+        return memberContext;
+    }
+
+    @Override
+    public void releaseAddress(String ip) {
+
+    }
+
+    @Override
+    public boolean isValidRegion(String region) throws InvalidRegionException {
+        return false;
+    }
+
+    @Override
+    public boolean isValidZone(String region, String zone) throws InvalidZoneException, InvalidRegionException {
+        return false;
+    }
+
+    @Override
+    public boolean isValidHost(String zone, String host) throws InvalidHostException {
+        return false;
+    }
+
+    @Override
+    public PartitionValidator getPartitionValidator() {
+        return partitionValidator;
+    }
+
+    @Override
+    public String createVolume(int sizeGB, String snapshotId) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String attachVolume(String instanceId, String volumeId, String deviceName) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void detachVolume(String instanceId, String volumeId) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void deleteVolume(String volumeId) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public String getIaasDevice(String device) {
+        throw new NotImplementedException();
+    }
+
+    @Override
+    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition) {
+
+    }
+
+    @Override
+    public void setDynamicPayload(byte[] payload) {
+
+    }
+
+    @Override
+    public void terminateInstance(MemberContext memberContext) throws InvalidCartridgeTypeException, InvalidMemberException {
+
+    }
+
+    public MemberContext startContainer(MemberContext memberContext)
+            throws CartridgeNotFoundException {
+        Lock lock = null;
+        try {
+            lock = CloudControllerContext.getInstance().acquireMemberContextWriteLock();
+
+            handleNullObject(memberContext, "Could not start container, member context is null");
+            if (log.isInfoEnabled()) {
+                log.info(String.format("Starting container: [cartridge-type] %s", memberContext.getCartridgeType()));
+            }
+
+            // Validate cluster id
+            String clusterId = memberContext.getClusterId();
+            handleNullObject(clusterId, "Could not start containers, cluster id is null in member context.");
+
+            // Validate cluster context
+            ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
+            handleNullObject(clusterContext, "Could not start containers, cluster context not found: [cluster-id] "
+                    + clusterId);
+
+            // Validate partition
+            Partition partition = memberContext.getPartition();
+            handleNullObject(partition, "Could not start containers, partition not found in member context.");
+
+            // Validate cartridge
+            String cartridgeType = clusterContext.getCartridgeType();
+            Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(cartridgeType);
+            if (cartridge == null) {
+                String msg = "Could not start containers, cartridge not found: [cartridge-type] " + cartridgeType;
+                log.error(msg);
+                throw new CartridgeNotFoundException(msg);
+            }
+
+            try {
+                String kubernetesClusterId = readProperty(StratosConstants.KUBERNETES_CLUSTER_ID,
+                        partition.getProperties(),
+                        partition.toString());
+
+                KubernetesGroup kubernetesGroup =
+                        CloudControllerContext.getInstance().getKubernetesGroup(kubernetesClusterId);
+                handleNullObject(kubernetesGroup, "Could not start container, kubernetes group not found: " +
+                        "[kubernetes-cluster-id] " + kubernetesClusterId);
+
+                String kubernetesMasterIp = kubernetesGroup.getKubernetesMaster().getHostIpAddress();
+                PortRange kubernetesPortRange = kubernetesGroup.getPortRange();
+
+                // optional
+                String kubernetesMasterPort = CloudControllerUtil.getProperty(
+                        kubernetesGroup.getKubernetesMaster().getProperties(), StratosConstants.KUBERNETES_MASTER_PORT,
+                        StratosConstants.KUBERNETES_MASTER_DEFAULT_PORT);
+
+                KubernetesClusterContext kubClusterContext = getKubernetesClusterContext(kubernetesClusterId,
+                        kubernetesMasterIp, kubernetesMasterPort, kubernetesPortRange.getLower(), kubernetesPortRange.getUpper());
+                KubernetesApiClient kubernetesApi = kubClusterContext.getKubApi();
+
+
+                // first let's create a replication controller.
+                ContainerClusterContextToReplicationController controllerFunction = new ContainerClusterContextToReplicationController();
+                ReplicationController controller = controllerFunction.apply(memberContext);
+                if (log.isDebugEnabled()) {
+                    log.debug("Cloud Controller is delegating request to start a replication controller " + controller +
+                            " for " + memberContext + " to Kubernetes layer.");
+                }
+                kubernetesApi.createReplicationController(controller);
+
+                if (log.isDebugEnabled()) {
+                    log.debug("Cloud Controller successfully started the controller "
+                            + controller + " via Kubernetes layer.");
+                }
+
+                // secondly let's create a kubernetes service proxy to load balance these containers
+                ContainerClusterContextToKubernetesService serviceFunction = new ContainerClusterContextToKubernetesService();
+                Service service = serviceFunction.apply(memberContext);
+
+                if(kubernetesApi.getService(service.getId()) == null) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("Delegating request to start a kubernetes service " + service +
+                                " for member " + memberContext.getMemberId());
+                    }
+                    kubernetesApi.createService(service);
+                }
+
+                // set host port and update
+                Property allocatedServiceHostPortProp = new Property();
+                allocatedServiceHostPortProp.setName(StratosConstants.ALLOCATED_SERVICE_HOST_PORT);
+                allocatedServiceHostPortProp.setValue(String.valueOf(service.getPort()));
+                clusterContext.getProperties().addProperty(allocatedServiceHostPortProp);
+                CloudControllerContext.getInstance().addClusterContext(clusterContext);
+
+                if (log.isDebugEnabled()) {
+                    log.debug("Successfully started the kubernetes service: "
+                            + controller);
+                }
+
+                // create a label query
+                Label label = new Label();
+                label.setName(clusterId);
+                // execute the label query
+                Pod[] newlyCreatedPods = new Pod[0];
+                int expectedCount = 1;
+
+                for (int i = 0; i < expectedCount; i++) {
+                    newlyCreatedPods = kubernetesApi.queryPods(new Label[]{label});
+                    if (log.isDebugEnabled()) {
+                        log.debug("Pods Count: " + newlyCreatedPods.length + " for cluster: " + clusterId);
+                    }
+                    if (newlyCreatedPods.length == expectedCount) {
+                        break;
+                    }
+                    Thread.sleep(10000);
+                }
+
+                if (newlyCreatedPods.length == 0) {
+                    if (log.isDebugEnabled()) {
+                        log.debug(String.format("Pods are not created for cluster : %s, hence deleting the service", clusterId));
+                    }
+                    terminateContainers(clusterId);
+                    return null;
+                }
+
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("Pods created : %s for cluster : %s", newlyCreatedPods.length, clusterId));
+                }
+
+                List<MemberContext> memberContexts = new ArrayList<MemberContext>();
+
+                PodToMemberContext podToMemberContextFunc = new PodToMemberContext();
+                // generate Member Contexts
+                for (Pod pod : newlyCreatedPods) {
+                    MemberContext context = podToMemberContextFunc.apply(pod);
+                    context.setCartridgeType(cartridgeType);
+                    context.setClusterId(clusterId);
+
+                    context.setProperties(CloudControllerUtil.addProperty(context.getProperties(),
+                            StratosConstants.ALLOCATED_SERVICE_HOST_PORT,
+                            String.valueOf(service.getPort())));
+
+                    CloudControllerContext.getInstance().addMemberContext(context);
+
+                    // wait till Pod status turns to running and send member spawned.
+                    ScheduledThreadExecutor exec = ScheduledThreadExecutor.getInstance();
+                    if (log.isDebugEnabled()) {
+                        log.debug("Cloud Controller is starting the instance start up thread.");
+                    }
+                    CloudControllerContext.getInstance().addScheduledFutureJob(context.getMemberId(),
+                            exec.schedule(new PodActivationWatcher(pod.getId(), context, kubernetesApi), 5000));
+                    memberContexts.add(context);
+                }
+
+                // persist in registry
+                CloudControllerContext.getInstance().persist();
+
+                log.info("Kubernetes entities are successfully starting up: " + memberContexts);
+
+                return memberContext;
+            } catch (Exception e) {
+                String msg = "Could not start container: " + memberContext.toString() + " Cause: " + e.getMessage();
+                log.error(msg, e);
+                throw new IllegalStateException(msg, e);
+            }
+        } finally {
+            if (lock != null) {
+                CloudControllerContext.getInstance().releaseWriteLock(lock);
+            }
+        }
+    }
+
+    public void unregisterDockerService(String clusterId)
+            throws UnregisteredClusterException {
+        Lock lock = null;
+        try {
+            lock = CloudControllerContext.getInstance().acquireClusterContextWriteLock();
+            // terminate all kubernetes units
+            try {
+                terminateContainers(clusterId);
+            } catch (InvalidClusterException e) {
+                String msg = "Docker instance termination fails for cluster: " + clusterId;
+                log.error(msg, e);
+                throw new UnregisteredClusterException(msg, e);
+            }
+            // send cluster removal notifications and update the state
+            //onClusterRemoval(clusterId);
+        } finally {
+            if (lock != null) {
+                CloudControllerContext.getInstance().releaseWriteLock(lock);
+            }
+        }
+    }
+
+    public MemberContext[] terminateContainers(String clusterId)
+            throws InvalidClusterException {
+        Lock lock = null;
+        try {
+            lock = CloudControllerContext.getInstance().acquireMemberContextWriteLock();
+
+            ClusterContext ctxt = CloudControllerContext.getInstance().getClusterContext(clusterId);
+            handleNullObject(ctxt, "Kubernetes units temrination failed. Invalid cluster id. " + clusterId);
+
+            String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(),
+                    StratosConstants.KUBERNETES_CLUSTER_ID);
+            handleNullObject(kubernetesClusterId, "Kubernetes units termination failed. Cannot find '" +
+                    StratosConstants.KUBERNETES_CLUSTER_ID + "'. " + ctxt);
+
+            KubernetesClusterContext kubClusterContext = CloudControllerContext.getInstance().getKubernetesClusterContext(kubernetesClusterId);
+            handleNullObject(kubClusterContext, "Kubernetes units termination failed. Cannot find a matching Kubernetes Cluster for cluster id: "
+                    + kubernetesClusterId);
+
+            KubernetesApiClient kubApi = kubClusterContext.getKubApi();
+            // delete the service
+            try {
+                kubApi.deleteService(CloudControllerUtil.getCompatibleId(clusterId));
+            } catch (KubernetesClientException e) {
+                // we're not going to throw this error, but proceed with other deletions
+                log.error("Failed to delete Kubernetes service with id: " + clusterId, e);
+            }
+
+            // set replicas=0 for the replication controller
+            try {
+                kubApi.updateReplicationController(clusterId, 0);
+            } catch (KubernetesClientException e) {
+                // we're not going to throw this error, but proceed with other deletions
+                log.error("Failed to update Kubernetes Controller with id: " + clusterId, e);
+            }
+
+            // delete pods forcefully
+            try {
+                // create a label query
+                Label l = new Label();
+                l.setName(clusterId);
+                // execute the label query
+                Pod[] pods = kubApi.queryPods(new Label[]{l});
+
+                for (Pod pod : pods) {
+                    try {
+                        // delete pods forcefully
+                        kubApi.deletePod(pod.getId());
+                    } catch (KubernetesClientException ignore) {
+                        // we can't do nothing here
+                        log.warn(String.format("Failed to delete Pod [%s] forcefully!", pod.getId()));
+                    }
+                }
+            } catch (KubernetesClientException e) {
+                // we're not going to throw this error, but proceed with other deletions
+                log.error("Failed to delete pods forcefully for cluster: " + clusterId, e);
+            }
+
+            // delete the replication controller.
+            try {
+                kubApi.deleteReplicationController(clusterId);
+            } catch (KubernetesClientException e) {
+                String msg = "Failed to delete Kubernetes Controller with id: " + clusterId;
+                log.error(msg, e);
+                throw new InvalidClusterException(msg, e);
+            }
+
+            String allocatedPort = CloudControllerUtil.getProperty(ctxt.getProperties(),
+                    StratosConstants.ALLOCATED_SERVICE_HOST_PORT);
+
+            if (allocatedPort != null) {
+                kubClusterContext.deallocateHostPort(Integer
+                        .parseInt(allocatedPort));
+            } else {
+                log.warn("Host port dealloacation failed due to a missing property: "
+                        + StratosConstants.ALLOCATED_SERVICE_HOST_PORT);
+            }
+
+            List<MemberContext> membersToBeRemoved = CloudControllerContext.getInstance().getMemberContextsOfClusterId(clusterId);
+
+            for (MemberContext memberContext : membersToBeRemoved) {
+                CloudControllerServiceUtil.executeMemberTerminationPostProcess(memberContext);
+            }
+
+            // persist
+            CloudControllerContext.getInstance().persist();
+            return membersToBeRemoved.toArray(new MemberContext[0]);
+        } finally {
+            if (lock != null) {
+                CloudControllerContext.getInstance().releaseWriteLock(lock);
+            }
+        }
+    }
+
+    public MemberContext[] updateContainers(String clusterId, int containerCount)
+            throws CartridgeNotFoundException {
+        Lock lock = null;
+        try {
+            lock = CloudControllerContext.getInstance().acquireMemberContextWriteLock();
+
+            if (log.isDebugEnabled()) {
+                log.debug("CloudControllerServiceImpl:updateContainers for cluster : " + clusterId);
+            }
+
+            ClusterContext clusterContext = CloudControllerContext.getInstance().getClusterContext(clusterId);
+            handleNullObject(clusterContext, "Container update failed. Invalid cluster id. " + clusterId);
+
+            String cartridgeType = clusterContext.getCartridgeType();
+            Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(cartridgeType);
+
+            if (cartridge == null) {
+                String msg = "Container update failed. No matching Cartridge found [type] " + cartridgeType
+                                + ". [cluster id] " + clusterId;
+                log.error(msg);
+                throw new CartridgeNotFoundException(msg);
+            }
+
+            try {
+                String kubernetesClusterId = readProperty(StratosConstants.KUBERNETES_CLUSTER_ID,
+                        clusterContext.getProperties(), clusterContext.toString());
+                KubernetesClusterContext kubClusterContext =
+                        CloudControllerContext.getInstance().getKubernetesClusterContext(kubernetesClusterId);
+
+                if (kubClusterContext == null) {
+                    String msg = "Instance startup failed. No matching Kubernetes context found for [id] " +
+                            kubernetesClusterId + " [cluster id] " + clusterId;
+                    log.error(msg);
+                    throw new CartridgeNotFoundException(msg);
+                }
+
+                KubernetesApiClient kubApi = kubClusterContext.getKubApi();
+                // create a label query
+                Label label = new Label();
+                label.setName(clusterId);
+
+                // get the current pods - useful when scale down
+                Pod[] pods = kubApi.queryPods(new Label[]{label});
+
+                // update the replication controller - cluster id = replication controller id
+                if (log.isDebugEnabled()) {
+                    log.debug("Cloud Controller is delegating request to update a replication controller " + clusterId +
+                            " to Kubernetes layer.");
+                }
+
+                kubApi.updateReplicationController(clusterId, containerCount);
+
+                if (log.isDebugEnabled()) {
+                    log.debug("Cloud Controller successfully updated the controller "
+                            + clusterId + " via Kubernetes layer.");
+                }
+
+                // execute the label query
+                Pod[] selectedPods = new Pod[0];
+
+                // wait replicas*5s time in the worst case ; best case = 0s
+                for (int i = 0; i < (containerCount * pods.length + 1); i++) {
+                    selectedPods = kubApi.queryPods(new Label[]{label});
+
+                    if (log.isDebugEnabled()) {
+                        log.debug("Pods count: " + selectedPods.length + " for cluster: " + clusterId);
+                    }
+                    if (selectedPods.length == containerCount) {
+                        break;
+                    }
+                    Thread.sleep(10000);
+                }
+
+                if (log.isDebugEnabled()) {
+
+                    log.debug(String.format("Pods created : %s for cluster : %s", selectedPods.length, clusterId));
+                }
+
+                List<MemberContext> memberContexts = new ArrayList<MemberContext>();
+
+                PodToMemberContext podToMemberContextFunc = new PodToMemberContext();
+                // generate Member Contexts
+                for (Pod pod : selectedPods) {
+                    MemberContext context;
+                    // if member context does not exist -> a new member (scale up)
+                    if ((context = CloudControllerContext.getInstance().getMemberContextOfMemberId(pod.getId())) == null) {
+
+                        context = podToMemberContextFunc.apply(pod);
+                        context.setCartridgeType(cartridgeType);
+                        context.setClusterId(clusterId);
+
+                        context.setProperties(CloudControllerUtil.addProperty(context
+                                        .getProperties(), StratosConstants.ALLOCATED_SERVICE_HOST_PORT,
+                                CloudControllerUtil.getProperty(clusterContext.getProperties(),
+                                        StratosConstants.ALLOCATED_SERVICE_HOST_PORT)));
+
+                        // wait till Pod status turns to running and send member spawned.
+                        ScheduledThreadExecutor exec = ScheduledThreadExecutor.getInstance();
+                        if (log.isDebugEnabled()) {
+                            log.debug("Cloud Controller is starting the instance start up thread.");
+                        }
+                        CloudControllerContext.getInstance().addScheduledFutureJob(context.getMemberId(), exec.schedule(new PodActivationWatcher(pod.getId(), context, kubApi), 5000));
+
+                        memberContexts.add(context);
+
+                    }
+                    // publish data
+                    // TODO
+//                CartridgeInstanceDataPublisher.publish(context.getMemberId(), null, null, context.getClusterId(), cartridgeType, MemberStatus.Created.toString(), node);
+
+                }
+
+                if (memberContexts.isEmpty()) {
+                    // terminated members
+                    @SuppressWarnings("unchecked")
+                    List<Pod> difference = ListUtils.subtract(Arrays.asList(pods), Arrays.asList(selectedPods));
+                    for (Pod pod : difference) {
+                        if (pod != null) {
+                            MemberContext context = CloudControllerContext.getInstance().getMemberContextOfMemberId(pod.getId());
+                            CloudControllerServiceUtil.executeMemberTerminationPostProcess(context);
+                            memberContexts.add(context);
+                        }
+                    }
+                }
+
+
+                // persist in registry
+                CloudControllerContext.getInstance().persist();
+
+                log.info("Kubernetes entities are successfully starting up. " + memberContexts);
+                return memberContexts.toArray(new MemberContext[0]);
+
+            } catch (Exception e) {
+                String msg = "Failed to update containers belong to cluster " + clusterId + ". Cause: " + e.getMessage();
+                log.error(msg, e);
+                throw new IllegalStateException(msg, e);
+            }
+        } finally {
+            if (lock != null) {
+                CloudControllerContext.getInstance().releaseWriteLock(lock);
+            }
+        }
+    }
+
+    public MemberContext terminateContainer(String memberId) throws MemberTerminationFailedException {
+        Lock lock = null;
+        try {
+            lock = CloudControllerContext.getInstance().acquireMemberContextWriteLock();
+            handleNullObject(memberId, "Failed to terminate member. Invalid Member id. [member-id] " + memberId);
+            MemberContext memberContext = CloudControllerContext.getInstance().getMemberContextOfMemberId(memberId);
+            handleNullObject(memberContext, "Failed to terminate member. Member id not found. [member-id] " + memberId);
+
+            String clusterId = memberContext.getClusterId();
+            handleNullObject(clusterId, "Failed to terminate member. Cluster id is null. [member-id] " + memberId);
+
+            ClusterContext ctxt = CloudControllerContext.getInstance().getClusterContext(clusterId);
+            handleNullObject(ctxt, String.format("Failed to terminate member [member-id] %s. Invalid cluster id %s ", memberId, clusterId));
+
+            String kubernetesClusterId = CloudControllerUtil.getProperty(ctxt.getProperties(),
+                    StratosConstants.KUBERNETES_CLUSTER_ID);
+
+            handleNullObject(kubernetesClusterId, String.format("Failed to terminate member [member-id] %s. Cannot find '" +
+                    StratosConstants.KUBERNETES_CLUSTER_ID + "' in [cluster context] %s ", memberId, ctxt));
+
+            KubernetesClusterContext kubClusterContext = CloudControllerContext.getInstance().getKubernetesClusterContext(kubernetesClusterId);
+            handleNullObject(kubClusterContext, String.format("Failed to terminate member [member-id] %s. Cannot find a matching Kubernetes Cluster in [cluster context] %s ", memberId, ctxt));
+            KubernetesApiClient kubApi = kubClusterContext.getKubApi();
+            // delete the Pod
+            try {
+                // member id = pod id
+                kubApi.deletePod(memberId);
+                MemberContext memberToBeRemoved = CloudControllerContext.getInstance().getMemberContextOfMemberId(memberId);
+                CloudControllerServiceUtil.executeMemberTerminationPostProcess(memberToBeRemoved);
+
+                return memberToBeRemoved;
+
+            } catch (KubernetesClientException e) {
+                String msg = String.format("Failed to terminate member: [member-id] %s", memberId);
+                log.error(msg, e);
+                throw new MemberTerminationFailedException(msg, e);
+            }
+        } finally {
+            if (lock != null) {
+                CloudControllerContext.getInstance().releaseWriteLock(lock);
+            }
+        }
+    }
+
+    private KubernetesClusterContext getKubernetesClusterContext(String kubernetesClusterId, String kubernetesMasterIp,
+                                                                 String kubernetesMasterPort, int upperPort, int lowerPort) {
+
+        KubernetesClusterContext origCtxt =
+                CloudControllerContext.getInstance().getKubernetesClusterContext(kubernetesClusterId);
+        KubernetesClusterContext newCtxt =
+                new KubernetesClusterContext(kubernetesClusterId, kubernetesMasterIp,
+                        kubernetesMasterPort, upperPort, lowerPort);
+
+        if (origCtxt == null) {
+            CloudControllerContext.getInstance().addKubernetesClusterContext(newCtxt);
+            return newCtxt;
+        }
+
+        if (!origCtxt.equals(newCtxt)) {
+            // if for some reason master IP etc. have changed
+            newCtxt.setAvailableHostPorts(origCtxt.getAvailableHostPorts());
+            CloudControllerContext.getInstance().addKubernetesClusterContext(newCtxt);
+            return newCtxt;
+        } else {
+            return origCtxt;
+        }
+    }
+
+    private String readProperty(String property, org.apache.stratos.common.Properties properties, String object) {
+        String propVal = CloudControllerUtil.getProperty(properties, property);
+        handleNullObject(propVal, "Property validation failed. Cannot find property: '" + property + " in " + object);
+        return propVal;
+
+    }
+
+    private void handleNullObject(Object obj, String errorMsg) {
+        if (obj == null) {
+            log.error(errorMsg);
+            throw new IllegalArgumentException(errorMsg);
+        }
+    }
+}

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/MockIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/MockIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/MockIaas.java
index 9e9273e..d4956d4 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/MockIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/MockIaas.java
@@ -19,14 +19,12 @@
 
 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.exception.*;
 import org.apache.stratos.cloud.controller.iaases.mock.MockIaasService;
 import org.apache.stratos.cloud.controller.iaases.validators.PartitionValidator;
-import org.jclouds.compute.domain.NodeMetadata;
 
 /**
  * Mock IaaS client for invoking mock IaaS service.
@@ -42,8 +40,8 @@ public class MockIaas extends Iaas {
     }
 
     @Override
-    public NodeMetadata createInstance(ClusterContext clusterContext, MemberContext memberContext) {
-        return MockIaasService.getInstance().createInstance(clusterContext, memberContext);
+    public MemberContext createInstance(MemberContext memberContext) {
+        return MockIaasService.getInstance().createInstance(memberContext);
     }
 
     @Override
@@ -97,9 +95,8 @@ public class MockIaas extends Iaas {
     }
 
     @Override
-    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition,
-                                  String cartridgeType, NodeMetadata node) {
-        MockIaasService.getInstance().allocateIpAddress(clusterId, memberContext, partition, cartridgeType, node);
+    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition) {
+        MockIaasService.getInstance().allocateIpAddress(clusterId, memberContext, partition);
     }
 
     @Override

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/mock/MockIaasService.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaasService.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaasService.java
index bbca7ea..354484b 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaasService.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockIaasService.java
@@ -21,9 +21,7 @@ package org.apache.stratos.cloud.controller.iaases.mock;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.stratos.cloud.controller.domain.ClusterContext;
-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.mock.config.MockIaasConfig;
 import org.apache.stratos.cloud.controller.iaases.mock.statistics.generator.MockHealthStatisticsGenerator;
@@ -105,19 +103,20 @@ public class MockIaasService {
         }
     }
 
-    public NodeMetadata createInstance(ClusterContext clusterContext, MemberContext memberContext) {
+    public MemberContext createInstance(MemberContext memberContext) {
         synchronized (MockIaasService.class) {
             // Create mock member instance
-            MockMemberContext mockMemberContext = new MockMemberContext(clusterContext.getCartridgeType(),
-                    clusterContext.getClusterId(), memberContext.getMemberId(), memberContext.getNetworkPartitionId(),
-                    memberContext.getPartition().getId(), memberContext.getInstanceId());
+            MockMemberContext mockMemberContext = new MockMemberContext(memberContext.getCartridgeType(),
+                    memberContext.getClusterId(), memberContext.getMemberId(), memberContext.getInstanceId(),
+                    memberContext.getClusterInstanceId(), memberContext.getNetworkPartitionId(),
+                    memberContext.getPartition().getId());
+
             MockMember mockMember = new MockMember(mockMemberContext);
             addMemberToMap(mockMember);
             mockMemberExecutorService.submit(mockMember);
 
-            // Prepare node metadata
-            MockNodeMetadata nodeMetadata = new MockNodeMetadata();
-            nodeMetadata.setId(UUID.randomUUID().toString());
+            // Generate instance id
+            memberContext.setInstanceId(UUID.randomUUID().toString());
 
             // Persist changes
             persistInRegistry();
@@ -125,7 +124,7 @@ public class MockIaasService {
             String serviceName = mockMemberContext.getServiceName();
             MockHealthStatisticsGenerator.getInstance().scheduleStatisticsUpdaterTasks(serviceName);
 
-            return nodeMetadata;
+            return memberContext;
         }
     }
 
@@ -149,11 +148,11 @@ public class MockIaasService {
     }
 
     private ConcurrentHashMap<String, Map<String, MockMember>> readFromRegistry() {
-        return (ConcurrentHashMap<String, Map<String, MockMember>>) RegistryManager.getInstance().read(MOCK_IAAS_MEMBERS);
+        return (ConcurrentHashMap<String, Map<String, MockMember>>)
+                RegistryManager.getInstance().read(MOCK_IAAS_MEMBERS);
     }
 
-    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition,
-                                  String cartridgeType, NodeMetadata node) {
+    public void allocateIpAddress(String clusterId, MemberContext memberContext, Partition partition) {
         // Allocate mock ip addresses
         memberContext.setPrivateIpAddress(MockIPAddressPool.getInstance().getNextPrivateIpAddress());
         memberContext.setPublicIpAddress(MockIPAddressPool.getInstance().getNextPublicIpAddress());

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/mock/MockMemberContext.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberContext.java
index 7189d11..a217218 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberContext.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberContext.java
@@ -28,18 +28,20 @@ public class MockMemberContext implements Serializable {
     private final String serviceName;
     private final String clusterId;
     private final String memberId;
+    private final String instanceId;
+    private final String clusterInstanceId;
     private final String networkPartitionId;
     private final String partitionId;
-    private final String instanceId;
 
-    public MockMemberContext(String serviceName, String clusterId, String memberId,
-                             String networkPartitionId, String partitionId, String instanceId) {
+    public MockMemberContext(String serviceName, String clusterId, String memberId, String instanceId,
+                             String clusterInstanceId, String networkPartitionId, String partitionId) {
         this.serviceName = serviceName;
         this.clusterId = clusterId;
         this.memberId = memberId;
+        this.instanceId = instanceId;
+        this.clusterInstanceId = clusterInstanceId;
         this.networkPartitionId = networkPartitionId;
         this.partitionId = partitionId;
-        this.instanceId = instanceId;
     }
 
     public String getServiceName() {
@@ -54,6 +56,14 @@ public class MockMemberContext implements Serializable {
         return memberId;
     }
 
+    public String getInstanceId() {
+        return instanceId;
+    }
+
+    public String getClusterInstanceId() {
+        return clusterInstanceId;
+    }
+
     public String getNetworkPartitionId() {
         return networkPartitionId;
     }
@@ -61,8 +71,4 @@ public class MockMemberContext implements Serializable {
     public String getPartitionId() {
         return partitionId;
     }
-
-    public String getInstanceId() {
-        return instanceId;
-    }
 }

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/mock/MockMemberEventPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberEventPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberEventPublisher.java
index 1b1ea43..54d4c58 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberEventPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockMemberEventPublisher.java
@@ -43,10 +43,11 @@ public class MockMemberEventPublisher {
         InstanceStartedEvent event = new InstanceStartedEvent(
                 mockMemberContext.getServiceName(),
                 mockMemberContext.getClusterId(),
-                mockMemberContext.getNetworkPartitionId(),
-                mockMemberContext.getPartitionId(),
                 mockMemberContext.getMemberId(),
-                mockMemberContext.getInstanceId());
+                mockMemberContext.getInstanceId(),
+                mockMemberContext.getClusterInstanceId(),
+                mockMemberContext.getNetworkPartitionId(),
+                mockMemberContext.getPartitionId());
         String topic = Util.getMessageTopicName(event);
         EventPublisher eventPublisher = EventPublisherPool
                 .getPublisher(topic);
@@ -63,10 +64,11 @@ public class MockMemberEventPublisher {
         InstanceActivatedEvent event = new InstanceActivatedEvent(
                 mockMemberContext.getServiceName(),
                 mockMemberContext.getClusterId(),
-                mockMemberContext.getNetworkPartitionId(),
-                mockMemberContext.getPartitionId(),
                 mockMemberContext.getMemberId(),
-                mockMemberContext.getInstanceId());
+                mockMemberContext.getInstanceId(),
+                mockMemberContext.getClusterInstanceId(),
+                mockMemberContext.getNetworkPartitionId(),
+                mockMemberContext.getPartitionId());
 
         // Event publisher connection will
         String topic = Util.getMessageTopicName(event);
@@ -85,10 +87,11 @@ public class MockMemberEventPublisher {
         InstanceReadyToShutdownEvent event = new InstanceReadyToShutdownEvent(
                 mockMemberContext.getServiceName(),
                 mockMemberContext.getClusterId(),
-                mockMemberContext.getNetworkPartitionId(),
-                mockMemberContext.getPartitionId(),
                 mockMemberContext.getMemberId(),
-                mockMemberContext.getInstanceId());
+                mockMemberContext.getInstanceId(),
+                mockMemberContext.getClusterInstanceId(),
+                mockMemberContext.getNetworkPartitionId(),
+                mockMemberContext.getPartitionId());
         String topic = Util.getMessageTopicName(event);
         EventPublisher eventPublisher = EventPublisherPool
                 .getPublisher(topic);
@@ -107,10 +110,11 @@ public class MockMemberEventPublisher {
         InstanceMaintenanceModeEvent event = new InstanceMaintenanceModeEvent(
                 mockMemberContext.getServiceName(),
                 mockMemberContext.getClusterId(),
-                mockMemberContext.getNetworkPartitionId(),
-                mockMemberContext.getPartitionId(),
                 mockMemberContext.getMemberId(),
-                mockMemberContext.getInstanceId());
+                mockMemberContext.getInstanceId(),
+                mockMemberContext.getClusterInstanceId(),
+                mockMemberContext.getNetworkPartitionId(),
+                mockMemberContext.getPartitionId());
         String topic = Util.getMessageTopicName(event);
         EventPublisher eventPublisher = EventPublisherPool.getPublisher(topic);
         eventPublisher.publish(event);

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/mock/MockNodeMetadata.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockNodeMetadata.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockNodeMetadata.java
deleted file mode 100644
index 6dd3faf..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockNodeMetadata.java
+++ /dev/null
@@ -1,143 +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.iaases.mock;
-
-import org.jclouds.compute.domain.ComputeType;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.domain.ResourceMetadata;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Mock node metadata definition.
- */
-public class MockNodeMetadata implements NodeMetadata {
-    private String id;
-
-    @Override
-    public String getHostname() {
-        return null;
-    }
-
-    @Override
-    public String getGroup() {
-        return null;
-    }
-
-    @Override
-    public Hardware getHardware() {
-        return null;
-    }
-
-    @Override
-    public String getImageId() {
-        return null;
-    }
-
-    @Override
-    public OperatingSystem getOperatingSystem() {
-        return null;
-    }
-
-    @Override
-    public int getLoginPort() {
-        return 0;
-    }
-
-    @Override
-    public LoginCredentials getCredentials() {
-        return null;
-    }
-
-    @Override
-    public Set<String> getPublicAddresses() {
-        return null;
-    }
-
-    @Override
-    public Set<String> getPrivateAddresses() {
-        return null;
-    }
-
-    @Override
-    public Status getStatus() {
-        return null;
-    }
-
-    @Override
-    public String getBackendStatus() {
-        return null;
-    }
-
-    @Override
-    public ComputeType getType() {
-        return null;
-    }
-
-    @Override
-    public String getProviderId() {
-        return null;
-    }
-
-    @Override
-    public String getName() {
-        return null;
-    }
-
-    @Override
-    public Location getLocation() {
-        return null;
-    }
-
-    @Override
-    public URI getUri() {
-        return null;
-    }
-
-    @Override
-    public Map<String, String> getUserMetadata() {
-        return null;
-    }
-
-    @Override
-    public String getId() {
-        return id;
-    }
-
-    @Override
-    public Set<String> getTags() {
-        return null;
-    }
-
-    @Override
-    public int compareTo(ResourceMetadata<ComputeType> computeTypeResourceMetadata) {
-        return 0;
-    }
-
-    public void setId(String id) {
-        this.id = 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/iaases/mock/MockPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java
index e1055f0..ef7ae94 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/mock/MockPartitionValidator.java
@@ -21,7 +21,6 @@ package org.apache.stratos.cloud.controller.iaases.mock;
 
 import org.apache.stratos.cloud.controller.domain.IaasProvider;
 import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
-import org.apache.stratos.cloud.controller.iaases.validators.IaasBasedPartitionValidator;
 import org.apache.stratos.cloud.controller.iaases.validators.PartitionValidator;
 
 import java.util.Properties;
@@ -29,7 +28,7 @@ import java.util.Properties;
 /**
  * Mock partition validator.
  */
-public class MockPartitionValidator extends IaasBasedPartitionValidator {
+public class MockPartitionValidator implements PartitionValidator {
 
     private IaasProvider iaasProvider;
 

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/validators/AWSEC2PartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/AWSEC2PartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/AWSEC2PartitionValidator.java
index 649eca2..4d16c87 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/AWSEC2PartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/AWSEC2PartitionValidator.java
@@ -36,7 +36,7 @@ import java.util.Properties;
  *
  *
  */
-public class AWSEC2PartitionValidator extends IaasBasedPartitionValidator {
+public class AWSEC2PartitionValidator implements PartitionValidator {
     
     private static final Log log = LogFactory.getLog(AWSEC2PartitionValidator.class);
     private IaasProvider iaasProvider;

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/validators/CloudstackPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/CloudstackPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/CloudstackPartitionValidator.java
index 2038a8c..70b32dd 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/CloudstackPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/CloudstackPartitionValidator.java
@@ -12,14 +12,13 @@ import org.apache.stratos.messaging.domain.topology.Scope;
 import java.util.Properties;
 
 
-public class CloudstackPartitionValidator extends IaasBasedPartitionValidator {
-
+public class CloudstackPartitionValidator implements PartitionValidator {
 
     private static final Log log = LogFactory.getLog(AWSEC2PartitionValidator.class);
+
     private IaasProvider iaasProvider;
     private Iaas iaas;
 
-
     @Override
     public void setIaasProvider(IaasProvider iaas) {
         this.iaasProvider = iaas;

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/validators/DockerPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/DockerPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/DockerPartitionValidator.java
index 2a57b3e..1a54297 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/DockerPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/DockerPartitionValidator.java
@@ -32,8 +32,9 @@ import java.util.Properties;
 /**
  * Docker partition validator definition.
  */
-public class DockerPartitionValidator extends IaasBasedPartitionValidator {
-    private static final Log log = LogFactory.getLog(DockerPartitionValidator.class);
+public class DockerPartitionValidator implements PartitionValidator {
+
+	private static final Log log = LogFactory.getLog(DockerPartitionValidator.class);
 
     private IaasProvider iaasProvider;
 

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/validators/GCEPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/GCEPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/GCEPartitionValidator.java
index ada45cd..4f119ac 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/GCEPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/GCEPartitionValidator.java
@@ -31,11 +31,11 @@ import org.apache.stratos.cloud.controller.domain.IaasProvider;
  * The VCloud {@link PartitionValidator} implementation.
  *
  */
-public class GCEPartitionValidator extends IaasBasedPartitionValidator {
+public class GCEPartitionValidator implements PartitionValidator {
     
     private static final Log log = LogFactory.getLog(VCloudPartitionValidator.class);
+
     private IaasProvider iaasProvider;
-    private Iaas iaas;
 
     @Override
     public IaasProvider validate(String partitionId, Properties properties) throws InvalidPartitionException {
@@ -45,9 +45,7 @@ public class GCEPartitionValidator extends IaasBasedPartitionValidator {
     }
 
     @Override
-    public void setIaasProvider(IaasProvider iaas) {
-        this.iaasProvider = iaas;
-        this.iaas = iaas.getIaas();
+    public void setIaasProvider(IaasProvider iaasProvider) {
+        this.iaasProvider = iaasProvider;
     }
-
 }

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/validators/IaasBasedPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/IaasBasedPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/IaasBasedPartitionValidator.java
deleted file mode 100644
index d9a77cf..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/IaasBasedPartitionValidator.java
+++ /dev/null
@@ -1,47 +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.iaases.validators;
-
-import java.util.Properties;
-
-import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
-import org.apache.stratos.cloud.controller.domain.IaasProvider;
-
-/**
- * All the IaaSes should write a partition validator which extends this class.
- */
-public abstract class IaasBasedPartitionValidator implements PartitionValidator {
-
-    /**
-     * set the IaasProvider reference.
-     * 
-     * @param iaas {@link IaasProvider}
-     */
-    public abstract void setIaasProvider(IaasProvider iaas);
-
-    /**
-     * Validate the given properties for its existent in this partition.
-     * 
-     * @param partitionId partition id.
-     * @param properties set of properties to be validated.
-     * @return cloned and modified {@link IaasProvider} which maps to the given partition.
-     * @throws InvalidPartitionException if at least one property is evaluated to be invalid.
-     */
-    public abstract IaasProvider validate(String partitionId, Properties properties) throws InvalidPartitionException;
-}

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/validators/KubernetesBasedPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/KubernetesBasedPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/KubernetesBasedPartitionValidator.java
deleted file mode 100644
index e6225f1..0000000
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/KubernetesBasedPartitionValidator.java
+++ /dev/null
@@ -1,67 +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.iaases.validators;
-
-import java.util.Properties;
-
-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.exception.InvalidPartitionException;
-import org.apache.stratos.cloud.controller.exception.NonExistingKubernetesGroupException;
-import org.apache.stratos.common.constants.StratosConstants;
-import org.apache.stratos.common.kubernetes.KubernetesGroup;
-
-/**
- * Kubernetes Partition Validator
- */
-public class KubernetesBasedPartitionValidator implements PartitionValidator {
-    
-    private static final Log log = LogFactory.getLog(KubernetesBasedPartitionValidator.class);
-
-    /**
-     * Validate the given properties for its existent in this partition.
-     * 
-     * @param partitionId partition id.
-     * @param properties set of properties to be validated.
-     * @return cloned and modified {@link IaasProvider} which maps to the given partition.
-     * @throws InvalidPartitionException if at least one property is evaluated to be invalid.
-     */
-    public KubernetesGroup validate(String partitionId, Properties properties) throws InvalidPartitionException {
-
-        if (properties.containsKey(StratosConstants.KUBERNETES_CLUSTER_ID)) {
-            String kubernetesClusterId = properties.getProperty(StratosConstants.KUBERNETES_CLUSTER_ID);
-            try {
-                KubernetesGroup kubGroup = CloudControllerContext.getInstance().getKubernetesGroup(kubernetesClusterId);
-                return kubGroup;
-            } catch (NonExistingKubernetesGroupException e) {
-                String msg = "Invalid Partition Detected : " + partitionId + ". Cause: " + e.getMessage();
-                log.error(msg, e);
-                throw new InvalidPartitionException(msg, e);
-            }
-        }
-
-        String msg =
-                "Invalid Partition Detected : " + partitionId + ". Cause: Essential "
-                        + StratosConstants.KUBERNETES_CLUSTER_ID + " property not found.";
-        log.error(msg);
-        throw new InvalidPartitionException(msg);
-
-    }
-}

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/validators/KubernetesPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/KubernetesPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/KubernetesPartitionValidator.java
new file mode 100644
index 0000000..a95aa37
--- /dev/null
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/KubernetesPartitionValidator.java
@@ -0,0 +1,72 @@
+/*
+ * 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.iaases.validators;
+
+import java.util.Properties;
+
+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.IaasProvider;
+import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
+import org.apache.stratos.cloud.controller.exception.NonExistingKubernetesGroupException;
+import org.apache.stratos.common.constants.StratosConstants;
+
+/**
+ * Kubernetes partition validator
+ */
+public class KubernetesPartitionValidator implements PartitionValidator {
+    
+    private static final Log log = LogFactory.getLog(KubernetesPartitionValidator.class);
+
+    private IaasProvider iaasProvider;
+
+    @Override
+    public void setIaasProvider(IaasProvider iaasProvider) {
+        this.iaasProvider = iaasProvider;
+    }
+
+    /**
+     * Validate the given properties for its existent in this partition.
+     * 
+     * @param partitionId partition id.
+     * @param properties set of properties to be validated.
+     * @return cloned and modified {@link IaasProvider} which maps to the given partition.
+     * @throws InvalidPartitionException if at least one property is evaluated to be invalid.
+     */
+    public IaasProvider validate(String partitionId, Properties properties) throws InvalidPartitionException {
+
+        if (properties.containsKey(StratosConstants.KUBERNETES_CLUSTER_ID)) {
+            String kubernetesClusterId = properties.getProperty(StratosConstants.KUBERNETES_CLUSTER_ID);
+            try {
+                CloudControllerContext.getInstance().getKubernetesGroup(kubernetesClusterId);
+                return iaasProvider;
+            } catch (NonExistingKubernetesGroupException e) {
+                String message = "Kubernetes partition is not valid: [partition-id] " + partitionId;
+                log.error(message, e);
+                throw new InvalidPartitionException(message, e);
+            }
+        }
+
+        String message = "Kubernetes partition is not valid: [partition-id] " + partitionId + ", property not found: "
+                        + StratosConstants.KUBERNETES_CLUSTER_ID;
+        log.error(message);
+        throw new InvalidPartitionException(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/iaases/validators/OpenstackNovaPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/OpenstackNovaPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/OpenstackNovaPartitionValidator.java
index bb8358c..f2205b2 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/OpenstackNovaPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/OpenstackNovaPartitionValidator.java
@@ -36,9 +36,10 @@ import java.util.Properties;
  *
  *
  */
-public class OpenstackNovaPartitionValidator extends IaasBasedPartitionValidator {
+public class OpenstackNovaPartitionValidator implements PartitionValidator {
     
     private static final Log log = LogFactory.getLog(OpenstackNovaPartitionValidator.class);
+
     private IaasProvider iaasProvider;
     private Iaas iaas;
 

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/validators/PartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/PartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/PartitionValidator.java
index ed29c2d..6bcbdcd 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/PartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/PartitionValidator.java
@@ -21,19 +21,27 @@ package org.apache.stratos.cloud.controller.iaases.validators;
 import java.util.Properties;
 
 import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
+import org.apache.stratos.cloud.controller.domain.IaasProvider;
 
 /**
- * All the Partition Validators should implement this interface.
- *
+ * All the IaaSes needs to write a partition validator which implements this interface.
  */
 public interface PartitionValidator {
-    
+
+    /**
+     * set the IaasProvider reference.
+     * 
+     * @param iaasProvider {@link IaasProvider}
+     */
+    public abstract void setIaasProvider(IaasProvider iaasProvider);
+
     /**
      * Validate the given properties for its existent in this partition.
+     * 
      * @param partitionId partition id.
      * @param properties set of properties to be validated.
-     * @return cloned and modified {@link Object} which maps to the given partition. 
+     * @return cloned and modified {@link IaasProvider} which maps to the given partition.
      * @throws InvalidPartitionException if at least one property is evaluated to be invalid.
      */
-    public Object validate(String partitionId, Properties properties) throws InvalidPartitionException;
+    public abstract IaasProvider validate(String partitionId, Properties properties) throws InvalidPartitionException;
 }

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/validators/VCloudPartitionValidator.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/VCloudPartitionValidator.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/VCloudPartitionValidator.java
index 21b3417..8af42d7 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/VCloudPartitionValidator.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/validators/VCloudPartitionValidator.java
@@ -31,7 +31,7 @@ import org.apache.stratos.cloud.controller.domain.IaasProvider;
  * The VCloud {@link PartitionValidator} implementation.
  *
  */
-public class VCloudPartitionValidator extends IaasBasedPartitionValidator {
+public class VCloudPartitionValidator implements PartitionValidator {
     
     @SuppressWarnings("unused")
 	private static final Log log = LogFactory.getLog(VCloudPartitionValidator.class);

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/messaging/publisher/StatisticsDataPublisher.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/publisher/StatisticsDataPublisher.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/publisher/StatisticsDataPublisher.java
index 15cf63b..0539e23 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/publisher/StatisticsDataPublisher.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/messaging/publisher/StatisticsDataPublisher.java
@@ -22,9 +22,12 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.config.CloudControllerConfig;
 import org.apache.stratos.cloud.controller.context.CloudControllerContext;
+import org.apache.stratos.cloud.controller.domain.IaasProvider;
+import org.apache.stratos.cloud.controller.domain.InstanceMetadata;
 import org.apache.stratos.cloud.controller.exception.CloudControllerException;
 import org.apache.stratos.cloud.controller.domain.Cartridge;
 import org.apache.stratos.cloud.controller.domain.MemberContext;
+import org.apache.stratos.cloud.controller.iaases.JcloudsIaas;
 import org.apache.stratos.cloud.controller.util.CloudControllerConstants;
 import org.jclouds.compute.domain.NodeMetadata;
 import org.wso2.carbon.base.ServerConfiguration;
@@ -56,7 +59,7 @@ public class StatisticsDataPublisher {
                                String clusterId,
                                String serviceName,
                                String status,
-                               NodeMetadata metadata) {
+                               InstanceMetadata metadata) {
         if(!CloudControllerConfig.getInstance().isBAMDataPublisherEnabled()){
             return;
         }
@@ -74,7 +77,6 @@ public class StatisticsDataPublisher {
             }
         }
 
-
         MemberContext memberContext = CloudControllerContext.getInstance().getMemberContextOfMemberId(memberId);
         String cartridgeType = memberContext.getCartridgeType();
         Cartridge cartridge = CloudControllerContext.getInstance().getCartridge(cartridgeType);
@@ -98,14 +100,14 @@ public class StatisticsDataPublisher {
 
         if(metadata != null) {
             payload.add(metadata.getHostname());
-            payload.add(metadata.getHardware().getHypervisor());
-            payload.add(String.valueOf(metadata.getHardware().getRam()));
+            payload.add(metadata.getHypervisor());
+            payload.add(String.valueOf(metadata.getRam()));
             payload.add(metadata.getImageId());
             payload.add(metadata.getLoginPort());
-            payload.add(metadata.getOperatingSystem().getName());
-            payload.add(metadata.getOperatingSystem().getVersion());
-            payload.add(metadata.getOperatingSystem().getArch());
-            payload.add(String.valueOf(metadata.getOperatingSystem().is64Bit()));
+            payload.add(metadata.getOperatingSystemName());
+            payload.add(metadata.getOperatingSystemVersion());
+            payload.add(metadata.getOperatingSystemArchitecture());
+            payload.add(String.valueOf(metadata.isOperatingSystem64bit()));
         } else {
             payload.add("");
             payload.add("");


Mime
View raw message