use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class VolumeRestHandlerTest method createTestRequest.
private ServiceInstancesRequest createTestRequest() {
ServiceInstancesRequest request = new ServiceInstancesRequest();
RequestDetails requestDetails = new RequestDetails();
RequestInfo requestInfo = new RequestInfo();
requestInfo.setInstanceName("instanceName");
requestDetails.setRequestInfo(requestInfo);
request.setRequestDetails(requestDetails);
return request;
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class VfModuleRestHandlerTest method createTestRequest.
private ServiceInstancesRequest createTestRequest() {
ServiceInstancesRequest request = new ServiceInstancesRequest();
RequestDetails requestDetails = new RequestDetails();
RequestInfo requestInfo = new RequestInfo();
requestInfo.setInstanceName("instanceName");
requestDetails.setRequestInfo(requestInfo);
request.setRequestDetails(requestDetails);
return request;
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class OrchestrationRequests method mapInfraActiveRequestToRequest.
protected Request mapInfraActiveRequestToRequest(InfraActiveRequests iar, boolean includeCloudRequest, String format, String version) throws ApiException {
String requestBody = iar.getRequestBody();
Request request = new Request();
ObjectMapper mapper = new ObjectMapper();
request.setRequestId(iar.getRequestId());
request.setRequestScope(iar.getRequestScope());
request.setRequestType(iar.getRequestAction());
String originalRequestId = iar.getOriginalRequestId();
if (originalRequestId != null) {
request.setOriginalRequestId(originalRequestId);
}
if (!version.matches("v[1-7]")) {
String workflowName = iar.getWorkflowName();
if (workflowName == null) {
workflowName = iar.getRequestAction();
}
request.setWorkflowName(workflowName);
String operationName = iar.getOperationName();
if (operationName != null) {
request.setOperationName(operationName);
}
}
InstanceReferences ir = new InstanceReferences();
if (iar.getNetworkId() != null)
ir.setNetworkInstanceId(iar.getNetworkId());
if (iar.getNetworkName() != null)
ir.setNetworkInstanceName(iar.getNetworkName());
if (iar.getServiceInstanceId() != null)
ir.setServiceInstanceId(iar.getServiceInstanceId());
if (iar.getServiceInstanceName() != null)
ir.setServiceInstanceName(iar.getServiceInstanceName());
if (iar.getVfModuleId() != null)
ir.setVfModuleInstanceId(iar.getVfModuleId());
if (iar.getVfModuleName() != null)
ir.setVfModuleInstanceName(iar.getVfModuleName());
if (iar.getVnfId() != null)
ir.setVnfInstanceId(iar.getVnfId());
if (iar.getVnfName() != null)
ir.setVnfInstanceName(iar.getVnfName());
if (iar.getVolumeGroupId() != null)
ir.setVolumeGroupInstanceId(iar.getVolumeGroupId());
if (iar.getVolumeGroupName() != null)
ir.setVolumeGroupInstanceName(iar.getVolumeGroupName());
if (iar.getInstanceGroupId() != null)
ir.setInstanceGroupId(iar.getInstanceGroupId());
if (iar.getInstanceGroupName() != null)
ir.setInstanceGroupName(iar.getInstanceGroupName());
request.setInstanceReferences(ir);
RequestDetails requestDetails = null;
if (StringUtils.isNotBlank(requestBody)) {
try {
if (requestBody.contains("\"requestDetails\":")) {
ServiceInstancesRequest sir = mapper.readValue(requestBody, ServiceInstancesRequest.class);
requestDetails = sir.getRequestDetails();
} else {
requestDetails = mapper.readValue(requestBody, RequestDetails.class);
}
if (requestDetails.getRequestInfo() != null && iar.getProductFamilyName() != null) {
requestDetails.getRequestInfo().setProductFamilyName(iar.getProductFamilyName());
}
if (requestDetails.getCloudConfiguration() != null && iar.getTenantName() != null) {
requestDetails.getCloudConfiguration().setTenantName(iar.getTenantName());
}
} catch (IOException e) {
logger.error("Exception occurred", e);
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, ErrorCode.SchemaError).build();
ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : ", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build();
throw validateException;
}
}
request.setRequestDetails(requestDetails);
if (iar.getStartTime() != null) {
String startTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getStartTime()) + " GMT";
request.setStartTime(startTimeStamp);
}
if (iar.getEndTime() != null) {
String endTimeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getEndTime()) + " GMT";
request.setFinishTime(endTimeStamp);
}
RequestStatus status = new RequestStatus();
if (iar.getModifyTime() != null) {
String timeStamp = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss").format(iar.getModifyTime()) + " GMT";
status.setTimeStamp(timeStamp);
}
status.setRequestState(mapRequestStatusToRequest(iar, format));
if (iar.getProgress() != null) {
status.setPercentProgress(iar.getProgress().intValue());
}
if (iar.getCloudApiRequests() != null && !iar.getCloudApiRequests().isEmpty() && includeCloudRequest) {
iar.getCloudApiRequests().stream().forEach(cloudRequest -> {
try {
request.getCloudRequestData().add(new CloudRequestData(mapper.readValue(cloudRequest.getRequestBody(), Object.class), cloudRequest.getCloudIdentifier()));
} catch (Exception e) {
logger.error("Error reading Cloud Request", e);
}
});
}
mapRequestStatusAndExtSysErrSrcToRequest(iar, status, format, version);
request.setRequestStatus(status);
return request;
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class MsoRequest method createRequestObject.
public InfraActiveRequests createRequestObject(ServiceInstancesRequest servInsReq, Actions action, String requestId, Status status, String originalRequestJSON, String requestScope) {
InfraActiveRequests aq = new InfraActiveRequests();
try {
if (null == servInsReq) {
servInsReq = new ServiceInstancesRequest();
}
String networkType = "";
String vnfType = "";
aq.setRequestId(requestId);
aq.setRequestAction(action.toString());
aq.setRequestUrl(MDC.get(LogConstants.HTTP_URL));
Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
aq.setStartTime(startTimeStamp);
if (requestScope.equals(ModelType.instanceGroup.name()) && action == Action.deleteInstance) {
aq.setRequestScope(requestScope);
} else {
RequestInfo requestInfo = servInsReq.getRequestDetails().getRequestInfo();
if (requestInfo != null) {
if (requestInfo.getSource() != null) {
aq.setSource(requestInfo.getSource());
}
if (requestInfo.getCallbackUrl() != null) {
aq.setCallBackUrl(requestInfo.getCallbackUrl());
}
if (requestInfo.getCorrelator() != null) {
aq.setCorrelator(requestInfo.getCorrelator());
}
if (requestInfo.getRequestorId() != null) {
aq.setRequestorId(requestInfo.getRequestorId());
}
}
if (servInsReq.getRequestDetails().getModelInfo() != null || (action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig)) {
aq.setRequestScope(requestScope);
}
if (servInsReq.getRequestDetails().getCloudConfiguration() != null) {
CloudConfiguration cloudConfiguration = servInsReq.getRequestDetails().getCloudConfiguration();
if (cloudConfiguration.getLcpCloudRegionId() != null) {
aq.setCloudRegion(cloudConfiguration.getLcpCloudRegionId());
}
if (cloudConfiguration.getTenantId() != null) {
aq.setTenantId(cloudConfiguration.getTenantId());
}
}
if (servInsReq.getServiceInstanceId() != null) {
aq.setServiceInstanceId(servInsReq.getServiceInstanceId());
}
if (servInsReq.getVnfInstanceId() != null) {
aq.setVnfId(servInsReq.getVnfInstanceId());
}
if (servInsReq.getPnfName() != null) {
aq.setRequestScope(requestScope);
aq.setPnfName(servInsReq.getPnfName());
}
if (servInsReq.getRequestDetails() != null && servInsReq.getRequestDetails().getRequestInfo() != null && servInsReq.getRequestDetails().getRequestInfo().getProductFamilyId() != null) {
logger.debug("Retrieving productFamilyName to put into requests db");
org.onap.aai.domain.yang.Service service = aaiDataRet.getService(servInsReq.getRequestDetails().getRequestInfo().getProductFamilyId());
if (service != null) {
logger.debug("Found service by service-id");
String productFamilyName = service.getServiceDescription();
if (productFamilyName != null) {
aq.setProductFamilyName(productFamilyName);
}
}
}
aq.setProductFamilyName(getProductFamilyNameFromAAI(servInsReq));
aq.setTenantName(getTenantNameFromAAI(servInsReq));
if (ModelType.service.name().equalsIgnoreCase(requestScope)) {
if (servInsReq.getRequestDetails().getRequestInfo() != null) {
if (servInsReq.getRequestDetails().getRequestInfo().getInstanceName() != null) {
aq.setServiceInstanceName(requestInfo.getInstanceName());
}
}
}
if (ModelType.network.name().equalsIgnoreCase(requestScope)) {
aq.setNetworkName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
aq.setNetworkType(networkType);
aq.setNetworkId(servInsReq.getNetworkInstanceId());
}
if (ModelType.volumeGroup.name().equalsIgnoreCase(requestScope)) {
aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
aq.setVolumeGroupName(servInsReq.getRequestDetails().getRequestInfo().getInstanceName());
aq.setVnfType(vnfType);
}
if (ModelType.vfModule.name().equalsIgnoreCase(requestScope)) {
aq.setVfModuleName(requestInfo.getInstanceName());
aq.setVfModuleModelName(servInsReq.getRequestDetails().getModelInfo().getModelName());
aq.setVfModuleId(servInsReq.getVfModuleInstanceId());
aq.setVolumeGroupId(servInsReq.getVolumeGroupInstanceId());
aq.setVnfType(vnfType);
}
if (ModelType.configuration.name().equalsIgnoreCase(requestScope)) {
aq.setConfigurationId(servInsReq.getConfigurationId());
aq.setConfigurationName(requestInfo.getInstanceName());
}
if (requestScope.equalsIgnoreCase(ModelType.instanceGroup.name())) {
aq.setInstanceGroupId(servInsReq.getInstanceGroupId());
aq.setInstanceGroupName(requestInfo.getInstanceName());
}
if (ModelType.vnf.name().equalsIgnoreCase(requestScope)) {
if (requestInfo != null) {
aq.setVnfName(requestInfo.getInstanceName());
}
if (null != servInsReq.getRequestDetails()) {
RelatedInstanceList[] instanceList = servInsReq.getRequestDetails().getRelatedInstanceList();
if (instanceList != null) {
for (RelatedInstanceList relatedInstanceList : instanceList) {
RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
if (relatedInstance.getModelInfo().getModelType().equals(ModelType.service)) {
aq.setVnfType(vnfType);
}
}
}
}
}
}
aq.setRequestBody(originalRequestJSON);
aq.setRequestStatus(status.toString());
aq.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
} catch (Exception e) {
logger.error("Exception when creation record request", e);
if (!status.equals(Status.FAILED)) {
throw e;
}
}
return aq;
}
use of org.onap.so.serviceinstancebeans.ServiceInstancesRequest in project so by onap.
the class ResumeOrchestrationRequest method resumeRequest.
protected Response resumeRequest(InfraActiveRequests infraActiveRequest, InfraActiveRequests currentActiveRequest, String version, String requestUri) throws ApiException {
String requestBody = infraActiveRequest.getRequestBody();
Action action = Action.valueOf(infraActiveRequest.getRequestAction());
String requestId = currentActiveRequest.getRequestId();
String requestScope = infraActiveRequest.getRequestScope();
String instanceName = getInstanceName(infraActiveRequest, requestScope, currentActiveRequest);
HashMap<String, String> instanceIdMap = setInstanceIdMap(infraActiveRequest, requestScope);
checkForInProgressRequest(currentActiveRequest, instanceIdMap, requestScope, instanceName, action);
ServiceInstancesRequest sir = null;
sir = requestHandlerUtils.convertJsonToServiceInstanceRequest(requestBody, action, requestId, requestUri);
Boolean aLaCarte = sir.getRequestDetails().getRequestParameters().getALaCarte();
String pnfCorrelationId = serviceInstances.getPnfCorrelationId(sir);
RecipeLookupResult recipeLookupResult = requestHandlerUtils.getServiceInstanceOrchestrationURI(sir, action, msoRequest.getAlacarteFlag(sir), currentActiveRequest);
requestDbSave(currentActiveRequest);
if (aLaCarte == null) {
aLaCarte = setALaCarteFlagIfNull(requestScope, action);
}
RequestClientParameter requestClientParameter = setRequestClientParameter(recipeLookupResult, version, infraActiveRequest, currentActiveRequest, pnfCorrelationId, aLaCarte, sir);
return requestHandlerUtils.postBPELRequest(currentActiveRequest, requestClientParameter, recipeLookupResult.getOrchestrationURI(), requestScope);
}
Aggregations