1 package org.onap.vid.job.command
3 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
4 import org.onap.vid.job.Job
5 import org.onap.vid.job.JobAdapter
6 import org.onap.vid.job.JobCommand
7 import org.onap.vid.model.serviceInstantiation.InstanceGroup
8 import org.onap.vid.mso.RestMsoImplementation
9 import org.onap.vid.services.AsyncInstantiationBusinessLogic
10 import org.springframework.beans.factory.annotation.Autowired
11 import org.springframework.beans.factory.config.ConfigurableBeanFactory
12 import org.springframework.context.annotation.Scope
13 import org.springframework.http.HttpMethod
14 import org.springframework.stereotype.Component
18 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
19 class InstanceGroupCommand @Autowired constructor(
20 private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
21 restMso: RestMsoImplementation,
22 msoResultHandlerService: MsoResultHandlerService,
23 inProgressStatusService:InProgressStatusService,
24 watchChildrenJobsBL: WatchChildrenJobsBL
25 ) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService, watchChildrenJobsBL), JobCommand {
28 private val LOGGER = EELFLoggerDelegate.getLogger(InstanceGroupCommand::class.java)
31 override fun createChildren(): Job.JobStatus {
32 return Job.JobStatus.COMPLETED_WITH_NO_ACTION
35 override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
36 val serviceInstanceId = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
37 val serviceModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
39 val instantiatePath = asyncInstantiationBL.getInstanceGroupInstantiationPath()
41 val requestDetailsWrapper = asyncInstantiationBL.generateInstanceGroupInstantiationRequest(
42 request as InstanceGroup,
43 serviceModelInfo, serviceInstanceId,
47 val actionDescription = "create instance group in $serviceInstanceId"
49 return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
52 override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
53 val path = asyncInstantiationBL.getInstanceGroupDeletePath(getRequest().instanceId)
54 return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.empty(), Optional.of(userId),
55 "delete instance group with id ${getRequest().instanceId}")