http://git-wip-us.apache.org/repos/asf/stratos/blob/02d01071/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
index bcd10b1..f869725 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackIaas.java
@@ -54,11 +54,9 @@ import java.util.Set;
 import java.util.concurrent.TimeoutException;
 
 public class OpenstackIaas extends JcloudsIaas {
-
     private static final Log log = LogFactory.getLog(OpenstackIaas.class);
     private static final String SUCCESSFUL_LOG_LINE = "A key-pair is created 
successfully in ";
     private static final String FAILED_LOG_LINE = "Key-pair is unable to 
create in ";
-
     private OpenstackNetworkingApi openstackNetworkingApi;
 
     public OpenstackIaas(IaasProvider iaasProvider) {
@@ -67,9 +65,10 @@ public class OpenstackIaas extends JcloudsIaas {
     }
 
     private void setOpenstackNetworkingApi(IaasProvider iaasProvider) {
-        String openstackNetworkingProvider = 
iaasProvider.getProperty(CloudControllerConstants.OPENSTACK_NETWORKING_PROVIDER);
-        if (openstackNetworkingProvider != null &&
-                
openstackNetworkingProvider.equals(CloudControllerConstants.OPENSTACK_NEUTRON_NETWORKING))
 {
+        String openstackNetworkingProvider = iaasProvider
+                
.getProperty(CloudControllerConstants.OPENSTACK_NETWORKING_PROVIDER);
+        if (openstackNetworkingProvider != null && openstackNetworkingProvider
+                
.equals(CloudControllerConstants.OPENSTACK_NEUTRON_NETWORKING)) {
             if (log.isDebugEnabled()) {
                 String msg = String.format("Openstack networking provider is 
%s. Trying to instanstiate %s",
                         openstackNetworkingProvider, 
NeutronNetworkingApi.class.getName());
@@ -100,52 +99,36 @@ public class OpenstackIaas extends JcloudsIaas {
         IaasProvider iaasProvider = getIaasProvider();
 
         if (iaasProvider.getComputeService() == null) {
-            throw new CloudControllerException(
-                    "Compute service is null for IaaS provider: "
-                            + iaasProvider.getName());
+            throw new CloudControllerException("Compute service is null for 
IaaS provider: " + iaasProvider.getName());
         }
 
-        TemplateBuilder templateBuilder = iaasProvider.getComputeService()
-                .templateBuilder();
+        TemplateBuilder templateBuilder = 
iaasProvider.getComputeService().templateBuilder();
         templateBuilder.imageId(iaasProvider.getImage());
-        if (!(iaasProvider instanceof IaasProvider)) {
-            templateBuilder.locationId(iaasProvider.getType());
-        }
-
-        // to avoid creation of template objects in each and every time, we
-        // create all at once!
 
+        // To avoid creation of template objects in each and every time, we 
create all at once!
         String instanceType;
 
         // set instance type
         if (((instanceType = 
iaasProvider.getProperty(CloudControllerConstants.INSTANCE_TYPE)) != null)) {
-
             templateBuilder.hardwareId(instanceType);
         }
-
         Template template = templateBuilder.build();
 
-        // In Openstack the call to IaaS should be blocking, in order to 
retrieve
-        // IP addresses.
+        // In Openstack the call to IaaS should be blocking, in order to 
retrieve IP addresses.
         boolean blockUntilRunning = true;
         if 
(iaasProvider.getProperty(CloudControllerConstants.BLOCK_UNTIL_RUNNING) != 
null) {
-            blockUntilRunning = Boolean.parseBoolean(iaasProvider.getProperty(
-                    CloudControllerConstants.BLOCK_UNTIL_RUNNING));
+            blockUntilRunning = Boolean
+                    
.parseBoolean(iaasProvider.getProperty(CloudControllerConstants.BLOCK_UNTIL_RUNNING));
         }
-        template.getOptions().as(TemplateOptions.class)
-                .blockUntilRunning(blockUntilRunning);
+        
template.getOptions().as(TemplateOptions.class).blockUntilRunning(blockUntilRunning);
 
-        // this is required in order to avoid creation of additional security
-        // groups by Jclouds.
-        template.getOptions().as(TemplateOptions.class)
-                .inboundPorts(new int[]{});
+        // this is required in order to avoid creation of additional security 
groups by Jclouds.
+        template.getOptions().as(TemplateOptions.class).inboundPorts();
 
         if (iaasProvider.getProperty(CloudControllerConstants.SECURITY_GROUPS) 
!= null) {
-            template.getOptions()
-                    .as(NovaTemplateOptions.class)
-                    .securityGroupNames(
-                            
iaasProvider.getProperty(CloudControllerConstants.SECURITY_GROUPS).split(
-                                    CloudControllerConstants.ENTRY_SEPARATOR));
+            
template.getOptions().as(NovaTemplateOptions.class).securityGroupNames(
+                    
iaasProvider.getProperty(CloudControllerConstants.SECURITY_GROUPS)
+                            .split(CloudControllerConstants.ENTRY_SEPARATOR));
         }
 
         if (iaasProvider.getProperty(CloudControllerConstants.KEY_PAIR) != 
null) {
@@ -168,10 +151,10 @@ public class OpenstackIaas extends JcloudsIaas {
         }
 
         //TODO
-//             if (iaas.getProperty(CloudControllerConstants.HOST) != null) {
-//            template.getOptions().as(NovaTemplateOptions.class)
-//                    .(CloudControllerConstants.HOST);
-//        }
+        //             if (iaas.getProperty(CloudControllerConstants.HOST) != 
null) {
+        //            template.getOptions().as(NovaTemplateOptions.class)
+        //                    .(CloudControllerConstants.HOST);
+        //        }
 
         // set Template
         iaasProvider.setTemplate(template);
@@ -185,33 +168,20 @@ public class OpenstackIaas extends JcloudsIaas {
     }
 
     @Override
-    public synchronized boolean createKeyPairFromPublicKey(String region, 
String keyPairName,
-                                                           String publicKey) {
-
+    public synchronized boolean createKeyPairFromPublicKey(String region, 
String keyPairName, String publicKey) {
         IaasProvider iaasInfo = getIaasProvider();
-
-        String openstackNovaMsg = " Openstack-nova. Region: " + region
-                + " - Name: ";
-
-        ComputeServiceContext context = iaasInfo.getComputeService()
-                .getContext();
+        String openstackNovaMsg = " Openstack-nova. Region: " + region + " - 
Name: ";
+        ComputeServiceContext context = 
iaasInfo.getComputeService().getContext();
         NovaApi novaApi = context.unwrapApi(NovaApi.class);
         KeyPairApi api = novaApi.getKeyPairExtensionForZone(region).get();
-
         KeyPair keyPair = api.createWithPublicKey(keyPairName, publicKey);
-
         if (keyPair != null) {
-
-            iaasInfo.getTemplate().getOptions().as(NovaTemplateOptions.class)
-                    .keyPairName(keyPair.getName());
-
+            
iaasInfo.getTemplate().getOptions().as(NovaTemplateOptions.class).keyPairName(keyPair.getName());
             log.info(SUCCESSFUL_LOG_LINE + openstackNovaMsg + 
keyPair.getName());
             return true;
         }
-
         log.error(FAILED_LOG_LINE + openstackNovaMsg);
         return false;
-
     }
 
     @Override
@@ -236,13 +206,11 @@ public class OpenstackIaas extends JcloudsIaas {
 
         // jclouds' zone = region in openstack
         if (region == null || iaasInfo == null) {
-            String msg =
-                    "Region or IaaSProvider is null: region: " + region + " - 
IaaSProvider: " +
-                            iaasInfo;
+            String msg = "Region or IaaSProvider is null: region: " + region + 
" - IaaSProvider: " +
+                    iaasInfo;
             log.error(msg);
             throw new InvalidRegionException(msg);
         }
-
         ComputeServiceContext context = 
iaasInfo.getComputeService().getContext();
         NovaApi novaApi = context.unwrapApi(NovaApi.class);
         Set<String> zones = novaApi.getConfiguredZones();
@@ -254,7 +222,6 @@ public class OpenstackIaas extends JcloudsIaas {
                 return true;
             }
         }
-
         String msg = "Invalid region: " + region + " in the iaas: " + 
iaasInfo.getType();
         log.error(msg);
         throw new InvalidRegionException(msg);
@@ -275,7 +242,6 @@ public class OpenstackIaas extends JcloudsIaas {
         NovaApi novaApi = context.unwrapApi(NovaApi.class);
         Optional<? extends AvailabilityZoneApi> availabilityZoneApi = 
novaApi.getAvailabilityZoneApi(region);
         for (AvailabilityZone z : availabilityZoneApi.get().list()) {
-
             if (zone.equalsIgnoreCase(z.getName())) {
                 if (log.isDebugEnabled()) {
                     log.debug("Found a matching availability zone: " + zone);
@@ -283,19 +249,18 @@ public class OpenstackIaas extends JcloudsIaas {
                 return true;
             }
         }
-
         String msg = "Invalid zone: " + zone + " in the region: " + region + " 
and of the iaas: " + iaasInfo.getType();
         log.error(msg);
         throw new InvalidZoneException(msg);
-
     }
 
     @Override
     public boolean isValidHost(String zone, String host) throws 
InvalidHostException {
         IaasProvider iaasInfo = getIaasProvider();
-
         if (host == null || zone == null || iaasInfo == null) {
-            String msg = String.format("Host or Zone or IaaSProvider is null: 
host: %s - zone: %s - IaaSProvider: %s", host, zone, iaasInfo);
+            String msg = String
+                    .format("Host or Zone or IaaSProvider is null: host: %s - 
zone: %s - IaaSProvider: %s", host, zone,
+                            iaasInfo);
             log.error(msg);
             throw new InvalidHostException(msg);
         }
@@ -312,8 +277,8 @@ public class OpenstackIaas extends JcloudsIaas {
                 }
             }
         }
-
-        String msg = String.format("Invalid host: %s in the zone: %s and of 
the iaas: %s", host, zone, iaasInfo.getType());
+        String msg = String
+                .format("Invalid host: %s in the zone: %s and of the iaas: 
%s", host, zone, iaasInfo.getType());
         log.error(msg);
         throw new InvalidHostException(msg);
     }
@@ -326,21 +291,17 @@ public class OpenstackIaas extends JcloudsIaas {
     @Override
     public String createVolume(int sizeGB, String snapshotId) {
         IaasProvider iaasInfo = getIaasProvider();
-
         if (iaasInfo == null) {
             log.fatal(String.format("Cannot create a new volume with snapshot 
ID : %s", snapshotId));
             return null;
         }
-
         String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
         String zone = ComputeServiceBuilderUtil.extractZone(iaasInfo);
-
         if (region == null) {
             log.fatal(String.format("Cannot create a new volume. Extracted 
region is null for Iaas : %s", iaasInfo));
             return null;
         }
         ComputeServiceContext context = 
iaasInfo.getComputeService().getContext();
-
         NovaApi novaApi = context.unwrapApi(NovaApi.class);
         VolumeApi volumeApi = novaApi.getVolumeExtensionForZone(region).get();
         Volume volume;
@@ -353,11 +314,13 @@ public class OpenstackIaas extends JcloudsIaas {
             if (log.isDebugEnabled()) {
                 log.info("Creating a volume in the zone " + zone + " from the 
shanpshot " + snapshotId);
             }
-            volume = volumeApi.create(sizeGB, 
CreateVolumeOptions.Builder.availabilityZone(zone).snapshotId(snapshotId));
+            volume = volumeApi
+                    .create(sizeGB, 
CreateVolumeOptions.Builder.availabilityZone(zone).snapshotId(snapshotId));
         }
 
         if (volume == null) {
-            log.fatal(String.format("Volume creation was unsuccessful. 
[region] : %s [zone] : %s of Iaas : %s", region, zone, iaasInfo));
+            log.fatal(String.format("Volume creation was unsuccessful. 
[region] : %s [zone] : %s of Iaas : %s", region,
+                    zone, iaasInfo));
             return null;
         }
 
@@ -366,7 +329,8 @@ public class OpenstackIaas extends JcloudsIaas {
         Volume.Status volumeStatus = this.getVolumeStatus(volumeApi, volumeId);
 
         if(!(volumeStatus == Volume.Status.AVAILABLE || volumeStatus == 
Volume.Status.CREATING)){
-            log.error(String.format("Error while creating [volume id] %s. 
Volume status is %s", volumeId, volumeStatus));
+            log.error(String.format("Error while creating [volume id] %s. 
Volume status is %s", volumeId,
+            volumeStatus));
             return volumeId;
         }
         try {
@@ -378,11 +342,14 @@ public class OpenstackIaas extends JcloudsIaas {
             return volumeId;
         }
         */
-        log.info(String.format("Successfully created a new volume [id]: %s in 
[region] : %s [zone] : %s of Iaas : %s [Volume ID]%s", volume.getId(), region, 
zone, iaasInfo, volume.getId()));
+        log.info(String.format(
+                "Successfully created a new volume [id]: %s in [region] : %s 
[zone] : %s of Iaas : %s [Volume ID]%s",
+                volume.getId(), region, zone, iaasInfo, volume.getId()));
         return volumeId;
     }
 
-    private boolean waitForStatus(String volumeId, Volume.Status 
expectedStatus, int timeoutInMins) throws TimeoutException {
+    private boolean waitForStatus(String volumeId, Volume.Status 
expectedStatus, int timeoutInMins)
+            throws TimeoutException {
         int timeout = 1000 * 60 * timeoutInMins;
         long timout = System.currentTimeMillis() + timeout;
 
@@ -396,7 +363,8 @@ public class OpenstackIaas extends JcloudsIaas {
         while (volumeStatus != expectedStatus) {
             try {
                 if (log.isDebugEnabled()) {
-                    log.debug(String.format("Volume %s is still NOT in %s. 
Current State=%s", volumeId, expectedStatus, volumeStatus));
+                    log.debug(String.format("Volume %s is still NOT in %s. 
Current State=%s", volumeId, expectedStatus,
+                            volumeStatus));
                 }
                 if (volumeStatus == Volume.Status.ERROR) {
                     log.error("Volume " + volumeId + " is in state ERROR");
@@ -414,36 +382,30 @@ public class OpenstackIaas extends JcloudsIaas {
         if (log.isDebugEnabled()) {
             log.debug(String.format("Volume %s status became %s", volumeId, 
expectedStatus));
         }
-
         return true;
     }
 
     @Override
     public String attachVolume(String instanceId, String volumeId, String 
deviceName) {
         IaasProvider iaasInfo = getIaasProvider();
-
         if (StringUtils.isEmpty(volumeId)) {
             log.error("Volume provided to attach can not be null");
         }
-
         if (StringUtils.isEmpty(instanceId)) {
             log.error("Instance provided to attach can not be null");
         }
-
-        ComputeServiceContext context = iaasInfo.getComputeService()
-                .getContext();
+        ComputeServiceContext context = 
iaasInfo.getComputeService().getContext();
         String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
         String device = deviceName == null ? "/dev/vdc" : deviceName;
-
         if (region == null) {
-            log.fatal(String.format("Cannot attach the volume [id]: %s. 
Extracted region is null for Iaas : %s", volumeId, iaasInfo));
+            log.fatal(
+                    String.format("Cannot attach the volume [id]: %s. 
Extracted region is null for Iaas : %s", volumeId,
+                            iaasInfo));
             return null;
         }
-
         NovaApi novaApi = context.unwrapApi(NovaApi.class);
         VolumeApi volumeApi = novaApi.getVolumeExtensionForZone(region).get();
         VolumeAttachmentApi volumeAttachmentApi = 
novaApi.getVolumeAttachmentExtensionForZone(region).get();
-
         Volume.Status volumeStatus = this.getVolumeStatus(volumeApi, volumeId);
 
         if (log.isDebugEnabled()) {
@@ -464,26 +426,26 @@ public class OpenstackIaas extends JcloudsIaas {
 
         VolumeAttachment attachment = null;
         if (volumeBecameAvailable) {
-
-            attachment = 
volumeAttachmentApi.attachVolumeToServerAsDevice(volumeId, 
removeRegionPrefix(instanceId), device);
-
+            attachment = volumeAttachmentApi
+                    .attachVolumeToServerAsDevice(volumeId, 
removeRegionPrefix(instanceId), device);
             try {
                 volumeBecameAttached = waitForStatus(volumeId, 
Volume.Status.IN_USE, 2);
             } catch (TimeoutException e) {
                 log.error("[Volume ID] " + volumeId + "did not become IN_USE 
within expected timeout");
             }
         }
-
         if (attachment == null) {
-            log.fatal(String.format("Volume [id]: %s attachment for instance 
[id]: %s was unsuccessful. [region] : %s of Iaas : %s", volumeId, instanceId, 
region, iaasInfo));
+            log.fatal(String.format(
+                    "Volume [id]: %s attachment for instance [id]: %s was 
unsuccessful. [region] : %s of Iaas : %s",
+                    volumeId, instanceId, region, iaasInfo));
             return null;
         }
-
         if (!volumeBecameAttached) {
             log.error(String.format("[Volume ID] %s attachment is called, but 
not yet became attached", volumeId));
         }
-
-        log.info(String.format("Volume [id]: %s attachment for instance [id]: 
%s was successful [status]: Attaching. [region] : %s of Iaas : %s", volumeId, 
instanceId, region, iaasInfo));
+        log.info(String.format(
+                "Volume [id]: %s attachment for instance [id]: %s was 
successful [status]: Attaching. [region] : %s "
+                        + "of Iaas : %s", volumeId, instanceId, region, 
iaasInfo));
         return "Attaching";
     }
 
@@ -499,18 +461,15 @@ public class OpenstackIaas extends JcloudsIaas {
     @Override
     public void detachVolume(String instanceId, String volumeId) {
         IaasProvider iaasInfo = getIaasProvider();
-
-        ComputeServiceContext context = iaasInfo.getComputeService()
-                .getContext();
-
+        ComputeServiceContext context = 
iaasInfo.getComputeService().getContext();
         String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
-
-
         //NovaApi novaApi = context.unwrapApi(NovaApi.class);
         //VolumeApi api = novaApi.getVolumeExtensionForZone(region).get();
 
         if (region == null) {
-            log.fatal(String.format("Cannot detach the volume [id]: %s from 
the instance [id]: %s. Extracted region is null for Iaas : %s", volumeId, 
instanceId, iaasInfo));
+            log.fatal(String.format(
+                    "Cannot detach the volume [id]: %s from the instance [id]: 
%s. Extracted region is null for Iaas "
+                            + ": %s", volumeId, instanceId, iaasInfo));
             return;
         }
         if (log.isDebugEnabled()) {
@@ -522,26 +481,27 @@ public class OpenstackIaas extends JcloudsIaas {
         VolumeApi volumeApi = novaApi.getVolumeExtensionForZone(region).get();
 
         if (attachmentApiapi.detachVolumeFromServer(volumeId, 
removeRegionPrefix(instanceId))) {
-            log.info(String.format("Detachment of Volume [id]: %s from 
instance [id]: %s was successful. [region] : %s of Iaas : %s", volumeId, 
instanceId, region, iaasInfo));
+            log.info(String.format(
+                    "Detachment of Volume [id]: %s from instance [id]: %s was 
successful. [region] : %s of Iaas : %s",
+                    volumeId, instanceId, region, iaasInfo));
         } else {
-            log.error(String.format("Detachment of Volume [id]: %s from 
instance [id]: %s was unsuccessful. [region] : %s [volume Status] : %s", 
volumeId, instanceId, region, getVolumeStatus(volumeApi, volumeId)));
+            log.error(String.format(
+                    "Detachment of Volume [id]: %s from instance [id]: %s was 
unsuccessful. [region] : %s [volume "
+                            + "Status] : %s", volumeId, instanceId, region, 
getVolumeStatus(volumeApi, volumeId)));
         }
     }
 
     @Override
     public void deleteVolume(String volumeId) {
         IaasProvider iaasInfo = getIaasProvider();
-
-        ComputeServiceContext context = iaasInfo.getComputeService()
-                .getContext();
-
+        ComputeServiceContext context = 
iaasInfo.getComputeService().getContext();
         String region = ComputeServiceBuilderUtil.extractRegion(iaasInfo);
         NovaApi novaApi = context.unwrapApi(NovaApi.class);
         VolumeApi api = novaApi.getVolumeExtensionForZone(region).get();
-
-
         if (region == null) {
-            log.fatal(String.format("Cannot delete the volume [id]: %s. 
Extracted region is null for Iaas : %s", volumeId, iaasInfo));
+            log.fatal(
+                    String.format("Cannot delete the volume [id]: %s. 
Extracted region is null for Iaas : %s", volumeId,
+                            iaasInfo));
             return;
         }
 
@@ -550,9 +510,7 @@ public class OpenstackIaas extends JcloudsIaas {
             log.warn(String.format("Could not remove volume [id] %s since 
volume does not exist", volumeId));
             return;
         }
-
         Volume.Status volumeStatus = volume.getStatus();
-
         if (volumeStatus == Volume.Status.IN_USE) {
             try {
                 waitForStatus(volumeId, Volume.Status.AVAILABLE, 2);
@@ -560,16 +518,20 @@ public class OpenstackIaas extends JcloudsIaas {
                 //Timeout Exception is occurred if the instance did not become 
available withing expected time period.
                 //Hence volume will not be deleted.
 
-                log.error("[Volume ID] " + volumeId + "did not become 
AVAILABLE within expected timeout, hence returning without deleting the 
volume");
+                log.error("[Volume ID] " + volumeId
+                        + "did not become AVAILABLE within expected timeout, 
hence returning without deleting the "
+                        + "volume");
                 return;
             }
         }
-
         // Coming here means either AVAILABLE or ERROR
         if (api.delete(volumeId)) {
-            log.info(String.format("Deletion of Volume [id]: %s was 
successful. [region] : %s of Iaas : %s", volumeId, region, iaasInfo));
+            log.info(String.format("Deletion of Volume [id]: %s was 
successful. [region] : %s of Iaas : %s", volumeId,
+                    region, iaasInfo));
         } else {
-            log.error(String.format("Deletion of Volume [id]: %s was 
unsuccessful. [region] : %s of Iaas : %s", volumeId, region, iaasInfo));
+            log.error(
+                    String.format("Deletion of Volume [id]: %s was 
unsuccessful. [region] : %s of Iaas : %s", volumeId,
+                            region, iaasInfo));
         }
     }
 
@@ -583,7 +545,6 @@ public class OpenstackIaas extends JcloudsIaas {
         if (volume != null) {
             return volume.getStatus();
         }
-
         return null;
     }
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/02d01071/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
index a8077b8..ec212cc 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/openstack/OpenstackPartitionValidator.java
@@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.domain.IaasProvider;
 import org.apache.stratos.cloud.controller.domain.Partition;
-import 
org.apache.stratos.cloud.controller.exception.InvalidIaasProviderException;
 import org.apache.stratos.cloud.controller.exception.InvalidPartitionException;
 import org.apache.stratos.cloud.controller.iaases.Iaas;
 import org.apache.stratos.cloud.controller.iaases.PartitionValidator;
@@ -32,14 +31,12 @@ import org.apache.stratos.cloud.controller.util.Scope;
 
 import java.util.Properties;
 
-
 /**
  * The Openstack Nova {@link 
org.apache.stratos.cloud.controller.iaases.PartitionValidator} implementation.
  */
 public class OpenstackPartitionValidator implements PartitionValidator {
 
     private static final Log log = 
LogFactory.getLog(OpenstackPartitionValidator.class);
-
     private IaasProvider iaasProvider;
     private Iaas iaas;
 
@@ -49,65 +46,44 @@ public class OpenstackPartitionValidator implements 
PartitionValidator {
             // validate the existence of the zone and hosts properties.
             if (properties.containsKey(Scope.REGION.toString())) {
                 String region = 
properties.getProperty(Scope.REGION.toString());
-
                 if (iaasProvider.getImage() != null && 
!iaasProvider.getImage().contains(region)) {
-
-                    String msg = "Invalid partition detected, invalid region: 
[partition-id] " + partition.getId() +
-                            " [region] " + region;
-                    log.error(msg);
-                    throw new InvalidPartitionException(msg);
+                    String message = String
+                            .format("Invalid partition detected [partition-id] 
%s, [region] %s. Image ID does not "
+                                            + "contain region [image] %s",
+                                    partition.getId(), region, 
iaasProvider.getImage());
+                    log.error(message);
+                    throw new InvalidPartitionException(message);
                 }
-
                 iaas.isValidRegion(region);
-
                 IaasProvider updatedIaasProvider = new 
IaasProvider(iaasProvider);
-                Iaas updatedIaas = 
CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
-                updatedIaas.setIaasProvider(updatedIaasProvider);
-
                 if (properties.containsKey(Scope.ZONE.toString())) {
                     String zone = 
properties.getProperty(Scope.ZONE.toString());
                     iaas.isValidZone(region, zone);
-
-                    
updatedIaasProvider.setProperty(CloudControllerConstants.AVAILABILITY_ZONE, 
zone);
-                    updatedIaas = 
CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
-                    updatedIaas.setIaasProvider(updatedIaasProvider);
                 }
-
                 updateOtherProperties(updatedIaasProvider, properties);
+                Iaas updatedIaas = updatedIaasProvider.buildIaas();
+                updatedIaas.setIaasProvider(updatedIaasProvider);
                 return updatedIaasProvider;
             } else {
-
                 return iaasProvider;
             }
         } catch (Exception e) {
-            String msg = "Invalid partition detected: [partition-id] " + 
partition.getId() + e.getMessage();
-            log.error(msg, e);
-            throw new InvalidPartitionException(msg, e);
+            String message = String.format("Invalid partition detected: 
[partition-id] %s", partition.getId());
+            log.error(message, e);
+            throw new InvalidPartitionException(message, e);
         }
     }
 
-    private void updateOtherProperties(IaasProvider updatedIaasProvider,
-                                       Properties properties) {
-        Iaas updatedIaas;
-        try {
-            updatedIaas = 
CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
-
-            for (Object property : properties.keySet()) {
-                if (property instanceof String) {
-                    String key = (String) property;
-                    updatedIaasProvider.setProperty(key,
-                            properties.getProperty(key));
-                    if (log.isDebugEnabled()) {
-                        log.debug("Added property " + key
-                                + " to the IaasProvider.");
-                    }
+    private void updateOtherProperties(IaasProvider updatedIaasProvider, 
Properties properties) {
+        for (Object property : properties.keySet()) {
+            if (property instanceof String) {
+                String key = (String) property;
+                updatedIaasProvider.setProperty(key, 
properties.getProperty(key));
+                if (log.isDebugEnabled()) {
+                    log.debug(String.format("Added [property] %s to the 
IaasProvider.", key));
                 }
             }
-            updatedIaas = 
CloudControllerServiceUtil.buildIaas(updatedIaasProvider);
-            updatedIaas.setIaasProvider(updatedIaasProvider);
-        } catch (InvalidIaasProviderException ignore) {
         }
-
     }
 
     @Override
@@ -115,5 +91,4 @@ public class OpenstackPartitionValidator implements 
PartitionValidator {
         this.iaasProvider = iaas;
         this.iaas = iaas.getIaas();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/stratos/blob/02d01071/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
index dc365dd..57f8ff4 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceImpl.java
@@ -68,8 +68,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
 
     }
 
-    public boolean addCartridge(Cartridge cartridgeConfig) throws 
InvalidCartridgeDefinitionException,
-            InvalidIaasProviderException, CartridgeAlreadyExistsException {
+    public boolean addCartridge(Cartridge cartridgeConfig)
+            throws InvalidCartridgeDefinitionException, 
InvalidIaasProviderException, CartridgeAlreadyExistsException {
 
         handleNullObject(cartridgeConfig, "Cartridge definition is null");
 
@@ -111,9 +111,9 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean updateCartridge(Cartridge cartridge) throws 
InvalidCartridgeDefinitionException,
-            InvalidIaasProviderException,
-            CartridgeDefinitionNotExistsException {
+    public boolean updateCartridge(Cartridge cartridge)
+            throws InvalidCartridgeDefinitionException, 
InvalidIaasProviderException,
+                   CartridgeDefinitionNotExistsException {
 
         handleNullObject(cartridge, "Cartridge definition is null");
 
@@ -155,12 +155,13 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         return true;
     }
 
-    private void copyIaasProviders(Cartridge destCartridge,
-                                   Cartridge sourceCartridge) {
+    private void copyIaasProviders(Cartridge destCartridge, Cartridge 
sourceCartridge) {
 
-        List<IaasProvider> newIaasProviders = 
CloudControllerContext.getInstance().getIaasProviders(destCartridge.getType());
+        List<IaasProvider> newIaasProviders = 
CloudControllerContext.getInstance()
+                .getIaasProviders(destCartridge.getType());
 
-        Map<String, IaasProvider> iaasProviderMap = 
CloudControllerContext.getInstance().getPartitionToIaasProvider(sourceCartridge.getType());
+        Map<String, IaasProvider> iaasProviderMap = 
CloudControllerContext.getInstance()
+                .getPartitionToIaasProvider(sourceCartridge.getType());
 
         if (iaasProviderMap != null) {
             for (Entry<String, IaasProvider> entry : 
iaasProviderMap.entrySet()) {
@@ -330,8 +331,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         return memberContextsArray;
     }
 
-    public MemberContext startInstance(InstanceContext instanceContext) throws
-            CartridgeNotFoundException, InvalidIaasProviderException, 
CloudControllerException {
+    public MemberContext startInstance(InstanceContext instanceContext)
+            throws CartridgeNotFoundException, InvalidIaasProviderException, 
CloudControllerException {
 
         try {
             // Validate instance context
@@ -348,7 +349,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             String partitionId = partition.getId();
             String clusterId = instanceContext.getClusterId();
             ClusterContext clusterContext = 
CloudControllerContext.getInstance().getClusterContext(clusterId);
-            handleNullObject(clusterContext, "Could not start instance, 
cluster context not found: [cluster-id] " + clusterId);
+            handleNullObject(clusterContext,
+                    "Could not start instance, cluster context not found: 
[cluster-id] " + clusterId);
 
             // Validate cartridge
             String cartridgeType = clusterContext.getCartridgeType();
@@ -360,12 +362,14 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             }
 
             // Validate iaas provider
-            IaasProvider iaasProvider = 
CloudControllerContext.getInstance().getIaasProviderOfPartition(cartridge.getType(),
 partitionId);
+            IaasProvider iaasProvider = CloudControllerContext.getInstance()
+                    .getIaasProviderOfPartition(cartridge.getType(), 
partitionId);
             if (iaasProvider == null) {
                 String msg = String.format("Could not start instance, " +
                                 "IaaS provider not found in cartridge %s for 
partition %s, " +
                                 "partitions found: %s ", cartridgeType, 
partitionId,
-                        
CloudControllerContext.getInstance().getPartitionToIaasProvider(cartridge.getType()).keySet().toString());
+                        
CloudControllerContext.getInstance().getPartitionToIaasProvider(cartridge.getType()).keySet()
+                                .toString());
                 log.error(msg);
                 throw new InvalidIaasProviderException(msg);
             }
@@ -376,7 +380,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             // Create member context
             String applicationId = clusterContext.getApplicationId();
             MemberContext memberContext = createMemberContext(applicationId, 
cartridgeType, memberId,
-                    
CloudControllerUtil.getLoadBalancingIPTypeEnumFromString(cartridge.getLoadBalancingIPType()),
 instanceContext);
+                    
CloudControllerUtil.getLoadBalancingIPTypeEnumFromString(cartridge.getLoadBalancingIPType()),
+                    instanceContext);
 
             // Prepare payload
             StringBuilder payload = new 
StringBuilder(clusterContext.getPayload());
@@ -390,16 +395,13 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
 
             if (memberContext.getProperties() != null) {
                 org.apache.stratos.common.Properties properties = 
memberContext.getProperties();
-                if (properties != null) {
-                    for (Property prop : properties.getProperties()) {
-                        addToPayload(payload, prop.getName(), 
String.valueOf(prop.getValue()));
-                    }
+                for (Property prop : properties.getProperties()) {
+                    addToPayload(payload, prop.getName(), 
String.valueOf(prop.getValue()));
                 }
             }
 
-            NetworkPartition networkPartition =
-                    
CloudControllerContext.getInstance().getNetworkPartition(memberContext.getNetworkPartitionId());
-
+            NetworkPartition networkPartition = 
CloudControllerContext.getInstance()
+                    
.getNetworkPartition(memberContext.getNetworkPartitionId());
 
             if (networkPartition.getProperties() != null) {
                 if (networkPartition.getProperties().getProperties() != null) {
@@ -456,8 +458,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
 
             // Start instance in a new thread
             if (log.isDebugEnabled()) {
-                log.debug(String.format("Starting instance creator thread: 
[cluster] %s [cluster-instance] %s " +
-                                "[member] %s [application-id] %s", 
instanceContext.getClusterId(),
+                log.debug(String.format("Starting instance creator thread: 
[cluster] %s [cluster-instance] %s "
+                                + "[member] %s [application-id] %s", 
instanceContext.getClusterId(),
                         instanceContext.getClusterInstanceId(), memberId, 
applicationId));
             }
             executorService.execute(new InstanceCreator(memberContext, 
iaasProvider, payload.toString().getBytes()));
@@ -472,9 +474,9 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     private MemberContext createMemberContext(String applicationId, String 
cartridgeType, String memberId,
-                                              LoadBalancingIPType 
loadBalancingIPType, InstanceContext instanceContext) {
-        MemberContext memberContext = new MemberContext(
-                applicationId, cartridgeType, instanceContext.getClusterId(), 
memberId);
+            LoadBalancingIPType loadBalancingIPType, InstanceContext 
instanceContext) {
+        MemberContext memberContext = new MemberContext(applicationId, 
cartridgeType, instanceContext.getClusterId(),
+                memberId);
 
         
memberContext.setClusterInstanceId(instanceContext.getClusterInstanceId());
         
memberContext.setNetworkPartitionId(instanceContext.getNetworkPartitionId());
@@ -489,8 +491,7 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         return memberContext;
     }
 
-    private Volume createVolumeAndSetInClusterContext(Volume volume,
-                                                      IaasProvider 
iaasProvider) {
+    private Volume createVolumeAndSetInClusterContext(Volume volume, 
IaasProvider iaasProvider) {
         // iaas cannot be null at this state #startInstance method
         Iaas iaas = iaasProvider.getIaas();
         int sizeGB = volume.getSize();
@@ -498,7 +499,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         if (StringUtils.isNotEmpty(volume.getVolumeId())) {
             // volumeID is specified, so not creating additional volumes
             if (log.isDebugEnabled()) {
-                log.debug("Volume creation is skipping since a volume ID is 
specified. [Volume ID] " + volume.getVolumeId());
+                log.debug("Volume creation is skipping since a volume ID is 
specified. [Volume ID] " + volume
+                        .getVolumeId());
             }
             volume.setId(volume.getVolumeId());
         } else {
@@ -511,7 +513,6 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         return volume;
     }
 
-
     private StringBuilder getPersistencePayload(ClusterContext ctx, Iaas iaas) 
{
         StringBuilder persistencePayload = new StringBuilder();
         if (isPersistenceMappingAvailable(ctx)) {
@@ -573,8 +574,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         if (memberTerminated) {
             log.info(String.format("Member terminated [member-id] %s ", 
memberId));
         } else {
-            log.warn(String.format("Stratos could not terminate the member 
[member-id] %s. This may due to a issue " +
-                    "in the underlying IaaS, Please terminate the member 
manually if it is available", memberId));
+            log.warn(String.format("Stratos could not terminate the member 
[member-id] %s. This may due to a issue "
+                    + "in the underlying IaaS, Please terminate the member 
manually if it is available", memberId));
             MemberContext memberContext = 
CloudControllerContext.getInstance().getMemberContextOfMemberId(memberId);
             
CloudControllerServiceUtil.executeMemberTerminationPostProcess(memberContext);
         }
@@ -582,8 +583,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean terminateInstance(String memberId) throws 
InvalidMemberException,
-            InvalidCartridgeTypeException, CloudControllerException {
+    public boolean terminateInstance(String memberId)
+            throws InvalidMemberException, InvalidCartridgeTypeException, 
CloudControllerException {
 
         try {
             handleNullObject(memberId, "Could not terminate instance, member 
id is null.");
@@ -597,10 +598,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
 
             if (StringUtils.isBlank(memberContext.getInstanceId())) {
                 if (log.isErrorEnabled()) {
-                    log.error(String.format(
-                            "Could not terminate instance, instance id is 
blank: [member-id] %s " +
-                                    ", removing member from topology...",
-                            memberContext.getMemberId()));
+                    log.error(String.format("Could not terminate instance, 
instance id is blank: [member-id] %s "
+                                    + ", removing member from topology...", 
memberContext.getMemberId()));
                 }
                 
CloudControllerServiceUtil.executeMemberTerminationPostProcess(memberContext);
             }
@@ -608,7 +607,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             // check if status == active, if true, then this is a termination 
on member faulty
             TopologyManager.acquireWriteLock();
             Topology topology = TopologyManager.getTopology();
-            org.apache.stratos.messaging.domain.topology.Service service = 
topology.getService(memberContext.getCartridgeType());
+            org.apache.stratos.messaging.domain.topology.Service service = 
topology
+                    .getService(memberContext.getCartridgeType());
 
             if (service != null) {
                 Cluster cluster = 
service.getCluster(memberContext.getClusterId());
@@ -618,11 +618,13 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
 
                         // check if ready to shutdown member is expired and 
send
                         // member terminated if it is.
-                        if (isMemberExpired(member, 
memberContext.getObsoleteInitTime(), memberContext.getObsoleteExpiryTime())) {
+                        if (isMemberExpired(member, 
memberContext.getObsoleteInitTime(),
+                                memberContext.getObsoleteExpiryTime())) {
                             if (log.isInfoEnabled()) {
                                 log.info(String.format(
-                                        "Member pending termination in 
ReadyToShutdown state exceeded expiry time. " +
-                                                "This member has to be 
manually deleted: %s", memberContext.getMemberId()));
+                                        "Member pending termination in 
ReadyToShutdown state exceeded expiry time. "
+                                                + "This member has to be 
manually deleted: %s",
+                                        memberContext.getMemberId()));
                             }
 
                             
CloudControllerServiceUtil.executeMemberTerminationPostProcess(memberContext);
@@ -674,12 +676,12 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     @Override
     public boolean terminateInstances(String clusterId) throws 
InvalidClusterException {
 
-        log.info("Starting to terminate all instances of cluster : "
-                + clusterId);
+        log.info("Starting to terminate all instances of cluster : " + 
clusterId);
 
         handleNullObject(clusterId, "Instance termination failed. Cluster id 
is null.");
 
-        List<MemberContext> memberContexts = 
CloudControllerContext.getInstance().getMemberContextsOfClusterId(clusterId);
+        List<MemberContext> memberContexts = 
CloudControllerContext.getInstance()
+                .getMemberContextsOfClusterId(clusterId);
         if (memberContexts == null) {
             String msg = "Instance termination failed. No members found for 
cluster id: " + clusterId;
             log.warn(msg);
@@ -693,8 +695,7 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean registerService(Registrant registrant)
-            throws CartridgeNotFoundException {
+    public boolean registerService(Registrant registrant) throws 
CartridgeNotFoundException {
 
         String cartridgeType = registrant.getCartridgeType();
         handleNullObject(cartridgeType, "Service registration failed, 
cartridge Type is null.");
@@ -771,9 +772,9 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         Cartridge cartridge = 
CloudControllerContext.getInstance().getCartridge(cartridgeType);
 
         if (cartridge == null) {
-            String msg =
-                    String.format("Service unregistration failed. No matching 
cartridge found: [cartridge-type] %s " +
-                            "[application-id] %s", cartridgeType, 
ctxt.getApplicationId());
+            String msg = String
+                    .format("Service unregistration failed. No matching 
cartridge found: [cartridge-type] %s "
+                            + "[application-id] %s", cartridgeType, 
ctxt.getApplicationId());
             log.error(msg);
             throw new UnregisteredClusterException(msg);
         }
@@ -783,8 +784,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             public void run() {
                 ClusterContext ctxt = 
CloudControllerContext.getInstance().getClusterContext(clusterId_);
                 if (ctxt == null) {
-                    String msg = String.format("Service unregistration failed. 
Cluster not found: [cluster-id] %s " +
-                            "[application-id] %s", clusterId_, 
ctxt.getApplicationId());
+                    String msg = String.format("Service unregistration failed. 
Cluster not found: [cluster-id] %s "
+                            + "[application-id] %s", clusterId_, 
ctxt.getApplicationId());
                     log.error(msg);
                     return;
                 }
@@ -813,8 +814,9 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                             terminateInstance(member.getMemberId());
                         } catch (Exception e) {
                             // we are not gonna stop the execution due to 
errors.
-                            log.warn((String.format("Instance termination 
failed of member [member-id] %s " +
-                                    "[application-id] %s", 
member.getMemberId(), ctxt.getApplicationId())), e);
+                            log.warn((String.format(
+                                    "Instance termination failed of member 
[member-id] %s " + "[application-id] %s",
+                                    member.getMemberId(), 
ctxt.getApplicationId())), e);
 
                         }
                     }
@@ -828,8 +830,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                     lock = 
CloudControllerContext.getInstance().acquireClusterContextWriteLock();
                     ClusterContext ctxt = 
CloudControllerContext.getInstance().getClusterContext(clusterId_);
                     if (ctxt == null) {
-                        String msg = String.format("Service unregistration 
failed. Cluster not found: [cluster-id] %s " +
-                                "[application-id] %s ", clusterId_, 
ctxt.getApplicationId());
+                        String msg = String.format("Service unregistration 
failed. Cluster not found: [cluster-id] %s "
+                                + "[application-id] %s ", clusterId_, 
ctxt.getApplicationId());
                         log.error(msg);
                         return;
                     }
@@ -858,12 +860,16 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                     try {
                         lock = 
CloudControllerContext.getInstance().acquireCartridgesWriteLock();
 
-                        Cartridge cartridge = 
CloudControllerContext.getInstance().getCartridge(ctxt.getCartridgeType());
-                        if (cartridge != null && 
CloudControllerContext.getInstance().getIaasProviders(cartridge.getType()) != 
null && ctxt.getVolumes() != null) {
+                        Cartridge cartridge = 
CloudControllerContext.getInstance()
+                                .getCartridge(ctxt.getCartridgeType());
+                        if (cartridge != null
+                                && 
CloudControllerContext.getInstance().getIaasProviders(cartridge.getType()) != 
null
+                                && ctxt.getVolumes() != null) {
                             for (Volume volume : ctxt.getVolumes()) {
                                 if (volume.getId() != null) {
                                     String iaasType = volume.getIaasType();
-                                    Iaas iaas = 
CloudControllerContext.getInstance().getIaasProvider(cartridge.getType(), 
iaasType).getIaas();
+                                    Iaas iaas = 
CloudControllerContext.getInstance()
+                                            
.getIaasProvider(cartridge.getType(), iaasType).getIaas();
                                     if (iaas != null) {
                                         try {
                                             // delete the volumes if remove on 
unsubscription is true.
@@ -873,9 +879,9 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                                             }
                                         } catch (Exception ignore) {
                                             if (log.isErrorEnabled()) {
-                                                
log.error((String.format("Error while deleting volume [id] %s " +
-                                                                
"[application-id]", volume.getId(), ctxt.getApplicationId())),
-                                                        ignore);
+                                                
log.error((String.format("Error while deleting volume [id] %s "
+                                                                + 
"[application-id]", volume.getId(),
+                                                                
ctxt.getApplicationId())), ignore);
                                             }
                                         }
                                     }
@@ -903,7 +909,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     public boolean validateDeploymentPolicyNetworkPartition(String 
cartridgeType, String networkPartitionId)
             throws InvalidPartitionException, InvalidCartridgeTypeException {
 
-        NetworkPartition networkPartition = 
CloudControllerContext.getInstance().getNetworkPartition(networkPartitionId);
+        NetworkPartition networkPartition = 
CloudControllerContext.getInstance()
+                .getNetworkPartition(networkPartitionId);
         Lock lock = null;
         try {
             lock = 
CloudControllerContext.getInstance().acquireCartridgesWriteLock();
@@ -942,8 +949,7 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                 }
 
                 Callable<IaasProvider> worker = new 
PartitionValidatorCallable(partition, cartridge);
-                Future<IaasProvider> job = CloudControllerContext.getInstance()
-                        .getExecutorService().submit(worker);
+                Future<IaasProvider> job = 
CloudControllerContext.getInstance().getExecutorService().submit(worker);
                 jobList.put(partition.getId(), job);
             }
 
@@ -969,7 +975,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                                 "[cartridge-type] " + cartridgeType);
                     }
                 } catch (Exception e) {
-                    String message = "Could not cache partitions against the 
cartridge: [cartridge-type] " + cartridgeType;
+                    String message = "Could not cache partitions against the 
cartridge: [cartridge-type] "
+                            + cartridgeType;
                     log.error(message, e);
                     throw new InvalidPartitionException(message, e);
                 }
@@ -1032,8 +1039,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean createApplicationClusters(String appId, 
ApplicationClusterContext[] appClustersContexts) throws
-            ApplicationClusterRegistrationException {
+    public boolean createApplicationClusters(String appId, 
ApplicationClusterContext[] appClustersContexts)
+            throws ApplicationClusterRegistrationException {
         if (appClustersContexts == null || appClustersContexts.length == 0) {
             String errorMsg = "No application cluster information found, 
unable to create clusters: " +
                     "[application-id] " + appId;
@@ -1057,19 +1064,22 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                         for (int i = 0; i < dependencyClusterIDs.length; i++) {
 
                             List<String> accessUrlPerCluster = new ArrayList();
-                            Collection<ClusterPortMapping> clusterPortMappings 
=
-                                    
CloudControllerContext.getInstance().getClusterPortMappings(appId, clusterId);
+                            Collection<ClusterPortMapping> clusterPortMappings 
= CloudControllerContext.getInstance()
+                                    .getClusterPortMappings(appId, clusterId);
 
                             for (ClusterPortMapping clusterPortMapping : 
clusterPortMappings) {
                                 try {
                                     if (clusterPortMapping.isKubernetes()) {
-                                        // Using type URI since only http, 
https, ftp, file, jar protocols are supported in URL
-                                        URI accessUrl = new 
URI(clusterPortMapping.getProtocol(), null, appClusterCtxt.getHostName(),
+                                        // Using type URI since only http, 
https, ftp, file, jar protocols are
+                                        // supported in URL
+                                        URI accessUrl = new 
URI(clusterPortMapping.getProtocol(), null,
+                                                appClusterCtxt.getHostName(),
                                                 
clusterPortMapping.getKubernetesServicePort(), null, null, null);
                                         
accessUrlPerCluster.add(accessUrl.toString());
                                     } else {
-                                        URI accessUrl = new 
URI(clusterPortMapping.getProtocol(), null, appClusterCtxt.getHostName(),
-                                                
clusterPortMapping.getProxyPort(), null, null, null);
+                                        URI accessUrl = new 
URI(clusterPortMapping.getProtocol(), null,
+                                                appClusterCtxt.getHostName(), 
clusterPortMapping.getProxyPort(), null,
+                                                null, null);
                                         
accessUrlPerCluster.add(accessUrl.toString());
                                     }
                                 } catch (URISyntaxException e) {
@@ -1084,9 +1094,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             }
 
             for (ApplicationClusterContext appClusterCtxt : 
appClustersContexts) {
-                ClusterContext clusterContext = new ClusterContext(
-                        appId, appClusterCtxt.getCartridgeType(), 
appClusterCtxt.getClusterId(),
-                        appClusterCtxt.getTextPayload(), 
appClusterCtxt.getHostName(),
+                ClusterContext clusterContext = new ClusterContext(appId, 
appClusterCtxt.getCartridgeType(),
+                        appClusterCtxt.getClusterId(), 
appClusterCtxt.getTextPayload(), appClusterCtxt.getHostName(),
                         appClusterCtxt.isLbCluster(), 
appClusterCtxt.getProperties());
 
                 if (appClusterCtxt.isVolumeRequired()) {
@@ -1120,14 +1129,13 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         return true;
     }
 
-    public boolean createClusterInstance(String serviceType, String clusterId,
-                                         String alias, String instanceId, 
String partitionId,
-                                         String networkPartitionId) throws 
ClusterInstanceCreationException {
+    public boolean createClusterInstance(String serviceType, String clusterId, 
String alias, String instanceId,
+            String partitionId, String networkPartitionId) throws 
ClusterInstanceCreationException {
         Lock lock = null;
         try {
             lock = 
CloudControllerContext.getInstance().acquireClusterContextWriteLock();
-            TopologyBuilder.handleClusterInstanceCreated(serviceType, 
clusterId, alias,
-                    instanceId, partitionId, networkPartitionId);
+            TopologyBuilder.handleClusterInstanceCreated(serviceType, 
clusterId, alias, instanceId, partitionId,
+                    networkPartitionId);
 
             CloudControllerContext.getInstance().persist();
         } finally {
@@ -1144,27 +1152,26 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public KubernetesCluster getKubernetesCluster(String kubernetesClusterId) 
throws
-            NonExistingKubernetesClusterException {
+    public KubernetesCluster getKubernetesCluster(String kubernetesClusterId)
+            throws NonExistingKubernetesClusterException {
         return 
CloudControllerContext.getInstance().getKubernetesCluster(kubernetesClusterId);
     }
 
     @Override
-    public KubernetesMaster getMasterForKubernetesCluster(String 
kubernetesClusterId) throws
-            NonExistingKubernetesClusterException {
+    public KubernetesMaster getMasterForKubernetesCluster(String 
kubernetesClusterId)
+            throws NonExistingKubernetesClusterException {
         return 
CloudControllerContext.getInstance().getKubernetesMasterInGroup(kubernetesClusterId);
     }
 
     @Override
-    public KubernetesHost[] getHostsForKubernetesCluster(String 
kubernetesClusterId) throws
-            NonExistingKubernetesClusterException {
+    public KubernetesHost[] getHostsForKubernetesCluster(String 
kubernetesClusterId)
+            throws NonExistingKubernetesClusterException {
         return 
CloudControllerContext.getInstance().getKubernetesHostsInGroup(kubernetesClusterId);
     }
 
-
     @Override
-    public boolean addKubernetesCluster(KubernetesCluster kubernetesCluster) 
throws InvalidKubernetesClusterException,
-            KubernetesClusterAlreadyExistsException {
+    public boolean addKubernetesCluster(KubernetesCluster kubernetesCluster)
+            throws InvalidKubernetesClusterException, 
KubernetesClusterAlreadyExistsException {
         if (kubernetesCluster == null) {
             throw new InvalidKubernetesClusterException("Kubernetes cluster 
cannot be null");
         }
@@ -1204,7 +1211,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean updateKubernetesCluster(KubernetesCluster 
kubernetesCluster) throws InvalidKubernetesClusterException {
+    public boolean updateKubernetesCluster(KubernetesCluster kubernetesCluster)
+            throws InvalidKubernetesClusterException {
         if (kubernetesCluster == null) {
             throw new InvalidKubernetesClusterException("Kubernetes cluster 
cannot be null");
         }
@@ -1237,8 +1245,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean addKubernetesHost(String kubernetesClusterId, 
KubernetesHost kubernetesHost) throws
-            InvalidKubernetesHostException, 
NonExistingKubernetesClusterException {
+    public boolean addKubernetesHost(String kubernetesClusterId, 
KubernetesHost kubernetesHost)
+            throws InvalidKubernetesHostException, 
NonExistingKubernetesClusterException {
         if (kubernetesHost == null) {
             throw new InvalidKubernetesHostException("Kubernetes host cannot 
be null");
         }
@@ -1251,8 +1259,9 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             lock = 
CloudControllerContext.getInstance().acquireKubernetesClusterWriteLock();
 
             if (log.isInfoEnabled()) {
-                log.info(String.format("Adding kubernetes host for kubernetes 
cluster: [kubernetes-cluster-id] %s " +
-                        "[hostname] %s", kubernetesClusterId, 
kubernetesHost.getHostname()));
+                log.info(String.format(
+                        "Adding kubernetes host for kubernetes cluster: 
[kubernetes-cluster-id] %s " + "[hostname] %s",
+                        kubernetesClusterId, kubernetesHost.getHostname()));
             }
             CloudControllerUtil.validateKubernetesHost(kubernetesHost);
 
@@ -1263,21 +1272,23 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                 kubernetesHostArrayList = new ArrayList<KubernetesHost>();
             } else {
                 if 
(CloudControllerContext.getInstance().kubernetesHostExists(kubernetesHost.getHostId()))
 {
-                    throw new InvalidKubernetesHostException("Kubernetes host 
already exists: [hostname] " +
-                            kubernetesHost.getHostId());
+                    throw new InvalidKubernetesHostException(
+                            "Kubernetes host already exists: [hostname] " + 
kubernetesHost.getHostId());
                 }
-                kubernetesHostArrayList = new
-                        
ArrayList<KubernetesHost>(Arrays.asList(kubernetesCluster.getKubernetesHosts()));
+                kubernetesHostArrayList = new ArrayList<KubernetesHost>(
+                        Arrays.asList(kubernetesCluster.getKubernetesHosts()));
             }
             kubernetesHostArrayList.add(kubernetesHost);
 
             // Update information model
-            
kubernetesCluster.setKubernetesHosts(kubernetesHostArrayList.toArray(new 
KubernetesHost[kubernetesHostArrayList.size()]));
+            kubernetesCluster.setKubernetesHosts(
+                    kubernetesHostArrayList.toArray(new 
KubernetesHost[kubernetesHostArrayList.size()]));
             
CloudControllerContext.getInstance().updateKubernetesCluster(kubernetesCluster);
             CloudControllerContext.getInstance().persist();
 
             if (log.isInfoEnabled()) {
-                log.info(String.format("Kubernetes host added successfully: 
[id] %s", kubernetesCluster.getClusterId()));
+                log.info(
+                        String.format("Kubernetes host added successfully: 
[id] %s", kubernetesCluster.getClusterId()));
             }
 
             return true;
@@ -1335,11 +1346,13 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                 log.info("Removing Kubernetes Host: " + kubernetesHostId);
             }
             try {
-                KubernetesCluster kubernetesClusterStored = 
CloudControllerContext.getInstance().getKubernetesClusterContainingHost(kubernetesHostId);
+                KubernetesCluster kubernetesClusterStored = 
CloudControllerContext.getInstance()
+                        .getKubernetesClusterContainingHost(kubernetesHostId);
 
                 // Kubernetes master cannot be removed
                 if 
(kubernetesClusterStored.getKubernetesMaster().getHostId().equals(kubernetesHostId))
 {
-                    throw new NonExistingKubernetesHostException("Kubernetes 
master is not allowed to be removed [id] " + kubernetesHostId);
+                    throw new NonExistingKubernetesHostException(
+                            "Kubernetes master is not allowed to be removed 
[id] " + kubernetesHostId);
                 }
 
                 List<KubernetesHost> kubernetesHostList = new 
ArrayList<KubernetesHost>();
@@ -1350,7 +1363,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                 }
                 // member count will be equal only when host object was not 
found
                 if (kubernetesHostList.size() == 
kubernetesClusterStored.getKubernetesHosts().length) {
-                    throw new NonExistingKubernetesHostException("Kubernetes 
host not found for [id] " + kubernetesHostId);
+                    throw new NonExistingKubernetesHostException(
+                            "Kubernetes host not found for [id] " + 
kubernetesHostId);
                 }
                 KubernetesHost[] kubernetesHostsArray = new 
KubernetesHost[kubernetesHostList.size()];
                 kubernetesHostList.toArray(kubernetesHostsArray);
@@ -1386,7 +1400,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                 log.info("Updating Kubernetes master: " + kubernetesMaster);
             }
             try {
-                KubernetesCluster kubernetesClusterStored = 
CloudControllerContext.getInstance().getKubernetesClusterContainingHost(kubernetesMaster.getHostId());
+                KubernetesCluster kubernetesClusterStored = 
CloudControllerContext.getInstance()
+                        
.getKubernetesClusterContainingHost(kubernetesMaster.getHostId());
 
                 // Update information model
                 kubernetesClusterStored.setKubernetesMaster(kubernetesMaster);
@@ -1394,7 +1409,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                 CloudControllerContext.getInstance().persist();
 
                 if (log.isInfoEnabled()) {
-                    log.info(String.format("Kubernetes master updated 
successfully: [id] %s", kubernetesMaster.getHostId()));
+                    log.info(String.format("Kubernetes master updated 
successfully: [id] %s",
+                            kubernetesMaster.getHostId()));
                 }
 
                 return true;
@@ -1409,8 +1425,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean updateKubernetesHost(KubernetesHost kubernetesHost) throws
-            InvalidKubernetesHostException, NonExistingKubernetesHostException 
{
+    public boolean updateKubernetesHost(KubernetesHost kubernetesHost)
+            throws InvalidKubernetesHostException, 
NonExistingKubernetesHostException {
 
         Lock lock = null;
         try {
@@ -1421,7 +1437,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             }
 
             try {
-                KubernetesCluster kubernetesClusterStored = 
CloudControllerContext.getInstance().getKubernetesClusterContainingHost(kubernetesHost.getHostId());
+                KubernetesCluster kubernetesClusterStored = 
CloudControllerContext.getInstance()
+                        
.getKubernetesClusterContainingHost(kubernetesHost.getHostId());
                 KubernetesHost[] kubernetesHosts = 
kubernetesClusterStored.getKubernetesHosts();
                 for (int i = 0; i < kubernetesHosts.length; i++) {
                     if 
(kubernetesHosts[i].getHostId().equals(kubernetesHost.getHostId())) {
@@ -1429,7 +1446,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                         kubernetesHosts[i] = kubernetesHost;
 
                         if (log.isInfoEnabled()) {
-                            log.info(String.format("Kubernetes host updated 
successfully: [id] %s", kubernetesHost.getHostId()));
+                            log.info(String.format("Kubernetes host updated 
successfully: [id] %s",
+                                    kubernetesHost.getHostId()));
                         }
 
                         
CloudControllerContext.getInstance().updateKubernetesCluster(kubernetesClusterStored);
@@ -1449,9 +1467,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
     }
 
     @Override
-    public boolean addNetworkPartition(NetworkPartition networkPartition) 
throws
-            NetworkPartitionAlreadyExistsException,
-            InvalidNetworkPartitionException {
+    public boolean addNetworkPartition(NetworkPartition networkPartition)
+            throws NetworkPartitionAlreadyExistsException, 
InvalidNetworkPartitionException {
 
         handleNullObject(networkPartition, "Network Partition is null");
         handleNullObject(networkPartition.getId(), "Network Partition ID is 
null");
@@ -1480,20 +1497,22 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                         validatePartition(partition);
                     } catch (InvalidPartitionException e) {
                         //Following message is shown to the end user in all 
the the API clients(GUI/CLI/Rest API)
-                        throw new 
InvalidNetworkPartitionException(String.format("Network partition " +
-                                        " %s, is invalid since the partition 
%s is invalid",
+                        throw new 
InvalidNetworkPartitionException(String.format(
+                                "Network partition " + " %s, is invalid since 
the partition %s is invalid",
                                 networkPartition.getId(), partition.getId()), 
e);
                     }
                     if (log.isInfoEnabled()) {
-                        log.info(String.format("Partition validated 
successfully: [network-partition-id] %s " +
-                                "[partition-id] %s", networkPartition.getId(), 
partition.getId()));
+                        log.info(String.format(
+                                "Partition validated successfully: 
[network-partition-id] %s " + "[partition-id] %s",
+                                networkPartition.getId(), partition.getId()));
                     }
                 }
             }
         } else {
             //Following message is shown to the end user in all the the API 
clients(GUI/CLI/Rest API)
-            throw new InvalidNetworkPartitionException(String.format("Network 
partition: " +
-                    "%s doesn't not have any partitions ", 
networkPartition.getId()));
+            throw new InvalidNetworkPartitionException(
+                    String.format("Network partition: " + "%s doesn't not have 
any partitions ",
+                            networkPartition.getId()));
         }
 
         // adding network partition to CC-Context
@@ -1544,7 +1563,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
             handleNullObject(networkPartition.getId(), "Network Partition ID 
is null");
 
             if (log.isInfoEnabled()) {
-                log.info(String.format("Updating network partition: 
[network-partition-id] %s", networkPartition.getId()));
+                log.info(String.format("Updating network partition: 
[network-partition-id] %s",
+                        networkPartition.getId()));
             }
 
             String networkPartitionID = networkPartition.getId();
@@ -1565,8 +1585,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
                         partition.setProvider(networkPartition.getProvider());
                         validatePartition(partition);
                         if (log.isInfoEnabled()) {
-                            log.info(String.format("Partition validated 
successfully: [network-partition-id] %s " +
-                                    "[partition-id] %s", 
networkPartition.getId(), partition.getId()));
+                            log.info(String.format("Partition validated 
successfully: [network-partition-id] %s "
+                                    + "[partition-id] %s", 
networkPartition.getId(), partition.getId()));
                         }
                     }
                 }
@@ -1605,8 +1625,8 @@ public class CloudControllerServiceImpl implements 
CloudControllerService {
         try {
             return 
CloudControllerContext.getInstance().getNetworkPartition(networkPartitionId);
         } catch (Exception e) {
-            String message = String.format("Could not get network partition: 
[network-partition-id] %s",
-                    networkPartitionId);
+            String message = String
+                    .format("Could not get network partition: 
[network-partition-id] %s", networkPartitionId);
             log.error(message);
             throw new CloudControllerException(message, e);
         }

http://git-wip-us.apache.org/repos/asf/stratos/blob/02d01071/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
index da23598..12a6f95 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/services/impl/CloudControllerServiceUtil.java
@@ -42,10 +42,6 @@ public class CloudControllerServiceUtil {
 
     private static final Log log = 
LogFactory.getLog(CloudControllerServiceUtil.class);
 
-    public static Iaas buildIaas(IaasProvider iaasProvider) throws 
InvalidIaasProviderException {
-        return iaasProvider.getIaas();
-    }
-
     /**
      * Update the topology, publish statistics to DAS, remove member context
      * and persist cloud controller context.
@@ -60,23 +56,23 @@ public class CloudControllerServiceUtil {
         String partitionId = memberContext.getPartition() == null ? null : 
memberContext.getPartition().getId();
 
         // Update the topology
-        
TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(),
-                memberContext.getClusterId(), 
memberContext.getNetworkPartitionId(),
-                partitionId, memberContext.getMemberId());
+        
TopologyBuilder.handleMemberTerminated(memberContext.getCartridgeType(), 
memberContext.getClusterId(),
+                memberContext.getNetworkPartitionId(), partitionId, 
memberContext.getMemberId());
 
         // Remove member context
-        
CloudControllerContext.getInstance().removeMemberContext(memberContext.getClusterId(),
 memberContext.getMemberId());
+        CloudControllerContext.getInstance()
+                .removeMemberContext(memberContext.getClusterId(), 
memberContext.getMemberId());
 
         // Persist cloud controller context
         CloudControllerContext.getInstance().persist();
     }
 
     public static boolean isValidIpAddress(String ip) {
-        boolean isValid = InetAddresses.isInetAddress(ip);
-        return isValid;
+        return InetAddresses.isInetAddress(ip);
     }
 
-    public static IaasProvider validatePartitionAndGetIaasProvider(Partition 
partition, IaasProvider iaasProvider) throws InvalidPartitionException {
+    public static IaasProvider validatePartitionAndGetIaasProvider(Partition 
partition, IaasProvider iaasProvider)
+            throws InvalidPartitionException {
         if (iaasProvider != null) {
             // if this is a IaaS based partition
             Iaas iaas = iaasProvider.getIaas();
@@ -93,7 +89,8 @@ public class CloudControllerServiceUtil {
         }
     }
 
-    public static boolean validatePartition(Partition partition, IaasProvider 
iaasProvider) throws InvalidPartitionException {
+    public static boolean validatePartition(Partition partition, IaasProvider 
iaasProvider)
+            throws InvalidPartitionException {
         validatePartitionAndGetIaasProvider(partition, iaasProvider);
         return true;
     }

http://git-wip-us.apache.org/repos/asf/stratos/blob/02d01071/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
index 6e527ae..842d29c 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/CloudControllerUtil.java
@@ -20,7 +20,6 @@ package org.apache.stratos.cloud.controller.util;
 
 import com.google.common.net.InetAddresses;
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.stratos.cloud.controller.config.CloudControllerConfig;
@@ -29,7 +28,10 @@ import org.apache.stratos.cloud.controller.domain.*;
 import org.apache.stratos.cloud.controller.domain.kubernetes.KubernetesCluster;
 import org.apache.stratos.cloud.controller.domain.kubernetes.KubernetesHost;
 import org.apache.stratos.cloud.controller.domain.kubernetes.KubernetesMaster;
-import org.apache.stratos.cloud.controller.exception.*;
+import 
org.apache.stratos.cloud.controller.exception.InvalidIaasProviderException;
+import 
org.apache.stratos.cloud.controller.exception.InvalidKubernetesClusterException;
+import 
org.apache.stratos.cloud.controller.exception.InvalidKubernetesHostException;
+import 
org.apache.stratos.cloud.controller.exception.InvalidKubernetesMasterException;
 import org.apache.stratos.cloud.controller.iaases.Iaas;
 import org.apache.stratos.cloud.controller.registry.RegistryManager;
 import org.apache.stratos.common.Property;
@@ -39,34 +41,26 @@ import 
org.wso2.carbon.registry.core.exceptions.RegistryException;
 
 import java.lang.reflect.Constructor;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map.Entry;
 import java.util.Properties;
 
-
 public class CloudControllerUtil {
     private static final Log log = 
LogFactory.getLog(CloudControllerUtil.class);
 
-    public static Iaas createIaasInstance(IaasProvider iaasProvider)
-            throws InvalidIaasProviderException {
+    public static Iaas createIaasInstance(IaasProvider iaasProvider) throws 
InvalidIaasProviderException {
         try {
             if (iaasProvider.getClassName() == null) {
-                String msg = "You have not specified a class which represents 
the iaas of type: ["
-                        + iaasProvider.getType() + "].";
-                log.error(msg);
-                throw new InvalidIaasProviderException(msg);
+                throw new InvalidIaasProviderException(
+                        String.format("IaaS provider implementation class name 
is not specified for IaaS [type] %s",
+                                iaasProvider.getType()));
             }
-
             Constructor<?> c = 
Class.forName(iaasProvider.getClassName()).getConstructor(IaasProvider.class);
-            Iaas iaas = (Iaas) c.newInstance(iaasProvider);
-            return iaas;
+            return (Iaas) c.newInstance(iaasProvider);
         } catch (Exception e) {
-            String msg = "Class [" + iaasProvider.getClassName()
-                    + "] which represents the iaas of type: ["
-                    + iaasProvider.getType() + "] has failed to instantiate.";
-            log.error(msg, e);
-            throw new InvalidIaasProviderException(msg, e);
+            throw new InvalidIaasProviderException(
+                    String.format("Failed to instantiate IaaS provider class 
for [type] %s", iaasProvider.getType()),
+                    e);
         }
     }
 
@@ -74,7 +68,6 @@ public class CloudControllerUtil {
         if (cartridge == null) {
             return;
         }
-
         List<IaasProvider> iaases = 
CloudControllerConfig.getInstance().getIaasProviders();
 
         // populate IaaSes
@@ -164,10 +157,9 @@ public class CloudControllerUtil {
         return getProperty(props, key, defaultValue);
     }
 
-    public static String getProperty(Properties properties, String key, String 
defaultValue) {
+    private static String getProperty(Properties properties, String key, 
String defaultValue) {
         if (key != null && properties != null) {
-            for (Iterator<Entry<Object, Object>> iterator = 
properties.entrySet().iterator(); iterator.hasNext(); ) {
-                Entry<Object, Object> type = iterator.next();
+            for (Entry<Object, Object> type : properties.entrySet()) {
                 String propName = type.getKey().toString();
                 String propValue = type.getValue().toString();
                 if (key.equals(propName)) {
@@ -179,7 +171,7 @@ public class CloudControllerUtil {
         return defaultValue;
     }
 
-    public static String getProperty(Properties properties, String key) {
+    private static String getProperty(Properties properties, String key) {
         return getProperty(properties, key, null);
     }
 
@@ -189,25 +181,13 @@ public class CloudControllerUtil {
         return getProperty(props, key);
     }
 
-    public static org.apache.stratos.common.Properties 
addProperty(org.apache.stratos.common.Properties properties,
-                                                                   String key, 
String value) {
-        Property property = new Property();
-        property.setName(key);
-        property.setValue(value);
-
-        org.apache.stratos.common.Properties newProperties = new 
org.apache.stratos.common.Properties();
-        newProperties.setProperties(ArrayUtils.add(properties.getProperties(), 
property));
-        return newProperties;
-    }
-
     /**
      * Converts org.apache.stratos.messaging.util.Properties to 
java.util.Properties
      *
      * @param properties org.apache.stratos.messaging.util.Properties
      * @return java.util.Properties
      */
-    public static Properties toJavaUtilProperties(
-            org.apache.stratos.common.Properties properties) {
+    public static Properties 
toJavaUtilProperties(org.apache.stratos.common.Properties properties) {
         Properties javaUtilsProperties = new Properties();
 
         if (properties != null && properties.getProperties() != null) {
@@ -243,21 +223,10 @@ public class CloudControllerUtil {
         }
     }
 
-
-    public static void handleException(String msg, Exception e) {
-        log.error(msg, e);
-        throw new CloudControllerException(msg, e);
-    }
-
-    public static void handleException(String msg) {
-        log.error(msg);
-        throw new CloudControllerException(msg);
-    }
-
     public static String getPartitionIds(Partition[] partitions) {
         StringBuilder str = new StringBuilder("");
         for (Partition partition : partitions) {
-            str.append(partition.getId() + ", ");
+            str.append(partition.getId()).append(", ");
         }
 
         String partitionStr = str.length() == 0 ? str.toString() : 
str.substring(0, str.length() - 2);
@@ -266,8 +235,6 @@ public class CloudControllerUtil {
 
     public static void validateKubernetesCluster(KubernetesCluster 
kubernetesCluster)
             throws InvalidKubernetesClusterException {
-        CloudControllerContext context = CloudControllerContext.getInstance();
-
         if (kubernetesCluster == null) {
             throw new InvalidKubernetesClusterException("Kubernetes cluster 
can not be null");
         }
@@ -301,7 +268,7 @@ public class CloudControllerUtil {
 
             // Check for duplicate hostIds
             if (kubernetesCluster.getKubernetesHosts() != null) {
-                List<String> hostIds = new ArrayList<String>();
+                List<String> hostIds = new ArrayList<>();
                 
hostIds.add(kubernetesCluster.getKubernetesMaster().getHostId());
 
                 for (KubernetesHost kubernetesHost : 
kubernetesCluster.getKubernetesHosts()) {
@@ -344,13 +311,13 @@ public class CloudControllerUtil {
                     "[host-id] " + kubernetesHost.getHostId());
         }
         if 
(!InetAddresses.isInetAddress(kubernetesHost.getPrivateIPAddress())) {
-            throw new InvalidKubernetesHostException("Kubernetes host private 
IP address is invalid: " +
-                    kubernetesHost.getPrivateIPAddress());
+            throw new InvalidKubernetesHostException(
+                    "Kubernetes host private IP address is invalid: " + 
kubernetesHost.getPrivateIPAddress());
         }
         if (StringUtils.isNotBlank(kubernetesHost.getPublicIPAddress())) {
             if 
(!InetAddresses.isInetAddress(kubernetesHost.getPublicIPAddress())) {
-                throw new InvalidKubernetesHostException("Kubernetes host 
public IP address is invalid: " +
-                        kubernetesHost.getPrivateIPAddress());
+                throw new InvalidKubernetesHostException(
+                        "Kubernetes host public IP address is invalid: " + 
kubernetesHost.getPrivateIPAddress());
             }
         }
     }
@@ -364,15 +331,6 @@ public class CloudControllerUtil {
         }
     }
 
-    public static String 
getLoadBalancingIPTypeStringFromEnum(LoadBalancingIPType loadBalancingIPType) {
-        if (loadBalancingIPType == LoadBalancingIPType.Private) {
-            return CloudControllerConstants.LOADBALANCING_IP_TYPE_PRIVATE;
-        } else if (loadBalancingIPType == LoadBalancingIPType.Public) {
-            return CloudControllerConstants.LOADBALANCING_IP_TYPE_PUBLIC;
-        }
-        return null;
-    }
-
     public static LoadBalancingIPType 
getLoadBalancingIPTypeEnumFromString(String loadBalancingIPType) {
         if 
(CloudControllerConstants.LOADBALANCING_IP_TYPE_PUBLIC.equals(loadBalancingIPType))
 {
             return LoadBalancingIPType.Public;

http://git-wip-us.apache.org/repos/asf/stratos/blob/02d01071/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java
----------------------------------------------------------------------
diff --git 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java
 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java
index 984494e..95584e7 100644
--- 
a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java
+++ 
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/util/Scope.java
@@ -22,5 +22,19 @@ package org.apache.stratos.cloud.controller.util;
  * represents the scope of each partition which can be configured in stratos.
  */
 public enum Scope {
-    PROVIDER, REGION, ZONE, HOST
+    PROVIDER("provider"), REGION("region"), ZONE("zone"), HOST("host");
+
+    private final String name;
+
+    private Scope(String s) {
+        name = s;
+    }
+
+    public boolean equalsName(String otherName) {
+        return (otherName != null) && name.equals(otherName);
+    }
+
+    public String toString() {
+        return this.name;
+    }
 }

Reply via email to