2 * Copyright © 2019 IBM.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package cba.resource.audit.functions
19 import cba.resource.audit.deviceResourceDefinitions
20 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
21 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction
22 import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor
23 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants
24 import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
25 import org.onap.ccsdk.cds.controllerblueprints.core.jsonAsJsonType
26 import org.onap.ccsdk.cds.controllerblueprints.core.logger
28 class ConfigCollector : AbstractScriptComponentFunction() {
30 val log = logger(ConfigCollector::class)
32 override suspend fun processNB(executionRequest: ExecutionServiceInput) {
34 val deviceId = bluePrintRuntimeService.getInputValue("device-id").textValue()
35 val sources = bluePrintRuntimeService.getInputValue("sources")
37 log.info("Processing Config Collection for device($deviceId), for sources($sources)")
38 deviceResourceDefinitions.forEach { name, resourceDefinition ->
39 log.info("collecting for the property : $name")
40 resourceDefinition.sources.forEach { sourceName, source ->
41 log.info("collecting for the Source : $sourceName")
46 setAttribute(ComponentScriptExecutor.ATTRIBUTE_STATUS, BluePrintConstants.STATUS_SUCCESS.asJsonPrimitive())
47 setAttribute(ComponentScriptExecutor.ATTRIBUTE_RESPONSE_DATA, """{
48 "port-speed" : "10MBS"
49 }""".trimIndent().jsonAsJsonType())
53 override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) {