Commit 67c6f075 authored by Jonathon Duerig's avatar Jonathon Duerig

ptopgen now produces output which conforms to the rspec advertisement schema....

ptopgen now produces output which conforms to the rspec advertisement schema. It produces URNs rather than UUIDs.
parent b063f05a
...@@ -15,15 +15,15 @@ WWW=www.emulab.net/dev/duerig ...@@ -15,15 +15,15 @@ WWW=www.emulab.net/dev/duerig
THISHOMEBASE=Duerig.Emulab.Net THISHOMEBASE=Duerig.Emulab.Net
# Turn off a bunch of stuff that Jon isn't actually going to need # Turn off a bunch of stuff that Jon isn't actually going to need
WINSUPPORT=0 #WINSUPPORT=0
WIKISUPPORT=0 #WIKISUPPORT=0
BUGDBSUPPORT=0 #BUGDBSUPPORT=0
MAILMANSUPPORT=0 #MAILMANSUPPORT=0
CVSSUPPORT=0 #CVSSUPPORT=0
CHATSUPPORT=0 #CHATSUPPORT=0
NFSTRACESUPPORT=0 #NFSTRACESUPPORT=0
ARCHIVESUPPORT=0 #ARCHIVESUPPORT=0
OPSDBSUPPORT=0 #OPSDBSUPPORT=0
SFSSUPPORT=0 #SFSSUPPORT=0
PELABSUPPORT=0 #PELABSUPPORT=0
PLABSUPPORT=0 #PLABSUPPORT=0
...@@ -32,7 +32,7 @@ NodeContents = ...@@ -32,7 +32,7 @@ NodeContents =
}* }*
LinkContents = LinkContents =
# Each link has exactly one virtualization technology, which we simply # Each link has exactly one virtualization technology, which we simply
# enumerate here # enumerate here
attribute virtualization_type { "raw" | "trellis-vserver" | attribute virtualization_type { "raw" | "trellis-vserver" |
"planetlab-vserver" | "emulab-vnode" }? & "planetlab-vserver" | "emulab-vnode" }? &
......
...@@ -13,6 +13,14 @@ use Math::BigInt; ...@@ -13,6 +13,14 @@ use Math::BigInt;
use lib "@prefix@/lib"; use lib "@prefix@/lib";
use libdb qw(TBGetSiteVar); use libdb qw(TBGetSiteVar);
my $PGENISUPPORT = @PROTOGENI_SUPPORT@;
if ($PGENISUPPORT) {
require GeniHRN;
}
use GeniHRN;
sub usage() sub usage()
{ {
print("Usage: ptopgen [-v] [-s switch] [-p pid [-e eid]] [-m factor] " . print("Usage: ptopgen [-v] [-s switch] [-p pid [-e eid]] [-m factor] " .
...@@ -47,7 +55,12 @@ my $do_xml = 0; ...@@ -47,7 +55,12 @@ my $do_xml = 0;
my $genimode = 0; my $genimode = 0;
my $useshared = 0; my $useshared = 0;
my $OURDOMAIN = "@OURDOMAIN@";
my $cmuuid = TBGetSiteVar('protogeni/cm_uuid'); my $cmuuid = TBGetSiteVar('protogeni/cm_uuid');
my $cmurn = "";
if ($PGENISUPPORT) {
$cmurn = GeniHRN::Generate($OURDOMAIN, "authority", "cm");
}
my $delaycap_override; my $delaycap_override;
...@@ -161,7 +174,7 @@ if (defined($options{"e"})) { ...@@ -161,7 +174,7 @@ if (defined($options{"e"})) {
} }
if (defined($options{"x"})) { if (defined($options{"x"})) {
$genimode = 1 $genimode = 1
if (defined($options{"g"})); if (defined($options{"g"}) && $PGENISUPPORT);
$do_xml = 1; $do_xml = 1;
} }
usage() usage()
...@@ -173,7 +186,7 @@ my %nodetointerface; ...@@ -173,7 +186,7 @@ my %nodetointerface;
# Read interfaces # Read interfaces
my $result = DBQueryFatal("SELECT node_id,card,port,iface,interface_type" . my $result = DBQueryFatal("SELECT node_id,card,port,iface,interface_type" .
" from interfaces"); " from interfaces;");
while (($node,$card,$port,$iface,$type) = $result->fetchrow_array) { while (($node,$card,$port,$iface,$type) = $result->fetchrow_array) {
push @{ $nodetointerface{"$node"} }, $iface; push @{ $nodetointerface{"$node"} }, $iface;
$interfacemap{"$node:$card:$port"} = $iface; $interfacemap{"$node:$card:$port"} = $iface;
...@@ -200,7 +213,10 @@ $result = DBQueryFatal("SELECT n.node_id, n.eventstate, n.role, n.uuid, " . ...@@ -200,7 +213,10 @@ $result = DBQueryFatal("SELECT n.node_id, n.eventstate, n.role, n.uuid, " .
"where nt.isvirtnode = 0 or nt.isvirtnode is null;"); "where nt.isvirtnode = 0 or nt.isvirtnode is null;");
while (($node,$eventstate, $role, $uuid, $reserved, $isremotenode, while (($node,$eventstate, $role, $uuid, $reserved, $isremotenode,
$wa_attrvalue, $sharing_mode) = $result->fetchrow_array) { $wa_attrvalue, $sharing_mode) = $result->fetchrow_array) {
$nodetouuid{$node} = $uuid; if (defined($uuid) && $uuid ne "")
{
$nodetouuid{$node} = $uuid;
}
my $islocal = $role eq 'testnode' my $islocal = $role eq 'testnode'
&& ((! defined($isremotenode) || $isremotenode == 0) && ((! defined($isremotenode) || $isremotenode == 0)
|| (defined($wa_attrvalue) && $wa_attrvalue == 1)); || (defined($wa_attrvalue) && $wa_attrvalue == 1));
...@@ -484,7 +500,6 @@ while (($node,$type,$physnode,$class,$issubnode,$def_boot_osid,$reserved, ...@@ -484,7 +500,6 @@ while (($node,$type,$physnode,$class,$issubnode,$def_boot_osid,$reserved,
$subnode_of{$node} = $physnode; $subnode_of{$node} = $physnode;
} }
$node_def_boot_osid{$node} = $def_boot_osid; $node_def_boot_osid{$node} = $def_boot_osid;
$node_uuids{$node} = $uuid;
if ($reserved) { if ($reserved) {
$is_reserved{$node} = 1; $is_reserved{$node} = 1;
...@@ -540,7 +555,7 @@ foreach $node (keys(%nodes)) { ...@@ -540,7 +555,7 @@ foreach $node (keys(%nodes)) {
my $cpu_speed = $typemap{$type}->{'SPEED'}; my $cpu_speed = $typemap{$type}->{'SPEED'};
my $ram = $typemap{$type}->{'RAM'}; my $ram = $typemap{$type}->{'RAM'};
my $trivspeed = $typemap{$type}->{'TRIVSPEED'}; my $trivspeed = $typemap{$type}->{'TRIVSPEED'};
my $uuid = $node_uuids{$node}; my $uuid = $nodetouuid{$node};
my @types = ("$type:1"); my @types = ("$type:1");
my @features; my @features;
...@@ -1129,10 +1144,9 @@ foreach $interconnect (keys(%interconnects)) { ...@@ -1129,10 +1144,9 @@ foreach $interconnect (keys(%interconnects)) {
# #
my @wireless_protos = ("80211", "80211a", "80211b", "80211g", "flex900"); my @wireless_protos = ("80211", "80211a", "80211b", "80211g", "flex900");
my $fake_switch = "airswitch"; my $fake_switch = "airswitch";
if (!$genimode) {
my @fake_switch_types = map("*$_:*", @wireless_protos); my @fake_switch_types = map("*$_:*", @wireless_protos);
print_node($fake_switch, \@fake_switch_types, [], [], undef, []); print_node($fake_switch, \@fake_switch_types, [], [], undef, []);
}
foreach my $interface (keys(%interfacetypes)) { foreach my $interface (keys(%interfacetypes)) {
my ($node,$card,$port) = split(":", $interface); my ($node,$card,$port) = split(":", $interface);
...@@ -1290,23 +1304,19 @@ sub print_node ...@@ -1290,23 +1304,19 @@ sub print_node
} elsif ($genimode) { } elsif ($genimode) {
# rspec format # rspec format
print "<node "; print "<node ";
print "component_manager_uuid=\"${cmuuid}\" "; print "component_manager_uuid=\"$cmurn\" ";
print "component_name=\"$name\" "; print "component_name=\"$name\" ";
if (defined($uuid)) { my $urn = GeniHRN::Generate($OURDOMAIN, "node", $name);
print " component_uuid=\"$uuid\" "; print " component_uuid=\"$urn\" ";
}
print ">\n"; print ">\n";
# TODO: Virtualization type # TODO: Virtualization type
print_node_types(@$types); print_node_types(@$types);
if ($nodetoavailable{$name}) if ($nodetoavailable{$name}) {
{ print " <available>true</available>\n";
print " <available>true</available>"; } else {
} print " <available>false</available>\n";
else
{
print " <available>false</available>";
} }
print_node_interfaces(@$interfaces); print_node_interfaces($name, @$interfaces);
print "</node>\n"; print "</node>\n";
} else { } else {
# ptop format # ptop format
...@@ -1398,10 +1408,13 @@ sub print_node_flags ...@@ -1398,10 +1408,13 @@ sub print_node_flags
sub print_node_interfaces sub print_node_interfaces
{ {
my $nodeName = shift(@_);
my @interfaces = @_;
my $i = 0; my $i = 0;
for (; $i < scalar(@_); ++$i) { for (; $i < scalar(@interfaces); ++$i) {
my $name = $_[$i]; my $name = $interfaces[$i];
print " <interface component_name=\"${name}\"/>\n"; my $urn = GeniHRN::GenerateInterface($OURDOMAIN, $nodeName, $name);
print " <interface component_name=\"$urn\"/>\n";
} }
} }
...@@ -1440,22 +1453,23 @@ sub print_named_link_xml ...@@ -1440,22 +1453,23 @@ sub print_named_link_xml
my $loss = shift(@_); my $loss = shift(@_);
my $proto_count = scalar(@_); my $proto_count = scalar(@_);
if ($genimode) { if ($genimode) {
print "<link>\n"; print "<link ";
print " <component_link ";
print "component_manager_uuid=\"${cmuuid}\" "; print "component_manager_uuid=\"${cmuuid}\" ";
print "component_name=\"$name\" "; print "component_name=\"$name\" ";
# TODO: link uuid my $urn = GeniHRN::Generate($OURDOMAIN, "link", $name);
print "component_uuid=\"00000\" "; print "component_uuid=\"$urn\" ";
print "/>\n"; print ">\n";
print_interface($source, $source_if);
print_interface($dest, $dest_if);
} else { } else {
print "<link name=\"$name\">\n"; print "<link name=\"$name\">\n";
print " <source_interface><interface>\n";
print_interface_contents($source, $source_if);
print " </interface></source_interface>\n";
print " <destination_interface><interface>\n";
print_interface_contents($dest, $dest_if);
print " </interface></destination_interface>\n";
} }
print " <source_interface><interface>\n";
print_interface_contents($source, $source_if);
print " </interface></source_interface>\n";
print " <destination_interface><interface>\n";
print_interface_contents($dest, $dest_if);
print " </interface></destination_interface>\n";
print " <bandwidth>$bw</bandwidth>\n"; print " <bandwidth>$bw</bandwidth>\n";
print " <latency>$delay</latency>\n"; print " <latency>$delay</latency>\n";
print " <packet_loss>$loss</packet_loss>\n"; print " <packet_loss>$loss</packet_loss>\n";
...@@ -1467,25 +1481,26 @@ sub print_named_link_xml ...@@ -1467,25 +1481,26 @@ sub print_named_link_xml
print "</link>\n\n"; print "</link>\n\n";
} }
sub print_interface_contents sub print_interface
{ {
my $node = shift(@_); my $node = shift(@_);
my $interface = shift(@_); my $interface = shift(@_);
if ($genimode) { print " <interface ";
print " <component_node_uuid>"; print "component_node_uuid=\"";
my $uuid = $nodetouuid{$node}; my $nodeUrn = GeniHRN::Generate($OURDOMAIN, "node", $node);
if (defined($uuid)) { print $nodeUrn;
print "$uuid"; my $interfaceUrn = GeniHRN::GenerateInterface($OURDOMAIN, $node,
} else { $interface);
print "0000"; print "\" component_interface_name=\"" . $interfaceUrn . "\"";
} print "/>\n";
print "</component_node_uuid>\n"; }
print " <component_interface_name>$interface</component_interface_name>\n";
} else {
print " <node_name>$node</node_name>\n";
print " <interface_name>$interface</interface_name>\n";
}
sub print_interface_contents
{
my $node = shift(@_);
my $interface = shift(@_);
print " <node_name>$node</node_name>\n";
print " <interface_name>$interface</interface_name>\n";
} }
# Print a link with a unique name not necessarily related to source, # Print a link with a unique name not necessarily related to source,
......
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