summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/main/java/org/openecomp/appc/adapter/iaas/impl/VMURL.java21
-rw-r--r--appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java16
2 files changed, 33 insertions, 4 deletions
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 20b15bb1e..d9c9c7ba6 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]+))?(/.*)?/(v[0-9\\.]+)/([^/]+)/servers/([^/]+)");
/**
* The URL scheme or protocol, such as HTTP or HTTPS
@@ -70,6 +70,11 @@ public class VMURL {
private String serverId;
/**
+ * The version of the service
+ */
+ private String version;
+
+ /**
* A private default constructor prevents instantiation by any method other than the factory method
*
* @see #parseURL(String)
@@ -96,8 +101,9 @@ public class VMURL {
obj.host = matcher.group(2);
obj.port = matcher.group(3);
obj.path = matcher.group(4);
- obj.tenantId = matcher.group(5);
- obj.serverId = matcher.group(6);
+ obj.version = matcher.group(5);
+ obj.tenantId = matcher.group(6);
+ obj.serverId = matcher.group(7);
}
}
@@ -146,6 +152,13 @@ public class VMURL {
return serverId;
}
+ /**
+ * @return The version of the service
+ */
+ public String getVersion() {
+ return version;
+ }
+
@Override
public String toString() {
StringBuilder str = new StringBuilder();
@@ -156,7 +169,7 @@ public class VMURL {
if (path != null) {
str.append(path);
}
- str.append("/v2/" + tenantId + "/servers/" + serverId);
+ str.append("/" + version + "/" + tenantId + "/servers/" + serverId);
return str.toString();
}
diff --git a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
index c1434273d..46dd5eea9 100644
--- a/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
+++ b/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestVMURL.java
@@ -94,6 +94,22 @@ public class TestVMURL {
assertEquals("/api/multicloud/v0/cloudowner_region", url.getPath());
assertEquals(TENANTID, url.getTenantId());
assertEquals(VMID, url.getServerId());
+ assertEquals("v2",url.getVersion());
+ assertEquals(url.toString(), URL);
+ }
+
+ @Test
+ public void testValidURL4() {
+ URL = "http://msb.onap.org:80/api/multicloud/v0/cloudowner_region/v2.1/abcde12345fghijk6789lmnopq123rst/servers/abc12345-1234-5678-890a-abcdefg12345";
+ VMURL url = VMURL.parseURL(URL);
+ assertNotNull(url);
+ assertEquals("http", url.getScheme());
+ assertEquals("msb.onap.org", url.getHost());
+ assertEquals("80", url.getPort());
+ assertEquals("/api/multicloud/v0/cloudowner_region", url.getPath());
+ assertEquals(TENANTID, url.getTenantId());
+ assertEquals(VMID, url.getServerId());
+ assertEquals("v2.1",url.getVersion());
assertEquals(url.toString(), URL);
}