mirror of https://github.com/apache/cloudstack.git
Option to create StorPool primary storage with a valid URL (#8356)
* Option to create primary storage with a valid URL * check if the scheme is valid
This commit is contained in:
parent
0ba26912df
commit
94c8b1da5c
|
|
@ -117,6 +117,8 @@ SP_API_HTTP - address of StorPool Api
|
|||
SP_AUTH_TOKEN - StorPool's token
|
||||
SP_TEMPLATE - name of StorPool's template
|
||||
|
||||
> **NOTE:** You can use the alternative format option for the URL - storpool://{SP_AUTH_TOKEN}@{SP_API_HTTP}:{SP_API_HTTP_PORT}/{SP_TEMPLATE}
|
||||
|
||||
Storage Tags: If left blank, the StorPool storage plugin will use the pool name to create a corresponding storage tag.
|
||||
This storage tag may be used later, when defining service or disk offerings.
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,12 @@ public class StorPoolUtil {
|
|||
private String templateName;
|
||||
|
||||
public SpConnectionDesc(String url) {
|
||||
try {
|
||||
extractUriParams(url);
|
||||
return;
|
||||
} catch (URISyntaxException e) {
|
||||
log.debug("[ignore] the uri is not valid");
|
||||
}
|
||||
String[] urlSplit = url.split(";");
|
||||
if (urlSplit.length == 1 && !urlSplit[0].contains("=")) {
|
||||
this.templateName = url;
|
||||
|
|
@ -240,6 +246,16 @@ public class StorPoolUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private void extractUriParams(String url) throws URISyntaxException {
|
||||
URI uri = new URI(url);
|
||||
if (!StringUtils.equalsIgnoreCase(uri.getScheme(), "storpool")) {
|
||||
throw new CloudRuntimeException("The scheme is invalid. The URL should be with a format storpool://{SP_AUTH_TOKEN}@{SP_API_HTTP}:{SP_API_HTTP_PORT}/{SP_TEMPLATE}");
|
||||
}
|
||||
hostPort = uri.getHost() + ":" + uri.getPort();
|
||||
authToken = uri.getUserInfo();
|
||||
templateName = uri.getPath().replace("/", "");
|
||||
}
|
||||
|
||||
public SpConnectionDesc(String host, String authToken2, String templateName2) {
|
||||
this.hostPort = host;
|
||||
this.authToken = authToken2;
|
||||
|
|
|
|||
Loading…
Reference in New Issue