import org.openo.commontosca.catalog.common.HttpServerPathConfig;
import org.openo.commontosca.catalog.common.MsbAddrConfig;
import org.openo.commontosca.catalog.common.ServiceRegistrer;
-import org.openo.commontosca.catalog.common.YmalParseBaseAddrConfig;
import org.openo.commontosca.catalog.db.dao.DaoManager;
import org.openo.commontosca.catalog.db.entity.NodeTemplateData;
import org.openo.commontosca.catalog.db.entity.PackageData;
MsbAddrConfig.setMsbAddress(configuration.getMsbServerAddr());
HttpServerAddrConfig.setHttpServerAddress(configuration.getHttpServerAddr());
HttpServerPathConfig.setHttpServerPath(configuration.getHttpServerPath());
- YmalParseBaseAddrConfig.setYmalParseBaseAddr(configuration.getYamlParseAddr());
initDao();
final ConsoleHealthCheck healthCheck = new ConsoleHealthCheck(configuration.getTemplate());
environment.healthChecks().register("template", healthCheck);
@NotEmpty
private String httpServerAddr;
-
- @NotEmpty
- private String opentoscaServerAddr;
-
- @NotEmpty
- private String yamlParseAddr;
@NotEmpty
private String parserType;
-
- @NotEmpty
- private String ariaParserAddr;
-
- @NotEmpty
- private String wso2HostIp;
-
- @NotEmpty
- private String wso2HostPort;
@NotEmpty
private String cataloguePath;
@NotEmpty
private String httpServerPath;
- @NotEmpty
- private String ldapServerIp;
-
- @NotEmpty
- private String ldapServerPort;
-
- @NotEmpty
- private String ldapLogindn;
- @NotEmpty
- private String ldapPassword;
-
- @NotEmpty
- private String ldapVersion;
@Valid
@NotNull
private DataSourceFactory database = new DataSourceFactory();
public void setHttpServerAddr(String httpServerAddr) {
this.httpServerAddr = httpServerAddr;
}
-
- @JsonProperty
- public String getOpentoscaServerAddr() {
- return opentoscaServerAddr;
- }
-
- @JsonProperty
- public void setOpentoscaServerAddr(String opentoscaServerAddr) {
- this.opentoscaServerAddr = opentoscaServerAddr;
- }
-
- @JsonProperty
- public String getYamlParseAddr() {
- return yamlParseAddr;
- }
-
- @JsonProperty
- public void setYamlParseAddr(String yamlParseAddr) {
- this.yamlParseAddr = yamlParseAddr;
- }
public String getParserType() {
return parserType;
this.parserType = parserType;
}
- public String getAriaParserAddr() {
- return ariaParserAddr;
- }
-
- public void setAriaParserAddr(String ariaParserAddr) {
- this.ariaParserAddr = ariaParserAddr;
- }
-
- @JsonProperty
- public String getWso2HostIp() {
- return wso2HostIp;
- }
-
- @JsonProperty
- public void setWso2HostIp(String wso2HostIp) {
- this.wso2HostIp = wso2HostIp;
- }
-
- @JsonProperty
- public String getWso2HostPort() {
- return wso2HostPort;
- }
-
- @JsonProperty
- public void setWso2HostPort(String wso2HostPort) {
- this.wso2HostPort = wso2HostPort;
- }
-
- public String getWso2BaseUrl() {
- return "http://" + this.wso2HostIp + ":" + this.wso2HostPort;
- }
-
@JsonProperty
public String getCataloguePath() {
return cataloguePath;
this.cataloguePath = cataloguePath;
}
- @JsonProperty
- public String getLdapServerIp() {
- return ldapServerIp;
- }
-
- @JsonProperty
- public void setLdapServerIp(String ldapServerIp) {
- this.ldapServerIp = ldapServerIp;
- }
-
- @JsonProperty
- public String getLdapServerPort() {
- return ldapServerPort;
- }
-
- @JsonProperty
- public void setLdapServerPort(String ldapServerPort) {
- this.ldapServerPort = ldapServerPort;
- }
-
- @JsonProperty
- public String getLdapLogindn() {
- return ldapLogindn;
- }
-
- @JsonProperty
- public void setLdapLogindn(String ldapLogindn) {
- this.ldapLogindn = ldapLogindn;
- }
-
- @JsonProperty
- public String getLdapPassword() {
- return ldapPassword;
- }
-
- @JsonProperty
- public void setLdapPassword(String ldapPassword) {
- this.ldapPassword = ldapPassword;
- }
-
- @JsonProperty
- public String getLdapVersion() {
- return ldapVersion;
- }
-
- @JsonProperty
- public void setLdapVersion(String ldapVersion) {
- this.ldapVersion = ldapVersion;
- }
-
@JsonProperty
public String getHttpServerPath() {
return httpServerPath;
}
public static String getYamlParseBaseUrl() {
- return YmalParseBaseAddrConfig.getYmalParseBaseAddr() + "/api/yamlparser/v1";
-// return Config.getConfigration().getYamlParseAddr() + "/api/yamlparser/v1";
+ return Config.getConfigration().getMsbServerAddr() + "/openoapi/yamlparser/v1";
}
}
+++ /dev/null
-/**
- * Copyright 2016 [ZTE] and others.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.commontosca.catalog.common;
-
-public class YmalParseBaseAddrConfig {
-
- protected static String yamlParseAddr;
-
- public static String getYmalParseBaseAddr() {
- return yamlParseAddr;
- }
-
- public static void setYmalParseBaseAddr(String yamlParseAddr) {
- YmalParseBaseAddrConfig.yamlParseAddr = yamlParseAddr;
- }
-}
*/
private static String getBaseUrl() {
StringBuffer buffer = new StringBuffer();
- buffer.append(Config.getConfigration().getOpentoscaServerAddr() + "/containerapi/extension");
+ buffer.append(Config.getConfigration().getMsbServerAddr() + "/containerapi/extension");
return buffer.toString();
}
*/
private static String getPackageUrl() {
StringBuffer buffer = new StringBuffer();
- buffer.append(Config.getConfigration().getOpentoscaServerAddr());
+ buffer.append(Config.getConfigration().getMsbServerAddr());
return buffer.toString();
}
}
String destPath = Class.class.getClass().getResource("/").getPath()
+ org.openo.commontosca.catalog.filemanage.http.ToolUtil.getHttpServerPath()
+ toTempFileLocalPath(fileLocation);
- if (!org.openo.commontosca.catalog.filemanage.http.ToolUtil.copyFile(fileLocation, destPath,
- true)) {
+ if (!org.openo.commontosca.catalog.filemanage.http.ToolUtil.copyFile(
+ fileLocation, destPath, true)) {
throw new CatalogResourceException("Copy Temporary To HttpServer Failed.");
}
return destPath;
// service template
CsarFileUriResponse stDownloadUri = buildServiceTemplateDownloadUri(packageId, fileLocation);
- ServiceTemplate st = parseServiceTemplate(packageId, result, stDownloadUri.getDownloadUri());
+ ServiceTemplate st = parseServiceTemplate(result, packageId, stDownloadUri.getDownloadUri());
// node templates
List<NodeTemplate> ntList = parseNodeTemplates(packageId, st.getServiceTemplateId(), result);
st.setType(getTemplateType(getSubstitutionType(result), ntList).toString());
/**
- * @param packageId
* @param result
+ * @param packageId
* @param downloadUri
* @return
*/
- private ServiceTemplate parseServiceTemplate(String packageId, AriaParserResult result,
+ private ServiceTemplate parseServiceTemplate(AriaParserResult result, String packageId,
String downloadUri) {
ServiceTemplate st = new ServiceTemplate();
try {
IAriaParserRest parseProxy =
ConsumerFactory.createConsumer(
- Config.getConfigration().getAriaParserAddr(),
+ Config.getConfigration().getMsbServerAddr(),
new ClientConfig(),
IAriaParserRest.class);
String jsonStr = parseProxy.parse(request);
import org.openo.commontosca.catalog.model.parser.yaml.aria.entity.AriaParserRequest;
-@Path("/indirect/plan")
+@Path("/openoapi/tosca/v1")
public interface IAriaParserRest {
@POST
+ @Path("/indirect/plan")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
String parse(AriaParserRequest request) throws Exception;
package org.openo.commontosca.catalog.model.plan.wso2;
-import com.google.gson.Gson;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
-import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
import org.apache.http.HttpEntity;
import org.apache.http.entity.ContentType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+import com.google.gson.Gson;
*/
public static DeployPackageResponse deployPackage(String zipFileLocation, String planFilePath)
throws CatalogResourceException {
+ IpPort ipPort = getIpPort(Config.getConfigration().getMsbServerAddr());
+ if (ipPort == null) {
+ throw new CatalogResourceException("getMsbServerAddr failed.");
+ }
InputStream ins = null;
try {
ins = getInputStream(zipFileLocation, planFilePath);
- RestResponse res = RestfulClient.post(Config.getConfigration().getWso2HostIp(),
- Integer.parseInt(Config.getConfigration().getWso2HostPort()), WSO2_APP_URL,
+ RestResponse res = RestfulClient.post(
+ ipPort.getIp(), ipPort.getPort(), WSO2_APP_URL,
buildRequest(ins, planFilePath));
if (res.getStatusCode() == null || res.getResult() == null) {
}
}
+ @Data
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class IpPort {
+ private String ip;
+ private int port;
+ }
+
+ private static IpPort getIpPort(String addr) {
+ Pattern p = Pattern.compile("//(.*?):(.*)");
+ Matcher m = p.matcher(addr);
+ while(m.find()){
+ return new IpPort(m.group(1), Integer.valueOf(m.group(2)));
+ }
+ return null;
+ }
+
private static HttpEntity buildRequest(InputStream inputStream, String filePath)
throws FileNotFoundException {
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
try {
ClientConfig config = new ClientConfig();
Iwso2RestService wso2Proxy = ConsumerFactory.createConsumer(
- Config.getConfigration().getWso2BaseUrl(), config, Iwso2RestService.class);
+ Config.getConfigration().getMsbServerAddr(), config, Iwso2RestService.class);
DeletePackageResponse response = wso2Proxy.deletePackage(packageName);
if (response.isSuccess()) {
return response;
try {
ClientConfig config = new ClientConfig();
Iwso2RestService wso2Proxy = ConsumerFactory.createConsumer(
- Config.getConfigration().getWso2BaseUrl(), config, Iwso2RestService.class);
+ Config.getConfigration().getMsbServerAddr(), config, Iwso2RestService.class);
StartProcessResponse response =
wso2Proxy.startProcess(new StartProcessRequest(processId, params));
if (response.isSuccess()) {
httpServerAddr: http://127.0.0.1:8080
-opentoscaServerAddr: http://127.0.0.1:1337
-
-yamlParseAddr: http://127.0.0.1:8210
-
parserType: zte
-ariaParserAddr: http://127.0.0.1:8204/openoapi/tosca/v1
-
-wso2HostIp: 127.0.0.1
-
-wso2HostPort: 9090
-
#catalogue path to store csar temperarily
cataloguePath: ./catalog
httpServerPath: ../tomcat/webapps/ROOT/
# the JDBC URL
url: jdbc:mysql://127.0.0.1:3306/catalog
-#LDAP
-ldapServerIp: 127.0.0.1
-ldapServerPort: 20096
-ldapLogindn: uid=admin,ou=system
-ldapPassword: nsoc
-ldapVersion: 3
# use the simple server factory if you only want to run on a single port
#server: