Cisco Ios DeviceDescription
Change-Id: I51561c51fe18a6ee9676a894ec698e2a2fc222b4
diff --git a/drivers/cisco/src/test/java/org/onosproject/drivers/cisco/TextBlockParserCiscoTest.java b/drivers/cisco/src/test/java/org/onosproject/drivers/cisco/TextBlockParserCiscoTest.java
index b9ec739..321704f 100644
--- a/drivers/cisco/src/test/java/org/onosproject/drivers/cisco/TextBlockParserCiscoTest.java
+++ b/drivers/cisco/src/test/java/org/onosproject/drivers/cisco/TextBlockParserCiscoTest.java
@@ -18,21 +18,24 @@
import org.junit.Test;
+import org.onlab.packet.ChassisId;
import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DefaultPortDescription;
import org.onosproject.net.device.PortDescription;
-
+import org.onosproject.net.provider.ProviderId;
import java.io.InputStream;
-import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
-
-
-
+import java.util.Scanner;
import static org.junit.Assert.assertEquals;
+import static org.onosproject.net.Device.Type.SWITCH;
+import static org.onosproject.net.DeviceId.deviceId;
+
/**
* Tests the parser for Netconf TextBlock configurations and replies from Cisco devices.
@@ -59,17 +62,47 @@
private static final long CONNECTION_SPEED_FDDI = 100000;
private static final boolean IS_ENABLED = true;
private static final boolean IS_NOT_ENABLED = false;
- private static final String TEXT_FILE = "/CiscoIosInterfaces.xml";
+ private static final String SHOW_VERSION = "/testShowVersion.xml";
+ private static final String SHOW_INTFS = "/testShowInterfaces.xml";
+ private static final String SW = "IOS C3560E 15.0(2)EJ";
+ private static final String HW = "SM-X-ES3-24-P";
+ private static final String MFR = "Cisco";
+ private static final String SN = "FOC18401Z3R";
+ private static final ProviderId PROVIDERID = new ProviderId("of", "foo");
+ private static final DeviceId DEVICE = deviceId("of:foo");
+ private static final ChassisId CID = new ChassisId();
@Test
- public void controllersConfig() {
- InputStream streamOrig = getClass().getResourceAsStream(TEXT_FILE);
+ public void controllersVersion() {
+ InputStream streamOrig = getClass().getResourceAsStream(SHOW_VERSION);
+ String version = new Scanner(streamOrig, "UTF-8").useDelimiter("\\Z").next();
+ version = version.substring(version.indexOf('\n') + 1);
+ String[] actualDetails = TextBlockParserCisco.parseCiscoIosDeviceDetails(version);
+
+ assertEquals("Information could not be retrieved",
+ getExpectedInfo(), actualInfo(actualDetails));
+ }
+
+ @Test
+ public void controllersIntfs() {
+ InputStream streamOrig = getClass().getResourceAsStream(SHOW_INTFS);
String rpcReply = new Scanner(streamOrig, "UTF-8").useDelimiter("\\Z").next();
List<PortDescription> actualIntfs = TextBlockParserCisco.parseCiscoIosPorts(rpcReply);
- assertEquals("Interfaces were not retrieved from configuration",
+ assertEquals("Information could not be retrieved",
getExpectedIntfs(), actualIntfs);
}
+ private DefaultDevice getExpectedInfo() {
+ return new DefaultDevice(PROVIDERID, DEVICE, SWITCH, MFR, HW, SW, SN, CID);
+ }
+
+ private DefaultDevice actualInfo(String[] actualDetails) {
+
+ return new DefaultDevice(PROVIDERID, DEVICE, SWITCH, actualDetails[0],
+ actualDetails[1], actualDetails[2],
+ actualDetails[3], CID);
+ }
+
private List<PortDescription> getExpectedIntfs() {
DefaultAnnotations.Builder int1Annotations = DefaultAnnotations.builder()
.set(AnnotationKeys.PORT_NAME, INTF1_NAME);
@@ -99,4 +132,5 @@
int6Annotations.build()));
return intfs;
}
+
}
diff --git a/drivers/cisco/src/test/resources/testShowInterfaces.xml b/drivers/cisco/src/test/resources/testShowInterfaces.xml
new file mode 100644
index 0000000..b6c5400
--- /dev/null
+++ b/drivers/cisco/src/test/resources/testShowInterfaces.xml
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8"?><rpc-reply message-id="7" xmlns="urn:ietf:params:netconf:base:1.0"><data><cli-oper-data-block><item><show>interfaces</show><response>
+FastEthernet0/0 is up, line protocol is up
+ Hardware is i82543 (Livengood), address is ca00.12b5.0008 (bia ca00.12b5.0008)
+ Internet address is 192.168.1.20/24
+ MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec,
+ reliability 255/255, txload 1/255, rxload 1/255
+ Encapsulation ARPA, loopback not set
+ Keepalive set (10 sec)
+ Full-duplex, 100Mb/s, 100BaseTX/FX
+ ARP type: ARPA, ARP Timeout 04:00:00
+ Last input 00:00:00, output 00:00:00, output hang never
+ Last clearing of "show interface" counters never
+ Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
+ Queueing strategy: fifo
+ Output queue: 0/40 (size/max)
+ 5 minute input rate 2000 bits/sec, 1 packets/sec
+ 5 minute output rate 0 bits/sec, 0 packets/sec
+ 3589 packets input, 681498 bytes
+ Received 2459 broadcasts, 0 runts, 0 giants, 0 throttles
+ 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
+ 0 watchdog
+ 0 input packets with dribble condition detected
+ 2518 packets output, 242991 bytes, 0 underruns
+ 0 output errors, 0 collisions, 2 interface resets
+ 149 unknown protocol drops
+ 0 babbles, 0 late collision, 0 deferred
+ 0 lost carrier, 0 no carrier
+ 0 output buffer failures, 0 output buffers swapped out
+Ethernet1/0 is administratively down, line protocol is down
+ Hardware is i82543 (Livengood), address is ca00.12b5.0006 (bia ca00.12b5.0006)
+ MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec,
+ reliability 255/255, txload 1/255, rxload 1/255
+ Encapsulation ARPA, loopback not set
+ Keepalive set (10 sec)
+ Full-duplex, 100Mb/s, 100BaseTX/FX
+ ARP type: ARPA, ARP Timeout 04:00:00
+ Last input never, output never, output hang never
+ Last clearing of "show interface" counters never
+ Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
+ Queueing strategy: fifo
+ Output queue: 0/40 (size/max)
+ 5 minute input rate 0 bits/sec, 0 packets/sec
+ 5 minute output rate 0 bits/sec, 0 packets/sec
+ 0 packets input, 0 bytes
+ Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
+ 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
+ 0 watchdog
+ 0 input packets with dribble condition detected
+ 0 packets output, 0 bytes, 0 underruns
+ 0 output errors, 0 collisions, 0 interface resets
+ 0 unknown protocol drops
+ 0 babbles, 0 late collision, 0 deferred
+ 0 lost carrier, 0 no carrier
+ 0 output buffer failures, 0 output buffers swapped out
+GigabitEthernet2/0 is administratively down, line protocol is down
+ Hardware is i82543 (Livengood), address is ca00.12b5.0006 (bia ca00.12b5.0006)
+ MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec,
+ reliability 255/255, txload 1/255, rxload 1/255
+ Encapsulation ARPA, loopback not set
+ Keepalive set (10 sec)
+ Full-duplex, 100Mb/s, 100BaseTX/FX
+ ARP type: ARPA, ARP Timeout 04:00:00
+ Last input never, output never, output hang never
+ Last clearing of "show interface" counters never
+ Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
+ Queueing strategy: fifo
+ Output queue: 0/40 (size/max)
+ 5 minute input rate 0 bits/sec, 0 packets/sec
+ 5 minute output rate 0 bits/sec, 0 packets/sec
+ 0 packets input, 0 bytes
+ Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
+ 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
+ 0 watchdog
+ 0 input packets with dribble condition detected
+ 0 packets output, 0 bytes, 0 underruns
+ 0 output errors, 0 collisions, 0 interface resets
+ 0 unknown protocol drops
+ 0 babbles, 0 late collision, 0 deferred
+ 0 lost carrier, 0 no carrier
+ 0 output buffer failures, 0 output buffers swapped out
+Serial3/0 is up, line protocol is up
+ Hardware is MCI Serial
+ Internet address is 192.168.10.203, subnet mask is 255.255.255.0
+ MTU 1500 bytes, BW 1544 Kbit/sec, DLY 20000 usec, rely 255/255, load 1/255
+ Encapsulation HDLC, loopback not set, keepalive set (10 sec)
+ Last input 0:00:07, output 0:00:00, output hang never
+ Output queue 0/40, 0 drops; input queue 0/75, 0 drops
+ 5 minute input rate 0 bits/sec, 0 packets/sec
+ 5 minute output rate 0 bits/sec, 0 packets/sec
+ 16263 packets input, 1347238 bytes, 0 no buffer
+ Received 13983 broadcasts, 0 runts, 0 giants
+ 2 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 2 abort
+ 1 carrier transitions
+ 22146 packets output, 2383680 bytes, 0 underruns
+ 0 output errors, 0 collisions, 2 interface resets, 0 restarts
+POS4/0 is up, line protocol is up
+ Hardware is Packet over SONET
+ Internet address is 10.41.41.2/24
+ MTU 4470 bytes, BW 9952000 Kbit/sec, DLY 100 usec, rely 255/255, load 1/255
+ Encapsulation HDLC, crc 32, loopback not set
+ Keepalive not set
+ Scramble enabled
+ Last input 00:00:59, output 00:00:11, output hang never
+ Last clearing of "show interface" counters 00:00:14
+ Queueing strategy: fifo
+ Output queue 0/40, 0 drops; input queue 0/75, 0 drops
+ Available Bandwidth 9582482 kilobits/sec
+ 5 minute input rate 0 bits/sec, 0 packets/sec
+ 5 minute output rate 0 bits/sec, 0 packets/sec
+ 0 packets input, 0 bytes, 0 no buffer
+ Received 0 broadcasts, 0 runts, 0 giants, 0 throttles
+ 0 parity
+ 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
+ 1 packets output, 314 bytes, 0 underruns
+ 0 output errors, 0 applique, 0 interface resets
+ 0 output buffer failures, 0 output buffers swapped out
+ 0 carrier transitions
+Fddi5/0 is up, line protocol is up
+ Hardware is cxBus Fddi, address is 0000.0c02.adf1 (bia 0000.0c02.adf1)
+ Internet address is 10.108.33.14, subnet mask is 255.255.255.0
+ MTU 4470 bytes, BW 100000 Kbit/sec, DLY 100 usec, rely 255/255, load 1/255
+ Encapsulation SNAP, loopback not set, keepalive not set
+ ARP type: SNAP, ARP Timeout 4:00:00
+ Phy-A state is active, neighbor is B, cmt signal bits 008/20C, status ILS
+ Phy-B state is active, neighbor is A, cmt signal bits 20C/008, status ILS
+ ECM is in, CFM is thru, RMT is ring_op
+ Token rotation 5000 usec, ring operational 21:32:34
+ Upstream neighbor 0000.0c02.ba83, downstream neighbor 0000.0c02.ba83
+ Last input 0:00:05, output 0:00:00, output hang never
+ Last clearing of “show interface” counters 0:59:10
+ Output queue 0/40, 0 drops; input queue 0/75, 0 drops
+ 5 minute input rate 69000 bits/sec, 44 packets/sec
+ 5 minute output rate 0 bits/sec, 1 packets/sec
+ 113157 packets input, 21622582 bytes, 0 no buffer
+ Received 276 broadcasts, 0 runts, 0 giants
+ 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
+ 4740 packets output, 487346 bytes, 0 underruns
+ 0 output errors, 0 collisions, 0 interface resets, 0 restarts
+ 0 transitions, 2 traces, 3 claims, 2 beacons</response></item></cli-oper-data-block></data></rpc-reply>]]>]]>
\ No newline at end of file
diff --git a/drivers/cisco/src/test/resources/testShowVersion.xml b/drivers/cisco/src/test/resources/testShowVersion.xml
new file mode 100644
index 0000000..bfa2210
--- /dev/null
+++ b/drivers/cisco/src/test/resources/testShowVersion.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?><rpc-reply message-id="7" xmlns="urn:ietf:params:netconf:base:1.0"><data><cli-oper-data-block><item><show>hardware</show><response>
+ Cisco IOS Software, C3560E Software (C3560E-UNIVERSALK9-M), Version 15.0(2)EJ, RELEASE SOFTWARE (fc1)
+ Technical Support: http://www.cisco.com/techsupport
+ Copyright (c) 1986-2013 by Cisco Systems, Inc.
+ Compiled Fri 13-Sep-13 12:09 by prod_rel_team
+ ROM: Bootstrap program is C3560E boot loader
+ BOOTLDR: C3560E Boot Loader (C3560X-HBOOT-M) Version 15.0(2r)EJ1, RELEASE SOFTWARE (fc1)
+ switch01 uptime is 1 week, 3 days, 21 hours, 39 minutes
+ System returned to ROM by power-on
+ System restarted at 08:15:31 UTC Thu Apr 14 2016
+ System image file is "flash:/c3560e-universalk9-mz.150-2.EJ.bin"
+ This product contains cryptographic features and is subject to United
+ States and local country laws governing import, export, transfer and
+ use. Delivery of Cisco cryptographic products does not imply
+ third-party authority to import, export, distribute or use encryption.
+ Importers, exporters, distributors and users are responsible for
+ compliance with U.S. and local country laws. By using this product you
+ agree to comply with applicable laws and regulations. If you are unable
+ to comply with U.S. and local laws, return this product immediately.
+ A summary of U.S. laws governing Cisco cryptographic products may be found at:
+ http://www.cisco.com/wwl/export/crypto/tool/stqrg.html
+ If you require further assistance please contact us by sending email to
+ export@cisco.com.
+ License Level: lanbase
+ License Type: Permanent
+ Next reload license Level: lanbase
+ cisco SM-X-ES3-24-P (PowerPC405) processor with 262144K bytes of memory.
+ Processor board ID FOC18401Z3R
+ Last reset from power-on
+ 2 Virtual Ethernet interfaces
+ 26 Gigabit Ethernet interfaces
+ The password-recovery mechanism is enabled.
+ 512K bytes of flash-simulated non-volatile configuration memory.
+ Base ethernet MAC Address : 68:99:CD:AA:2F:80
+ Model number : SM-X-ES3-24-P
+ System serial number : FOC18401Z3R
+ Hardware Board Revision Number : 0x00
+ Switch Ports Model SW Version SW Image
+ ------ ----- ----- ---------- ----------
+ * 1 26 SM-X-ES3-24-P 15.0(2)EJ C3560E-UNIVERSALK9-M
+</response></item></cli-oper-data-block></data></rpc-reply>]]>]]>