Committed by
Gerrit Code Review
Add CLI command to view provisioned subscribers
Change-Id: I67a49d7fa569e9f4f28eb8eaea1b34ba2bd5a5fa
Showing
5 changed files
with
65 additions
and
4 deletions
| ... | @@ -21,6 +21,7 @@ import org.onosproject.event.ListenerService; | ... | @@ -21,6 +21,7 @@ import org.onosproject.event.ListenerService; |
| 21 | import org.onosproject.net.ConnectPoint; | 21 | import org.onosproject.net.ConnectPoint; |
| 22 | import org.onosproject.net.DeviceId; | 22 | import org.onosproject.net.DeviceId; |
| 23 | 23 | ||
| 24 | +import java.util.Collection; | ||
| 24 | import java.util.Map; | 25 | import java.util.Map; |
| 25 | 26 | ||
| 26 | /** | 27 | /** |
| ... | @@ -45,6 +46,13 @@ public interface AccessDeviceService | ... | @@ -45,6 +46,13 @@ public interface AccessDeviceService |
| 45 | void removeSubscriber(ConnectPoint port); | 46 | void removeSubscriber(ConnectPoint port); |
| 46 | 47 | ||
| 47 | /** | 48 | /** |
| 49 | + * Returns information about the provisioned subscribers. | ||
| 50 | + * | ||
| 51 | + * @return subscribers | ||
| 52 | + */ | ||
| 53 | + Collection<Map.Entry<ConnectPoint, VlanId>> getSubscribers(); | ||
| 54 | + | ||
| 55 | + /** | ||
| 48 | * Returns the map of configured OLTs. | 56 | * Returns the map of configured OLTs. |
| 49 | * | 57 | * |
| 50 | * @return a map | 58 | * @return a map | ... | ... |
| ... | @@ -26,9 +26,9 @@ import org.onosproject.olt.AccessDeviceService; | ... | @@ -26,9 +26,9 @@ import org.onosproject.olt.AccessDeviceService; |
| 26 | import java.util.Map; | 26 | import java.util.Map; |
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | - * Adds a subscriber to an access device. | 29 | + * Shows configured OLTs. |
| 30 | */ | 30 | */ |
| 31 | -@Command(scope = "onos", name = "show-olts", | 31 | +@Command(scope = "onos", name = "olts", |
| 32 | description = "Shows configured OLTs") | 32 | description = "Shows configured OLTs") |
| 33 | public class ShowOltCommand extends AbstractShellCommand { | 33 | public class ShowOltCommand extends AbstractShellCommand { |
| 34 | 34 | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016 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 | + | ||
| 17 | +package org.onosproject.olt.cli; | ||
| 18 | + | ||
| 19 | +import org.apache.karaf.shell.commands.Command; | ||
| 20 | +import org.onlab.packet.VlanId; | ||
| 21 | +import org.onosproject.cli.AbstractShellCommand; | ||
| 22 | +import org.onosproject.net.ConnectPoint; | ||
| 23 | +import org.onosproject.olt.AccessDeviceService; | ||
| 24 | + | ||
| 25 | +import java.util.Map; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Shows provisioned subscribers. | ||
| 29 | + */ | ||
| 30 | +@Command(scope = "onos", name = "subscribers", | ||
| 31 | + description = "Shows provisioned subscribers") | ||
| 32 | +public class ShowSubscribersCommand extends AbstractShellCommand { | ||
| 33 | + | ||
| 34 | + private static final String FORMAT = "port=%s, cvlan=%s"; | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + protected void execute() { | ||
| 38 | + AccessDeviceService service = AbstractShellCommand.get(AccessDeviceService.class); | ||
| 39 | + service.getSubscribers().forEach(this::display); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + private void display(Map.Entry<ConnectPoint, VlanId> subscriber) { | ||
| 43 | + print(FORMAT, subscriber.getKey(), subscriber.getValue()); | ||
| 44 | + } | ||
| 45 | +} |
| ... | @@ -67,6 +67,7 @@ import org.onosproject.store.service.StorageService; | ... | @@ -67,6 +67,7 @@ import org.onosproject.store.service.StorageService; |
| 67 | import org.osgi.service.component.ComponentContext; | 67 | import org.osgi.service.component.ComponentContext; |
| 68 | import org.slf4j.Logger; | 68 | import org.slf4j.Logger; |
| 69 | 69 | ||
| 70 | +import java.util.Collection; | ||
| 70 | import java.util.Dictionary; | 71 | import java.util.Dictionary; |
| 71 | import java.util.List; | 72 | import java.util.List; |
| 72 | import java.util.Map; | 73 | import java.util.Map; |
| ... | @@ -243,6 +244,11 @@ public class Olt | ... | @@ -243,6 +244,11 @@ public class Olt |
| 243 | } | 244 | } |
| 244 | 245 | ||
| 245 | @Override | 246 | @Override |
| 247 | + public Collection<Map.Entry<ConnectPoint, VlanId>> getSubscribers() { | ||
| 248 | + return subscribers.entrySet(); | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + @Override | ||
| 246 | public Map<DeviceId, AccessDeviceData> fetchOlts() { | 252 | public Map<DeviceId, AccessDeviceData> fetchOlts() { |
| 247 | return Maps.newHashMap(oltData); | 253 | return Maps.newHashMap(oltData); |
| 248 | } | 254 | } |
| ... | @@ -459,11 +465,10 @@ public class Olt | ... | @@ -459,11 +465,10 @@ public class Olt |
| 459 | public void event(DeviceEvent event) { | 465 | public void event(DeviceEvent event) { |
| 460 | DeviceId devId = event.subject().id(); | 466 | DeviceId devId = event.subject().id(); |
| 461 | if (!oltData.containsKey(devId)) { | 467 | if (!oltData.containsKey(devId)) { |
| 462 | - log.debug("Device {} is not an OLT", devId); | ||
| 463 | return; | 468 | return; |
| 464 | } | 469 | } |
| 465 | switch (event.type()) { | 470 | switch (event.type()) { |
| 466 | - //TODO: Port handling and bookkeeping should be inproved once | 471 | + //TODO: Port handling and bookkeeping should be improved once |
| 467 | // olt firmware handles correct behaviour. | 472 | // olt firmware handles correct behaviour. |
| 468 | case PORT_ADDED: | 473 | case PORT_ADDED: |
| 469 | if (!oltData.get(devId).uplink().equals(event.port().number()) && | 474 | if (!oltData.get(devId).uplink().equals(event.port().number()) && | ... | ... |
| ... | @@ -37,6 +37,9 @@ | ... | @@ -37,6 +37,9 @@ |
| 37 | <null/> | 37 | <null/> |
| 38 | </completers> | 38 | </completers> |
| 39 | </command> | 39 | </command> |
| 40 | + <command> | ||
| 41 | + <action class="org.onosproject.olt.cli.ShowSubscribersCommand"/> | ||
| 42 | + </command> | ||
| 40 | </command-bundle> | 43 | </command-bundle> |
| 41 | 44 | ||
| 42 | <bean id="deviceIdCompleter" class="org.onosproject.cli.net.DeviceIdCompleter"/> | 45 | <bean id="deviceIdCompleter" class="org.onosproject.cli.net.DeviceIdCompleter"/> | ... | ... |
-
Please register or login to post a comment