use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.
the class DeviceTest method sharedDatastoreTest.
@Test
public void sharedDatastoreTest() throws InterruptedException, ExecutionException, TimeoutException, SAXException, IOException, URISyntaxException {
final SimpleNetconfClientSessionListener sessionListener = SESSION_LISTENERS.get(0);
final NetconfMessage createToasterResponse = sendRequestToDevice(CREATE_TOASTER_REQUEST_XML, sessionListener);
assertTrue(containsOkElement(createToasterResponse));
for (SimpleNetconfClientSessionListener listener : SESSION_LISTENERS) {
final NetconfMessage toasterData = sendRequestToDevice(GET_TOASTER_DATA_REQUEST_XML, listener);
final String toasterDarknessFactor = toasterData.getDocument().getDocumentElement().getElementsByTagName("darknessFactor").item(0).getTextContent();
Assertions.assertEquals(EXPECTED_DARKNESS_FACTOR, toasterDarknessFactor);
}
}
use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.
the class DeviceTest method getSchemaTest.
@Test
public void getSchemaTest() throws IOException, URISyntaxException, SAXException, InterruptedException, ExecutionException, TimeoutException {
final SimpleNetconfClientSessionListener sessionListener = new SimpleNetconfClientSessionListener();
try (NetconfClientSession session = dispatcher.createClient(createSHHConfig(sessionListener)).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
final NetconfMessage schemaResponse = sendRequestToDevice(GET_SCHEMAS_REQUEST_XML, sessionListener);
final NodeList schema = schemaResponse.getDocument().getDocumentElement().getElementsByTagName("schema");
assertTrue(schema.getLength() > 0);
boolean networkTopologySchemaContained = false;
for (int i = 0; i < schema.getLength(); i++) {
if (schema.item(i).getNodeType() == Node.ELEMENT_NODE) {
final Element item = (Element) schema.item(i);
final String schemaName = item.getElementsByTagName("identifier").item(0).getTextContent();
final String schemaNameSpace = item.getElementsByTagName("namespace").item(0).getTextContent();
if ("network-topology".equals(schemaName) && "urn:TBD:params:xml:ns:yang:network-topology".equals(schemaNameSpace)) {
networkTopologySchemaContained = true;
}
}
}
assertTrue(networkTopologySchemaContained);
}
}
use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.
the class DeviceTest method deviceConfigOperationsTest.
@Test
public void deviceConfigOperationsTest() throws InterruptedException, ExecutionException, IOException, TimeoutException, URISyntaxException, SAXException {
final SimpleNetconfClientSessionListener sessionListener = new SimpleNetconfClientSessionListener();
try (NetconfClientSession session = dispatcher.createClient(createSHHConfig(sessionListener)).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
final NetconfMessage createTopoResponse = sendRequestToDevice(CREATE_TOPOLOGY_CONFIG_REQUEST_XML, sessionListener);
assertTrue(containsOkElement(createTopoResponse));
final NetconfMessage mergeTopoResponse = sendRequestToDevice(MERGE_TOPOLOGY_CONFIG_REQUEST_XML, sessionListener);
assertTrue(containsOkElement(mergeTopoResponse));
final NetconfMessage getConfigDataResponse = sendRequestToDevice(GET_CONFIG_REQUEST_XML, sessionListener);
final NodeList topologies = getConfigDataResponse.getDocument().getElementsByTagName("topology");
assertEquals(topologies.getLength(), 2);
if (getTopologyID(topologies.item(0)).equals("test-config-topology")) {
assertEquals(getTopologyID(topologies.item(0)), "test-config-topology");
assertEquals(getTopologyID(topologies.item(1)), "test-config-topology-merge");
} else {
assertEquals(getTopologyID(topologies.item(1)), "test-config-topology");
assertEquals(getTopologyID(topologies.item(0)), "test-config-topology-merge");
}
final NodeList nodes = getConfigDataResponse.getDocument().getElementsByTagName("node");
assertEquals(nodes.getLength(), 1);
final NetconfMessage deleteTopologyResponse = sendRequestToDevice(DELETE_TOPOLOGY_CONFIG_REQUEST_XML, sessionListener);
assertTrue(containsOkElement(deleteTopologyResponse));
final NetconfMessage getConfigDataResponseAfterDelete = sendRequestToDevice(GET_CONFIG_REQUEST_XML, sessionListener);
final NodeList topologiesAfterDelete = getConfigDataResponseAfterDelete.getDocument().getElementsByTagName("topology");
assertEquals(topologiesAfterDelete.getLength(), 1);
}
}
use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.
the class ActionDeviceTest method getSchemaTest.
@Test
public void getSchemaTest() throws IOException, URISyntaxException, SAXException, InterruptedException, ExecutionException, TimeoutException {
final SimpleNetconfClientSessionListener sessionListener = new SimpleNetconfClientSessionListener();
try (NetconfClientSession session = dispatcher.createClient(createSHHConfig(sessionListener)).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
final NetconfMessage schemaResponse = sentRequesttoDevice(sessionListener, "get_schemas_request.xml");
final NodeList schema = schemaResponse.getDocument().getDocumentElement().getElementsByTagName("schema");
assertTrue(schema.getLength() > 0);
boolean exampleDataCenterSchemaContained = false;
for (int i = 0; i < schema.getLength(); i++) {
if (schema.item(i).getNodeType() == Node.ELEMENT_NODE) {
final Element item = (Element) schema.item(i);
final String schemaName = item.getElementsByTagName("identifier").item(0).getTextContent();
final String schemaNameSpace = item.getElementsByTagName("namespace").item(0).getTextContent();
if ("example-data-center".equals(schemaName) && "urn:example:data-center".equals(schemaNameSpace)) {
exampleDataCenterSchemaContained = true;
}
}
}
assertTrue(exampleDataCenterSchemaContained);
}
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class NetconfClientSessionNegotiatorFactory method getSessionNegotiator.
@Override
public NetconfClientSessionNegotiator getSessionNegotiator(final NetconfSessionListenerFactory<NetconfClientSessionListener> sessionListenerFactory, final Channel channel, final Promise<NetconfClientSession> promise) {
NetconfMessage startExiMessage = NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID);
NetconfHelloMessage helloMessage = NetconfHelloMessage.createClientHello(clientCapabilities, additionalHeader);
NetconfClientSessionPreferences proposal = new NetconfClientSessionPreferences(helloMessage, startExiMessage);
return new NetconfClientSessionNegotiator(proposal, promise, channel, timer, sessionListenerFactory.getSessionListener(), connectionTimeoutMillis);
}
Aggregations