2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 highstreet technologies GmbH
4 * Modifications Copyright (C) 2021-2023 Nordix Foundation
5 * Modifications Copyright (C) 2021 Pantheon.tech
6 * Modifications Copyright (C) 2021-2022 Bell Canada
7 * Modifications Copyright (C) 2023 TechMahindra Ltd.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * SPDX-License-Identifier: Apache-2.0
22 * ============LICENSE_END=========================================================
25 package org.onap.cps.ncmp.api.impl;
27 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_FOUND;
28 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLES_NOT_READY;
29 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_ALREADY_EXIST;
30 import static org.onap.cps.ncmp.api.NcmpResponseStatus.CM_HANDLE_INVALID_ID;
31 import static org.onap.cps.ncmp.api.impl.inventory.LockReasonCategory.MODULE_UPGRADE;
32 import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NCMP_DMI_REGISTRY_PARENT;
33 import static org.onap.cps.ncmp.api.impl.ncmppersistence.NcmpPersistence.NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME;
34 import static org.onap.cps.ncmp.api.impl.utils.RestQueryParametersValidator.validateCmHandleQueryParameters;
36 import com.google.common.collect.Lists;
37 import com.hazelcast.map.IMap;
38 import java.text.MessageFormat;
39 import java.time.OffsetDateTime;
40 import java.util.ArrayList;
41 import java.util.Collection;
42 import java.util.HashMap;
43 import java.util.HashSet;
44 import java.util.List;
47 import java.util.stream.Collectors;
48 import lombok.RequiredArgsConstructor;
49 import lombok.extern.slf4j.Slf4j;
50 import org.onap.cps.api.CpsDataService;
51 import org.onap.cps.ncmp.api.NetworkCmProxyCmHandleQueryService;
52 import org.onap.cps.ncmp.api.NetworkCmProxyDataService;
53 import org.onap.cps.ncmp.api.impl.events.lcm.LcmEventsCmHandleStateHandler;
54 import org.onap.cps.ncmp.api.impl.inventory.CmHandleQueries;
55 import org.onap.cps.ncmp.api.impl.inventory.CmHandleState;
56 import org.onap.cps.ncmp.api.impl.inventory.CompositeState;
57 import org.onap.cps.ncmp.api.impl.inventory.CompositeStateBuilder;
58 import org.onap.cps.ncmp.api.impl.inventory.CompositeStateUtils;
59 import org.onap.cps.ncmp.api.impl.inventory.DataStoreSyncState;
60 import org.onap.cps.ncmp.api.impl.inventory.InventoryPersistence;
61 import org.onap.cps.ncmp.api.impl.operations.DmiDataOperations;
62 import org.onap.cps.ncmp.api.impl.operations.OperationType;
63 import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel;
64 import org.onap.cps.ncmp.api.impl.utils.CmHandleQueryConditions;
65 import org.onap.cps.ncmp.api.impl.utils.InventoryQueryConditions;
66 import org.onap.cps.ncmp.api.impl.utils.YangDataConverter;
67 import org.onap.cps.ncmp.api.impl.yangmodels.YangModelCmHandle;
68 import org.onap.cps.ncmp.api.models.CmHandleQueryApiParameters;
69 import org.onap.cps.ncmp.api.models.CmHandleQueryServiceParameters;
70 import org.onap.cps.ncmp.api.models.CmHandleRegistrationResponse;
71 import org.onap.cps.ncmp.api.models.DataOperationRequest;
72 import org.onap.cps.ncmp.api.models.DmiPluginRegistration;
73 import org.onap.cps.ncmp.api.models.DmiPluginRegistrationResponse;
74 import org.onap.cps.ncmp.api.models.NcmpServiceCmHandle;
75 import org.onap.cps.ncmp.api.models.UpgradedCmHandles;
76 import org.onap.cps.spi.FetchDescendantsOption;
77 import org.onap.cps.spi.exceptions.AlreadyDefinedException;
78 import org.onap.cps.spi.exceptions.CpsException;
79 import org.onap.cps.spi.exceptions.DataNodeNotFoundException;
80 import org.onap.cps.spi.exceptions.DataValidationException;
81 import org.onap.cps.spi.model.ModuleDefinition;
82 import org.onap.cps.spi.model.ModuleReference;
83 import org.onap.cps.utils.JsonObjectMapper;
84 import org.springframework.http.ResponseEntity;
85 import org.springframework.stereotype.Service;
89 @RequiredArgsConstructor
90 public class NetworkCmProxyDataServiceImpl implements NetworkCmProxyDataService {
92 private static final int DELETE_BATCH_SIZE = 100;
93 private final JsonObjectMapper jsonObjectMapper;
94 private final DmiDataOperations dmiDataOperations;
95 private final NetworkCmProxyDataServicePropertyHandler networkCmProxyDataServicePropertyHandler;
96 private final InventoryPersistence inventoryPersistence;
97 private final CmHandleQueries cmHandleQueries;
98 private final NetworkCmProxyCmHandleQueryService networkCmProxyCmHandleQueryService;
99 private final LcmEventsCmHandleStateHandler lcmEventsCmHandleStateHandler;
100 private final CpsDataService cpsDataService;
101 private final IMap<String, Object> moduleSyncStartedOnCmHandles;
102 private final Map<String, TrustLevel> trustLevelPerDmiPlugin;
105 public DmiPluginRegistrationResponse updateDmiRegistrationAndSyncModule(
106 final DmiPluginRegistration dmiPluginRegistration) {
107 dmiPluginRegistration.validateDmiPluginRegistration();
108 final DmiPluginRegistrationResponse dmiPluginRegistrationResponse = new DmiPluginRegistrationResponse();
110 if (!dmiPluginRegistration.getRemovedCmHandles().isEmpty()) {
111 dmiPluginRegistrationResponse.setRemovedCmHandles(
112 parseAndProcessDeletedCmHandlesInRegistration(dmiPluginRegistration.getRemovedCmHandles()));
115 if (!dmiPluginRegistration.getCreatedCmHandles().isEmpty()) {
116 dmiPluginRegistrationResponse.setCreatedCmHandles(
117 parseAndProcessCreatedCmHandlesInRegistration(dmiPluginRegistration));
119 if (!dmiPluginRegistration.getUpdatedCmHandles().isEmpty()) {
120 dmiPluginRegistrationResponse.setUpdatedCmHandles(
121 networkCmProxyDataServicePropertyHandler
122 .updateCmHandleProperties(dmiPluginRegistration.getUpdatedCmHandles()));
124 if (dmiPluginRegistration.getUpgradedCmHandles() != null
125 && !dmiPluginRegistration.getUpgradedCmHandles().getCmHandles().isEmpty()) {
126 dmiPluginRegistrationResponse.setUpgradedCmHandles(
127 parseAndProcessUpgradedCmHandlesInRegistration(dmiPluginRegistration));
130 setTrustLevelPerDmiPlugin(dmiPluginRegistration);
132 return dmiPluginRegistrationResponse;
136 public Object getResourceDataForCmHandle(final String datastoreName,
137 final String cmHandleId,
138 final String resourceIdentifier,
139 final String optionsParamInQuery,
140 final String topicParamInQuery,
141 final String requestId) {
142 final ResponseEntity<?> responseEntity = dmiDataOperations.getResourceDataFromDmi(datastoreName, cmHandleId,
147 return responseEntity.getBody();
151 public Object getResourceDataForCmHandle(final String datastoreName,
152 final String cmHandleId,
153 final String resourceIdentifier,
154 final FetchDescendantsOption fetchDescendantsOption) {
155 return cpsDataService.getDataNodes(datastoreName, cmHandleId, resourceIdentifier,
156 fetchDescendantsOption).iterator().next();
160 public void executeDataOperationForCmHandles(final String topicParamInQuery,
161 final DataOperationRequest
162 dataOperationRequest,
163 final String requestId) {
164 dmiDataOperations.requestResourceDataFromDmi(topicParamInQuery, dataOperationRequest, requestId);
168 public Object writeResourceDataPassThroughRunningForCmHandle(final String cmHandleId,
169 final String resourceIdentifier,
170 final OperationType operationType,
171 final String requestData,
172 final String dataType) {
173 return dmiDataOperations.writeResourceDataPassThroughRunningFromDmi(cmHandleId, resourceIdentifier,
174 operationType, requestData, dataType);
178 public Collection<ModuleReference> getYangResourcesModuleReferences(final String cmHandleId) {
179 return inventoryPersistence.getYangResourcesModuleReferences(cmHandleId);
183 public Collection<ModuleDefinition> getModuleDefinitionsByCmHandleId(final String cmHandleId) {
184 return inventoryPersistence.getModuleDefinitionsByCmHandleId(cmHandleId);
188 * Retrieve cm handles with details for the given query parameters.
190 * @param cmHandleQueryApiParameters cm handle query parameters
191 * @return cm handles with details
194 public Collection<NcmpServiceCmHandle> executeCmHandleSearch(
195 final CmHandleQueryApiParameters cmHandleQueryApiParameters) {
196 final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(
197 cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class);
198 validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES);
199 return networkCmProxyCmHandleQueryService.queryCmHandles(cmHandleQueryServiceParameters);
203 * Retrieve cm handle ids for the given query parameters.
205 * @param cmHandleQueryApiParameters cm handle query parameters
206 * @return cm handle ids
209 public Collection<String> executeCmHandleIdSearch(final CmHandleQueryApiParameters cmHandleQueryApiParameters) {
210 final CmHandleQueryServiceParameters cmHandleQueryServiceParameters = jsonObjectMapper.convertToValueType(
211 cmHandleQueryApiParameters, CmHandleQueryServiceParameters.class);
212 validateCmHandleQueryParameters(cmHandleQueryServiceParameters, CmHandleQueryConditions.ALL_CONDITION_NAMES);
213 return networkCmProxyCmHandleQueryService.queryCmHandleIds(cmHandleQueryServiceParameters);
217 * Set the data sync enabled flag, along with the data sync state
218 * based on the data sync enabled boolean for the cm handle id provided.
220 * @param cmHandleId cm handle id
221 * @param dataSyncEnabledTargetValue data sync enabled flag
224 public void setDataSyncEnabled(final String cmHandleId, final Boolean dataSyncEnabledTargetValue) {
225 final CompositeState compositeState = inventoryPersistence.getCmHandleState(cmHandleId);
226 if (dataSyncEnabledTargetValue.equals(compositeState.getDataSyncEnabled())) {
227 log.info("Data-Sync Enabled flag is already: {} ", dataSyncEnabledTargetValue);
230 if (CmHandleState.READY.equals(compositeState.getCmHandleState())) {
231 final DataStoreSyncState dataStoreSyncState = compositeState.getDataStores()
232 .getOperationalDataStore().getDataStoreSyncState();
233 if (Boolean.FALSE.equals(dataSyncEnabledTargetValue)
234 && DataStoreSyncState.SYNCHRONIZED.equals(dataStoreSyncState)) {
235 // TODO : This is hard-coded for onap dmi that need to be addressed
236 cpsDataService.deleteDataNode(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId,
237 "/netconf-state", OffsetDateTime.now());
239 CompositeStateUtils.setDataSyncEnabledFlagWithDataSyncState(dataSyncEnabledTargetValue, compositeState);
240 inventoryPersistence.saveCmHandleState(cmHandleId, compositeState);
242 throw new CpsException("State mismatch exception.", "Cm-Handle not in READY state. Cm handle state is: "
243 + compositeState.getCmHandleState());
248 * Get all cm handle IDs by DMI plugin identifier.
250 * @param dmiPluginIdentifier DMI plugin identifier
251 * @return set of cm handle IDs
254 public Collection<String> getAllCmHandleIdsByDmiPluginIdentifier(final String dmiPluginIdentifier) {
255 return cmHandleQueries.getCmHandleIdsByDmiPluginIdentifier(dmiPluginIdentifier);
259 * Get all cm handle IDs by various properties.
261 * @param cmHandleQueryServiceParameters cm handle query parameters
262 * @return set of cm handle IDs
265 public Collection<String> executeCmHandleIdSearchForInventory(
266 final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) {
267 validateCmHandleQueryParameters(cmHandleQueryServiceParameters, InventoryQueryConditions.ALL_CONDITION_NAMES);
268 return networkCmProxyCmHandleQueryService.queryCmHandleIdsForInventory(cmHandleQueryServiceParameters);
272 * Retrieve cm handle details for a given cm handle.
274 * @param cmHandleId cm handle identifier
275 * @return cm handle details
278 public NcmpServiceCmHandle getNcmpServiceCmHandle(final String cmHandleId) {
279 return YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(
280 inventoryPersistence.getYangModelCmHandle(cmHandleId));
284 * Get cm handle public properties for a given cm handle id.
286 * @param cmHandleId cm handle identifier
287 * @return cm handle public properties
290 public Map<String, String> getCmHandlePublicProperties(final String cmHandleId) {
291 final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId);
292 final List<YangModelCmHandle.Property> yangModelPublicProperties = yangModelCmHandle.getPublicProperties();
293 final Map<String, String> cmHandlePublicProperties = new HashMap<>();
294 YangDataConverter.asPropertiesMap(yangModelPublicProperties, cmHandlePublicProperties);
295 return cmHandlePublicProperties;
299 * Get cm handle composite state for a given cm handle id.
301 * @param cmHandleId cm handle identifier
302 * @return cm handle state
305 public CompositeState getCmHandleCompositeState(final String cmHandleId) {
306 return inventoryPersistence.getYangModelCmHandle(cmHandleId).getCompositeState();
310 * THis method registers a cm handle and initiates modules sync.
312 * @param dmiPluginRegistration dmi plugin registration information.
313 * @return cm-handle registration response for create cm-handle requests.
315 public List<CmHandleRegistrationResponse> parseAndProcessCreatedCmHandlesInRegistration(
316 final DmiPluginRegistration dmiPluginRegistration) {
317 final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle = new HashMap<>();
318 dmiPluginRegistration.getCreatedCmHandles()
319 .forEach(cmHandle -> {
320 final YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(
321 dmiPluginRegistration.getDmiPlugin(),
322 dmiPluginRegistration.getDmiDataPlugin(),
323 dmiPluginRegistration.getDmiModelPlugin(),
325 cmHandle.getModuleSetTag());
326 cmHandleStatePerCmHandle.put(yangModelCmHandle, CmHandleState.ADVISED);
328 return registerNewCmHandles(cmHandleStatePerCmHandle);
331 protected List<CmHandleRegistrationResponse> parseAndProcessDeletedCmHandlesInRegistration(
332 final List<String> tobeRemovedCmHandles) {
333 final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses =
334 new ArrayList<>(tobeRemovedCmHandles.size());
335 final Collection<YangModelCmHandle> yangModelCmHandles =
336 inventoryPersistence.getYangModelCmHandles(tobeRemovedCmHandles);
338 updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETING);
340 final Set<String> notDeletedCmHandles = new HashSet<>();
341 for (final List<String> tobeRemovedCmHandleBatch : Lists.partition(tobeRemovedCmHandles, DELETE_BATCH_SIZE)) {
343 batchDeleteCmHandlesFromDbAndModuleSyncMap(tobeRemovedCmHandleBatch);
344 tobeRemovedCmHandleBatch.forEach(cmHandleId ->
345 cmHandleRegistrationResponses.add(CmHandleRegistrationResponse.createSuccessResponse(cmHandleId)));
347 } catch (final RuntimeException batchException) {
348 log.error("Unable to de-register cm-handle batch, retrying on each cm handle");
349 for (final String cmHandleId : tobeRemovedCmHandleBatch) {
350 final CmHandleRegistrationResponse cmHandleRegistrationResponse =
351 deleteCmHandleAndGetCmHandleRegistrationResponse(cmHandleId);
352 cmHandleRegistrationResponses.add(cmHandleRegistrationResponse);
353 if (cmHandleRegistrationResponse.getStatus() != CmHandleRegistrationResponse.Status.SUCCESS) {
354 notDeletedCmHandles.add(cmHandleId);
360 yangModelCmHandles.removeIf(yangModelCmHandle -> notDeletedCmHandles.contains(yangModelCmHandle.getId()));
361 updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETED);
363 return cmHandleRegistrationResponses;
366 protected List<CmHandleRegistrationResponse> parseAndProcessUpgradedCmHandlesInRegistration(
367 final DmiPluginRegistration dmiPluginRegistration) {
369 final UpgradedCmHandles upgradedCmHandles = dmiPluginRegistration.getUpgradedCmHandles();
370 final String moduleSetTag = dmiPluginRegistration.getUpgradedCmHandles().getModuleSetTag();
371 final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle =
372 new HashMap<>(upgradedCmHandles.getCmHandles().size());
373 final Collection<String> notReadyCmHandles = new ArrayList<>(upgradedCmHandles.getCmHandles().size());
374 final NcmpServiceCmHandle ncmpServiceCmHandle = new NcmpServiceCmHandle();
375 final String formattedModuleSetTag = MessageFormat.format("new moduleSetTag: {0}", moduleSetTag);
377 upgradedCmHandles.getCmHandles().forEach(cmHandleId -> {
378 if (cmHandleQueries.cmHandleHasState(cmHandleId, CmHandleState.READY)) {
379 ncmpServiceCmHandle.setCmHandleId(cmHandleId);
380 ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder()
381 .withCmHandleState(CmHandleState.READY)
382 .withLockReason(MODULE_UPGRADE, formattedModuleSetTag).build());
383 final YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(
384 dmiPluginRegistration.getDmiPlugin(),
385 dmiPluginRegistration.getDmiDataPlugin(),
386 dmiPluginRegistration.getDmiModelPlugin(),
389 cmHandleStatePerCmHandle.put(yangModelCmHandle, CmHandleState.LOCKED);
391 notReadyCmHandles.add(cmHandleId);
395 return prepareAndGetCmHandleUpgradeResponses(cmHandleStatePerCmHandle, notReadyCmHandles);
398 private CmHandleRegistrationResponse deleteCmHandleAndGetCmHandleRegistrationResponse(final String cmHandleId) {
400 deleteCmHandleFromDbAndModuleSyncMap(cmHandleId);
401 return CmHandleRegistrationResponse.createSuccessResponse(cmHandleId);
402 } catch (final DataNodeNotFoundException dataNodeNotFoundException) {
403 log.error("Unable to find dataNode for cmHandleId : {} , caused by : {}",
404 cmHandleId, dataNodeNotFoundException.getMessage());
405 return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLES_NOT_FOUND);
406 } catch (final DataValidationException dataValidationException) {
407 log.error("Unable to de-register cm-handle id: {}, caused by: {}",
408 cmHandleId, dataValidationException.getMessage());
409 return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLE_INVALID_ID);
410 } catch (final Exception exception) {
411 log.error("Unable to de-register cm-handle id : {} , caused by : {}", cmHandleId, exception.getMessage());
412 return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, exception);
416 private void updateCmHandleStateBatch(final Collection<YangModelCmHandle> yangModelCmHandles,
417 final CmHandleState cmHandleState) {
418 final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle = new HashMap<>(yangModelCmHandles.size());
419 yangModelCmHandles.forEach(yangModelCmHandle -> cmHandleStatePerCmHandle.put(yangModelCmHandle, cmHandleState));
420 lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
423 private void deleteCmHandleFromDbAndModuleSyncMap(final String cmHandleId) {
424 inventoryPersistence.deleteSchemaSetWithCascade(cmHandleId);
425 inventoryPersistence.deleteDataNode(NCMP_DMI_REGISTRY_PARENT + "/cm-handles[@id='" + cmHandleId
427 removeDeletedCmHandleFromModuleSyncMap(cmHandleId);
430 private void batchDeleteCmHandlesFromDbAndModuleSyncMap(final Collection<String> tobeRemovedCmHandles) {
431 inventoryPersistence.deleteSchemaSetsWithCascade(tobeRemovedCmHandles);
432 inventoryPersistence.deleteDataNodes(mapCmHandleIdsToXpaths(tobeRemovedCmHandles));
433 tobeRemovedCmHandles.forEach(this::removeDeletedCmHandleFromModuleSyncMap);
436 private Collection<String> mapCmHandleIdsToXpaths(final Collection<String> cmHandles) {
437 return cmHandles.stream()
438 .map(cmHandleId -> NCMP_DMI_REGISTRY_PARENT + "/cm-handles[@id='" + cmHandleId + "']")
439 .collect(Collectors.toSet());
442 // CPS-1239 Robustness cleaning of in progress cache
443 private void removeDeletedCmHandleFromModuleSyncMap(final String deletedCmHandleId) {
444 if (moduleSyncStartedOnCmHandles.remove(deletedCmHandleId) != null) {
445 log.debug("{} removed from in progress map", deletedCmHandleId);
449 private List<CmHandleRegistrationResponse> registerNewCmHandles(final Map<YangModelCmHandle, CmHandleState>
450 cmHandleStatePerCmHandle) {
451 final List<String> cmHandleIds = getCmHandleIds(cmHandleStatePerCmHandle);
453 lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
454 return CmHandleRegistrationResponse.createSuccessResponses(cmHandleIds);
455 } catch (final AlreadyDefinedException alreadyDefinedException) {
456 return CmHandleRegistrationResponse.createFailureResponses(
457 alreadyDefinedException.getAlreadyDefinedObjectNames(),
458 CM_HANDLE_ALREADY_EXIST);
459 } catch (final Exception exception) {
460 return CmHandleRegistrationResponse.createFailureResponses(cmHandleIds, exception);
464 private List<CmHandleRegistrationResponse> prepareAndGetCmHandleUpgradeResponses(final Map<YangModelCmHandle,
465 CmHandleState> cmHandleStatePerCmHandle, final Collection<String> notReadyCmHandles) {
466 final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses
467 = upgradeCmHandles(cmHandleStatePerCmHandle);
468 final List<CmHandleRegistrationResponse> failedCmHandleRegistrationResponses
469 = CmHandleRegistrationResponse.createFailureResponses(notReadyCmHandles, CM_HANDLES_NOT_READY);
470 failedCmHandleRegistrationResponses.forEach(cmHandleRegistrationResponses::add);
471 return cmHandleRegistrationResponses;
474 private List<CmHandleRegistrationResponse> upgradeCmHandles(final Map<YangModelCmHandle, CmHandleState>
475 cmHandleStatePerCmHandle) {
476 final List<String> cmHandleIds = getCmHandleIds(cmHandleStatePerCmHandle);
477 log.info("Moving cm handles : {} into locked (for upgrade) state.", cmHandleIds);
479 lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
480 return CmHandleRegistrationResponse.createSuccessResponses(cmHandleIds);
481 } catch (final Exception exception) {
482 return CmHandleRegistrationResponse.createFailureResponses(cmHandleIds, exception);
486 private static List<String> getCmHandleIds(final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle) {
487 return cmHandleStatePerCmHandle.keySet().stream().map(YangModelCmHandle::getId).toList();
490 private void setTrustLevelPerDmiPlugin(final DmiPluginRegistration dmiPluginRegistration) {
491 if (DmiPluginRegistration.isNullEmptyOrBlank(dmiPluginRegistration.getDmiDataPlugin())) {
492 trustLevelPerDmiPlugin.put(dmiPluginRegistration.getDmiPlugin(), TrustLevel.COMPLETE);
494 trustLevelPerDmiPlugin.put(dmiPluginRegistration.getDmiDataPlugin(), TrustLevel.COMPLETE);