2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.vid.job.command;
24 import org.apache.commons.lang3.StringUtils;
25 import org.onap.vid.changeManagement.RequestDetailsWrapper;
26 import org.onap.vid.job.*;
27 import org.onap.vid.job.command.CommandParentData.CommandDataKey;
28 import org.onap.vid.model.serviceInstantiation.VfModule;
29 import org.onap.vid.mso.model.VolumeGroupRequestDetails;
30 import org.onap.vid.services.AsyncInstantiationBusinessLogic;
31 import org.springframework.beans.factory.config.ConfigurableBeanFactory;
32 import org.springframework.context.annotation.Scope;
33 import org.springframework.stereotype.Component;
35 import javax.inject.Inject;
36 import java.util.Collections;
37 import java.util.List;
41 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
42 public class VolumeGroupInstantiationCommand extends ResourceInstantiationCommand {
44 private AsyncInstantiationBusinessLogic asyncInstantiationBL;
47 protected JobsBrokerService jobsBrokerService;
50 protected JobAdapter jobAdapter;
53 protected String getRequestPath() {
54 return asyncInstantiationBL.getVolumeGroupInstantiationPath(commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),commandParentData.getInstanceId(CommandDataKey.VNF_INSTANCE_ID));
58 protected RequestDetailsWrapper<VolumeGroupRequestDetails> generateMSORequest(JobAdapter.AsyncJobRequest request, String userId) {
59 return asyncInstantiationBL.generateVolumeGroupInstantiationRequest(
60 (VfModule) getSharedData().getRequest(),
61 commandParentData.getModelInfo(CommandDataKey.SERVICE_MODEL_INFO),
62 commandParentData.getInstanceId(CommandDataKey.SERVICE_INSTANCE_ID),
63 commandParentData.getModelInfo(CommandDataKey.VNF_MODEL_INFO),
64 commandParentData.getInstanceId(CommandDataKey.VNF_INSTANCE_ID),
65 getSharedData().getUserId()
70 protected NextCommand getNextCommand(String requestId, String instanceId){
71 return new NextCommand(
72 Job.JobStatus.RESOURCE_IN_PROGRESS,
73 new VolumeGroupInProgressStatusCommand(getSharedData(), requestId, instanceId, commandParentData)
78 protected String getJobAuditMSOStatus() {
79 return "VOLUME_GROUP_REQUESTED";
83 public NextCommand call() {
84 String vgName = ((VfModule)getSharedData().getRequest()).getVolumeGroupInstanceName();
85 if(StringUtils.isNotEmpty(vgName)){
86 return super.call();//create volume group
88 //go to vf module creation
89 VfModule request = (VfModule) getSharedData().getRequest();
90 Map<String, Object> dataForChild = buildDataForChild();
91 List<String> vfModuleJob = Collections.singletonList(jobsBrokerService.add(
92 jobAdapter.createChildJob(JobType.VfmoduleInstantiation, Job.JobStatus.CREATING, request, getSharedData(), dataForChild)).toString());
94 return new NextCommand(Job.JobStatus.RESOURCE_IN_PROGRESS, new WatchingCommand(getSharedData(), vfModuleJob, false));
99 private Map<String, Object> buildDataForChild() {
100 return commandParentData.getParentData();