@Test public void testDeviceAddedWithCorrectDefaultXml() throws ExecutionException, IOException, NetconfMessageBuilderException { String editConfigRequestString = "<rpc message-id=\"e1\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" + System.lineSeparator() + " <edit-config>" + System.lineSeparator() + " <target>" + System.lineSeparator() + " <running/>" + System.lineSeparator() + " </target>" + System.lineSeparator() + " <default-operation>merge</default-operation>" + System.lineSeparator() + " <test-option>set</test-option>" + System.lineSeparator() + " <error-option>stop-on-error</error-option>" + System.lineSeparator() + " <config>" + System.lineSeparator() + " <if:interfaces xmlns=\"urn:bbf:yang:obbaa:network-manager\" xmlns:if=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\">" + System.lineSeparator() + " <if:interface xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" xc:operation=\"create\">" + System.lineSeparator() + " <if:name>Interface</if:name>" + System.lineSeparator() + " <if:type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:fastdsl</if:type>" + System.lineSeparator() + " <if:description>InterfaceDescription</if:description>" + System.lineSeparator() + " </if:interface>" + System.lineSeparator() + " </if:interfaces>" + System.lineSeparator() + " </config>" + System.lineSeparator() + " </edit-config>" + System.lineSeparator() + "</rpc>" + System.lineSeparator(); EditConfigRequest request = DocumentToPojoTransformer.getEditConfig(DocumentUtils.stringToDocument(editConfigRequestString)); when(m_adapterManager.getEditRequestForAdapter(any())).thenReturn(request); m_defaultConfigService.deviceAdded(m_device.getDeviceName()); verify(m_pmaRegistry).executeNC(m_device.getDeviceName(), editConfigRequestString); m_deviceMgmt.setPushPmaConfigurationToDevice("false"); m_device.setDeviceManagement(m_deviceMgmt); m_defaultConfigService.deviceAdded(m_device.getDeviceName()); verify(m_pmaRegistry).executeNC(m_device.getDeviceName(), editConfigRequestString); }
@Override public void deviceAdded(String deviceName) { Device device = m_deviceManager.getDevice(deviceName); EditConfigRequest editReq = AdapterUtils.getDefaultEditReq(device, m_adapterManager); if (editReq != null) { if (AlignmentOption.PUSH.equals(device.getAlignmentOption())) { try { m_pmaRegistry.executeNC(deviceName, editReq.requestToString()); } catch (ExecutionException e) { LOGGER.error(String.format("Error when executing default-config xml request for device %s", deviceName)); throw new RuntimeException(e); } } else { LOGGER.info(String.format("For device %s, the alignment mechanism is pull configuration from device to PMA", deviceName)); } } else { LOGGER.info(String.format("The adapter for device %s does not contain any default configurations", deviceName)); } }
DefaultConfigService implements DeviceStateProvider { @Override public void deviceAdded(String deviceName) { Device device = m_deviceManager.getDevice(deviceName); EditConfigRequest editReq = AdapterUtils.getDefaultEditReq(device, m_adapterManager); if (editReq != null) { if (AlignmentOption.PUSH.equals(device.getAlignmentOption())) { try { m_pmaRegistry.executeNC(deviceName, editReq.requestToString()); } catch (ExecutionException e) { LOGGER.error(String.format("Error when executing default-config xml request for device %s", deviceName)); throw new RuntimeException(e); } } else { LOGGER.info(String.format("For device %s, the alignment mechanism is pull configuration from device to PMA", deviceName)); } } else { LOGGER.info(String.format("The adapter for device %s does not contain any default configurations", deviceName)); } } }
DefaultConfigService implements DeviceStateProvider { @Override public void deviceAdded(String deviceName) { Device device = m_deviceManager.getDevice(deviceName); EditConfigRequest editReq = AdapterUtils.getDefaultEditReq(device, m_adapterManager); if (editReq != null) { if (AlignmentOption.PUSH.equals(device.getAlignmentOption())) { try { m_pmaRegistry.executeNC(deviceName, editReq.requestToString()); } catch (ExecutionException e) { LOGGER.error(String.format("Error when executing default-config xml request for device %s", deviceName)); throw new RuntimeException(e); } } else { LOGGER.info(String.format("For device %s, the alignment mechanism is pull configuration from device to PMA", deviceName)); } } else { LOGGER.info(String.format("The adapter for device %s does not contain any default configurations", deviceName)); } } DefaultConfigService(DeviceManager deviceManager, PmaRegistry pmaRegistry, AdapterManager adapterManager); }
DefaultConfigService implements DeviceStateProvider { @Override public void deviceAdded(String deviceName) { Device device = m_deviceManager.getDevice(deviceName); EditConfigRequest editReq = AdapterUtils.getDefaultEditReq(device, m_adapterManager); if (editReq != null) { if (AlignmentOption.PUSH.equals(device.getAlignmentOption())) { try { m_pmaRegistry.executeNC(deviceName, editReq.requestToString()); } catch (ExecutionException e) { LOGGER.error(String.format("Error when executing default-config xml request for device %s", deviceName)); throw new RuntimeException(e); } } else { LOGGER.info(String.format("For device %s, the alignment mechanism is pull configuration from device to PMA", deviceName)); } } else { LOGGER.info(String.format("The adapter for device %s does not contain any default configurations", deviceName)); } } DefaultConfigService(DeviceManager deviceManager, PmaRegistry pmaRegistry, AdapterManager adapterManager); void init(); void destroy(); @Override void deviceAdded(String deviceName); @Override void deviceRemoved(String deviceName); }
DefaultConfigService implements DeviceStateProvider { @Override public void deviceAdded(String deviceName) { Device device = m_deviceManager.getDevice(deviceName); EditConfigRequest editReq = AdapterUtils.getDefaultEditReq(device, m_adapterManager); if (editReq != null) { if (AlignmentOption.PUSH.equals(device.getAlignmentOption())) { try { m_pmaRegistry.executeNC(deviceName, editReq.requestToString()); } catch (ExecutionException e) { LOGGER.error(String.format("Error when executing default-config xml request for device %s", deviceName)); throw new RuntimeException(e); } } else { LOGGER.info(String.format("For device %s, the alignment mechanism is pull configuration from device to PMA", deviceName)); } } else { LOGGER.info(String.format("The adapter for device %s does not contain any default configurations", deviceName)); } } DefaultConfigService(DeviceManager deviceManager, PmaRegistry pmaRegistry, AdapterManager adapterManager); void init(); void destroy(); @Override void deviceAdded(String deviceName); @Override void deviceRemoved(String deviceName);  }