tom

Adding ability to push remote bundle updates.

1 package org.onlab.onos.cli.net; 1 package org.onlab.onos.cli.net;
2 2
3 +import org.apache.karaf.shell.commands.Argument;
3 import org.apache.karaf.shell.commands.Command; 4 import org.apache.karaf.shell.commands.Command;
4 import org.onlab.onos.net.Device; 5 import org.onlab.onos.net.Device;
5 import org.onlab.onos.net.Host; 6 import org.onlab.onos.net.Host;
...@@ -18,8 +19,22 @@ import org.onlab.onos.net.intent.IntentState; ...@@ -18,8 +19,22 @@ import org.onlab.onos.net.intent.IntentState;
18 description = "Wipes-out the entire network information base, i.e. devices, links, hosts") 19 description = "Wipes-out the entire network information base, i.e. devices, links, hosts")
19 public class WipeOutCommand extends ClustersListCommand { 20 public class WipeOutCommand extends ClustersListCommand {
20 21
22 +
23 + private static final String DISCLAIMER = "Yes, I know it will delete everything!";
24 +
25 + @Argument(index = 0, name = "disclaimer", description = "Device ID",
26 + required = true, multiValued = false)
27 + String disclaimer = null;
28 +
21 @Override 29 @Override
22 protected void execute() { 30 protected void execute() {
31 + if (!disclaimer.equals(DISCLAIMER)) {
32 + print("I'm afraid I can't do that...");
33 + print("You have to acknowledge by: " + DISCLAIMER);
34 + return;
35 + }
36 +
37 + print("Good bye...");
23 DeviceAdminService deviceAdminService = get(DeviceAdminService.class); 38 DeviceAdminService deviceAdminService = get(DeviceAdminService.class);
24 DeviceService deviceService = get(DeviceService.class); 39 DeviceService deviceService = get(DeviceService.class);
25 for (Device device : deviceService.getDevices()) { 40 for (Device device : deviceService.getDevices()) {
......
...@@ -15,7 +15,7 @@ name=${2:-onos-1} ...@@ -15,7 +15,7 @@ name=${2:-onos-1}
15 15
16 ssh $remote " 16 ssh $remote "
17 sudo perl -pi.bak -e \"s/127.0.1.1.*/127.0.1.1 $name/g\" /etc/hosts 17 sudo perl -pi.bak -e \"s/127.0.1.1.*/127.0.1.1 $name/g\" /etc/hosts
18 - sudo perl -pi.bak -e \"local \$/ = ''; s/.*/$name/g\" /etc/hostname 18 + sudo bash -c \"echo $name >/etc/hostname\"
19 sudo hostname $name 19 sudo hostname $name
20 " 2>/dev/null 20 " 2>/dev/null
21 21
......
...@@ -9,5 +9,9 @@ ...@@ -9,5 +9,9 @@
9 remote=$ONOS_USER@${1:-$OCI} 9 remote=$ONOS_USER@${1:-$OCI}
10 10
11 scp -q ~/.ssh/id_rsa.pub $remote:/tmp 11 scp -q ~/.ssh/id_rsa.pub $remote:/tmp
12 -ssh $remote "cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys" 12 +ssh $remote "
13 + cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys
14 + sort -u ~/.ssh/authorized_keys > ~/.ssh/authorized_keys.bak
15 + mv ~/.ssh/authorized_keys.bak ~/.ssh/authorized_keys
16 +"
13 ssh -n -o PasswordAuthentication=no $remote true 17 ssh -n -o PasswordAuthentication=no $remote true
......
1 +#!/bin/bash
2 +#-------------------------------------------------------------------------------
3 +# Pushes the specified bundle to the remote ONOS cell machines and updates it.
4 +#-------------------------------------------------------------------------------
5 +
6 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 +. $ONOS_ROOT/tools/build/envDefaults
8 +
9 +cd ~/.m2/repository
10 +jar=$(find org/onlab -type f -name '*.jar' | grep $1 | grep -v -e -tests | head -n 1)
11 +
12 +[ -z "$jar" ] && echo "No bundle $1 found for" && exit 1
13 +
14 +bundle=$(echo $(basename $jar .jar) | sed 's/-[0-9].*//g')
15 +
16 +nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
17 +for node in $nodes; do
18 + scp $jar $ONOS_USER@$node:$ONOS_INSTALL_DIR/$KARAF_DIST/system/$jar
19 + ssh $ONOS_USER@$node $ONOS_INSTALL_DIR/bin/onos update $bundle
20 +done