Commit 49028d95 authored by Leigh Stoller's avatar Leigh Stoller

Fix up cooked mode to handle SFA nodes, now that PLC is handling urns

properly. Now able to allocate and redeem tickets at PLC via cooked
mode.
parent a43f84af
......@@ -2414,23 +2414,18 @@ sub ConvertAdSFAtoPG($$)
my $siteid = GeniXML::GetText("id", $site);
foreach my $node (GeniXML::FindNodes("node",
$site)->get_nodelist()) {
# Dumb; plc uses the hostname in the URN.
# plc uses the qualified hostname in the URN.
my $hostname = GeniXML::GetText("hostname", $node);
my ($hname) = ($hostname =~ /^([^.]*)\./);
my $nodeid = GeniXML::GetText("id", $node);
my $urn = GeniHRN::Generate("$netid:$siteid",
"node", $hname);
# Dumb; the name to urn scheme for plc causes duplicates.
next
if (exists($names{$urn}));
$names{$urn} = 1;
my $id = GeniXML::GetText("id", $node);
my $urn = GeniXML::GetText("urn", $node);
my $name = GeniXML::GetText("name", $site);
my $rspecnode = addChildToRspec($doc, $root, 'node');
$rspecnode->setAttribute('component_manager_urn', $manager_urn);
$rspecnode->setAttribute('component_manager_uuid', $manager_urn);
$rspecnode->setAttribute('component_manager_uuid',$manager_urn);
$rspecnode->setAttribute('component_uuid', $urn);
$rspecnode->setAttribute('component_urn', $urn);
$rspecnode->setAttribute('component_name', "$nodeid:$hostname");
$rspecnode->setAttribute('component_name', "$id:$name");
my $tmp = addChildToRspec($doc, $rspecnode, 'node_type');
$tmp->setAttribute("type_name", "pc");
$tmp->setAttribute("type_slots", "1");
......@@ -2465,7 +2460,7 @@ sub ConvertReqPGtoSFA($$)
my $network;
my $request;
if (0) {
if (1) {
$network = addChildToRspec($doc, $root, 'network');
$network->setAttribute("name", "plc");
}
......@@ -2477,24 +2472,31 @@ sub ConvertReqPGtoSFA($$)
foreach my $ref (GeniXML::FindNodes("n:node",
$rspec)->get_nodelist()) {
my $urn = GeniXML::GetText("component_urn", $ref);
my $name = GeniXML::GetText("component_name", $ref);
my ($auth,$which,$hname) = GeniHRN::Parse($urn);
my $comname= GeniXML::GetText("component_name", $ref);
my ($auth,$which,$hostname) = GeniHRN::Parse($urn);
my ($netid,$siteid) = split(":", $auth);
my ($nodeid,$hostname) = split(":", $name);
my ($id,$name) = split(":", $comname);
if (0) {
if (1) {
my $sitenode = addChildToRspec($doc, $network, 'site');
$sitenode->setAttribute("id", $siteid);
my $namenode = addChildToRspec($doc, $sitenode, 'name');
$namenode->appendText("$name");
my $nodenode = addChildToRspec($doc, $sitenode, 'node');
$nodenode->setAttribute("id", $nodeid);
$nodenode->setAttribute("id", $id);
my $tmp = addChildToRspec($doc, $nodenode, 'hostname');
$tmp->appendText("$hostname");
$tmp = addChildToRspec($doc, $nodenode, 'urn');
$tmp->appendText("$urn");
addChildToRspec($doc, $nodenode, 'sliver');
}
else {
my $sliver = addChildToRspec($doc, $request, 'sliver');
$sliver->setAttribute("nodeid", $nodeid);
$sliver->setAttribute("nodeid", $id);
}
}
return $root;
......
......@@ -257,25 +257,46 @@ sub CreatePhysNode($$)
return undef
if (!defined($blob));
my $hrn = $blob->{'hrn'};
my $IP = $blob->{'physctrl'};
my $hostname = $blob->{'hostname'};
if (! (defined($hrn) && defined($hostname))) {
if (! defined($hostname)) {
print STDERR "Missing stuff in blob from CM for $node_urn\n";
goto bad;
}
if (! ($hrn =~ /^[-\w\.]*$/)) {
print STDERR "Invalid hrn '$hrn' in blob from CM for $node_urn\n";
goto bad;
}
if (! ($hostname =~ /^[-\w\.]*$/)) {
print STDERR
"Invalid hostname '$hostname' in blob from CM for $node_urn\n";
goto bad;
}
$node_id = $hrn;
if ($authority->IsSFA()) {
#
# Generate a suitable node_id.
#
my $site = $blob->{'site'};
if (! defined($site)) {
print STDERR "Missing site in blob from CM for $node_urn\n";
goto bad;
}
if (! ($site =~ /^[-\w\.]*$/)) {
print STDERR "Invalid site '$site' in blob from CM for $node_urn\n";
goto bad;
}
my @tmp = split(/\./, $hostname);
$node_id = $site . "-" . $tmp[0];
}
else {
my $hrn = $blob->{'hrn'};
if (! defined($hrn)) {
print STDERR "Missing hrn in blob from CM for $node_urn\n";
goto bad;
}
if (! ($hrn =~ /^[-\w\.]*$/)) {
print STDERR "Invalid hrn '$hrn' in blob from CM for $node_urn\n";
goto bad;
}
$node_id = $hrn;
}
$node_id =~ s/\./\-/g;
if (length($node_id) > 32) {
print STDERR "Nodeid '$node_id' too long for $node_urn\n";
goto bad;
......@@ -285,12 +306,6 @@ sub CreatePhysNode($$)
# Find control network.
#
if ($authority->IsSFA()) {
#
# Generate a suitable node_id.
#
my ($pl) = ($blob->{'hrn'} =~ /^([^.]*)\./);
$node_id = "$pl" . "-" . $blob->{'node_id'};
#
# Find the IP from the hostname and generate a stub iface entry.
#
......
......@@ -3642,7 +3642,7 @@ sub MapResources($)
$self->printdb("Mapping geni resources ...\n");
if (libGeni::MapResources($self->experiment(),
if (libGeni::MapResourcesNew($self->experiment(),
$self->user(), $self->rspec(),
\$genirspec, $self->verbose())) {
tberror("Could not map Geni resources\n");
......
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