diff options
author | 2017-09-16 15:46:54 +0800 | |
---|---|---|
committer | 2017-09-16 15:46:54 +0800 | |
commit | 567917ad3680d64f56568aee3d6c854e79f049ab (patch) | |
tree | b728504c40b6ceb0ab606728ea9b882702614621 /esr-mgr/src | |
parent | 66596a09241e9548bb2a286f2341705a3ddf26f2 (diff) |
Realize the delete VNFM API.
Realize the delete VNFM API.
Fix the parameter definition error.
Add to print exception.
Change-Id: I486ccff968a9a55b24cce2e32c03ae60146fca58
Issue-ID: AAI-313
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr/src')
8 files changed, 91 insertions, 52 deletions
diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java index f49d973..8f3dd0f 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrThirdpartySdncDetail.java @@ -32,8 +32,8 @@ public class EsrThirdpartySdncDetail implements Serializable { @SerializedName("product-name") private String productName; - @SerializedName("resouce-version") - private String resouceVersion; + @SerializedName("resource-version") + private String resourceVersion; @SerializedName("esr-system-info-list") private EsrSystemInfoList esrSystemInfoList; @@ -70,11 +70,11 @@ public class EsrThirdpartySdncDetail implements Serializable { this.esrSystemInfoList = esrSystemInfoList; } - public String getResouceVersion() { - return resouceVersion; + public String getResourceVersion() { + return resourceVersion; } - public void setResouceVersion(String resouceVersion) { - this.resouceVersion = resouceVersion; + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; } } diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java index 660dedf..f0b8bb8 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfm.java @@ -32,8 +32,8 @@ public class EsrVnfm implements Serializable { @SerializedName("certificate-id") private String certificateUrl; - @SerializedName("resouce-version") - private String resouceVersion; + @SerializedName("resource-version") + private String resourceVersion; public String getVnfmId() { return vnfmId; @@ -59,12 +59,12 @@ public class EsrVnfm implements Serializable { this.certificateUrl = certificateUrl; } - public String getResouceVersion() { - return resouceVersion; + public String getResourceVersion() { + return resourceVersion; } - public void setResouceVersion(String resouceVersion) { - this.resouceVersion = resouceVersion; + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; } public static long getSerialversionuid() { diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java index 238f03f..eab70cd 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/entity/aai/EsrVnfmDetail.java @@ -32,8 +32,8 @@ public class EsrVnfmDetail implements Serializable { @SerializedName("certificate-url") private String certificateUrl; - @SerializedName("resouce-version") - private String resouceVersion; + @SerializedName("resource-version") + private String resourceVersion; @SerializedName("esr-system-info-list") private EsrSystemInfoList esrSystemInfoList; @@ -70,12 +70,12 @@ public class EsrVnfmDetail implements Serializable { this.esrSystemInfoList = esrSystemInfoList; } - public String getResouceVersion() { - return resouceVersion; + public String getResourceVersion() { + return resourceVersion; } - public void setResouceVersion(String resouceVersion) { - this.resouceVersion = resouceVersion; + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; } } diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java index ea7c805..7328f97 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/ExternalSystemProxy.java @@ -48,4 +48,8 @@ public class ExternalSystemProxy { public static String queryVnfmList() throws Exception { return externalSystemproxy.queryVNFMList(transactionId, fromAppId, authorization); } + + public static void deleteVnfm(String vnfmId, String resourceVersion) throws Exception { + externalSystemproxy.deleteVNFM(transactionId, fromAppId, authorization, vnfmId, resourceVersion); + } } diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java index c38935b..859120d 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/externalservice/aai/IExternalSystem.java @@ -67,7 +67,7 @@ public interface IExternalSystem { @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization, @PathParam("vnfm_id") String vnfmId, - @QueryParam("resouce-version") String resourceVersion) throws Exception; + @QueryParam("resource-version") String resourceVersion) throws Exception; @PUT @Path("/esr-ems-list/esr-ems/{ems_id}") @@ -103,7 +103,7 @@ public interface IExternalSystem { @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization, @PathParam("ems_id") String emsId, - @QueryParam("resouce-version") String resourceVersion) throws Exception; + @QueryParam("resource-version") String resourceVersion) throws Exception; @PUT @Path("/esr-thirdparty-sdnc-list/esr-thirdparty-sdnc/{thirdparty-sdnc-id}") @@ -139,5 +139,5 @@ public interface IExternalSystem { @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization, @PathParam("thirdparty-sdnc-id") String thirdpartySdncId, - @QueryParam("resouce-version") String resourceVersion) throws Exception; + @QueryParam("resource-version") String resourceVersion) throws Exception; } diff --git a/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java b/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java index f94b118..57b754b 100644 --- a/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java +++ b/esr-mgr/src/main/java/org/onap/aai/esr/util/VnfmManagerUtil.java @@ -28,7 +28,7 @@ public class VnfmManagerUtil { EsrSystemInfoList esrSystemInfo = new EsrSystemInfoList(); EsrSystemInfo authInfo = new EsrSystemInfo(); esrVnfm.setCertificateUrl(vnfmRegisterInfo.getCertificateUrl()); - esrVnfm.setResouceVersion(vnfmRegisterInfo.getVersion()); + esrVnfm.setResourceVersion(vnfmRegisterInfo.getVersion()); esrVnfm.setVimId(vnfmRegisterInfo.getVimId()); esrVnfm.setVnfmId(ExtsysUtil.generateId()); authInfo = getAuthInfoFromVnfmRegisterInfo(vnfmRegisterInfo); 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 b6e19ff..ad31f27 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 @@ -39,6 +39,7 @@ public class VimManagerWrapper { /** * get VimManagerWrapper instance. + * * @return vim manager wrapper instance */ public static VimManagerWrapper getInstance() { @@ -46,11 +47,12 @@ public class VimManagerWrapper { vimManagerWrapper = new VimManagerWrapper(); } return vimManagerWrapper; - + } - + public Response registerVim(VimRegisterInfo vimRegisterInfo) { - LOG.info("Start register VIM, input VIM info is: " + ExtsysUtil.objectToString(vimRegisterInfo)); + LOG.info( + "Start register VIM, input VIM info is: " + ExtsysUtil.objectToString(vimRegisterInfo)); CloudRegionDetail cloudRegion = new CloudRegionDetail(); VimRegisterResponse result = new VimRegisterResponse(); cloudRegion = VimManagerUtil.vimRegisterInfo2CloudRegion(vimRegisterInfo); @@ -61,12 +63,13 @@ public class VimManagerWrapper { result.setCloudOwner(cloudOwner); result.setCloudRegionId(cloudRegionId); return Response.ok(result).build(); - } catch (Exception e) { - LOG.error("Register VIM failed !" + e.getMessage()); + } catch (Exception error) { + error.printStackTrace(); + LOG.error("Register VIM failed !" + error.getMessage()); return Response.serverError().build(); } } - + public Response updateVim(VimRegisterInfo vimRegisterInfo) { LOG.info("Start update VIM, input VIM info is: " + ExtsysUtil.objectToString(vimRegisterInfo)); String cloudOwner = vimRegisterInfo.getCloudOwner(); @@ -88,7 +91,7 @@ public class VimManagerWrapper { return Response.serverError().build(); } } - + public Response queryVimListDetails() { ArrayList<VimRegisterInfo> vimRegisterInfos = new ArrayList<VimRegisterInfo>(); CloudRegionList cloudRegionList = new CloudRegionList(); @@ -98,12 +101,13 @@ public class VimManagerWrapper { vimRegisterInfos = getVimDetailList(cloudRegionList); return Response.ok(vimRegisterInfos).build(); } catch (Exception error) { + error.printStackTrace(); LOG.error("Query vim list details failed !" + error.getMessage()); return Response.serverError().build(); } - + } - + public Response queryVimById(String cloudOwner, String cloudRegionId) { VimRegisterInfo vim = new VimRegisterInfo(); CloudRegionDetail cloudRegionDetail = new CloudRegionDetail(); @@ -117,14 +121,14 @@ public class VimManagerWrapper { e.printStackTrace(); return Response.serverError().build(); } - + } - + private ArrayList<VimRegisterInfo> getVimDetailList(CloudRegionList cloudRegionList) { ArrayList<VimRegisterInfo> vimRegisterInfos = new ArrayList<VimRegisterInfo>(); VimRegisterInfo vimRegisterInfo = new VimRegisterInfo(); int cloudRegionNum = cloudRegionList.getCloudRegion().size(); - for (int i=0; i<cloudRegionNum; i++) { + for (int i = 0; i < cloudRegionNum; i++) { String cloudOwner = cloudRegionList.getCloudRegion().get(i).getCloudOwner(); String cloudRegionId = cloudRegionList.getCloudRegion().get(i).getCloudRegionId(); vimRegisterInfo = getVimDetail(cloudOwner, cloudRegionId); @@ -132,7 +136,7 @@ public class VimManagerWrapper { } return vimRegisterInfos; } - + private VimRegisterInfo getVimDetail(String cloudOwner, String cloudRegionId) { CloudRegionDetail cloudRegionDetail = new CloudRegionDetail(); VimRegisterInfo registeredVimInfo = new VimRegisterInfo(); @@ -141,11 +145,13 @@ public class VimManagerWrapper { cloudRegionDetail = new Gson().fromJson(cloudRegionstr, CloudRegionDetail.class); registeredVimInfo = VimManagerUtil.cloudRegion2VimRegisterInfo(cloudRegionDetail); } catch (Exception error) { - LOG.error("query VIM detail failed ! cloud-owner = " + cloudOwner +", cloud-region-id = "+ cloudRegionId + error.getMessage()); + error.printStackTrace(); + LOG.error("query VIM detail failed ! cloud-owner = " + cloudOwner + ", cloud-region-id = " + + cloudRegionId + error.getMessage()); } return registeredVimInfo; } - + private String getResourceVersion(String cloudOwner, String cloudRegionId) { CloudRegionDetail cloudRegionDetail = new CloudRegionDetail(); try { @@ -153,13 +159,15 @@ public class VimManagerWrapper { cloudRegionDetail = new Gson().fromJson(cloudRegionstr, CloudRegionDetail.class); return cloudRegionDetail.getResouceVersion(); } catch (Exception error) { - LOG.error("query VIM detail failed ! cloud-owner = " + cloudOwner +", cloud-region-id = "+ cloudRegionId + error.getMessage()); + error.printStackTrace(); + LOG.error("query VIM detail failed ! cloud-owner = " + cloudOwner + ", cloud-region-id = " + + cloudRegionId + error.getMessage()); return null; } } - + public Response delVim(String vimId) { - //TODO + // TODO return Response.noContent().build(); } } 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 5127371..30d4e3d 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 @@ -36,6 +36,7 @@ public class VnfmManagerWrapper { /** * get VnfmManagerWrapper instance. + * * @return vnfm manager wrapper instance */ public static VnfmManagerWrapper getInstance() { @@ -55,31 +56,34 @@ public class VnfmManagerWrapper { result.setId(vnfmId); return Response.ok(result).build(); } catch (Exception e) { + e.printStackTrace(); LOG.error("Register VNFM failed !" + e.getMessage()); return Response.serverError().build(); } } - + public Response updateVnfm(VnfmRegisterInfo vnfm, String vnfmId) { - //TODO + // TODO return Response.ok().build(); } - + public Response queryVnfmList() { ArrayList<VnfmRegisterInfo> vnfmList = new ArrayList<VnfmRegisterInfo>(); EsrVnfmList esrVnfm = new EsrVnfmList(); try { String esrVnfmStr = ExternalSystemProxy.queryVnfmList(); esrVnfm = new Gson().fromJson(esrVnfmStr, EsrVnfmList.class); + LOG.info("Response from AAI by query VNFM list: " + esrVnfm); vnfmList = getVnfmDetailList(esrVnfm); return Response.ok(vnfmList).build(); } catch (Exception e) { + e.printStackTrace(); LOG.error("Query VNFM list failed !"); return Response.serverError().build(); } - + } - + public Response queryVnfmById(String vnfmId) { VnfmRegisterInfo vnfm = new VnfmRegisterInfo(); vnfm = queryVnfmDetail(vnfmId); @@ -89,12 +93,34 @@ public class VnfmManagerWrapper { return Response.serverError().build(); } } - + public Response delVnfm(String vnfmId) { - //TODO - return Response.noContent().build(); + EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail(); + try { + String esrVnfmstr = ExternalSystemProxy.queryVnfmDetail(vnfmId); + LOG.info("Response from AAI by query VNFM: " + esrVnfmstr); + esrVnfmDetail = new Gson().fromJson(esrVnfmstr, EsrVnfmDetail.class); + } catch (Exception e) { + e.printStackTrace(); + LOG.error("Query VNFM detail failed! VNFM ID: " + vnfmId, e.getMessage()); + } + if (esrVnfmDetail != null && esrVnfmDetail.getResourceVersion() != null) { + String resourceVersion = esrVnfmDetail.getResourceVersion(); + try { + ExternalSystemProxy.deleteVnfm(vnfmId, resourceVersion); + return Response.ok().build(); + } catch (Exception e) { + e.printStackTrace(); + LOG.error("Delete VNFM from A&AI failed! VNFM ID: " + vnfmId + "resouce-version:" + + resourceVersion, e.getMessage()); + return Response.serverError().build(); + } + } else { + LOG.error("resouce-version is null ! Can not delete resouce from A&AI. "); + return Response.serverError().build(); + } } - + private VnfmRegisterInfo queryVnfmDetail(String vnfmId) { VnfmRegisterInfo vnfm = new VnfmRegisterInfo(); EsrVnfmDetail esrVnfmDetail = new EsrVnfmDetail(); @@ -105,18 +131,19 @@ public class VnfmManagerWrapper { vnfm = VnfmManagerUtil.esrVnfm2VnfmRegisterInfo(esrVnfmDetail); return vnfm; } catch (Exception e) { + e.printStackTrace(); LOG.error("Query VNFM detail failed! VNFM ID: " + vnfmId, e.getMessage()); return null; } } - + private ArrayList<VnfmRegisterInfo> getVnfmDetailList(EsrVnfmList esrVnfm) { ArrayList<VnfmRegisterInfo> vnfmInfoList = new ArrayList<VnfmRegisterInfo>(); VnfmRegisterInfo vnfmInfo = new VnfmRegisterInfo(); - for (int i=0; i<esrVnfm.getEsrVnfm().size(); i++) { + for (int i = 0; i < esrVnfm.getEsrVnfm().size(); i++) { String vnfmId = esrVnfm.getEsrVnfm().get(i).getVnfmId(); vnfmInfo = queryVnfmDetail(vnfmId); - if(vnfmInfo != null) { + if (vnfmInfo != null) { vnfmInfoList.add(vnfmInfo); } } |