summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlizi00164331 <li.zi30@zte.com.cn>2017-09-15 14:56:26 +0800
committerlizi00164331 <li.zi30@zte.com.cn>2017-09-15 14:56:26 +0800
commit9fccad8f53ef43026a8632bfb6eabc32849a8c46 (patch)
treede8fc9d0a4eaad14aa530e3028f3b10c08a03b93
parent1c8188bacbe7a7ddff2387758c1d9dbfd5f2fcc0 (diff)
Realize the function of VIM API.
Realize the function of register VIM and query VIM detail. Change-Id: I001af373be4c197c290a9d42f5461cfe7d6caa5c Issue-ID: AAI-300 Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java10
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java51
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/CloudRegion.java34
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfo.java28
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfoList.java1
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/CommonRegisterResponse.java (renamed from esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/RegisterResponse.java)2
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VimRegisterResponse.java (renamed from esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiServiceConsumer.java)34
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiAdapterConfig.java20
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java47
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java53
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ICloudRegion.java53
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java81
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java57
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbInfoConfig.java39
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java15
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java1
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java4
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java53
-rw-r--r--esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java4
-rw-r--r--standalone/src/main/assembly/conf/extsys.yml10
21 files changed, 387 insertions, 214 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
index ae8797b..93459c7 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysApp.java
@@ -16,7 +16,9 @@
package org.onap.aai.esr;
+import org.onap.aai.esr.externalservice.aai.AaiAdapterConfig;
import org.onap.aai.esr.externalservice.msb.MsbHelper;
+import org.onap.aai.esr.externalservice.msb.MsbInfoConfig;
import org.onap.aai.esr.resource.EmsManager;
import org.onap.aai.esr.resource.ThirdpatySdncManager;
import org.onap.aai.esr.resource.VimManager;
@@ -44,14 +46,18 @@ public class ExtsysApp extends Application<ExtsysAppConfiguration> {
@Override
public void run(ExtsysAppConfiguration configuration, Environment environment) {
LOGGER.info("Start to initialize esr.");
+ AaiAdapterConfig.setCloudInfrastructureAddr(configuration.getCloudInfrastructureAddr());
+ AaiAdapterConfig.setExternalSystemAddr(configuration.getExternalSystemAddr());
+ MsbInfoConfig.setMsbDiscoveryIp(configuration.getMsbDiscoveryIp());
+ MsbInfoConfig.setMsbDiscoveryPort(configuration.getMsbDiscoveryPort());
environment.jersey().register(new EmsManager());
environment.jersey().register(new ThirdpatySdncManager());
environment.jersey().register(new VimManager());
environment.jersey().register(new VnfmManager());
if (configuration.getRegistByHand().endsWith("true")){
- String MSB_IP=configuration.getMsbIp();
- Integer MSB_Port= Integer.valueOf(configuration.getMsbPort());
+ String MSB_IP=configuration.getMsbDiscoveryIp();
+ Integer MSB_Port= Integer.valueOf(configuration.getMsbDiscoveryPort());
MSBServiceClient msbClient = new MSBServiceClient(MSB_IP, MSB_Port);
MsbHelper helper = new MsbHelper(msbClient);
try {
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java
index 111199b..83bd831 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/ExtsysAppConfiguration.java
@@ -33,10 +33,10 @@ public class ExtsysAppConfiguration extends Configuration {
private String defaultName = "ONAP-A&AI-ESR";
@NotEmpty
- private String msbIp;
+ private String msbDiscoveryIp;
@NotEmpty
- private String msbPort;
+ private String msbDiscoveryPort;
@NotEmpty
private String registByHand;
@@ -44,6 +44,12 @@ public class ExtsysAppConfiguration extends Configuration {
@NotEmpty
private String msbServerAddr;
+ @NotEmpty
+ private String cloudInfrastructureAddr;
+
+ @NotEmpty
+ private String externalSystemAddr;
+
@Valid
private String serviceIp;
@@ -68,13 +74,13 @@ public class ExtsysAppConfiguration extends Configuration {
}
@JsonProperty
- public String getMsbIp() {
- return msbIp;
+ public String getMsbDiscoveryIp() {
+ return msbDiscoveryIp;
}
@JsonProperty
- public String setMsbIp() {
- return msbIp;
+ public String setMsbDiscoveryIp() {
+ return msbDiscoveryIp;
}
@JsonProperty
@@ -107,12 +113,37 @@ public class ExtsysAppConfiguration extends Configuration {
}
@JsonProperty
- public void setMsbPort(String msbPort) {
- this.msbPort = msbPort;
+ public void setMsbDiscoveryPort(String msbDiscoveryPort) {
+ this.msbDiscoveryPort = msbDiscoveryPort;
}
@JsonProperty
- public String getMsbPort() {
- return msbPort;
+ public String getMsbDiscoveryPort() {
+ return msbDiscoveryPort;
+ }
+
+ @JsonProperty
+ public String getCloudInfrastructureAddr() {
+ return cloudInfrastructureAddr;
+ }
+
+ @JsonProperty
+ public void setCloudInfrastructureAddr(String cloudInfrastructureAddr) {
+ this.cloudInfrastructureAddr = cloudInfrastructureAddr;
+ }
+
+ @JsonProperty
+ public String getExternalSystemAddr() {
+ return externalSystemAddr;
+ }
+
+ @JsonProperty
+ public void setExternalSystemAddr(String externalSystemAddr) {
+ this.externalSystemAddr = externalSystemAddr;
+ }
+
+ @JsonProperty
+ public void setMsbDiscoveryIp(String msbDiscoveryIp) {
+ this.msbDiscoveryIp = msbDiscoveryIp;
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/CloudRegion.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/CloudRegion.java
index 49d7f9d..e037177 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/CloudRegion.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/CloudRegion.java
@@ -15,26 +15,43 @@
*/
package org.onap.aai.esr.entity.aai;
-public class CloudRegion {
+import java.io.Serializable;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.gson.annotations.SerializedName;
+
+public class CloudRegion implements Serializable {
+
+ public static final long serialVersionUID = 1L;
+
+ @SerializedName("cloud-owner")
private String cloudOwner;
+ @SerializedName("cloud-region-id")
private String cloudRegionId;
+ @SerializedName("cloud-type")
private String cloudType;
+ @SerializedName("cloud-region-version")
private String cloudRegionVersion;
+ @SerializedName("owner-defined-type")
private String ownerDefinedType;
+ @SerializedName("cloud-zone")
private String cloudZone;
+ @SerializedName("complex-name")
private String complexName;
+ @SerializedName("cloud-extra-info")
private String cloudExtraInfo;
+ @SerializedName("resouce-version")
private String resouceVersion;
+ @SerializedName("esr-system-info-list")
private EsrSystemInfoList esrSystemInfoList;
public String getCloudOwner() {
@@ -101,6 +118,14 @@ public class CloudRegion {
this.cloudExtraInfo = cloudExtraInfo;
}
+ public String getResouceVersion() {
+ return resouceVersion;
+ }
+
+ public void setResouceVersion(String resouceVersion) {
+ this.resouceVersion = resouceVersion;
+ }
+
public EsrSystemInfoList getEsrSystemInfoList() {
return esrSystemInfoList;
}
@@ -109,11 +134,4 @@ public class CloudRegion {
this.esrSystemInfoList = esrSystemInfoList;
}
- public String getResouceVersion() {
- return resouceVersion;
- }
-
- public void setResouceVersion(String resouceVersion) {
- this.resouceVersion = resouceVersion;
- }
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfo.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfo.java
index 1e1a60e..02b6fe5 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfo.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfo.java
@@ -15,89 +15,69 @@
*/
package org.onap.aai.esr.entity.aai;
-import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
public class EsrSystemInfo {
@SerializedName("esr-system-info-id")
- @JsonProperty("esr-system-info-id")
private String esrSystemInfoId;
@SerializedName("system-name")
- @JsonProperty("system-name")
private String systemName;
@SerializedName("type")
- @JsonProperty("type")
private String type;
@SerializedName("vendor")
- @JsonProperty("vendor")
private String vendor;
@SerializedName("version")
- @JsonProperty("version")
private String version;
@SerializedName("service-url")
- @JsonProperty("service-url")
private String serviceUrl;
@SerializedName("user-name")
- @JsonProperty("user-name")
private String userName;
@SerializedName("password")
- @JsonProperty("password")
private String password;
@SerializedName("system-type")
- @JsonProperty("system-type")
private String systemType;
@SerializedName("protocol")
- @JsonProperty("protocol")
private String protocol;
@SerializedName("ssl-cassert")
- @JsonProperty("ssl-cassert")
private String sslCassert;
@SerializedName("ssl-insecure")
- @JsonProperty("ssl-insecure")
private Boolean sslInsecure;
@SerializedName("ip-address")
- @JsonProperty("ip-address")
private String ipAddress;
@SerializedName("port")
- @JsonProperty("port")
private String port;
@SerializedName("cloud-domain")
- @JsonProperty("cloud-domain")
private String cloudDomain;
@SerializedName("default-tenant")
- @JsonProperty("default-tenant")
private String defaultTenant;
@SerializedName("passive")
- @JsonProperty("passive")
private Boolean passive;
@SerializedName("remote-path")
- @JsonProperty("remote-path")
private String remotePath;
@SerializedName("system-status")
- @JsonProperty("system-status")
private String systemStatus;
- @JsonProperty("resouce-version")
- private String resouceVersion;
+ @SerializedName("resource-version")
+ private String resourceVersion;
public String getEsrSystemInfoId() {
return esrSystemInfoId;
@@ -252,11 +232,11 @@ public class EsrSystemInfo {
}
public String getResouceVersion() {
- return resouceVersion;
+ return resourceVersion;
}
public void setResouceVersion(String resouceVersion) {
- this.resouceVersion = resouceVersion;
+ this.resourceVersion = resouceVersion;
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfoList.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfoList.java
index 71256ff..9a98aac 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfoList.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrSystemInfoList.java
@@ -23,7 +23,6 @@ import com.google.gson.annotations.SerializedName;
public class EsrSystemInfoList {
@SerializedName("esr-system-info")
- @JsonProperty("esr-system-info")
private ArrayList<EsrSystemInfo> esrSystemInfo;
public ArrayList<EsrSystemInfo> getEsrSystemInfo() {
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/RegisterResponse.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/CommonRegisterResponse.java
index 617edf9..88f38cc 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/RegisterResponse.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/CommonRegisterResponse.java
@@ -15,7 +15,7 @@
*/
package org.onap.aai.esr.entity.rest;
-public class RegisterResponse {
+public class CommonRegisterResponse {
private String id;
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiServiceConsumer.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VimRegisterResponse.java
index 6d7b10d..f12a2bc 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiServiceConsumer.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/rest/VimRegisterResponse.java
@@ -13,20 +13,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.onap.aai.esr.externalservice.aai;
+package org.onap.aai.esr.entity.rest;
-//import org.glassfish.jersey.client.ClientConfig;
-//
-//import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+public class VimRegisterResponse {
+
+ private String cloudOwner;
+
+ private String cloudRegionId;
-public class AaiServiceConsumer {
-// private static IEsrVimRest aaiAdapterProxy;
-//
-// static {
-// ClientConfig config = new ClientConfig();
-// aaiAdapterProxy =
-// ConsumerFactory.createConsumer(AaiAdapterConfig.getAaiAdapterAddr(),
-// config, IEsrVimRest.class);
-// }
+ public String getCloudOwner() {
+ return cloudOwner;
+ }
+
+ public void setCloudOwner(String cloudOwner) {
+ this.cloudOwner = cloudOwner;
+ }
+
+ public String getCloudRegionId() {
+ return cloudRegionId;
+ }
+
+ public void setCloudRegionId(String cloudRegionId) {
+ this.cloudRegionId = cloudRegionId;
+ }
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiAdapterConfig.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiAdapterConfig.java
index 68bf1c9..4c8a786 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiAdapterConfig.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiAdapterConfig.java
@@ -17,13 +17,23 @@ package org.onap.aai.esr.externalservice.aai;
public class AaiAdapterConfig {
- protected static String aaiAdapterAddr;
+ protected static String cloudInfrastructureAddr;
- public static void setAaiAdapterAddr(String address){
- aaiAdapterAddr = "https://" + address;
+ protected static String externalSystemAddr;
+
+ public static void setCloudInfrastructureAddr(String address){
+ cloudInfrastructureAddr = address;
}
- public static String getAaiAdapterAddr(){
- return aaiAdapterAddr;
+ public static String getCloudInfrastructureAddr(){
+ return cloudInfrastructureAddr;
+ }
+
+ public static String getExternalSystemAddr() {
+ return externalSystemAddr;
+ }
+
+ public static void setExternalSystemAddr(String externalSystemAddr) {
+ AaiAdapterConfig.externalSystemAddr = externalSystemAddr;
}
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java
index 12d1d61..ab5e030 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/AaiCommon.java
@@ -15,48 +15,15 @@
*/
package org.onap.aai.esr.externalservice.aai;
-import java.io.IOException;
-import java.io.StringReader;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.glassfish.jersey.client.ClientResponse;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
public class AaiCommon {
-// private static String AAI_AUTHENTICATION_USER = "AAI";
-// private static String AAI_AUTHENTICATION_PAASWORD = "AAI";
- private static String RESOURCE_VERSION_PARAM = "resource-version";
+ private static String AAI_AUTHENTICATION_USER = "AAI";
+ private static String AAI_AUTHENTICATION_PAASWORD = "AAI";
-// public String getAuthenticationCredentials() {
-// String usernameAndPassword = AAI_AUTHENTICATION_USER + ":"
-// + AAI_AUTHENTICATION_PAASWORD;
-// return "Basic " + java.util.Base64.getEncoder().encodeToString("AAI:AAI".getBytes());
-// }
-
- public String getResourceVersion(ClientResponse response)
- throws ParserConfigurationException, SAXException, IOException {
- String respData = response.readEntity(String.class);
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputSource is = new InputSource(new StringReader(respData));
- Document doc = builder.parse(is);
-
- NodeList nodeList = doc.getDocumentElement().getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node currentNode = nodeList.item(i);
- if (currentNode.getNodeName().equals(RESOURCE_VERSION_PARAM)) {
- return currentNode.getTextContent();
- }
- }
-
- return null;
+ public static String getAuthenticationCredentials() {
+ String usernameAndPassword = AAI_AUTHENTICATION_USER + ":"
+ + AAI_AUTHENTICATION_PAASWORD;
+ return "Basic " + java.util.Base64.getEncoder().encodeToString(usernameAndPassword.getBytes());
}
+
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
new file mode 100644
index 0000000..5c2bb33
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/CloudRegionProxy.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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.onap.aai.esr.externalservice.aai;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.onap.aai.esr.entity.aai.CloudRegion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.eclipsesource.jaxrs.consumer.ConsumerFactory;
+
+public class CloudRegionProxy {
+
+ private static final Logger logger = LoggerFactory.getLogger(CloudRegionProxy.class);
+ private static ICloudRegion adapterServiceproxy;
+
+ private static String transactionId = "9999";
+ private static String fromAppId = "esr-server";
+ private static String authorization = AaiCommon.getAuthenticationCredentials();
+ static {
+ ClientConfig config = new ClientConfig();
+ adapterServiceproxy = ConsumerFactory.createConsumer(AaiAdapterConfig.getCloudInfrastructureAddr(),
+ config, ICloudRegion.class);
+ }
+
+
+ public static void registerVim(String cloudOwner, String cloudRegionId, CloudRegion cloudRegion)
+ throws Exception {
+ ClientConfig config = new ClientConfig(new RegisterVimProvider());
+ ICloudRegion registerVimServiceproxy = ConsumerFactory
+ .createConsumer(AaiAdapterConfig.getCloudInfrastructureAddr(), config, ICloudRegion.class);
+ registerVimServiceproxy.registerVIMService(transactionId, fromAppId, authorization, cloudOwner,
+ cloudRegionId, cloudRegion);
+ }
+
+ public static String queryVimDetail(String cloud_owner, String cloud_region_id) throws Exception {
+ return adapterServiceproxy.queryVIMDetail(transactionId, fromAppId, authorization, cloud_owner,
+ cloud_region_id);
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ICloudRegion.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ICloudRegion.java
new file mode 100644
index 0000000..5a5d15c
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ICloudRegion.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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.onap.aai.esr.externalservice.aai;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.onap.aai.esr.entity.aai.CloudRegion;
+
+
+@Path("/cloud-regions")
+public interface ICloudRegion {
+
+ @PUT
+ @Path("/cloud-region/{cloud_owner}/{cloud_region_id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public void registerVIMService(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp,
+ @HeaderParam("Authorization") String authorization,
+ @PathParam("cloud_owner") String cloud_owner,
+ @PathParam("cloud_region_id") String cloud_region_id, CloudRegion cloudRegion) throws Exception;
+
+ @GET
+ @Path("/cloud-region/{cloud_owner}/{cloud_region_id}?depth=all")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public String queryVIMDetail(@HeaderParam("X-TransactionId") String transactionId,
+ @HeaderParam("X-FromAppId") String fromApp,
+ @HeaderParam("Authorization") String authorization,
+ @PathParam("cloud_owner") String cloud_owner,
+ @PathParam("cloud_region_id") String cloud_region_id) throws Exception;
+
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java
deleted file mode 100644
index b257d79..0000000
--- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IEsrVimRest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * 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.onap.aai.esr.externalservice.aai;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.glassfish.jersey.client.ClientResponse;
-import org.onap.aai.esr.entity.aai.CloudRegion;
-
-import retrofit2.http.Header;
-import retrofit2.http.Headers;
-
-
-@Path("/aai/v11/cloud-infrastructure/cloud-regions")
-public interface IEsrVimRest {
-
- @Headers({
- "X-TransactionId: 9999",
- "Accept: application/json",
- "X-FromAppId: aai-esr"
- })
- @Path("/cloud-region/{cloud_owner}/{cloud_region_id}")
- @PUT
- @Consumes(MediaType.APPLICATION_JSON)
-
- public ClientResponse registerVIMServce(@Header("Authorization") String authorization, @PathParam("cloud_owner") String cloud_owner,
- CloudRegion entity);
-
- @Headers({
- "X-TransactionId: 9999",
- "Accept: application/json",
- "X-FromAppId: aai-esr"
- })
- @Path("/cloud-region/{cloud_owner}/{cloud_region_id}?depth=all")
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public ClientResponse queryVIMDetail(@Header("Authorization") String authorization, @PathParam("cloud_owner") String cloud_owner,
- @PathParam("cloud_region_id") String cloud_region_id);
-
- @Headers({
- "X-TransactionId: 9999",
- "Accept: application/json",
- "X-FromAppId: aai-esr"
- })
- @Path("/")
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public ClientResponse queryVIMList(@Header("Authorization") String authorization);
-
-
- @Headers({
- "X-TransactionId: 9999",
- "Accept: application/json",
- "X-FromAppId: aai-esr"
- })
- @Path("/cloud-region/{cloud_owner}/{cloud_region_id}/esr-system-info/{esr_system_info_id}")
- @GET
- public ClientResponse delVIMAuthInfo(@Header("Authorization") String authorization, @PathParam("cloud_owner") String cloud_owner,
- @PathParam("cloud_region_id") String cloud_region_id, @PathParam("esr_system_info_id") String esr_system_info_id);
-
-}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java
new file mode 100644
index 0000000..5c6d645
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/RegisterVimProvider.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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.onap.aai.esr.externalservice.aai;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+
+import org.onap.aai.esr.entity.aai.CloudRegion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
+public class RegisterVimProvider implements MessageBodyWriter<CloudRegion>{
+ private static final Logger logger = LoggerFactory.getLogger(RegisterVimProvider.class);
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
+ MediaType mediaType) {
+ return CloudRegion.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(CloudRegion t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ @Override
+ public void writeTo(CloudRegion t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException, WebApplicationException {
+ String json = new Gson().toJson(t, CloudRegion.class);
+ logger.info("the param to createNetworkByAdapter input is:" + json);
+ entityStream.write(json.getBytes("UTF-8"));
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbInfoConfig.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbInfoConfig.java
new file mode 100644
index 0000000..fca641f
--- /dev/null
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/msb/MsbInfoConfig.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * 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.onap.aai.esr.externalservice.msb;
+
+public class MsbInfoConfig {
+
+ protected static String msbDiscoveryIp;
+
+ protected static String msbDiscoveryPort;
+
+ public static String getMsbDiscoveryIp() {
+ return msbDiscoveryIp;
+ }
+
+ public static void setMsbDiscoveryIp(String msbDiscoveryIp) {
+ MsbInfoConfig.msbDiscoveryIp = msbDiscoveryIp;
+ }
+
+ public static String getMsbDiscoveryPort() {
+ return msbDiscoveryPort;
+ }
+
+ public static void setMsbDiscoveryPort(String msbDiscoveryPort) {
+ MsbInfoConfig.msbDiscoveryPort = msbDiscoveryPort;
+ }
+}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java b/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java
index 354e3af..e44cddb 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/resource/VimManager.java
@@ -67,7 +67,7 @@ public class VimManager {
/**
* query vim by id.
*/
- @Path("/{vimId}")
+ @Path("/{cloudOwner}/{cloudRegionId}")
@GET
@ApiOperation(value = "get vim by id")
@Produces(MediaType.APPLICATION_JSON)
@@ -79,9 +79,9 @@ public class VimManager {
@ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
response = String.class)})
@Timed
- public Response queryVimById(@ApiParam(value = "vim id") @PathParam("vimId") String vimId) {
- LOGGER.info("start query vim by id." + vimId);
- return VimManagerWrapper.getInstance().queryVimById(vimId);
+ public Response queryVimById(@PathParam("cloudOwner") String cloudOwner, @PathParam("cloudRegionId") String cloudRegionId) {
+ LOGGER.info("start query vim by cloud owner and cloud region id." + cloudOwner +"," + cloudRegionId);
+ return VimManagerWrapper.getInstance().queryVimById(cloudOwner, cloudRegionId);
}
/**
@@ -98,7 +98,7 @@ public class VimManager {
@ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
response = String.class)})
@Timed
- public Response delvim(@ApiParam(value = "vim id") @PathParam("vimId") String vimId) {
+ public Response delvim(@PathParam("vimId") String vimId) {
LOGGER.info("start delete vim .id:" + vimId);
return VimManagerWrapper.getInstance().delVim(vimId);
}
@@ -119,8 +119,7 @@ public class VimManager {
@ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
response = String.class)})
@Timed
- public Response updatevims(@ApiParam(value = "vim", required = true) VimRegisterInfo vim,
- @ApiParam(value = "vim id", required = true) @PathParam("vimId") String vimId) {
+ public Response updatevims(VimRegisterInfo vim, @PathParam("vimId") String vimId) {
LOGGER.info("start update vim .id:" + vimId + " info:" + ExtsysUtil.objectToString(vim));
return VimManagerWrapper.getInstance().updateVim(vim);
}
@@ -141,7 +140,7 @@ public class VimManager {
@ApiResponse(code = HttpStatus.INTERNAL_SERVER_ERROR_500, message = "internal server error",
response = String.class)})
@Timed
- public Response registerVims(@ApiParam(value = "vim", required = true) VimRegisterInfo vim) {
+ public Response registerVims(VimRegisterInfo vim) {
LOGGER.info("start add vim" + " info:" + ExtsysUtil.objectToString(vim));
return VimManagerWrapper.getInstance().registerVim(vim);
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java
index 240e762..681b288 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/VimManagerUtil.java
@@ -85,6 +85,7 @@ public class VimManagerUtil {
vimRegisterInfo.setCloudType(cloudRegion.getCloudType());
vimRegisterInfo.setCloudZone(cloudRegion.getCloudZone());
vimRegisterInfo.setComplexName(cloudRegion.getComplexName());
+ vimRegisterInfo.setCloudRegionVersion(cloudRegion.getCloudRegionVersion());
vimRegisterInfo.setOwnerDefinedType(cloudRegion.getOwnerDefinedType());
return vimRegisterInfo;
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java
index 15fa016..4467eae 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/EmsManagerWrapper.java
@@ -20,7 +20,7 @@ import java.util.ArrayList;
import javax.ws.rs.core.Response;
import org.onap.aai.esr.entity.rest.EmsRegisterInfo;
-import org.onap.aai.esr.entity.rest.RegisterResponse;
+import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
@@ -41,7 +41,7 @@ public class EmsManagerWrapper {
public Response registerEms(EmsRegisterInfo ems) {
//TODO
- RegisterResponse result = null;
+ CommonRegisterResponse result = null;
return Response.ok(result).build();
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java
index 603fcc3..b06b1f7 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/ThirdpatySdncWrapper.java
@@ -19,7 +19,7 @@ import java.util.ArrayList;
import javax.ws.rs.core.Response;
-import org.onap.aai.esr.entity.rest.RegisterResponse;
+import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
import org.onap.aai.esr.entity.rest.ThirdpartySdncRegisterInfo;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
@@ -42,7 +42,7 @@ public class ThirdpatySdncWrapper {
public Response registerThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc) {
//TODO
- RegisterResponse result = null;
+ CommonRegisterResponse result = null;
return Response.ok(result).build();
}
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
index b985c20..b20116c 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VimManagerWrapper.java
@@ -19,15 +19,22 @@ import java.util.ArrayList;
import javax.ws.rs.core.Response;
-import org.onap.aai.esr.entity.rest.RegisterResponse;
+import org.onap.aai.esr.entity.aai.CloudRegion;
import org.onap.aai.esr.entity.rest.VimRegisterInfo;
-//import org.slf4j.Logger;
-//import org.slf4j.LoggerFactory;
+import org.onap.aai.esr.entity.rest.VimRegisterResponse;
+import org.onap.aai.esr.externalservice.aai.CloudRegionProxy;
+import org.onap.aai.esr.util.ExtsysUtil;
+import org.onap.aai.esr.util.VimManagerUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.gson.Gson;
+
public class VimManagerWrapper {
private static VimManagerWrapper vimManagerWrapper;
-// private static final Logger LOG = LoggerFactory.getLogger(VimManagerWrapper.class);
+ private static final Logger LOG = LoggerFactory.getLogger(VimManagerWrapper.class);
/**
* get VimManagerWrapper instance.
@@ -38,12 +45,26 @@ public class VimManagerWrapper {
vimManagerWrapper = new VimManagerWrapper();
}
return vimManagerWrapper;
+
}
- public Response registerVim(VimRegisterInfo vim) {
- //TODO
- RegisterResponse result = null;
- return Response.ok(result).build();
+ public Response registerVim(VimRegisterInfo vimRegisterInfo) {
+ LOG.info("Start register VIM, input VIM info is: " + ExtsysUtil.objectToString(vimRegisterInfo));
+ CloudRegion cloudRegion = new CloudRegion();
+ VimRegisterResponse result = new VimRegisterResponse();
+ cloudRegion = VimManagerUtil.vimRegisterInfo2CloudRegion(vimRegisterInfo);
+ String cloud_owner = vimRegisterInfo.getCloudOwner();
+ String cloud_region_id = vimRegisterInfo.getCloudRegionId();
+
+ try {
+ CloudRegionProxy.registerVim(cloud_owner, cloud_region_id, cloudRegion);
+ result.setCloudOwner(cloud_owner);
+ result.setCloudRegionId(cloud_region_id);
+ return Response.ok(result).build();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return Response.serverError().build();
+ }
}
public Response updateVim(VimRegisterInfo vim) {
@@ -57,10 +78,20 @@ public class VimManagerWrapper {
return Response.ok(vimList).build();
}
- public Response queryVimById(String vimId) {
+ public Response queryVimById(String cloudOwner, String cloudRegionId) {
VimRegisterInfo vim = new VimRegisterInfo();
- //TODO
- return Response.ok(vim).build();
+ CloudRegion cloudRegion = new CloudRegion();
+ try {
+ String cloudRegionstr = CloudRegionProxy.queryVimDetail(cloudOwner, cloudRegionId);
+ LOG.info("Response from AAI by query VIM: " + cloudRegionstr);
+ cloudRegion = new Gson().fromJson(cloudRegionstr, CloudRegion.class);
+ vim = VimManagerUtil.cloudRegion2VimRegisterInfo(cloudRegion);
+ return Response.ok(vim).build();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return Response.serverError().build();
+ }
+
}
public Response delVim(String vimId) {
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
index 660a519..755fcf6 100644
--- a/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
+++ b/esr-mgr/src/main/java/org/onap/aai/esr/wrapper/VnfmManagerWrapper.java
@@ -19,7 +19,7 @@ import java.util.ArrayList;
import javax.ws.rs.core.Response;
-import org.onap.aai.esr.entity.rest.RegisterResponse;
+import org.onap.aai.esr.entity.rest.CommonRegisterResponse;
import org.onap.aai.esr.entity.rest.VnfmRegisterInfo;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
@@ -41,7 +41,7 @@ public class VnfmManagerWrapper {
public Response registerVnfm(VnfmRegisterInfo vnfm) {
//TODO
- RegisterResponse result = null;
+ CommonRegisterResponse result = null;
return Response.ok(result).build();
}
diff --git a/standalone/src/main/assembly/conf/extsys.yml b/standalone/src/main/assembly/conf/extsys.yml
index 9059e2a..b6f66ae 100644
--- a/standalone/src/main/assembly/conf/extsys.yml
+++ b/standalone/src/main/assembly/conf/extsys.yml
@@ -19,10 +19,12 @@ template: Hello, %s!
#defaultName: ${DW_DEFAULT_NAME:-Stranger}
# the micro service ip
serviceIp:
-msbIp: 127.0.0.1
-msbPort: 10081
-msbServerAddr: http://127.0.0.1:80
-registByHand: false
+msbDiscoveryIp: 127.0.0.1
+msbDiscoveryPort: 10081
+msbServerAddr: http://127.0.0.1:10081
+cloudInfrastructureAddr: http://127.0.0.1/api/aai-cloudInfrastructure/v11
+externalSystemAddr: http://127.0.0.1/api/aai-externalSystem/v11
+registByHand: true
# use the simple server factory if you only want to run on a single port
#server: