cloudinfo-set 1020 Bytes
Newer Older
Kevin Atkinson's avatar
 
Kevin Atkinson committed
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.
#
Kevin Atkinson's avatar
 
Kevin Atkinson committed
7 8 9

#
# cloudinfo-set: Set the cloud info based on an input file of the form:
Kevin Atkinson's avatar
 
Kevin Atkinson committed
10
#
Kevin Atkinson's avatar
 
Kevin Atkinson committed
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";

Kevin Atkinson's avatar
 
Kevin Atkinson committed
25 26
my $failures = 0;

Kevin Atkinson's avatar
 
Kevin Atkinson committed
27 28
while (<>) {
    my ($src, $dst, $bw, $del, $plr) = split /\s+/;
Kevin Atkinson's avatar
 
Kevin Atkinson committed
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";
    }
Kevin Atkinson's avatar
 
Kevin Atkinson committed
34 35
    my $cmd = "$TEVC -e $pid/$eid now elabc-$src MODIFY ".
      "DEST=$dstip BANDWIDTH=$bw DELAY=$del PLR=$plr";
Kevin Atkinson's avatar
 
Kevin Atkinson committed
36
    #print STDERR "$cmd\n";
Kevin Atkinson's avatar
 
Kevin Atkinson committed
37
    system("$cmd");
Kevin Atkinson's avatar
 
Kevin Atkinson committed
38 39 40 41
    if ($? != 0) {
	print STDERR "*** Failed to set paramters for $src -> $dst\n";
	$failures++;
    }
Kevin Atkinson's avatar
 
Kevin Atkinson committed
42 43
}

Kevin Atkinson's avatar
 
Kevin Atkinson committed
44
exit $failures;