stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From im...@apache.org
Subject [2/2] stratos git commit: Fixing invalid characters found in replication controller id and name
Date Thu, 25 Dec 2014 20:24:07 GMT
Fixing invalid characters found in replication controller id and name


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

Branch: refs/heads/master
Commit: ef267bb6a2a2efb0785bc9c8e6b033b3d56a33f5
Parents: 5609530
Author: Imesh Gunaratne <imesh@apache.org>
Authored: Fri Dec 26 01:53:53 2014 +0530
Committer: Imesh Gunaratne <imesh@apache.org>
Committed: Fri Dec 26 01:53:53 2014 +0530

----------------------------------------------------------------------
 .../cloud/controller/iaases/kubernetes/KubernetesIaas.java   | 7 ++++---
 .../controller/iaases/kubernetes/KubernetesIaasUtil.java     | 6 +-----
 .../stratos/cloud/controller/util/CloudControllerUtil.java   | 8 ++++----
 3 files changed, 9 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/ef267bb6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
index a55048c..aeaf999 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java
@@ -321,8 +321,8 @@ public class KubernetesIaas extends Iaas {
         memberContext.setDynamicPayload(payload);
 
         // Create replication controller
-        String replicationControllerId = memberContext.getMemberId();
-        String replicationControllerName = memberContext.getMemberId();
+        String replicationControllerId = CloudControllerUtil.replaceDotsWithDash(memberContext.getMemberId());
+        String replicationControllerName = replicationControllerId;
         String dockerImage = iaasProvider.getImage();
         List<Integer> containerPorts = KubernetesIaasUtil.prepareCartridgePorts(cartridge);
         EnvironmentVariable[] environmentVariables = KubernetesIaasUtil.prepareEnvironmentVariables(
@@ -361,7 +361,8 @@ public class KubernetesIaas extends Iaas {
 
         List<PortMapping> portMappings = cartridge.getPortMappings();
         for(PortMapping portMapping : portMappings) {
-            String serviceId = KubernetesIaasUtil.prepareKubernetesServiceId(clusterId, portMapping);
+            String serviceId = KubernetesIaasUtil.prepareKubernetesServiceId(
+                    CloudControllerUtil.replaceDotsWithDash(clusterId), portMapping);
             int nextServicePort = kubernetesClusterContext.getNextServicePort();
             if(nextServicePort == -1) {
                 throw new RuntimeException(String.format("Could not generate service port:
[cluster-id] %s ",

http://git-wip-us.apache.org/repos/asf/stratos/blob/ef267bb6/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java
b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java
index 6d2ad4f..623f851 100644
--- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java
+++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaasUtil.java
@@ -61,11 +61,7 @@ public class KubernetesIaasUtil {
      * @return
      */
     public static String prepareKubernetesServiceId(String clusterId, PortMapping portMapping)
{
-        String serviceId = String.format("%s-%s-%s", clusterId, portMapping.getProtocol(),
portMapping.getPort());
-        if(serviceId.contains(".")) {
-            serviceId = serviceId.replace(".", "-");
-        }
-        return serviceId;
+        return String.format("%s-%s-%s", clusterId, portMapping.getProtocol(), portMapping.getPort());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/stratos/blob/ef267bb6/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 0bca0bd..fd1397d 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
@@ -357,11 +357,11 @@ public class CloudControllerUtil {
 		return "[" +partitionStr+ "]";
 	}
 	
-	public static String getCompatibleId(String clusterId) {
-		if (clusterId.indexOf('.') != -1) {
-			clusterId = clusterId.replace('.', '-');
+	public static String replaceDotsWithDash(String id) {
+		if (id.indexOf('.') != -1) {
+			id = id.replace('.', '-');
 		}
-		return clusterId;
+		return id;
 	}
 	
 	public static void validateKubernetesCluster(KubernetesCluster kubernetesCluster) throws
InvalidKubernetesClusterException {


Mime
View raw message