summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main
diff options
context:
space:
mode:
authorRY303T <RY303T@att.com>2017-08-30 16:12:42 -0400
committerRanda Maher <rx196w@att.com>2017-09-01 00:18:57 +0000
commit94cd1ffc720bc206f6b75a8781acbcdb147f7778 (patch)
tree09a40eab18f13eba2c4b1b85baee705302230892 /appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main
parent3df3182a7badeef662f743bfc8d67cea805b1ef4 (diff)
Modify IaaS adapter URL parsing to include path
Modified the pattern in IdentityURL and VMURL to include optional path Modified the toString in IdentityURL and VMURL to properly print the full url string Updated tests to include new URL format Issue-ID: APPC-133 Change-Id: Ic7c272b70d4fe18c815d5dd5311f760d8b8953c1 Signed-off-by: RY303T <RY303T@att.com>
Diffstat (limited to 'appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main')
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java30
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java30
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties7
3 files changed, 60 insertions, 7 deletions
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java
index 482e54a9d..327191af2 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/IdentityURL.java
@@ -35,7 +35,7 @@ public class IdentityURL {
* The regular expression pattern used to parse the URL. Capturing groups are used to identify and extract the
* various component parts of the URL.
*/
- private static Pattern pattern = Pattern.compile("(\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?/(v[0-9\\.]+)/?");
+ private static Pattern pattern = Pattern.compile("(\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?(/.*)?/(v[0-9\\.]+)/?");
/**
* The URL scheme or protocol, such as HTTP or HTTPS
@@ -48,6 +48,11 @@ public class IdentityURL {
private String host;
/**
+ * The path of the service, or null if no path is defined
+ */
+ private String path;
+
+ /**
* The port number, or null if no port is defined
*/
private String port;
@@ -83,7 +88,8 @@ public class IdentityURL {
obj.scheme = matcher.group(1);
obj.host = matcher.group(2);
obj.port = matcher.group(3);
- obj.version = matcher.group(4);
+ obj.path = matcher.group(4);
+ obj.version = matcher.group(5);
}
}
@@ -105,6 +111,13 @@ public class IdentityURL {
}
/**
+ * @return The URL path, or null if no path was defined
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
* @return The URL port, or null if no port was defined
*/
public String getPort() {
@@ -117,7 +130,18 @@ public class IdentityURL {
@Override
public String toString() {
- return String.format("%s://%s:%s/%s", scheme, host, port, version);
+ StringBuilder str = new StringBuilder();
+
+ str.append(scheme + "://" + host);
+ if (port != null) {
+ str.append(":" + port);
+ }
+ if (path != null) {
+ str.append(path);
+ }
+ str.append("/" + version);
+
+ return str.toString();
}
}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java
index e591a5616..20b15bb1e 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java
@@ -37,7 +37,7 @@ public class VMURL {
* various component parts of the URL.
*/
private static Pattern pattern = Pattern
- .compile("(\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?/v2/([^/]+)/servers/([^/]+)");
+ .compile("(\\p{Alnum}+)://([^/:]+)(?::([0-9]+))?(/.*)?/v2/([^/]+)/servers/([^/]+)");
/**
* The URL scheme or protocol, such as HTTP or HTTPS
@@ -50,6 +50,11 @@ public class VMURL {
private String host;
/**
+ * The path, or null if no path is defined
+ */
+ private String path;
+
+ /**
* The port number, or null if no port is defined
*/
private String port;
@@ -90,8 +95,9 @@ public class VMURL {
obj.scheme = matcher.group(1);
obj.host = matcher.group(2);
obj.port = matcher.group(3);
- obj.tenantId = matcher.group(4);
- obj.serverId = matcher.group(5);
+ obj.path = matcher.group(4);
+ obj.tenantId = matcher.group(5);
+ obj.serverId = matcher.group(6);
}
}
@@ -113,6 +119,13 @@ public class VMURL {
}
/**
+ * @return THe URL path, or null if no path was defined
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
* @return The URL port, or null if no port was defined
*/
public String getPort() {
@@ -135,7 +148,16 @@ public class VMURL {
@Override
public String toString() {
- return String.format("%s://%s:%s/%s/servers/%s", scheme, host, port, tenantId, serverId);
+ StringBuilder str = new StringBuilder();
+ str.append(scheme + "://" + host);
+ if (port != null) {
+ str.append(":" + port);
+ }
+ if (path != null) {
+ str.append(path);
+ }
+ str.append("/v2/" + tenantId + "/servers/" + serverId);
+ return str.toString();
}
}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
index 75fc1edf8..21f96d9ee 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/resources/org/openecomp/appc/default.properties
@@ -103,3 +103,10 @@ provider1.identity=appc
provider1.tenant1.name=appc
provider1.tenant1.userid=appc
provider1.tenant1.password=appc
+
+#Your OpenStack IP
+test.ip=192.168.1.2
+# Your OpenStack Platform's Keystone Port (default is 5000)
+test.port=5000
+test.tenantid=abcde12345fghijk6789lmnopq123rst
+test.vmid=abc12345-1234-5678-890a-abcdefg12345