cloudinfo-set 1.17 KB
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 <pid> <eid>: Set the cloud info based on an input file of the form:
10
#
11
#####################   <pid> <eid>
12 13 14 15 16 17 18 19
#   <src> <dst> <bw> <delay> <loss>
#
# Where <src> and <dst> or of the form "elab-*" for now.

use strict;

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

20 21 22 23 24 25
#local $_ = <>;
#chop;
#my ($pid,$eid) = /^(\S+)\s+(\S+)$/ or die
#  "First line must be of the form \"<pid> <eid>\"\n";
my $pid = $ARGV[0];
my $eid = $ARGV[1];
26

27 28
my $failures = 0;

29
while (<STDIN>) {
30
    my ($src, $dst, $bw, $del, $plr) = split /\s+/;
31 32 33 34 35
    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";
    }
36 37 38 39 40
    my $srcip = $src;
    if ($srcip =~ /^\d+\.\d+\.\d+\.(\d+)$/)
    {
	$src = "elab-$1";
    }
41 42
    my $cmd = "$TEVC -e $pid/$eid now elabc-$src MODIFY ".
      "DEST=$dstip BANDWIDTH=$bw DELAY=$del PLR=$plr";
43
    print STDERR "$cmd\n";
44
    system("$cmd");
45 46 47 48
    if ($? != 0) {
	print STDERR "*** Failed to set paramters for $src -> $dst\n";
	$failures++;
    }
49 50
}

51
exit $failures;