Committed by
Gerrit Code Review
Device driver framework enhancements and CLI.
Change-Id: I5dea67620259797eff89a985718934034a86d63e
Showing
11 changed files
with
202 additions
and
53 deletions
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.cli.net; | ||
17 | + | ||
18 | +import org.apache.karaf.shell.console.Completer; | ||
19 | +import org.apache.karaf.shell.console.completer.StringsCompleter; | ||
20 | +import org.onosproject.cli.AbstractShellCommand; | ||
21 | +import org.onosproject.net.driver.DriverAdminService; | ||
22 | + | ||
23 | +import java.util.List; | ||
24 | +import java.util.SortedSet; | ||
25 | + | ||
26 | +/** | ||
27 | + * Device driver name completer. | ||
28 | + */ | ||
29 | +public class DriverNameCompleter implements Completer { | ||
30 | + @Override | ||
31 | + public int complete(String buffer, int cursor, List<String> candidates) { | ||
32 | + // Delegate string completer | ||
33 | + StringsCompleter delegate = new StringsCompleter(); | ||
34 | + SortedSet<String> strings = delegate.getStrings(); | ||
35 | + | ||
36 | + // Fetch our service and feed it's offerings to the string completer | ||
37 | + DriverAdminService service = AbstractShellCommand.get(DriverAdminService.class); | ||
38 | + service.getDrivers().forEach(d -> strings.add(d.name())); | ||
39 | + | ||
40 | + // Now let the completer do the work for figuring out what to offer. | ||
41 | + return delegate.complete(buffer, cursor, candidates); | ||
42 | + } | ||
43 | + | ||
44 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.cli.net; | ||
17 | + | ||
18 | +import org.apache.karaf.shell.commands.Argument; | ||
19 | +import org.apache.karaf.shell.commands.Command; | ||
20 | +import org.onosproject.cli.AbstractShellCommand; | ||
21 | +import org.onosproject.net.driver.Driver; | ||
22 | +import org.onosproject.net.driver.DriverAdminService; | ||
23 | + | ||
24 | +/** | ||
25 | + * Lists device drivers. | ||
26 | + */ | ||
27 | +@Command(scope = "onos", name = "drivers", | ||
28 | + description = "Lists device drivers") | ||
29 | +public class DriversListCommand extends AbstractShellCommand { | ||
30 | + | ||
31 | + private static final String FMT = "driver=%s, mfr=%s, hw=%s, sw=%s"; | ||
32 | + private static final String FMT_B = " %s via %s"; | ||
33 | + private static final String FMT_P = " %s=%s"; | ||
34 | + | ||
35 | + @Argument(index = 0, name = "driverName", description = "Driver name", | ||
36 | + required = false, multiValued = false) | ||
37 | + String driverName = null; | ||
38 | + | ||
39 | + @Override | ||
40 | + protected void execute() { | ||
41 | + DriverAdminService service = get(DriverAdminService.class); | ||
42 | + | ||
43 | + if (driverName != null) { | ||
44 | + printDriver(service.getDriver(driverName)); | ||
45 | + } else { | ||
46 | + service.getDrivers().forEach(this::printDriver); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + private void printDriver(Driver driver) { | ||
51 | + print(FMT, driver.name(), driver.manufacturer(), | ||
52 | + driver.hwVersion(), driver.swVersion()); | ||
53 | + driver.behaviours().forEach(b -> print(FMT_B, b.getCanonicalName(), | ||
54 | + driver.implementation(b).getCanonicalName())); | ||
55 | + driver.properties().forEach((k, v) -> print(FMT_P, k, v)); | ||
56 | + } | ||
57 | + | ||
58 | +} |
... | @@ -71,6 +71,14 @@ | ... | @@ -71,6 +71,14 @@ |
71 | </command> | 71 | </command> |
72 | 72 | ||
73 | <command> | 73 | <command> |
74 | + <action class="org.onosproject.cli.net.DriversListCommand"/> | ||
75 | + <completers> | ||
76 | + <ref component-id="driverNameCompleter"/> | ||
77 | + <null/> | ||
78 | + </completers> | ||
79 | + </command> | ||
80 | + | ||
81 | + <command> | ||
74 | <action class="org.onosproject.cli.net.DevicesListCommand"/> | 82 | <action class="org.onosproject.cli.net.DevicesListCommand"/> |
75 | </command> | 83 | </command> |
76 | <command> | 84 | <command> |
... | @@ -316,5 +324,6 @@ | ... | @@ -316,5 +324,6 @@ |
316 | <bean id="nullCompleter" class="org.apache.karaf.shell.console.completer.NullCompleter"/> | 324 | <bean id="nullCompleter" class="org.apache.karaf.shell.console.completer.NullCompleter"/> |
317 | <bean id="ethTypeCompleter" class="org.onosproject.cli.net.EthTypeCompleter"/> | 325 | <bean id="ethTypeCompleter" class="org.onosproject.cli.net.EthTypeCompleter"/> |
318 | <bean id="ipProtocolCompleter" class="org.onosproject.cli.net.IpProtocolCompleter"/> | 326 | <bean id="ipProtocolCompleter" class="org.onosproject.cli.net.IpProtocolCompleter"/> |
327 | + <bean id="driverNameCompleter" class="org.onosproject.cli.net.DriverNameCompleter"/> | ||
319 | 328 | ||
320 | </blueprint> | 329 | </blueprint> | ... | ... |
... | @@ -69,15 +69,17 @@ public class DefaultDriver implements Driver { | ... | @@ -69,15 +69,17 @@ public class DefaultDriver implements Driver { |
69 | * @param other other driver | 69 | * @param other other driver |
70 | * @return new driver | 70 | * @return new driver |
71 | */ | 71 | */ |
72 | - DefaultDriver merge(DefaultDriver other) { | 72 | + @Override |
73 | + public Driver merge(Driver other) { | ||
73 | // Merge the behaviours. | 74 | // Merge the behaviours. |
74 | ImmutableMap.Builder<Class<? extends Behaviour>, Class<? extends Behaviour>> | 75 | ImmutableMap.Builder<Class<? extends Behaviour>, Class<? extends Behaviour>> |
75 | behaviours = ImmutableMap.builder(); | 76 | behaviours = ImmutableMap.builder(); |
76 | - behaviours.putAll(other.behaviours).putAll(this.behaviours); | 77 | + behaviours.putAll(this.behaviours); |
78 | + other.behaviours().forEach(b -> behaviours.put(b, other.implementation(b))); | ||
77 | 79 | ||
78 | // Merge the properties. | 80 | // Merge the properties. |
79 | ImmutableMap.Builder<String, String> properties = ImmutableMap.builder(); | 81 | ImmutableMap.Builder<String, String> properties = ImmutableMap.builder(); |
80 | - properties.putAll(other.properties).putAll(this.properties); | 82 | + properties.putAll(this.properties).putAll(other.properties()); |
81 | 83 | ||
82 | return new DefaultDriver(name, manufacturer, hwVersion, swVersion, | 84 | return new DefaultDriver(name, manufacturer, hwVersion, swVersion, |
83 | behaviours.build(), properties.build()); | 85 | behaviours.build(), properties.build()); |
... | @@ -109,6 +111,11 @@ public class DefaultDriver implements Driver { | ... | @@ -109,6 +111,11 @@ public class DefaultDriver implements Driver { |
109 | } | 111 | } |
110 | 112 | ||
111 | @Override | 113 | @Override |
114 | + public Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour) { | ||
115 | + return behaviours.get(behaviour); | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
112 | public boolean hasBehaviour(Class<? extends Behaviour> behaviourClass) { | 119 | public boolean hasBehaviour(Class<? extends Behaviour> behaviourClass) { |
113 | return behaviours.containsKey(behaviourClass); | 120 | return behaviours.containsKey(behaviourClass); |
114 | } | 121 | } | ... | ... |
... | @@ -16,8 +16,8 @@ | ... | @@ -16,8 +16,8 @@ |
16 | package org.onosproject.net.driver; | 16 | package org.onosproject.net.driver; |
17 | 17 | ||
18 | import com.google.common.collect.ImmutableSet; | 18 | import com.google.common.collect.ImmutableSet; |
19 | +import com.google.common.collect.Maps; | ||
19 | 20 | ||
20 | -import java.util.HashMap; | ||
21 | import java.util.Map; | 21 | import java.util.Map; |
22 | import java.util.Set; | 22 | import java.util.Set; |
23 | 23 | ||
... | @@ -28,7 +28,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; | ... | @@ -28,7 +28,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; |
28 | */ | 28 | */ |
29 | public class DefaultDriverProvider implements DriverProvider { | 29 | public class DefaultDriverProvider implements DriverProvider { |
30 | 30 | ||
31 | - private final Map<String, DefaultDriver> drivers = new HashMap<>(); | 31 | + protected final Map<String, Driver> drivers = Maps.newConcurrentMap(); |
32 | 32 | ||
33 | @Override | 33 | @Override |
34 | public Set<Driver> getDrivers() { | 34 | public Set<Driver> getDrivers() { |
... | @@ -36,30 +36,47 @@ public class DefaultDriverProvider implements DriverProvider { | ... | @@ -36,30 +36,47 @@ public class DefaultDriverProvider implements DriverProvider { |
36 | } | 36 | } |
37 | 37 | ||
38 | /** | 38 | /** |
39 | - * Adds the specified driver to be provided. | 39 | + * Adds the specified drivers to the provider. |
40 | * | 40 | * |
41 | - * @param driverClasses driver to be provided | 41 | + * @param drivers drivers to be added |
42 | */ | 42 | */ |
43 | - public void addDrivers(Set<DefaultDriver> driverClasses) { | 43 | + public void addDrivers(Set<Driver> drivers) { |
44 | - for (DefaultDriver driverClass : driverClasses) { | 44 | + drivers.forEach(this::addDriver); |
45 | - addDriver(driverClass); | ||
46 | - } | ||
47 | } | 45 | } |
48 | 46 | ||
49 | /** | 47 | /** |
50 | - * Adds the specified driver to be provided. | 48 | + * Adds the specified driver to the provider. |
51 | * | 49 | * |
52 | - * @param driverClass driver to be provided | 50 | + * @param driver driver to be provided |
53 | */ | 51 | */ |
54 | - public void addDriver(DefaultDriver driverClass) { | 52 | + public void addDriver(Driver driver) { |
55 | - DefaultDriver ddc = drivers.get(driverClass.name()); | 53 | + Driver ddc = drivers.get(driver.name()); |
56 | if (ddc == null) { | 54 | if (ddc == null) { |
57 | // If we don't have the driver yet, just use the new one. | 55 | // If we don't have the driver yet, just use the new one. |
58 | - drivers.put(driverClass.name(), driverClass); | 56 | + drivers.put(driver.name(), driver); |
59 | } else { | 57 | } else { |
60 | // Otherwise merge the existing driver with the new one and rebind. | 58 | // Otherwise merge the existing driver with the new one and rebind. |
61 | - drivers.put(driverClass.name(), ddc.merge(driverClass)); | 59 | + drivers.put(driver.name(), ddc.merge(driver)); |
60 | + } | ||
62 | } | 61 | } |
62 | + | ||
63 | + /** | ||
64 | + * Removes the specified drivers from the provider. | ||
65 | + * | ||
66 | + * @param drivers drivers to be removed | ||
67 | + */ | ||
68 | + public void removeDrivers(Set<Driver> drivers) { | ||
69 | + drivers.forEach(this::removeDriver); | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Removes the specified driver from the provider. | ||
74 | + * | ||
75 | + * @param driver driver to be removed | ||
76 | + */ | ||
77 | + public void removeDriver(Driver driver) { | ||
78 | + // TODO: make selective if possible | ||
79 | + drivers.remove(driver.name()); | ||
63 | } | 80 | } |
64 | 81 | ||
65 | @Override | 82 | @Override | ... | ... |
... | @@ -63,6 +63,14 @@ public interface Driver extends Annotations { | ... | @@ -63,6 +63,14 @@ public interface Driver extends Annotations { |
63 | Set<Class<? extends Behaviour>> behaviours(); | 63 | Set<Class<? extends Behaviour>> behaviours(); |
64 | 64 | ||
65 | /** | 65 | /** |
66 | + * Returns the implementation class for the specified behaviour. | ||
67 | + * | ||
68 | + * @param behaviour behaviour interface | ||
69 | + * @return implementation class | ||
70 | + */ | ||
71 | + Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour); | ||
72 | + | ||
73 | + /** | ||
66 | * Indicates whether or not the driver supports the specified class | 74 | * Indicates whether or not the driver supports the specified class |
67 | * of behaviour. | 75 | * of behaviour. |
68 | * | 76 | * |
... | @@ -90,4 +98,13 @@ public interface Driver extends Annotations { | ... | @@ -90,4 +98,13 @@ public interface Driver extends Annotations { |
90 | */ | 98 | */ |
91 | Map<String, String> properties(); | 99 | Map<String, String> properties(); |
92 | 100 | ||
101 | + /** | ||
102 | + * Merges the specified driver behaviours and properties into this one, | ||
103 | + * giving preference to the other driver when dealing with conflicts. | ||
104 | + * | ||
105 | + * @param other other driver | ||
106 | + * @return merged driver | ||
107 | + */ | ||
108 | + Driver merge(Driver other); | ||
109 | + | ||
93 | } | 110 | } | ... | ... |
... | @@ -25,13 +25,19 @@ import java.util.Set; | ... | @@ -25,13 +25,19 @@ import java.util.Set; |
25 | public interface DriverService { | 25 | public interface DriverService { |
26 | 26 | ||
27 | /** | 27 | /** |
28 | - * Returns the overall set of drivers being provided, optionally | 28 | + * Returns the overall set of drivers being provided. |
29 | - * filtered to only those that support all specified behaviours. | ||
30 | * | 29 | * |
31 | - * @param withBehaviours optional behaviour classes to query by | ||
32 | * @return provided drivers | 30 | * @return provided drivers |
33 | */ | 31 | */ |
34 | - Set<Driver> getDrivers(Class<? extends Behaviour>... withBehaviours); | 32 | + Set<Driver> getDrivers(); |
33 | + | ||
34 | + /** | ||
35 | + * Returns the set of drivers which support the specified behaviour. | ||
36 | + * | ||
37 | + * @param withBehaviour behaviour class to query by | ||
38 | + * @return provided drivers | ||
39 | + */ | ||
40 | + Set<Driver> getDrivers(Class<? extends Behaviour> withBehaviour); | ||
35 | 41 | ||
36 | /** | 42 | /** |
37 | * Returns the specified driver. | 43 | * Returns the specified driver. | ... | ... |
... | @@ -50,7 +50,7 @@ public class DefaultDriverTest { | ... | @@ -50,7 +50,7 @@ public class DefaultDriverTest { |
50 | ImmutableMap.of(TestBehaviour.class, | 50 | ImmutableMap.of(TestBehaviour.class, |
51 | TestBehaviourImpl.class), | 51 | TestBehaviourImpl.class), |
52 | ImmutableMap.of("foo", "bar")); | 52 | ImmutableMap.of("foo", "bar")); |
53 | - DefaultDriver ddc = | 53 | + Driver ddc = |
54 | one.merge(new DefaultDriver("foo.bar", "", "", "", | 54 | one.merge(new DefaultDriver("foo.bar", "", "", "", |
55 | ImmutableMap.of(TestBehaviourTwo.class, | 55 | ImmutableMap.of(TestBehaviourTwo.class, |
56 | TestBehaviourTwoImpl.class), | 56 | TestBehaviourTwoImpl.class), | ... | ... |
... | @@ -30,6 +30,7 @@ import org.onosproject.net.device.DeviceService; | ... | @@ -30,6 +30,7 @@ import org.onosproject.net.device.DeviceService; |
30 | import org.onosproject.net.driver.Behaviour; | 30 | import org.onosproject.net.driver.Behaviour; |
31 | import org.onosproject.net.driver.DefaultDriverData; | 31 | import org.onosproject.net.driver.DefaultDriverData; |
32 | import org.onosproject.net.driver.DefaultDriverHandler; | 32 | import org.onosproject.net.driver.DefaultDriverHandler; |
33 | +import org.onosproject.net.driver.DefaultDriverProvider; | ||
33 | import org.onosproject.net.driver.Driver; | 34 | import org.onosproject.net.driver.Driver; |
34 | import org.onosproject.net.driver.DriverAdminService; | 35 | import org.onosproject.net.driver.DriverAdminService; |
35 | import org.onosproject.net.driver.DriverHandler; | 36 | import org.onosproject.net.driver.DriverHandler; |
... | @@ -40,6 +41,7 @@ import org.slf4j.LoggerFactory; | ... | @@ -40,6 +41,7 @@ import org.slf4j.LoggerFactory; |
40 | import java.util.Map; | 41 | import java.util.Map; |
41 | import java.util.Optional; | 42 | import java.util.Optional; |
42 | import java.util.Set; | 43 | import java.util.Set; |
44 | +import java.util.stream.Collectors; | ||
43 | 45 | ||
44 | import static org.onlab.util.Tools.nullIsNotFound; | 46 | import static org.onlab.util.Tools.nullIsNotFound; |
45 | import static org.onosproject.net.AnnotationKeys.DRIVER; | 47 | import static org.onosproject.net.AnnotationKeys.DRIVER; |
... | @@ -49,7 +51,7 @@ import static org.onosproject.net.AnnotationKeys.DRIVER; | ... | @@ -49,7 +51,7 @@ import static org.onosproject.net.AnnotationKeys.DRIVER; |
49 | */ | 51 | */ |
50 | @Component(immediate = true) | 52 | @Component(immediate = true) |
51 | @Service | 53 | @Service |
52 | -public class DriverManager implements DriverAdminService { | 54 | +public class DriverManager extends DefaultDriverProvider implements DriverAdminService { |
53 | 55 | ||
54 | private final Logger log = LoggerFactory.getLogger(getClass()); | 56 | private final Logger log = LoggerFactory.getLogger(getClass()); |
55 | 57 | ||
... | @@ -61,7 +63,6 @@ public class DriverManager implements DriverAdminService { | ... | @@ -61,7 +63,6 @@ public class DriverManager implements DriverAdminService { |
61 | protected DeviceService deviceService; | 63 | protected DeviceService deviceService; |
62 | 64 | ||
63 | private Set<DriverProvider> providers = Sets.newConcurrentHashSet(); | 65 | private Set<DriverProvider> providers = Sets.newConcurrentHashSet(); |
64 | - private Map<String, Driver> driverByName = Maps.newConcurrentMap(); | ||
65 | private Map<String, Driver> driverByKey = Maps.newConcurrentMap(); | 66 | private Map<String, Driver> driverByKey = Maps.newConcurrentMap(); |
66 | 67 | ||
67 | @Activate | 68 | @Activate |
... | @@ -83,7 +84,7 @@ public class DriverManager implements DriverAdminService { | ... | @@ -83,7 +84,7 @@ public class DriverManager implements DriverAdminService { |
83 | @Override | 84 | @Override |
84 | public void registerProvider(DriverProvider provider) { | 85 | public void registerProvider(DriverProvider provider) { |
85 | provider.getDrivers().forEach(driver -> { | 86 | provider.getDrivers().forEach(driver -> { |
86 | - driverByName.put(driver.name(), driver); | 87 | + addDrivers(provider.getDrivers()); |
87 | driverByKey.put(key(driver.manufacturer(), | 88 | driverByKey.put(key(driver.manufacturer(), |
88 | driver.hwVersion(), | 89 | driver.hwVersion(), |
89 | driver.swVersion()), driver); | 90 | driver.swVersion()), driver); |
... | @@ -94,7 +95,7 @@ public class DriverManager implements DriverAdminService { | ... | @@ -94,7 +95,7 @@ public class DriverManager implements DriverAdminService { |
94 | @Override | 95 | @Override |
95 | public void unregisterProvider(DriverProvider provider) { | 96 | public void unregisterProvider(DriverProvider provider) { |
96 | provider.getDrivers().forEach(driver -> { | 97 | provider.getDrivers().forEach(driver -> { |
97 | - driverByName.remove(driver.name()); | 98 | + removeDrivers(provider.getDrivers()); |
98 | driverByKey.remove(key(driver.manufacturer(), | 99 | driverByKey.remove(key(driver.manufacturer(), |
99 | driver.hwVersion(), | 100 | driver.hwVersion(), |
100 | driver.swVersion())); | 101 | driver.swVersion())); |
... | @@ -103,21 +104,22 @@ public class DriverManager implements DriverAdminService { | ... | @@ -103,21 +104,22 @@ public class DriverManager implements DriverAdminService { |
103 | } | 104 | } |
104 | 105 | ||
105 | @Override | 106 | @Override |
106 | - public Set<Driver> getDrivers(Class<? extends Behaviour>... withBehaviours) { | 107 | + public Set<Driver> getDrivers() { |
107 | ImmutableSet.Builder<Driver> builder = ImmutableSet.builder(); | 108 | ImmutableSet.Builder<Driver> builder = ImmutableSet.builder(); |
108 | - for (Class<? extends Behaviour> behaviour : withBehaviours) { | 109 | + drivers.values().forEach(builder::add); |
109 | - driverByName.forEach((name, driver) -> { | ||
110 | - if (driver.hasBehaviour(behaviour)) { | ||
111 | - builder.add(driver); | ||
112 | - } | ||
113 | - }); | ||
114 | - } | ||
115 | return builder.build(); | 110 | return builder.build(); |
116 | } | 111 | } |
117 | 112 | ||
118 | @Override | 113 | @Override |
114 | + public Set<Driver> getDrivers(Class<? extends Behaviour> withBehaviour) { | ||
115 | + return drivers.values().stream() | ||
116 | + .filter(d -> d.hasBehaviour(withBehaviour)) | ||
117 | + .collect(Collectors.toSet()); | ||
118 | + } | ||
119 | + | ||
120 | + @Override | ||
119 | public Driver getDriver(String driverName) { | 121 | public Driver getDriver(String driverName) { |
120 | - return nullIsNotFound(driverByName.get(driverName), NO_DRIVER); | 122 | + return nullIsNotFound(drivers.get(driverName), NO_DRIVER); |
121 | } | 123 | } |
122 | 124 | ||
123 | @Override | 125 | @Override |
... | @@ -134,7 +136,7 @@ public class DriverManager implements DriverAdminService { | ... | @@ -134,7 +136,7 @@ public class DriverManager implements DriverAdminService { |
134 | .filter(d -> matches(d, mfr, hw, sw)).findFirst(); | 136 | .filter(d -> matches(d, mfr, hw, sw)).findFirst(); |
135 | 137 | ||
136 | // If no matching driver is found, return default. | 138 | // If no matching driver is found, return default. |
137 | - return optional.isPresent() ? optional.get() : driverByName.get(DEFAULT); | 139 | + return optional.isPresent() ? optional.get() : drivers.get(DEFAULT); |
138 | } | 140 | } |
139 | 141 | ||
140 | // Matches the given driver using ERE matching against the given criteria. | 142 | // Matches the given driver using ERE matching against the given criteria. |
... | @@ -163,6 +165,7 @@ public class DriverManager implements DriverAdminService { | ... | @@ -163,6 +165,7 @@ public class DriverManager implements DriverAdminService { |
163 | return new DefaultDriverHandler(new DefaultDriverData(driver)); | 165 | return new DefaultDriverHandler(new DefaultDriverData(driver)); |
164 | } | 166 | } |
165 | 167 | ||
168 | + // Produces a composite driver key using the specified components. | ||
166 | private String key(String mfr, String hw, String sw) { | 169 | private String key(String mfr, String hw, String sw) { |
167 | return String.format("%s-%s-%s", mfr, hw, sw); | 170 | return String.format("%s-%s-%s", mfr, hw, sw); |
168 | } | 171 | } | ... | ... |
... | @@ -21,7 +21,7 @@ import org.onosproject.core.DefaultGroupId; | ... | @@ -21,7 +21,7 @@ import org.onosproject.core.DefaultGroupId; |
21 | import org.onosproject.net.DeviceId; | 21 | import org.onosproject.net.DeviceId; |
22 | import org.onosproject.net.behaviour.Pipeliner; | 22 | import org.onosproject.net.behaviour.Pipeliner; |
23 | import org.onosproject.net.behaviour.PipelinerContext; | 23 | import org.onosproject.net.behaviour.PipelinerContext; |
24 | -import org.onosproject.net.driver.DriverData; | 24 | +import org.onosproject.net.driver.AbstractBehaviour; |
25 | import org.onosproject.net.flow.DefaultFlowRule; | 25 | import org.onosproject.net.flow.DefaultFlowRule; |
26 | import org.onosproject.net.flow.FlowRule; | 26 | import org.onosproject.net.flow.FlowRule; |
27 | import org.onosproject.net.flow.FlowRuleOperations; | 27 | import org.onosproject.net.flow.FlowRuleOperations; |
... | @@ -41,7 +41,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -41,7 +41,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
41 | /** | 41 | /** |
42 | * Simple single table pipeline abstraction. | 42 | * Simple single table pipeline abstraction. |
43 | */ | 43 | */ |
44 | -public class DefaultSingleTablePipeline implements Pipeliner { | 44 | +public class DefaultSingleTablePipeline extends AbstractBehaviour implements Pipeliner { |
45 | 45 | ||
46 | private final Logger log = getLogger(getClass()); | 46 | private final Logger log = getLogger(getClass()); |
47 | 47 | ||
... | @@ -115,8 +115,4 @@ public class DefaultSingleTablePipeline implements Pipeliner { | ... | @@ -115,8 +115,4 @@ public class DefaultSingleTablePipeline implements Pipeliner { |
115 | throw new UnsupportedOperationException("Single table does not next hop."); | 115 | throw new UnsupportedOperationException("Single table does not next hop."); |
116 | } | 116 | } |
117 | 117 | ||
118 | - @Override | ||
119 | - public void setData(DriverData data) { | ||
120 | - | ||
121 | - } | ||
122 | } | 118 | } | ... | ... |
... | @@ -24,7 +24,7 @@ import org.onosproject.core.CoreService; | ... | @@ -24,7 +24,7 @@ import org.onosproject.core.CoreService; |
24 | import org.onosproject.net.DeviceId; | 24 | import org.onosproject.net.DeviceId; |
25 | import org.onosproject.net.behaviour.Pipeliner; | 25 | import org.onosproject.net.behaviour.Pipeliner; |
26 | import org.onosproject.net.behaviour.PipelinerContext; | 26 | import org.onosproject.net.behaviour.PipelinerContext; |
27 | -import org.onosproject.net.driver.DriverData; | 27 | +import org.onosproject.net.driver.AbstractBehaviour; |
28 | import org.onosproject.net.flow.DefaultFlowRule; | 28 | import org.onosproject.net.flow.DefaultFlowRule; |
29 | import org.onosproject.net.flow.DefaultTrafficSelector; | 29 | import org.onosproject.net.flow.DefaultTrafficSelector; |
30 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 30 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
... | @@ -45,9 +45,9 @@ import java.util.concurrent.Future; | ... | @@ -45,9 +45,9 @@ import java.util.concurrent.Future; |
45 | import static org.slf4j.LoggerFactory.getLogger; | 45 | import static org.slf4j.LoggerFactory.getLogger; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | - * Created by ash on 07/04/15. | 48 | + * Corsa pipeline handler. |
49 | */ | 49 | */ |
50 | -public class OVSCorsaPipeline implements Pipeliner { | 50 | +public class OVSCorsaPipeline extends AbstractBehaviour implements Pipeliner { |
51 | 51 | ||
52 | private static final int CONTROLLER_PRIORITY = 255; | 52 | private static final int CONTROLLER_PRIORITY = 255; |
53 | private static final int DROP_PRIORITY = 0; | 53 | private static final int DROP_PRIORITY = 0; |
... | @@ -92,12 +92,6 @@ public class OVSCorsaPipeline implements Pipeliner { | ... | @@ -92,12 +92,6 @@ public class OVSCorsaPipeline implements Pipeliner { |
92 | return null; | 92 | return null; |
93 | } | 93 | } |
94 | 94 | ||
95 | - @Override | ||
96 | - public void setData(DriverData data) { | ||
97 | - | ||
98 | - } | ||
99 | - | ||
100 | - | ||
101 | private void pushDefaultRules() { | 95 | private void pushDefaultRules() { |
102 | boolean install = true; | 96 | boolean install = true; |
103 | processTableZero(install); | 97 | processTableZero(install); |
... | @@ -130,7 +124,6 @@ public class OVSCorsaPipeline implements Pipeliner { | ... | @@ -130,7 +124,6 @@ public class OVSCorsaPipeline implements Pipeliner { |
130 | ops = install ? ops.add(rule) : ops.remove(rule); | 124 | ops = install ? ops.add(rule) : ops.remove(rule); |
131 | 125 | ||
132 | 126 | ||
133 | - | ||
134 | //Drop rule | 127 | //Drop rule |
135 | selector = DefaultTrafficSelector.builder(); | 128 | selector = DefaultTrafficSelector.builder(); |
136 | treatment = DefaultTrafficTreatment.builder(); | 129 | treatment = DefaultTrafficTreatment.builder(); |
... | @@ -195,7 +188,6 @@ public class OVSCorsaPipeline implements Pipeliner { | ... | @@ -195,7 +188,6 @@ public class OVSCorsaPipeline implements Pipeliner { |
195 | FlowRule rule; | 188 | FlowRule rule; |
196 | 189 | ||
197 | 190 | ||
198 | - | ||
199 | //Drop rule | 191 | //Drop rule |
200 | selector = DefaultTrafficSelector.builder(); | 192 | selector = DefaultTrafficSelector.builder(); |
201 | treatment = DefaultTrafficTreatment.builder(); | 193 | treatment = DefaultTrafficTreatment.builder(); | ... | ... |
-
Please register or login to post a comment