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 dataSyncEnabled data sync enabled flag
224 public void setDataSyncEnabled(final String cmHandleId, final boolean dataSyncEnabled) {
225 final CompositeState compositeState = inventoryPersistence.getCmHandleState(cmHandleId);
226 if (compositeState.getDataSyncEnabled().equals(dataSyncEnabled)) {
227 log.info("Data-Sync Enabled flag is already: {} ", dataSyncEnabled);
228 } else if (compositeState.getCmHandleState() != CmHandleState.READY) {
229 throw new CpsException("State mismatch exception.", "Cm-Handle not in READY state. Cm handle state is: "
230 + compositeState.getCmHandleState());
232 final DataStoreSyncState dataStoreSyncState = compositeState.getDataStores()
233 .getOperationalDataStore().getDataStoreSyncState();
234 if (!dataSyncEnabled && dataStoreSyncState == DataStoreSyncState.SYNCHRONIZED) {
235 cpsDataService.deleteDataNode(NFP_OPERATIONAL_DATASTORE_DATASPACE_NAME, cmHandleId,
236 "/netconf-state", OffsetDateTime.now());
238 CompositeStateUtils.setDataSyncEnabledFlagWithDataSyncState(dataSyncEnabled, compositeState);
239 inventoryPersistence.saveCmHandleState(cmHandleId,
245 * Get all cm handle IDs by DMI plugin identifier.
247 * @param dmiPluginIdentifier DMI plugin identifier
248 * @return set of cm handle IDs
251 public Collection<String> getAllCmHandleIdsByDmiPluginIdentifier(final String dmiPluginIdentifier) {
252 return cmHandleQueries.getCmHandleIdsByDmiPluginIdentifier(dmiPluginIdentifier);
256 * Get all cm handle IDs by various properties.
258 * @param cmHandleQueryServiceParameters cm handle query parameters
259 * @return set of cm handle IDs
262 public Collection<String> executeCmHandleIdSearchForInventory(
263 final CmHandleQueryServiceParameters cmHandleQueryServiceParameters) {
264 validateCmHandleQueryParameters(cmHandleQueryServiceParameters, InventoryQueryConditions.ALL_CONDITION_NAMES);
265 return networkCmProxyCmHandleQueryService.queryCmHandleIdsForInventory(cmHandleQueryServiceParameters);
269 * Retrieve cm handle details for a given cm handle.
271 * @param cmHandleId cm handle identifier
272 * @return cm handle details
275 public NcmpServiceCmHandle getNcmpServiceCmHandle(final String cmHandleId) {
276 return YangDataConverter.convertYangModelCmHandleToNcmpServiceCmHandle(
277 inventoryPersistence.getYangModelCmHandle(cmHandleId));
281 * Get cm handle public properties for a given cm handle id.
283 * @param cmHandleId cm handle identifier
284 * @return cm handle public properties
287 public Map<String, String> getCmHandlePublicProperties(final String cmHandleId) {
288 final YangModelCmHandle yangModelCmHandle = inventoryPersistence.getYangModelCmHandle(cmHandleId);
289 final List<YangModelCmHandle.Property> yangModelPublicProperties = yangModelCmHandle.getPublicProperties();
290 final Map<String, String> cmHandlePublicProperties = new HashMap<>();
291 YangDataConverter.asPropertiesMap(yangModelPublicProperties, cmHandlePublicProperties);
292 return cmHandlePublicProperties;
296 * Get cm handle composite state for a given cm handle id.
298 * @param cmHandleId cm handle identifier
299 * @return cm handle state
302 public CompositeState getCmHandleCompositeState(final String cmHandleId) {
303 return inventoryPersistence.getYangModelCmHandle(cmHandleId).getCompositeState();
307 * THis method registers a cm handle and initiates modules sync.
309 * @param dmiPluginRegistration dmi plugin registration information.
310 * @return cm-handle registration response for create cm-handle requests.
312 public List<CmHandleRegistrationResponse> parseAndProcessCreatedCmHandlesInRegistration(
313 final DmiPluginRegistration dmiPluginRegistration) {
314 final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle = new HashMap<>();
315 dmiPluginRegistration.getCreatedCmHandles()
316 .forEach(cmHandle -> {
317 final YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(
318 dmiPluginRegistration.getDmiPlugin(),
319 dmiPluginRegistration.getDmiDataPlugin(),
320 dmiPluginRegistration.getDmiModelPlugin(),
322 cmHandle.getModuleSetTag());
323 cmHandleStatePerCmHandle.put(yangModelCmHandle, CmHandleState.ADVISED);
325 return registerNewCmHandles(cmHandleStatePerCmHandle);
328 protected List<CmHandleRegistrationResponse> parseAndProcessDeletedCmHandlesInRegistration(
329 final List<String> tobeRemovedCmHandles) {
330 final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses =
331 new ArrayList<>(tobeRemovedCmHandles.size());
332 final Collection<YangModelCmHandle> yangModelCmHandles =
333 inventoryPersistence.getYangModelCmHandles(tobeRemovedCmHandles);
335 updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETING);
337 final Set<String> notDeletedCmHandles = new HashSet<>();
338 for (final List<String> tobeRemovedCmHandleBatch : Lists.partition(tobeRemovedCmHandles, DELETE_BATCH_SIZE)) {
340 batchDeleteCmHandlesFromDbAndModuleSyncMap(tobeRemovedCmHandleBatch);
341 tobeRemovedCmHandleBatch.forEach(cmHandleId ->
342 cmHandleRegistrationResponses.add(CmHandleRegistrationResponse.createSuccessResponse(cmHandleId)));
344 } catch (final RuntimeException batchException) {
345 log.error("Unable to de-register cm-handle batch, retrying on each cm handle");
346 for (final String cmHandleId : tobeRemovedCmHandleBatch) {
347 final CmHandleRegistrationResponse cmHandleRegistrationResponse =
348 deleteCmHandleAndGetCmHandleRegistrationResponse(cmHandleId);
349 cmHandleRegistrationResponses.add(cmHandleRegistrationResponse);
350 if (cmHandleRegistrationResponse.getStatus() != CmHandleRegistrationResponse.Status.SUCCESS) {
351 notDeletedCmHandles.add(cmHandleId);
357 yangModelCmHandles.removeIf(yangModelCmHandle -> notDeletedCmHandles.contains(yangModelCmHandle.getId()));
358 updateCmHandleStateBatch(yangModelCmHandles, CmHandleState.DELETED);
360 return cmHandleRegistrationResponses;
363 protected List<CmHandleRegistrationResponse> parseAndProcessUpgradedCmHandlesInRegistration(
364 final DmiPluginRegistration dmiPluginRegistration) {
366 final UpgradedCmHandles upgradedCmHandles = dmiPluginRegistration.getUpgradedCmHandles();
367 final String moduleSetTag = dmiPluginRegistration.getUpgradedCmHandles().getModuleSetTag();
368 final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle =
369 new HashMap<>(upgradedCmHandles.getCmHandles().size());
370 final Collection<String> notReadyCmHandles = new ArrayList<>(upgradedCmHandles.getCmHandles().size());
371 final NcmpServiceCmHandle ncmpServiceCmHandle = new NcmpServiceCmHandle();
372 final String formattedModuleSetTag = MessageFormat.format("new moduleSetTag: {0}", moduleSetTag);
374 upgradedCmHandles.getCmHandles().forEach(cmHandleId -> {
375 if (cmHandleQueries.cmHandleHasState(cmHandleId, CmHandleState.READY)) {
376 ncmpServiceCmHandle.setCmHandleId(cmHandleId);
377 ncmpServiceCmHandle.setCompositeState(new CompositeStateBuilder()
378 .withCmHandleState(CmHandleState.READY)
379 .withLockReason(MODULE_UPGRADE, formattedModuleSetTag).build());
380 final YangModelCmHandle yangModelCmHandle = YangModelCmHandle.toYangModelCmHandle(
381 dmiPluginRegistration.getDmiPlugin(),
382 dmiPluginRegistration.getDmiDataPlugin(),
383 dmiPluginRegistration.getDmiModelPlugin(),
386 cmHandleStatePerCmHandle.put(yangModelCmHandle, CmHandleState.LOCKED);
388 notReadyCmHandles.add(cmHandleId);
392 return prepareAndGetCmHandleUpgradeResponses(cmHandleStatePerCmHandle, notReadyCmHandles);
395 private CmHandleRegistrationResponse deleteCmHandleAndGetCmHandleRegistrationResponse(final String cmHandleId) {
397 deleteCmHandleFromDbAndModuleSyncMap(cmHandleId);
398 return CmHandleRegistrationResponse.createSuccessResponse(cmHandleId);
399 } catch (final DataNodeNotFoundException dataNodeNotFoundException) {
400 log.error("Unable to find dataNode for cmHandleId : {} , caused by : {}",
401 cmHandleId, dataNodeNotFoundException.getMessage());
402 return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLES_NOT_FOUND);
403 } catch (final DataValidationException dataValidationException) {
404 log.error("Unable to de-register cm-handle id: {}, caused by: {}",
405 cmHandleId, dataValidationException.getMessage());
406 return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, CM_HANDLE_INVALID_ID);
407 } catch (final Exception exception) {
408 log.error("Unable to de-register cm-handle id : {} , caused by : {}", cmHandleId, exception.getMessage());
409 return CmHandleRegistrationResponse.createFailureResponse(cmHandleId, exception);
413 private void updateCmHandleStateBatch(final Collection<YangModelCmHandle> yangModelCmHandles,
414 final CmHandleState cmHandleState) {
415 final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle = new HashMap<>(yangModelCmHandles.size());
416 yangModelCmHandles.forEach(yangModelCmHandle -> cmHandleStatePerCmHandle.put(yangModelCmHandle, cmHandleState));
417 lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
420 private void deleteCmHandleFromDbAndModuleSyncMap(final String cmHandleId) {
421 inventoryPersistence.deleteSchemaSetWithCascade(cmHandleId);
422 inventoryPersistence.deleteDataNode(NCMP_DMI_REGISTRY_PARENT + "/cm-handles[@id='" + cmHandleId
424 removeDeletedCmHandleFromModuleSyncMap(cmHandleId);
427 private void batchDeleteCmHandlesFromDbAndModuleSyncMap(final Collection<String> tobeRemovedCmHandles) {
428 inventoryPersistence.deleteSchemaSetsWithCascade(tobeRemovedCmHandles);
429 inventoryPersistence.deleteDataNodes(mapCmHandleIdsToXpaths(tobeRemovedCmHandles));
430 tobeRemovedCmHandles.forEach(this::removeDeletedCmHandleFromModuleSyncMap);
433 private Collection<String> mapCmHandleIdsToXpaths(final Collection<String> cmHandles) {
434 return cmHandles.stream()
435 .map(cmHandleId -> NCMP_DMI_REGISTRY_PARENT + "/cm-handles[@id='" + cmHandleId + "']")
436 .collect(Collectors.toSet());
439 // CPS-1239 Robustness cleaning of in progress cache
440 private void removeDeletedCmHandleFromModuleSyncMap(final String deletedCmHandleId) {
441 if (moduleSyncStartedOnCmHandles.remove(deletedCmHandleId) != null) {
442 log.debug("{} removed from in progress map", deletedCmHandleId);
446 private List<CmHandleRegistrationResponse> registerNewCmHandles(final Map<YangModelCmHandle, CmHandleState>
447 cmHandleStatePerCmHandle) {
448 final List<String> cmHandleIds = getCmHandleIds(cmHandleStatePerCmHandle);
450 lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
451 return CmHandleRegistrationResponse.createSuccessResponses(cmHandleIds);
452 } catch (final AlreadyDefinedException alreadyDefinedException) {
453 return CmHandleRegistrationResponse.createFailureResponses(
454 alreadyDefinedException.getAlreadyDefinedObjectNames(),
455 CM_HANDLE_ALREADY_EXIST);
456 } catch (final Exception exception) {
457 return CmHandleRegistrationResponse.createFailureResponses(cmHandleIds, exception);
461 private List<CmHandleRegistrationResponse> prepareAndGetCmHandleUpgradeResponses(final Map<YangModelCmHandle,
462 CmHandleState> cmHandleStatePerCmHandle, final Collection<String> notReadyCmHandles) {
463 final List<CmHandleRegistrationResponse> cmHandleRegistrationResponses
464 = upgradeCmHandles(cmHandleStatePerCmHandle);
465 final List<CmHandleRegistrationResponse> failedCmHandleRegistrationResponses
466 = CmHandleRegistrationResponse.createFailureResponses(notReadyCmHandles, CM_HANDLES_NOT_READY);
467 failedCmHandleRegistrationResponses.forEach(cmHandleRegistrationResponses::add);
468 return cmHandleRegistrationResponses;
471 private List<CmHandleRegistrationResponse> upgradeCmHandles(final Map<YangModelCmHandle, CmHandleState>
472 cmHandleStatePerCmHandle) {
473 final List<String> cmHandleIds = getCmHandleIds(cmHandleStatePerCmHandle);
474 log.info("Moving cm handles : {} into locked (for upgrade) state.", cmHandleIds);
476 lcmEventsCmHandleStateHandler.updateCmHandleStateBatch(cmHandleStatePerCmHandle);
477 return CmHandleRegistrationResponse.createSuccessResponses(cmHandleIds);
478 } catch (final Exception exception) {
479 return CmHandleRegistrationResponse.createFailureResponses(cmHandleIds, exception);
483 private static List<String> getCmHandleIds(final Map<YangModelCmHandle, CmHandleState> cmHandleStatePerCmHandle) {
484 return cmHandleStatePerCmHandle.keySet().stream().map(YangModelCmHandle::getId).toList();
487 private void setTrustLevelPerDmiPlugin(final DmiPluginRegistration dmiPluginRegistration) {
488 if (DmiPluginRegistration.isNullEmptyOrBlank(dmiPluginRegistration.getDmiDataPlugin())) {
489 trustLevelPerDmiPlugin.put(dmiPluginRegistration.getDmiPlugin(), TrustLevel.COMPLETE);
491 trustLevelPerDmiPlugin.put(dmiPluginRegistration.getDmiDataPlugin(), TrustLevel.COMPLETE);