1 package org.onap.vid.job.command
3 import org.apache.commons.lang3.StringUtils.isNotEmpty
4 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
5 import org.onap.vid.job.*
6 import org.onap.vid.model.Action
7 import org.onap.vid.model.serviceInstantiation.BaseResource
8 import org.onap.vid.model.serviceInstantiation.VfModule
9 import org.onap.vid.mso.RestMsoImplementation
10 import org.onap.vid.services.AsyncInstantiationBusinessLogic
11 import org.springframework.beans.factory.annotation.Autowired
12 import org.springframework.beans.factory.config.ConfigurableBeanFactory
13 import org.springframework.context.annotation.Scope
14 import org.springframework.http.HttpMethod
15 import org.springframework.stereotype.Component
19 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
20 class VolumeGroupCommand @Autowired constructor(
21 private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
22 restMso: RestMsoImplementation,
23 private val msoRequestBuilder: MsoRequestBuilder,
24 msoResultHandlerService: MsoResultHandlerService,
25 inProgressStatusService:InProgressStatusService,
26 watchChildrenJobsBL: WatchChildrenJobsBL,
27 jobsBrokerService: JobsBrokerService,
28 jobAdapter: JobAdapter
29 ) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
30 watchChildrenJobsBL, jobsBrokerService, jobAdapter), JobCommand {
33 private val LOGGER = EELFLoggerDelegate.getLogger(VolumeGroupCommand::class.java)
36 override fun createChildren(): Job.JobStatus {
37 val request: VfModule = getRequest()
38 val dataForChild = buildDataForChild(request, actionPhase)
40 childJobs = pushChildrenJobsToBroker(listOf(request), dataForChild, JobType.VfmoduleInstantiation)
42 return Job.JobStatus.COMPLETED_WITH_NO_ACTION
45 override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
46 val serviceInstanceId = serviceInstanceIdFromRequest()
47 val vnfInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.VNF_INSTANCE_ID)
48 val vnfModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.VNF_MODEL_INFO)
50 val instantiatePath = asyncInstantiationBL.getVolumeGroupInstantiationPath(serviceInstanceId,vnfInstanceId)
52 val requestDetailsWrapper = msoRequestBuilder.generateVolumeGroupInstantiationRequest(
54 serviceModelInfoFromRequest(), serviceInstanceId,
55 vnfModelInfo,vnfInstanceId,
60 val actionDescription = "create volumeGroup in $vnfInstanceId"
62 return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
65 override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
66 TODO("not implemented")
69 override fun isNeedToCreateMyself(): Boolean {
70 return super.isNeedToCreateMyself() && isNotEmpty(getRequest().volumeGroupInstanceName)
73 override fun isNeedToDeleteMyself(): Boolean {
77 override fun getRequest(): VfModule {
78 return sharedData.request as VfModule
81 override fun isDescendantHasAction(phase: Action): Boolean {
82 return phase == getRequest().action
85 override fun addMyselfToChildrenData(commandParentData: CommandParentData, request: BaseResource) {
86 commandParentData.addInstanceId(CommandParentData.CommandDataKey.VG_INSTANCE_ID, getActualInstanceId(request));
89 override fun replaceMyself(): Job.JobStatus {
90 return Job.JobStatus.COMPLETED