Commit 90a546f5 authored by Jonathon Duerig's avatar Jonathon Duerig

Add support for GENI rspecV3.

parent 1c31cdff
......@@ -87,7 +87,7 @@ sub GetVersion()
my $default_ad = {
"type" => "ProtoGENI",
"version" => $coder->string("0.2") };
"version" => $coder->string("2") };
my $request_0_1 = {
"type" => "ProtoGENI",
"version" => $coder->string("0.1"),
......@@ -109,6 +109,14 @@ sub GetVersion()
"namespace" => "http://www.protogeni.net/resources/rspec/2",
"extensions" => ["http://www.protogeni.net/resources/rspec/ext/emulab/1"]
};
my $request_3 = {
"type" => "GENI",
"version" => $coder->string("3"),
"schema" => "http://www.geni.net/resources/rspec/3/request.xsd",
"namespace" => "http://www.geni.net/resources/rspec/3",
"extensions" => ["http://www.protogeni.net/resources/rspec/ext/emulab/1\
"]
};
my $ad_0_1 = {
"type" => "ProtoGENI",
"version" => $coder->string("0.1"),
......@@ -130,6 +138,13 @@ sub GetVersion()
"namespace" => "http://www.protogeni.net/resources/rspec/2",
"extensions" => ["http://www.protogeni.net/resources/rspec/ext/emulab/1"]
};
my $ad_3 = {
"type" => "GENI",
"version" => $coder->string("3"),
"schema" => "http://www.geni.net/resources/rspec/3/ad.xsd",
"namespace" => "http://www.geni.net/resources/rspec/3",
"extensions" => ["http://www.protogeni.net/resources/rspec/ext/emulab/1"]
};
my $blob = {
"geni_api" => $API_VERSION,
......@@ -140,8 +155,9 @@ sub GetVersion()
"code_tag" => $commithash,
# XXX
"hostname" => $hostname,
"request_rspec_versions" => [$request_0_1, $request_0_2, $request_2],
"ad_rspec_versions" => [$ad_0_1, $ad_0_2, $ad_2],
"request_rspec_versions" => [$request_0_1, $request_0_2, $request_2,
$request_3],
"ad_rspec_versions" => [$ad_0_1, $ad_0_2, $ad_2, $ad_3],
"default_ad_rspec" => $default_ad
};
$blob->{"peers"} = $peers
......@@ -189,9 +205,10 @@ sub ListResources()
} else {
my $pgversion = undef;
if (! defined($version)) {
$pgversion = "0.2";
$pgversion = "2";
} elsif (defined($version->{'type'}) &&
lc($version->{'type'}) eq "protogeni") {
(lc($version->{'type'}) eq "protogeni"
|| lc($version->{'type'}) eq "geni")) {
$pgversion = $version->{'version'};
} else {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
......
......@@ -211,13 +211,14 @@ sub DiscoverResourcesAux($$$$)
{
my ($available, $compress, $version, $credentials) = @_;
my $user_urn = $ENV{'GENIRN'};
$version = "0.2"
$version = "2"
if (!defined($version));
# Sanity check since this can come from client.
if (! ($version eq "0.1" || $version eq "0.2" || $version eq "2"
|| $version eq "PG 0.1" || $version eq "PG 0.2"
|| $version eq "PG 2")) {
|| $version eq "3"
|| $version eq "PG 0.1" || $version eq "PG 0.2"
|| $version eq "PG 2")) {
return GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Improper version request");
}
......
......@@ -29,17 +29,19 @@ use GeniHRN;
use GeniUtil;
use Carp qw(cluck carp);
use vars qw($RSPEC_0_1 $RSPEC_0_2 $RSPEC_2
use vars qw($RSPEC_0_1 $RSPEC_0_2 $RSPEC_2 $RSPEC_3
$RSPEC_0_1_NS $RSPEC_0_2_NS $RSPEC_2_NS
$EMULAB_NS $XSI_NS $STITCH_NS
$REQUEST_URL $MANIFEST_URL);
$RSPEC_0_1 = "0.1";
$RSPEC_0_2 = "0.2";
$RSPEC_2 = "2";
$RSPEC_3 = "3";
our $RSPEC_0_1_NS = "http://www.protogeni.net/resources/rspec/0.1";
our $RSPEC_0_2_NS = "http://www.protogeni.net/resources/rspec/0.2";
our $RSPEC_2_NS = "http://www.protogeni.net/resources/rspec/2";
our $RSPEC_3_NS = "http://www.geni.net/resources/rspec/3";
our $EMULAB_NS = "http://www.protogeni.net/resources/rspec/ext/emulab/1";
our $XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
our $STITCH_NS = "http://hpn.east.isi.edu/rspec/ext/stitch/0.1/";
......@@ -101,6 +103,8 @@ sub GetXmlVersion($)
$result = $RSPEC_0_2;
} elsif ($ns =~ /protogeni.net\/resources\/rspec\/2$/) {
$result = $RSPEC_2;
} elsif ($ns =~ /geni.net\/resources\/rspec\/3$/) {
$result = $RSPEC_3;
} else {
carp("Unknown rspec namespace: " . $ns);
$result = $RSPEC_0_1;
......
......@@ -27,6 +27,7 @@ $NO_GENI = "0";
$V_0_1 = "0.1";
$V_0_2 = "0.2";
$V_2 = "2";
$V_3 = "3";
$emulabns = "http://www.protogeni.net/resources/rspec/ext/emulab/1";
# XXX: This needs to be changed
......@@ -571,7 +572,8 @@ usage()
|| ($genimode ne $NO_GENI
&& $genimode ne $V_0_1
&& $genimode ne $V_0_2
&& $genimode ne $V_2));
&& $genimode ne $V_2
&& $genimode ne $V_3));
if (defined($pid) && ! defined($options{"Z"})) {
my $group = Group->Lookup($pid, $pid);
......@@ -2041,9 +2043,12 @@ sub print_header {
} elsif ($genimode eq $V_2) {
$ns = "http://www.protogeni.net/resources/rspec/2";
$url = "http://www.protogeni.net/resources/rspec/2/ad.xsd";
} elsif ($genimode eq $V_3) {
$ns = "http://www.geni.net/resources/rspec/3";
$url = "http://www.geni.net/resources/rspec/3/ad.xsd";
}
print "xmlns=\"$ns\" ";
if ($genimode eq $V_2) {
if ($genimode eq $V_2 || $genimode eq $V_3) {
print "xmlns:emulab=\"$emulabns\" ";
print "xsi:schemaLocation=\"$ns $url $emulabns $emulaburl ";
if (defined($MAINSITE) && $MAINSITE) {
......@@ -2059,7 +2064,7 @@ sub print_header {
printf("generated=\"%04d-%02d-%02dT%02d:%02d:%02dZ\" ",
$times[5] + 1900, $times[4] + 1, $times[3],
$times[2], $times[1], $times[0]);
if ($genimode eq $V_2) {
if ($genimode eq $V_2 || $genimode eq $V_3) {
print "expires=";
} else {
print "valid_until=";
......@@ -2079,7 +2084,7 @@ sub print_footer {
if ($do_xml && $genimode eq $NO_GENI) {
print "</ptop>\n";
} elsif ($do_xml && $genimode ne $NO_GENI) {
if ($genimode eq $V_2) {
if ($genimode eq $V_2 || $genimode eq $V_3) {
print_type_limits();
if (defined($MAINSITE) && $MAINSITE) {
print $stitchxml;
......@@ -2150,17 +2155,17 @@ sub print_node
print "<node ";
if ($genimode eq $V_0_1 || $genimode eq $V_0_2) {
print "component_manager_uuid=\"$cmurn\" ";
} elsif ($genimode eq $V_2) {
} elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print "component_manager_id=\"$cmurn\" ";
}
print "component_name=\"$name\" ";
my $urn = GeniHRN::Generate($OURDOMAIN, "node", $name);
if ($genimode eq $V_0_1 || $genimode eq $V_0_2) {
print " component_uuid=\"$urn\" ";
} elsif ($genimode eq $V_2) {
} elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print " component_id=\"$urn\" ";
}
if ($genimode eq $V_2) {
if ($genimode eq $V_2 || $genimode eq $V_3) {
print " exclusive=\"$exclusive\" ";
}
print ">\n";
......@@ -2177,7 +2182,7 @@ sub print_node
if ($genimode eq $V_0_1 || $genimode eq $V_0_2)
{
print " <available>$avail</available>\n";
} elsif ($genimode eq $V_2)
} elsif ($genimode eq $V_2 || $genimode eq $V_3)
{
print " <available now=\"$avail\" />\n";
}
......@@ -2252,7 +2257,7 @@ sub print_type_limits
print "set-type-limit $typeclass $count\n";
}
else {
if ($genimode eq $V_2) {
if ($genimode eq $V_2 || $genimode eq $V_3) {
print "<emulab:set_type_limit ";
print "typeclass=\"$typeclass\" ";
print "count=\"$count\"";
......@@ -2288,7 +2293,7 @@ sub print_node_types
print "static=\"true\"\n";
}
print " />\n";
} elsif ($genimode eq $V_2) {
} elsif ($genimode eq $V_2 || $genimode eq $V_3) {
if ($name eq "pc") {
print " <sliver_type name=\"raw-pc\">\n";
if (defined($mainType)) {
......@@ -2335,7 +2340,7 @@ sub print_node_features
$flags .= " global_operator=\"OnceOnly\" ";
$name = substr($name, 2);
}
if ($genimode eq $V_2) {
if ($genimode eq $V_2 || $genimode eq $V_3) {
print " <emulab:fd name=\"$name\" weight=\"$value\" ";
if ($flags ne "") {
print $flags;
......@@ -2363,7 +2368,7 @@ sub print_node_flags
if ($genimode eq $NO_GENI) {
print " <trivial_bandwidth>$value</trivial_bandwidth>\n";
}
elsif ($genimode eq $V_2) {
elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print " <emulab:trivial_bandwidth value=\"$value\" />\n";
}
}
......@@ -2371,7 +2376,7 @@ sub print_node_flags
if ($genimode eq $NO_GENI) {
print " <subnode_of>$value</subnode_of>\n";
}
elsif ($genimode eq $V_2) {
elsif ($genimode eq $V_2 || $genimode eq $V_3) {
$value = GeniHRN::Generate($OURDOMAIN, "node", $value);
print " <relation type=\"subnode_of\" ";
print "component_id=\"$value\" />\n";
......@@ -2381,7 +2386,7 @@ sub print_node_flags
if ($genimode eq $NO_GENI) {
print " <unique/>\n";
}
elsif ($genimode eq $V_2) {
elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print " <emulab:unique />\n";
}
}
......@@ -2389,7 +2394,7 @@ sub print_node_flags
if ($genimode eq $NO_GENI) {
print " <disallow_trivial_mix/>\n";
}
elsif ($genimode eq $V_2) {
elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print " <emulab:disallow_trivial_mix /> \n";
}
}
......@@ -2466,7 +2471,7 @@ sub print_node_interfaces
print "public_ipv4=\"$ip\" ";
}
print ">\n";
if ($genimode eq $V_2)
if ($genimode eq $V_2 || $genimode eq $V_3)
{
print " <emulab:interface name=\"$name\"/>\n";
}
......@@ -2523,11 +2528,11 @@ sub print_named_link_xml
my $urn = GeniHRN::Generate($OURDOMAIN, "link", $name);
if ($genimode eq $V_0_1 || $genimode eq $V_0_2) {
print "component_uuid=\"$urn\" ";
} elsif ($genimode eq $V_2) {
} elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print "component_id=\"$urn\" ";
}
print ">\n";
if ($genimode eq $V_2) {
if ($genimode eq $V_2 || $genimode eq $V_3) {
print "<component_manager name=\"$cmurn\" />\n";
}
print_interface($source, $source_if);
......@@ -2546,7 +2551,7 @@ sub print_named_link_xml
print " <bandwidth>$bw</bandwidth>\n";
print " <latency>$delay</latency>\n";
print " <packet_loss>$loss</packet_loss>\n";
} elsif ($genimode eq $V_2) {
} elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print_property($source, $source_if, $dest, $dest_if,
$bw, $delay, $loss);
print_property($dest, $dest_if, $source, $source_if,
......@@ -2559,7 +2564,7 @@ sub print_named_link_xml
. "</type_name></link_type>\n";
} elsif ($genimode eq $V_0_1 || $genimode eq $V_0_2) {
print " <link_type type_name=\"" . $proto[$i] . "\" />\n";
} elsif ($genimode eq $V_2) {
} elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print " <link_type name=\"" . $proto[$i] . "\" />\n";
}
}
......@@ -2577,7 +2582,7 @@ sub print_interface
if ($genimode eq $V_0_1 || $genimode eq $V_0_2) {
print "component_node_uuid=\"$nodeUrn\" ";
print "component_interface_id=\"" . $interfaceUrn . "\"";
} elsif ($genimode eq $V_2) {
} elsif ($genimode eq $V_2 || $genimode eq $V_3) {
print "component_id=\"$interfaceUrn\"";
}
print "/>\n";
......
......@@ -98,6 +98,8 @@ sub processArgs()
$print_ns = $GeniXML::RSPEC_0_2_NS;
} elsif ($mode eq "2") {
$print_ns = $GeniXML::RSPEC_2_NS;
} elsif ($mode eq "3") {
$print_ns = $GeniXML::RSPEC_3_NS;
} else {
usage();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment