diff options
author | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-21 16:29:10 +0800 |
---|---|---|
committer | lizi00164331 <li.zi30@zte.com.cn> | 2017-09-21 17:16:27 +0800 |
commit | 07c89153d16b14bda54f16ef9f37e54bfc0a68f8 (patch) | |
tree | 9d0975fc83cee4799925127ee9bdcd2ad67495b0 /esr-mgr | |
parent | 979f0fa70cbe576f8eed5e56db467b261a1919cf (diff) |
Realize the delete VIM API.
Change-Id: I674f900fe68ab1f38def6b9297b0999ef65e1455
Issue-ID: AAI-360
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'esr-mgr')
6 files changed, 67 insertions, 18 deletions
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 index f21510e..89b8ab2 100644 --- 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 @@ -33,8 +33,8 @@ public class CloudRegionProxy { config, ICloudRegion.class); } - public static void registerVim(String cloudOwner, String cloudRegionId, CloudRegionDetail cloudRegion) - throws Exception { + public static void registerVim(String cloudOwner, String cloudRegionId, + CloudRegionDetail cloudRegion) throws Exception { ClientConfig config = new ClientConfig(new VimRegisterProvider()); ICloudRegion registerVimServiceproxy = ConsumerFactory .createConsumer(AaiAdapterConfig.getCloudInfrastructureAddr(), config, ICloudRegion.class); @@ -46,8 +46,14 @@ public class CloudRegionProxy { return adapterServiceproxy.queryVIMDetail(transactionId, fromAppId, authorization, cloud_owner, cloud_region_id); } - + public static String qureyVimList() throws Exception { return adapterServiceproxy.queryVIMList(transactionId, fromAppId, authorization); } + + public static void deleteVim(String cloud_owner, String cloud_region_id, String resourceVersion) + throws Exception { + adapterServiceproxy.deleteVim(transactionId, fromAppId, authorization, cloud_owner, + cloud_region_id, resourceVersion); + } } 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 index 77b44ba..3b51e29 100644 --- 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 @@ -16,12 +16,14 @@ package org.onap.aai.esr.externalservice.aai; import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; 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.QueryParam; import javax.ws.rs.core.MediaType; import org.onap.aai.esr.entity.aai.CloudRegionDetail; @@ -57,4 +59,14 @@ public interface ICloudRegion { @HeaderParam("X-FromAppId") String fromApp, @HeaderParam("Authorization") String authorization) throws Exception; + @DELETE + @Path("/cloud-region/{cloud_owner}/{cloud_region_id}") + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + public void deleteVim(@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, + @QueryParam("resource-version") String resourceVersion) throws Exception; } 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 07e510e..6436bf8 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 @@ -90,7 +90,7 @@ public class EmsManagerWrapper { } catch (Exception e) { e.printStackTrace(); LOG.error("Query EMS list failed !"); - return Response.ok().build(); + return Response.ok(emsList).build(); } } @@ -100,7 +100,7 @@ public class EmsManagerWrapper { if (ems != null) { return Response.ok(ems).build(); } else { - return Response.ok().build(); + return Response.ok(ems).build(); } } @@ -120,7 +120,7 @@ public class EmsManagerWrapper { } } else { LOG.error("resouce-version is null ! Can not delete resouce from A&AI. "); - return Response.noContent().build(); + return Response.serverError().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 9e6f3f8..effc244 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 @@ -105,7 +105,7 @@ public class ThirdpatySdncWrapper { } catch (Exception e) { e.printStackTrace(); LOG.error("Query thirdparty SDNC list failed !"); - return Response.ok().build(); + return Response.ok(sdncList).build(); } } @@ -115,7 +115,7 @@ public class ThirdpatySdncWrapper { if(thirdpartySdnc != null) { return Response.ok(thirdpartySdnc).build(); } else { - return Response.ok().build(); + return Response.ok(thirdpartySdnc).build(); } } @@ -131,11 +131,11 @@ public class ThirdpatySdncWrapper { e.printStackTrace(); LOG.error("Delete VNFM from A&AI failed! thirdparty SDNC ID: " + thirdpartySdncId + "resouce-version:" + resourceVersion, e.getMessage()); - return Response.noContent().build(); + return Response.serverError().build(); } } else { LOG.error("resouce-version is null ! Can not delete resouce from A&AI. "); - return Response.noContent().build(); + return Response.serverError().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 bdf4705..2a4174a 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 @@ -101,7 +101,7 @@ public class VimManagerWrapper { } catch (Exception error) { error.printStackTrace(); LOG.error("Query vim list details failed !" + error.getMessage()); - return Response.ok().build(); + return Response.ok(vimRegisterInfos).build(); } } @@ -117,7 +117,7 @@ public class VimManagerWrapper { return Response.ok(vim).build(); } catch (Exception e) { e.printStackTrace(); - return Response.serverError().build(); + return Response.ok(vim).build(); } } @@ -183,7 +183,38 @@ public class VimManagerWrapper { } public Response delVim(String cloudOwner, String cloudRegionId) { - // TODO - return Response.noContent().build(); + CloudRegionDetail cloudRegionDetail = new CloudRegionDetail(); + cloudRegionDetail = queryCloudRegionDetail(cloudOwner, cloudRegionId); + String resourceVersion = cloudRegionDetail.getResourceVersion(); + if (resourceVersion != null) { + try { + CloudRegionProxy.deleteVim(cloudOwner, cloudRegionId, resourceVersion); + return Response.noContent().build(); + } catch (Exception e) { + e.printStackTrace(); + LOG.error( + "Delete cloud region from A&AI failed! cloud-owner = " + cloudOwner + + ", cloud-region-id = " + cloudRegionId + "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 CloudRegionDetail queryCloudRegionDetail (String cloudOwner, String cloudRegionId) { + CloudRegionDetail cloudRegionDetail = new CloudRegionDetail(); + try { + String cloudRegionStr = CloudRegionProxy.queryVimDetail(cloudOwner, cloudRegionId); + LOG.info("Response from AAI by query cloud region: " + cloudRegionStr); + cloudRegionDetail = new Gson().fromJson(cloudRegionStr, CloudRegionDetail.class); + } catch (Exception e) { + e.printStackTrace(); + LOG.error("Query EMS detail failed! cloud-owner = " + cloudOwner + + ", cloud-region-id = " + cloudRegionId , e.getMessage()); + } + return cloudRegionDetail; } } 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 9187897..65c26c3 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 @@ -103,7 +103,7 @@ public class VnfmManagerWrapper { } catch (Exception e) { e.printStackTrace(); LOG.error("Query VNFM list failed !"); - return Response.ok().build(); + return Response.ok(vnfmList).build(); } } @@ -113,7 +113,7 @@ public class VnfmManagerWrapper { if (vnfm != null) { return Response.ok(vnfm).build(); } else { - return Response.ok().build(); + return Response.ok(vnfm).build(); } } @@ -127,11 +127,11 @@ public class VnfmManagerWrapper { e.printStackTrace(); LOG.error("Delete VNFM from A&AI failed! VNFM ID: " + vnfmId + "resouce-version:" + resourceVersion, e.getMessage()); - return Response.noContent().build(); + return Response.serverError().build(); } } else { LOG.error("resouce-version is null ! Can not delete resouce from A&AI. "); - return Response.noContent().build(); + return Response.serverError().build(); } } |