Table of Contents |
---|
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
...
- Call dmi–plugin rest endpoint to retrieve all modules on new node (depends
CPS-483andCPS-531) - Call CPS-Core rest endpoint to get all existing modules in cps-core (depends CPS-506)
- Calculate difference (delta)
- Call dmi–plugin rest endpoint to retrieve missing modules
CPS-483 - Add missing modules to cps-core to anchor (cm handle) (depends CPS-508)
Implementation Proposal
Within the DMI plugin there is a method where cm handles are sent to a registration method in NCMP.
From: DmiServiceImpl.registerCmHandlesWithNcmp(final String jsonData) To: NetworkCmProxyController.updateDmiPluginRegistration()
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Override public void registerCmHandles(final List<String> cmHandles) { final CmHandleOperation cmHandleOperation = new CmHandleOperation(); cmHandleOperation.setDmiPlugin(dmiPluginProperties.getDmiServiceName()); final List<CreatedCmHandle> createdCmHandleList = new ArrayList<>(); for (final String cmHandle: cmHandles) { final CreatedCmHandle createdCmHandle = new CreatedCmHandle(); createdCmHandle.setCmHandle(cmHandle); createdCmHandleList.add(createdCmHandle); } cmHandleOperation.setCreatedCmHandles(createdCmHandleList); final String cmHandlesJson; try { cmHandlesJson = objectMapper.writeValueAsString(cmHandleOperation); } catch (final JsonProcessingException e) { log.error("Parsing error occurred while converting cm-handles to JSON {}", cmHandles); throw new DmiException("Internal Server Error.", "Parsing error occurred while converting given cm-handles object list to JSON "); } final ResponseEntity<String> responseEntity = ncmpRestClient.registerCmHandlesWithNcmp(cmHandlesJson); if (!(responseEntity.getStatusCode() == HttpStatus.CREATED)) { throw new CmHandleRegistrationException(responseEntity.getBody()); } } |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Override public void updateDmiPluginRegistration(final DmiPluginRegistration dmiPluginRegistration) { try { final List<PersistenceCmHandle> persistenceCmHandles = new ArrayList<>(); for (final CmHandle cmHandle: dmiPluginRegistration.getCreatedCmHandles()) { final PersistenceCmHandle persistenceCmHandle = new PersistenceCmHandle(); persistenceCmHandle.setDmiServiceName(dmiPluginRegistration.getDmiPlugin()); persistenceCmHandle.setId(cmHandle.getCmHandle()); persistenceCmHandle.setAdditionalProperties(cmHandle.getCmHandleProperties()); persistenceCmHandles.add(persistenceCmHandle); } final PersistenceCmHandlesList persistenceCmHandlesList = new PersistenceCmHandlesList(); persistenceCmHandlesList.setCmHandles(persistenceCmHandles); final String cmHandleJsonData = objectMapper.writeValueAsString(persistenceCmHandlesList); cpsDataService.saveListNodeData(NCMP_DATASPACE_NAME, NCMP_ANCHOR_NAME, NCMP_DATA_TOP_PATH, cmHandleJsonData); } catch (final JsonProcessingException e) { throw new DataValidationException( "Parsing error occurred while processing DMI Plugin Registration" + dmiPluginRegistration, e .getMessage(), e); } } |
...
Append deriving modules after line 137 in method updateDmiPluginRegistration() in NetworkCmProxyDataServiceImpl
deriveModulesForCmHandle(cmHandleJsonData);
get cm handles from string
call dmi to get modules for this cmhandle
compare with cps and get delta
call dmi for delta modules
return Map<String, String> newYangResourcesModuleNameToContentMap