cloudinfo-set 1020 Bytes
Newer Older
1
#!/usr/bin/perl
Mike Hibler's avatar
Mike Hibler committed
2 3 4 5 6
#
# EMULAB-COPYRIGHT
# Copyright (c) 2006 University of Utah and the Flux Group.
# All rights reserved.
#
7 8 9

#
# cloudinfo-set: Set the cloud info based on an input file of the form:
10
#
11 12 13 14 15 16 17 18 19 20 21 22 23 24
#   <pid> <eid>
#   <src> <dst> <bw> <delay> <loss>
#
# Where <src> and <dst> or of the form "elab-*" for now.

use strict;

my $TEVC = "/usr/testbed/bin/tevc";

local $_ = <>;
chop;
my ($pid,$eid) = /^(\S+)\s+(\S+)$/ or die
  "First line must be of the form \"<pid> <eid>\"\n";

25 26
my $failures = 0;

27 28
while (<>) {
    my ($src, $dst, $bw, $del, $plr) = split /\s+/;
29 30 31 32 33
    my $dstip = $dst;
    if ($dstip !~ /^\d+\.\d+\.\d+\.\d+$/) {
	$dst =~ (/^elab-(\d+)$/) or die "Host names must be of the form elab-NUM\n";
	$dstip = "10.0.0.$1";
    }
34 35
    my $cmd = "$TEVC -e $pid/$eid now elabc-$src MODIFY ".
      "DEST=$dstip BANDWIDTH=$bw DELAY=$del PLR=$plr";
36
    #print STDERR "$cmd\n";
37
    system("$cmd");
38 39 40 41
    if ($? != 0) {
	print STDERR "*** Failed to set paramters for $src -> $dst\n";
	$failures++;
    }
42 43
}

44
exit $failures;