diff options
author | 2017-09-20 14:08:19 +0300 | |
---|---|---|
committer | 2017-09-20 14:14:56 +0300 | |
commit | 1ba64a4a45f26e8bdb58e866e540aa58f32e2e52 (patch) | |
tree | dac3ada662bb141fe986526d13b2436032e5012e /vid-app-common/src/main/java/org/openecomp/vid/services | |
parent | cbdd17f586a4914890bd2b26ee91be135568f38c (diff) |
Change management and PNF support
Issue-ID: VID-44, VID-48, VID-49, VID-50, VID-51, VID-52
Change-Id: I83e940aad2e4e294a0927b546c4c08ca8e539a65
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-app-common/src/main/java/org/openecomp/vid/services')
6 files changed, 214 insertions, 2 deletions
diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/AaiService.java b/vid-app-common/src/main/java/org/openecomp/vid/services/AaiService.java index 274419fb..d3bacade 100644 --- a/vid-app-common/src/main/java/org/openecomp/vid/services/AaiService.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/AaiService.java @@ -5,6 +5,7 @@ import org.openecomp.vid.aai.SubscriberFilteredResults; import org.openecomp.vid.aai.model.AaiGetTenatns.GetTenantsResponse; import org.openecomp.vid.roles.RoleValidator; +import javax.ws.rs.core.Response; import java.util.List; /** @@ -21,5 +22,13 @@ public interface AaiService { AaiResponse getAaiZones(); + AaiResponse getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId); + + Response getVNFData(String globalSubscriberId, String serviceType); + AaiResponse<GetTenantsResponse[]> getTenants(String globalCustomerId, String serviceType, RoleValidator roleValidator); + + AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId); + + Response getVersionByInvariantId(List<String> modelInvariantId); } diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java b/vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java index 38b670fe..cb096286 100644 --- a/vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/AaiServiceImpl.java @@ -1,12 +1,17 @@ package org.openecomp.vid.services; import org.ecomp.aai.model.AaiAICZones.AicZones; +import org.openecomp.portalsdk.core.util.SystemProperties; import org.openecomp.vid.aai.*; import org.openecomp.vid.aai.model.AaiGetServicesRequestModel.*; import org.openecomp.vid.aai.model.AaiGetTenatns.GetTenantsResponse; import org.openecomp.vid.model.*; import org.openecomp.vid.roles.RoleValidator; +import org.openecomp.vid.scheduler.SchedulerProperties; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; + +import javax.ws.rs.core.Response; import java.util.List; @@ -37,13 +42,23 @@ public class AaiServiceImpl implements AaiService { String subscriberGlobalId = subscriberResponse.getT().globalCustomerId; for (ServiceSubscription serviceSubscription : subscriberResponse.getT().serviceSubscriptions.serviceSubscription) { String serviceType = serviceSubscription.serviceType; - serviceSubscription.isPermitted = roleProvider.isServicePermitted(subscriberGlobalId,serviceType);; + serviceSubscription.isPermitted = roleProvider.isServicePermitted(subscriberGlobalId,serviceType); } return subscriberResponse; } @Override + public Response getVersionByInvariantId(List<String> modelInvariantId) { + try { + return aaiClient.getVersionByInvariantId(modelInvariantId); + }catch (Exception e){ + e.printStackTrace(); + } + return null; + } + + @Override public AaiResponse getServices(RoleValidator roleValidator) { AaiResponse<GetServicesAAIRespone> subscriberResponse = aaiClient.getServices(); for (org.openecomp.vid.aai.model.AaiGetServicesRequestModel.Service service :subscriberResponse.getT().service){ @@ -62,9 +77,25 @@ public class AaiServiceImpl implements AaiService { return aaiGetTenantsResponse; } - @Override + @Override + public AaiResponse getVNFData(String globalSubscriberId, String serviceType, String serviceInstanceId) { + return aaiClient.getVNFData(globalSubscriberId,serviceType,serviceInstanceId); + } + + @Override + public Response getVNFData(String globalSubscriberId, String serviceType) { + return aaiClient.getVNFData(globalSubscriberId,serviceType); + } + + @Override public AaiResponse getAaiZones() { AaiResponse<AicZones> response = aaiClient.getAllAicZones(); return response; } + + @Override + public AaiResponse getAicZoneForPnf(String globalCustomerId , String serviceType , String serviceId) { + AaiResponse<AicZones> response = aaiClient.getAicZoneForPnf(globalCustomerId , serviceType , serviceId); + return response; + } } diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/ChangeManagementService.java b/vid-app-common/src/main/java/org/openecomp/vid/services/ChangeManagementService.java new file mode 100644 index 00000000..3ac52828 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/ChangeManagementService.java @@ -0,0 +1,14 @@ +package org.openecomp.vid.services; + +import org.openecomp.vid.changeManagement.ChangeManagementRequest; +import org.json.simple.JSONArray; +import org.openecomp.vid.mso.rest.Request; +import org.springframework.http.ResponseEntity; + +import java.util.Collection; + +public interface ChangeManagementService { + Collection<Request> getMSOChangeManagements(); + ResponseEntity<String> doChangeManagement(ChangeManagementRequest request, String vnfName); + JSONArray getSchedulerChangeManagements(); +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/ChangeManagementServiceImpl.java b/vid-app-common/src/main/java/org/openecomp/vid/services/ChangeManagementServiceImpl.java new file mode 100644 index 00000000..7e69d8fe --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/ChangeManagementServiceImpl.java @@ -0,0 +1,109 @@ +package org.openecomp.vid.services; + +import org.openecomp.portalsdk.core.logging.logic.EELFLoggerDelegate; +import org.openecomp.vid.changeManagement.ChangeManagementRequest; +import org.openecomp.vid.changeManagement.RequestDetails; +import org.openecomp.vid.mso.MsoBusinessLogic; +import org.openecomp.vid.mso.MsoResponseWrapper; +import org.openecomp.vid.controller.MsoController; +import org.openecomp.portalsdk.core.util.SystemProperties; +import org.openecomp.vid.scheduler.*; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.openecomp.vid.mso.rest.Request; +import org.springframework.stereotype.Service; +import org.json.simple.JSONArray; +import org.json.simple.parser.JSONParser; + +import java.util.Date; +import java.util.List; +import java.util.Collection; + + +@Service +public class ChangeManagementServiceImpl implements ChangeManagementService { + @Override + public Collection<Request> getMSOChangeManagements() { + Collection<Request> result = null; + MsoBusinessLogic msoBusinessLogic = new MsoBusinessLogic(); + try { + result = msoBusinessLogic.getOrchestrationRequestsForDashboard(); + } catch (Exception e) { + e.printStackTrace(); + } + + return result; + } + + private RequestDetails findRequestByVnfName(List<RequestDetails> requests, String vnfName){ + + if (requests == null) + return null; + + for(RequestDetails requestDetails: requests){ + if(requestDetails.getVnfName().equals(vnfName)){ + return requestDetails; + } + } + + return null; + } + + @Override + public ResponseEntity<String> doChangeManagement(ChangeManagementRequest request, String vnfName) { + if (request == null) + return null; + ResponseEntity<String> response = null; + RequestDetails currentRequestDetails = findRequestByVnfName(request.getRequestDetails(), vnfName); + MsoResponseWrapper msoResponseWrapperObject = null; + if(currentRequestDetails != null){ + MsoBusinessLogic msoBusinessLogicObject = new MsoBusinessLogic(); + String serviceInstanceId = currentRequestDetails.getRelatedInstList().get(0).getRelatedInstance().getInstanceId(); + String vnfInstanceId = currentRequestDetails.getVnfInstanceId(); + try { + if (request.getRequestType().equalsIgnoreCase("update")) { + + msoResponseWrapperObject = msoBusinessLogicObject.updateVnf(currentRequestDetails, serviceInstanceId, vnfInstanceId); + } + else if (request.getRequestType().equalsIgnoreCase("replace")) + { + msoResponseWrapperObject = msoBusinessLogicObject.replaceVnf(currentRequestDetails, serviceInstanceId, vnfInstanceId); +// throw new NotImplementedException(); + } + response = new ResponseEntity<String>(msoResponseWrapperObject.getResponse(), HttpStatus.OK); + return response; + } catch (Exception e) { + e.printStackTrace(); + } + + } + + // AH:TODO: return ChangeManagementResponse + return null; + } + + @Override + public JSONArray getSchedulerChangeManagements() { + JSONArray result = null; + try { + String path = SystemProperties.getProperty(SchedulerProperties.SCHEDULER_GET_SCHEDULES); + org.openecomp.vid.scheduler.RestObject<String> restObject = new org.openecomp.vid.scheduler.RestObject<>(); + SchedulerRestInterfaceIfc restClient = SchedulerRestInterfaceFactory.getInstance(); + + String str = new String(); + restObject.set(str); + restClient.Get(str, "", path, restObject); + String restCallResult = restObject.get(); + JSONParser parser = new JSONParser(); + Object parserResult = parser.parse(restCallResult); + result = (JSONArray) parserResult; + } catch (Exception e) { + e.printStackTrace(); + } + + return result; + } + + +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/WorkflowService.java b/vid-app-common/src/main/java/org/openecomp/vid/services/WorkflowService.java new file mode 100644 index 00000000..7f43433d --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/WorkflowService.java @@ -0,0 +1,9 @@ +package org.openecomp.vid.services; + +import org.openecomp.vid.model.Workflow; +import java.util.Collection; + +public interface WorkflowService { + Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames); + Collection<String> getAllWorkflows(); +} diff --git a/vid-app-common/src/main/java/org/openecomp/vid/services/WorkflowServiceImpl.java b/vid-app-common/src/main/java/org/openecomp/vid/services/WorkflowServiceImpl.java new file mode 100644 index 00000000..deb50606 --- /dev/null +++ b/vid-app-common/src/main/java/org/openecomp/vid/services/WorkflowServiceImpl.java @@ -0,0 +1,40 @@ +package org.openecomp.vid.services; + +import org.openecomp.vid.model.Workflow; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.stream.Collectors; + +@Service +public class WorkflowServiceImpl implements WorkflowService { + //TODO: Add the list of workflows hard coded or from DB. + private ArrayList<Workflow> workflows = new ArrayList<>(Arrays.asList( + new Workflow(0, "Upgrade", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3", "VNF4"))), + new Workflow(1, "Clean", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF3"))), + new Workflow(2, "Reinstall", new ArrayList<>(Arrays.asList("VNF1", "VNF2", "VNF4"))), + new Workflow(3, "Dump", new ArrayList<>(Arrays.asList("VNF1", "VNF3", "VNF4"))), + new Workflow(4, "Flush", new ArrayList<>(Arrays.asList("VNF2", "VNF3", "VNF4"))) + )); + + @Override + public Collection<String> getWorkflowsForVNFs(Collection<String> vnfNames) { + Collection<String> result = workflows.stream() + .filter(workflow -> workflow.getVnfNames().containsAll(vnfNames)) + .map(workflow -> workflow.getWorkflowName()) + .distinct() + .collect(Collectors.toList()); + + return result; + } + + @Override + public Collection<String> getAllWorkflows() { + return workflows.stream() + .map(workflow -> workflow.getWorkflowName()) + .distinct() + .collect(Collectors.toList()); + } +} |