Thomas Vachuska
Committed by Gerrit Code Review

Adding ability to get borrowed cell definition without changing the existing reservation.

Change-Id: Ib1fba430371f49f3c928998af98a6d347fabd93d
......@@ -120,13 +120,17 @@ function cell {
export ONOS_INSTANCES=$(env | grep 'OC[0-9]*=' | sort | cut -d= -f2)
setPrimaryInstance 1 >/dev/null
cell
onos-verify-cell
;;
"return")
curl -sS -X DELETE "http://$CELL_WARDEN:4321/?user=$(id -un)"
unset ONOS_CELL ONOS_NIC ONOS_IP ONOS_APPS ONOS_BOOT_FEATURES
unset OCI OCN OCT ONOS_INSTANCES ONOS_FEATURES
unset $(env | sed -n 's:\(^OC[0-9]\{1,\}\)=.*:\1 :g p')
;;
"status")
curl -sS "http://$CELL_WARDEN:4321/"
curl -sS "http://$CELL_WARDEN:4321/" | sort
;;
"")
......
#!/bin/bash
# -----------------------------------------------------------------------------
# List available ONOS cells configuration.
# -----------------------------------------------------------------------------
[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
. $ONOS_ROOT/tools/dev/bash_profile
cell "$@"
\ No newline at end of file
......@@ -55,7 +55,6 @@ class Warden {
private static final long TIMEOUT = 10; // 10 seconds
private static final int MAX_MINUTES = 240; // 4 hours max
private static final int MINUTE = 60_000; // 1 minute
private static final int DEFAULT_MINUTES = 60;
private final File log = new File("warden.log");
......@@ -158,10 +157,11 @@ class Warden {
long now = System.currentTimeMillis();
Reservation reservation = currentUserReservation(userName);
if (reservation == null) {
checkArgument(minutes > 0, "Number of minutes must be positive");
Set<String> cells = getAvailableCells();
checkState(!cells.isEmpty(), "No cells are presently available");
String cellName = ImmutableList.copyOf(cells).get(random.nextInt(cells.size()));
reservation = new Reservation(cellName, userName, now, minutes == 0 ? DEFAULT_MINUTES : minutes);
reservation = new Reservation(cellName, userName, now, minutes);
} else if (minutes == 0) {
// If minutes are 0, simply return the cell definition
return getCellDefinition(reservation.cellName);
......