tom

Added onos-test.

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