Correcting basic driver configuration for various HP product families.
Added means to inherit mfg/hwVersion/swVersion properties from the
driver being extended.

Change-Id: I23ef891d1df7f346edc8822cee69e3d772c3171d
diff --git a/core/api/src/main/java/org/onosproject/net/driver/XmlDriverLoader.java b/core/api/src/main/java/org/onosproject/net/driver/XmlDriverLoader.java
index 6afdef3..008c422 100644
--- a/core/api/src/main/java/org/onosproject/net/driver/XmlDriverLoader.java
+++ b/core/api/src/main/java/org/onosproject/net/driver/XmlDriverLoader.java
@@ -145,14 +145,32 @@
             parents = parentsNames.stream().map(parent -> (parent != null) ?
                     resolve(parent, resolver) : null).collect(Collectors.toList());
         }
-        String manufacturer = driverCfg.getString(MFG, "");
-        String hwVersion = driverCfg.getString(HW, "");
-        String swVersion = driverCfg.getString(SW, "");
+        String manufacturer = driverCfg.getString(MFG, getParentAttribute(parents, MFG));
+        String hwVersion = driverCfg.getString(HW, getParentAttribute(parents, HW));
+        String swVersion = driverCfg.getString(SW, getParentAttribute(parents, SW));
         return new DefaultDriver(name, parents, manufacturer, hwVersion, swVersion,
                                  parseBehaviours(driverCfg),
                                  parseProperties(driverCfg));
     }
 
+    // Returns the specified property from the highest priority parent
+    private String getParentAttribute(List<Driver> parents, String attribute) {
+        if (!parents.isEmpty()) {
+            Driver parent = parents.get(0);
+            switch (attribute) {
+                case MFG:
+                    return parent.manufacturer();
+                case HW:
+                    return parent.hwVersion();
+                case SW:
+                    return parent.swVersion();
+                default:
+                    throw new IllegalArgumentException("Unsupported attribute");
+            }
+        }
+        return "";
+    }
+
     // Resolves the driver by name locally at first and then using the specified resolver.
     private Driver resolve(String parentName, DriverResolver resolver) {
         Driver driver = drivers.get(parentName);
diff --git a/core/api/src/test/java/org/onosproject/net/driver/XmlDriverLoaderTest.java b/core/api/src/test/java/org/onosproject/net/driver/XmlDriverLoaderTest.java
index cc9a17f..1969524 100644
--- a/core/api/src/test/java/org/onosproject/net/driver/XmlDriverLoaderTest.java
+++ b/core/api/src/test/java/org/onosproject/net/driver/XmlDriverLoaderTest.java
@@ -39,11 +39,7 @@
         System.out.println(provider);
         assertEquals("incorrect driver count", 2, provider.getDrivers().size());
 
-        Iterator<Driver> iterator = provider.getDrivers().iterator();
-        Driver driver = iterator.next();
-        if (!"foo.1".equals(driver.name())) {
-            driver = iterator.next();
-        }
+        Driver driver = getDriver(provider, "foo.1");
 
         assertEquals("incorrect driver name", "foo.1", driver.name());
         assertEquals("incorrect driver mfg", "Circus", driver.manufacturer());
@@ -83,13 +79,19 @@
         XmlDriverLoader loader = new XmlDriverLoader(getClass().getClassLoader(), null);
         InputStream stream = getClass().getResourceAsStream("drivers.multipleInheritance.xml");
         DriverProvider provider = loader.loadDrivers(stream, null);
-        Iterator<Driver> iterator = provider.getDrivers().iterator();
-        Driver driver;
-        do {
-            driver = iterator.next();
-        } while (!"foo.2".equals(driver.name()));
+
+        Driver driver1 = getDriver(provider, "foo.1");
+        assertEquals("incorrect driver mfg", "Circus", driver1.manufacturer());
+        assertEquals("incorrect driver hw", "1.2a", driver1.hwVersion());
+        assertEquals("incorrect driver sw", "2.2", driver1.swVersion());
+
+        Driver driver = getDriver(provider, "foo.2");
         assertTrue("incorrect multiple behaviour inheritance", driver.hasBehaviour(TestBehaviour.class));
         assertTrue("incorrect multiple behaviour inheritance", driver.hasBehaviour(TestBehaviourTwo.class));
+
+        assertEquals("incorrect driver mfg", "Big Top OEM", driver.manufacturer());
+        assertEquals("incorrect driver hw", "1.2", driver.hwVersion());
+        assertEquals("incorrect driver sw", "2.0", driver.swVersion());
     }
 
     @Test
@@ -112,4 +114,13 @@
         assertTrue("incorrect multiple behaviour inheritance", driver.hasBehaviour(TestBehaviourTwo.class));
     }
 
+    private Driver getDriver(DriverProvider provider, String name) {
+        Iterator<Driver> iterator = provider.getDrivers().iterator();
+        Driver driver;
+        do {
+            driver = iterator.next();
+        } while (!name.equals(driver.name()));
+        return driver;
+    }
+
 }
diff --git a/core/api/src/test/resources/org/onosproject/net/driver/drivers.1.xml b/core/api/src/test/resources/org/onosproject/net/driver/drivers.1.xml
index 67e0ec8..389c37c 100644
--- a/core/api/src/test/resources/org/onosproject/net/driver/drivers.1.xml
+++ b/core/api/src/test/resources/org/onosproject/net/driver/drivers.1.xml
@@ -20,7 +20,7 @@
                    impl="org.onosproject.net.driver.TestBehaviourImpl"/>
     </driver>
 
-    <driver name="foo.1" extends="foo.0" manufacturer="Circus" hwVersion="1.2a" swVersion="2.2">
+    <driver name="foo.1" extends="foo.0" hwVersion="1.2a" swVersion="2.2">
         <fingerprint>ding</fingerprint>
         <fingerprint>bat</fingerprint>
 
diff --git a/core/api/src/test/resources/org/onosproject/net/driver/drivers.multipleInheritance.xml b/core/api/src/test/resources/org/onosproject/net/driver/drivers.multipleInheritance.xml
index 754ef91..fc26eba 100644
--- a/core/api/src/test/resources/org/onosproject/net/driver/drivers.multipleInheritance.xml
+++ b/core/api/src/test/resources/org/onosproject/net/driver/drivers.multipleInheritance.xml
@@ -20,7 +20,7 @@
                    impl="org.onosproject.net.driver.TestBehaviourImpl"/>
     </driver>
 
-    <driver name="foo.1" extends="foo.0" manufacturer="Circus" hwVersion="1.2a" swVersion="2.2">
+    <driver name="foo.1" extends="foo.0" hwVersion="1.2a" swVersion="2.2">
         <fingerprint>ding</fingerprint>
         <fingerprint>bat</fingerprint>
 
@@ -31,7 +31,7 @@
         <property name="p2">v2</property>
     </driver>
 
-    <driver name="foo.2" extends="foo.0,foo.1" manufacturer="Circus" hwVersion="1.2" swVersion="2.0">
+    <driver name="foo.2" extends="foo.0,foo.1" manufacturer="Big Top OEM">
         <behaviour api="org.onosproject.net.driver.TestBehaviourThree"
                    impl="org.onosproject.net.driver.TestBehaviourThreeImpl"/>
     </driver>
diff --git a/drivers/hp/src/main/resources/hp-driver.xml b/drivers/hp/src/main/resources/hp-driver.xml
index 4e67129..fd1090a 100644
--- a/drivers/hp/src/main/resources/hp-driver.xml
+++ b/drivers/hp/src/main/resources/hp-driver.xml
@@ -15,47 +15,25 @@
   ~ limitations under the License.
   -->
 <drivers>
-    <driver name="hp-switch">
+    <driver name="hp-switch" manufacturer="(HP|Aruba)" swVersion=".*">
         <behaviour api="org.onosproject.net.behaviour.Pipeliner"
                    impl="org.onosproject.drivers.hp.HPPipelineV3800"/>
         <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
                    impl="org.onosproject.drivers.hp.HPSwitchHandshaker"/>
     </driver>
 
-    <driver name="hp-2920" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="2920-(24G|48G).* Switch" swVersion=".*"/>
+    <driver name="hp-2920"  extends="hp-switch" hwVersion=".*2920.*"/>
+    <driver name="hp-2930"  extends="hp-switch" hwVersion=".*2930.*"/>
+    <driver name="hp-3500"  extends="hp-switch" hwVersion=".*3500.*"/>
+    <driver name="hp-3800"  extends="hp-switch" hwVersion=".*3800.*"/>
+    <driver name="hp-3810"  extends="hp-switch" hwVersion=".*3810.*"/>
+    <driver name="hp-5400"  extends="hp-switch" hwVersion=".*54[0-9][0-9]z.*"/>
+    <driver name="hp-5400R" extends="hp-switch" hwVersion=".*54[0-9][0-9]R.*"/>
+    <driver name="hp-6200"  extends="hp-switch" hwVersion=".*6200.*"/>
+    <driver name="hp-6600"  extends="hp-switch" hwVersion=".*6600.*"/>
+    <driver name="hp-8200"  extends="hp-switch" hwVersion=".*82[0-9][0-9].*"/>
 
-    <driver name="hp-2930" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="2930[FM]-(8G|8SR|24G|40G|48G).* Switch" swVersion=".*"/>
-
-    <driver name="hp-3500" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="Switch 3500.*" swVersion=".*"/>
-
-    <driver name="hp-3800" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="3800-(24G|24SFP|48G).* Switch" swVersion=".*"/>
-
-    <driver name="hp-3810" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="3810M-(16SFP|16SR|24G|24SFP|40G|48G).* Switch" swVersion=".*"/>
-
-    <driver name="hp-5400" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="Switch (5406zl|5412zl)" swVersion=".*"/>
-
-    <driver name="hp-5400R" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="Switch (5406Rzl2|5412Rzl2)" swVersion=".*"/>
-
-    <driver name="hp-6200" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="Switch 6200zl-24G" swVersion=".*"/>
-
-    <driver name="hp-6600" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="Switch (E6600|6600ml|6600).*" swVersion=".*"/>
-
-    <driver name="aruba-7000" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="Aruba70(05|08|10|24|30)" swVersion=".*"/>
-
-    <driver name="aruba-7200" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="Aruba72(05|10|20|40)" swVersion=".*"/>
-
-    <driver name="hp-8200" extends="hp-switch" manufacturer="(HP|Aruba)"
-            hwVersion="Switch 8212zl" swVersion=".*"/>
+    <driver name="aruba-7000" extends="hp-switch,ovs" hwVersion=".*Aruba70[0-9][0-9].*"/>
+    <driver name="aruba-7200" extends="hp-switch,ovs" hwVersion=".*Aruba72[0-9][0-9].*"/>
 
 </drivers>