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>
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;
@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 {
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;
@NotEmpty
private String msbServerAddr;
+ @NotEmpty
+ private String cloudInfrastructureAddr;
+
+ @NotEmpty
+ private String externalSystemAddr;
+
@Valid
private String serviceIp;
}
@JsonProperty
- public String getMsbIp() {
- return msbIp;
+ public String getMsbDiscoveryIp() {
+ return msbDiscoveryIp;
}
@JsonProperty
- public String setMsbIp() {
- return msbIp;
+ public String setMsbDiscoveryIp() {
+ return msbDiscoveryIp;
}
@JsonProperty
}
@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;
}
}
*/
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() {
this.cloudExtraInfo = cloudExtraInfo;
}
+ public String getResouceVersion() {
+ return resouceVersion;
+ }
+
+ public void setResouceVersion(String resouceVersion) {
+ this.resouceVersion = resouceVersion;
+ }
+
public EsrSystemInfoList getEsrSystemInfoList() {
return esrSystemInfoList;
}
this.esrSystemInfoList = esrSystemInfoList;
}
- public String getResouceVersion() {
- return resouceVersion;
- }
-
- public void setResouceVersion(String resouceVersion) {
- this.resouceVersion = resouceVersion;
- }
}
*/
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;
}
public String getResouceVersion() {
- return resouceVersion;
+ return resourceVersion;
}
public void setResouceVersion(String resouceVersion) {
- this.resouceVersion = resouceVersion;
+ this.resourceVersion = resouceVersion;
}
}
public class EsrSystemInfoList {
@SerializedName("esr-system-info")
- @JsonProperty("esr-system-info")
private ArrayList<EsrSystemInfo> esrSystemInfo;
public ArrayList<EsrSystemInfo> getEsrSystemInfo() {
*/
package org.onap.aai.esr.entity.rest;
-public class RegisterResponse {
+public class CommonRegisterResponse {
private String id;
* 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;
+ }
}
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;
}
}
*/
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());
}
+
}
--- /dev/null
+/**
+ * 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);
+ }
+}
--- /dev/null
+/**
+ * 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;
+
+}
+++ /dev/null
-/**
- * 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);
-
-}
--- /dev/null
+/**
+ * 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"));
+ }
+}
--- /dev/null
+/**
+ * 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;
+ }
+}
/**
* query vim by id.
*/
- @Path("/{vimId}")
+ @Path("/{cloudOwner}/{cloudRegionId}")
@GET
@ApiOperation(value = "get vim by id")
@Produces(MediaType.APPLICATION_JSON)
@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);
}
/**
@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);
}
@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);
}
@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);
}
vimRegisterInfo.setCloudType(cloudRegion.getCloudType());
vimRegisterInfo.setCloudZone(cloudRegion.getCloudZone());
vimRegisterInfo.setComplexName(cloudRegion.getComplexName());
+ vimRegisterInfo.setCloudRegionVersion(cloudRegion.getCloudRegionVersion());
vimRegisterInfo.setOwnerDefinedType(cloudRegion.getOwnerDefinedType());
return vimRegisterInfo;
}
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;
public Response registerEms(EmsRegisterInfo ems) {
//TODO
- RegisterResponse result = null;
+ CommonRegisterResponse result = null;
return Response.ok(result).build();
}
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;
public Response registerThirdpartySdnc(ThirdpartySdncRegisterInfo thirdpartySdnc) {
//TODO
- RegisterResponse result = null;
+ CommonRegisterResponse result = null;
return Response.ok(result).build();
}
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.
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) {
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) {
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;
public Response registerVnfm(VnfmRegisterInfo vnfm) {
//TODO
- RegisterResponse result = null;
+ CommonRegisterResponse result = null;
return Response.ok(result).build();
}
#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: