Showing
14 changed files
with
38 additions
and
37 deletions
... | @@ -15,6 +15,7 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport { | ... | @@ -15,6 +15,7 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport { |
15 | * @param serviceClass service class | 15 | * @param serviceClass service class |
16 | * @param <T> type of service | 16 | * @param <T> type of service |
17 | * @return service implementation | 17 | * @return service implementation |
18 | + * @throws org.onlab.osgi.ServiceNotFoundException if service is unavailable | ||
18 | */ | 19 | */ |
19 | public static <T> T get(Class<T> serviceClass) { | 20 | public static <T> T get(Class<T> serviceClass) { |
20 | return DefaultServiceDirectory.getService(serviceClass); | 21 | return DefaultServiceDirectory.getService(serviceClass); |
... | @@ -26,7 +27,7 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport { | ... | @@ -26,7 +27,7 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport { |
26 | * @param format format string; see {@link String#format} | 27 | * @param format format string; see {@link String#format} |
27 | * @param args arguments | 28 | * @param args arguments |
28 | */ | 29 | */ |
29 | - public static void print(String format, Object... args) { | 30 | + public void print(String format, Object... args) { |
30 | System.out.println(String.format(format, args)); | 31 | System.out.println(String.format(format, args)); |
31 | } | 32 | } |
32 | 33 | ||
... | @@ -36,7 +37,7 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport { | ... | @@ -36,7 +37,7 @@ public abstract class AbstractShellCommand extends OsgiCommandSupport { |
36 | * @param format format string; see {@link String#format} | 37 | * @param format format string; see {@link String#format} |
37 | * @param args arguments | 38 | * @param args arguments |
38 | */ | 39 | */ |
39 | - public static void error(String format, Object... args) { | 40 | + public void error(String format, Object... args) { |
40 | System.err.println(String.format(format, args)); | 41 | System.err.println(String.format(format, args)); |
41 | } | 42 | } |
42 | 43 | ... | ... |
... | @@ -36,7 +36,7 @@ public class DevicePortsListCommand extends DevicesListCommand { | ... | @@ -36,7 +36,7 @@ public class DevicePortsListCommand extends DevicesListCommand { |
36 | 36 | ||
37 | @Override | 37 | @Override |
38 | protected void execute() { | 38 | protected void execute() { |
39 | - DeviceService service = getService(DeviceService.class); | 39 | + DeviceService service = get(DeviceService.class); |
40 | if (uri == null) { | 40 | if (uri == null) { |
41 | for (Device device : getSortedDevices(service)) { | 41 | for (Device device : getSortedDevices(service)) { |
42 | printDevice(service, device); | 42 | printDevice(service, device); | ... | ... |
... | @@ -19,7 +19,7 @@ public class DeviceRemoveCommand extends AbstractShellCommand { | ... | @@ -19,7 +19,7 @@ public class DeviceRemoveCommand extends AbstractShellCommand { |
19 | 19 | ||
20 | @Override | 20 | @Override |
21 | protected void execute() { | 21 | protected void execute() { |
22 | - getService(DeviceAdminService.class).removeDevice(DeviceId.deviceId(uri)); | 22 | + get(DeviceAdminService.class).removeDevice(DeviceId.deviceId(uri)); |
23 | } | 23 | } |
24 | 24 | ||
25 | } | 25 | } | ... | ... |
... | @@ -25,7 +25,7 @@ public class DeviceRoleCommand extends AbstractShellCommand { | ... | @@ -25,7 +25,7 @@ public class DeviceRoleCommand extends AbstractShellCommand { |
25 | @Override | 25 | @Override |
26 | protected void execute() { | 26 | protected void execute() { |
27 | MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase()); | 27 | MastershipRole mastershipRole = MastershipRole.valueOf(role.toUpperCase()); |
28 | - getService(DeviceAdminService.class).setRole(DeviceId.deviceId(uri), | 28 | + get(DeviceAdminService.class).setRole(DeviceId.deviceId(uri), |
29 | mastershipRole); | 29 | mastershipRole); |
30 | } | 30 | } |
31 | 31 | ... | ... |
... | @@ -30,7 +30,7 @@ public class DevicesListCommand extends AbstractShellCommand { | ... | @@ -30,7 +30,7 @@ public class DevicesListCommand extends AbstractShellCommand { |
30 | 30 | ||
31 | @Override | 31 | @Override |
32 | protected void execute() { | 32 | protected void execute() { |
33 | - DeviceService service = getService(DeviceService.class); | 33 | + DeviceService service = get(DeviceService.class); |
34 | for (Device device : getSortedDevices(service)) { | 34 | for (Device device : getSortedDevices(service)) { |
35 | printDevice(service, device); | 35 | printDevice(service, device); |
36 | } | 36 | } | ... | ... |
... | @@ -35,8 +35,8 @@ public class FlowsListCommand extends AbstractShellCommand { | ... | @@ -35,8 +35,8 @@ public class FlowsListCommand extends AbstractShellCommand { |
35 | 35 | ||
36 | @Override | 36 | @Override |
37 | protected void execute() { | 37 | protected void execute() { |
38 | - DeviceService deviceService = getService(DeviceService.class); | 38 | + DeviceService deviceService = get(DeviceService.class); |
39 | - FlowRuleService service = getService(FlowRuleService.class); | 39 | + FlowRuleService service = get(FlowRuleService.class); |
40 | Map<Device, List<FlowRule>> flows = getSortedFlows(deviceService, service); | 40 | Map<Device, List<FlowRule>> flows = getSortedFlows(deviceService, service); |
41 | for (Device d : deviceService.getDevices()) { | 41 | for (Device d : deviceService.getDevices()) { |
42 | printFlows(d, flows.get(d)); | 42 | printFlows(d, flows.get(d)); | ... | ... |
... | @@ -30,7 +30,7 @@ public class HostsListCommand extends AbstractShellCommand { | ... | @@ -30,7 +30,7 @@ public class HostsListCommand extends AbstractShellCommand { |
30 | 30 | ||
31 | @Override | 31 | @Override |
32 | protected void execute() { | 32 | protected void execute() { |
33 | - HostService service = getService(HostService.class); | 33 | + HostService service = get(HostService.class); |
34 | for (Host host : getSortedHosts(service)) { | 34 | for (Host host : getSortedHosts(service)) { |
35 | printHost(host); | 35 | printHost(host); |
36 | } | 36 | } | ... | ... |
... | @@ -24,7 +24,7 @@ public class LinksListCommand extends AbstractShellCommand { | ... | @@ -24,7 +24,7 @@ public class LinksListCommand extends AbstractShellCommand { |
24 | 24 | ||
25 | @Override | 25 | @Override |
26 | protected void execute() { | 26 | protected void execute() { |
27 | - LinkService service = getService(LinkService.class); | 27 | + LinkService service = get(LinkService.class); |
28 | Iterable<Link> links = uri != null ? | 28 | Iterable<Link> links = uri != null ? |
29 | service.getDeviceLinks(deviceId(uri)) : service.getLinks(); | 29 | service.getDeviceLinks(deviceId(uri)) : service.getLinks(); |
30 | for (Link link : links) { | 30 | for (Link link : links) { | ... | ... |
... | @@ -23,7 +23,7 @@ public class TopologyCommand extends AbstractShellCommand { | ... | @@ -23,7 +23,7 @@ public class TopologyCommand extends AbstractShellCommand { |
23 | * Initializes the context for all cluster commands. | 23 | * Initializes the context for all cluster commands. |
24 | */ | 24 | */ |
25 | protected void init() { | 25 | protected void init() { |
26 | - service = getService(TopologyService.class); | 26 | + service = get(TopologyService.class); |
27 | topology = service.currentTopology(); | 27 | topology = service.currentTopology(); |
28 | } | 28 | } |
29 | 29 | ... | ... |
... | @@ -30,6 +30,7 @@ alias mci='mvn clean install' | ... | @@ -30,6 +30,7 @@ alias mci='mvn clean install' |
30 | 30 | ||
31 | # Short-hand for ONOS build from the top of the source tree. | 31 | # Short-hand for ONOS build from the top of the source tree. |
32 | alias ob='o && mvn clean install javadoc:aggregate' | 32 | alias ob='o && mvn clean install javadoc:aggregate' |
33 | +alias ot='onos-test' | ||
33 | 34 | ||
34 | # Short-hand for tailing the ONOS (karaf) log | 35 | # Short-hand for tailing the ONOS (karaf) log |
35 | alias tl='$ONOS_ROOT/tools/dev/watchLog' | 36 | alias tl='$ONOS_ROOT/tools/dev/watchLog' | ... | ... |
... | @@ -8,25 +8,4 @@ | ... | @@ -8,25 +8,4 @@ |
8 | 8 | ||
9 | remote=$ONOS_USER@${1:-$OCI} | 9 | remote=$ONOS_USER@${1:-$OCI} |
10 | 10 | ||
11 | -LOG=$ONOS_INSTALL_DIR/config.log | 11 | +echo "Deprecated!" |
12 | -onos=$ONOS_INSTALL_DIR/bin/onos | ||
13 | - | ||
14 | -ssh $remote " | ||
15 | - # Wait until we reach the run-level 100 | ||
16 | - echo 'Waiting for cluster bootstrap...' | ||
17 | - running="" | ||
18 | - while [ -z \$running ]; do | ||
19 | - $onos bundle:list 2>>$LOG | grep -q 'START LEVEL 100' && running=1 || sleep 2 | ||
20 | - done | ||
21 | - | ||
22 | - echo 'Installing ONOS bundles...' | ||
23 | - $onos cluster:feature-install default onos-api 1>>$LOG 2>&1 | ||
24 | - # $onos cluster:feature-install default onos-core 1>>$LOG 2>&1 | ||
25 | - $onos cluster:feature-install default onos-core-trivial 1>>$LOG 2>&1 | ||
26 | - $onos cluster:feature-install default onos-openflow 1>>$LOG 2>&1 | ||
27 | - $onos cluster:feature-install default onos-cli 1>>$LOG 2>&1 | ||
28 | - # $onos cluster:feature-install default onos-gui 1>>$LOG 2>&1 | ||
29 | - # $onos cluster:feature-install default onos-rest 1>>$LOG 2>&1 | ||
30 | - $onos cluster:feature-install default onos-app-tvue 1>>$LOG 2>&1 | ||
31 | - $onos cluster:feature-install default onos-app-fwd 1>>$LOG 2>&1 | ||
32 | -" | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -14,6 +14,7 @@ trap "ssh $remote 'ps -ef | grep \"tail -n 512\" | grep -v grep | cut -c10-15 | | ... | @@ -14,6 +14,7 @@ trap "ssh $remote 'ps -ef | grep \"tail -n 512\" | grep -v grep | cut -c10-15 | |
14 | 14 | ||
15 | ssh $remote " | 15 | ssh $remote " |
16 | while true; do | 16 | while true; do |
17 | + echo ================================================================== | ||
17 | [ ! -f $LOG ] && sleep 2 && continue | 18 | [ ! -f $LOG ] && sleep 2 && continue |
18 | tail -n 512 --follow=name $LOG --sleep-interval 2 | 19 | tail -n 512 --follow=name $LOG --sleep-interval 2 |
19 | done | 20 | done | ... | ... |
tools/test/bin/onos-test
0 → 100755
1 | +#!/bin/bash | ||
2 | +#------------------------------------------------------------------------------- | ||
3 | +# Launches the ONOS tests on the current cell environment. | ||
4 | +#------------------------------------------------------------------------------- | ||
5 | + | ||
6 | +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 | ||
7 | +. $ONOS_ROOT/tools/build/envDefaults | ||
8 | + | ||
9 | +nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2) | ||
10 | + | ||
11 | +onos-package | ||
12 | +for node in $nodes; do onos-install -f $node; done | ||
13 | +for node in $nodes; do onos-wait-for-start $node; done |
... | @@ -2,6 +2,7 @@ package org.onlab.osgi; | ... | @@ -2,6 +2,7 @@ package org.onlab.osgi; |
2 | 2 | ||
3 | import org.osgi.framework.BundleContext; | 3 | import org.osgi.framework.BundleContext; |
4 | import org.osgi.framework.FrameworkUtil; | 4 | import org.osgi.framework.FrameworkUtil; |
5 | +import org.osgi.framework.ServiceReference; | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | * Default implementation of the service directory using OSGi framework utilities. | 8 | * Default implementation of the service directory using OSGi framework utilities. |
... | @@ -17,11 +18,16 @@ public class DefaultServiceDirectory implements ServiceDirectory { | ... | @@ -17,11 +18,16 @@ public class DefaultServiceDirectory implements ServiceDirectory { |
17 | */ | 18 | */ |
18 | public static <T> T getService(Class<T> serviceClass) { | 19 | public static <T> T getService(Class<T> serviceClass) { |
19 | BundleContext bc = FrameworkUtil.getBundle(serviceClass).getBundleContext(); | 20 | BundleContext bc = FrameworkUtil.getBundle(serviceClass).getBundleContext(); |
20 | - T impl = bc.getService(bc.getServiceReference(serviceClass)); | 21 | + if (bc != null) { |
21 | - if (impl == null) { | 22 | + ServiceReference<T> reference = bc.getServiceReference(serviceClass); |
22 | - throw new ServiceNotFoundException("Service " + serviceClass.getName() + " not found"); | 23 | + if (reference != null) { |
24 | + T impl = bc.getService(reference); | ||
25 | + if (impl != null) { | ||
26 | + return impl; | ||
27 | + } | ||
28 | + } | ||
23 | } | 29 | } |
24 | - return impl; | 30 | + throw new ServiceNotFoundException("Service " + serviceClass.getName() + " not found"); |
25 | } | 31 | } |
26 | 32 | ||
27 | @Override | 33 | @Override | ... | ... |
-
Please register or login to post a comment