Commit e3742570 authored by Jonathon Duerig's avatar Jonathon Duerig

Added support for a vnode name field in RSpecv2 Emulab extension.

URNs in component_ids should now always refer to the physical node rather than the virtual container.
parent 24174a51
......@@ -216,6 +216,12 @@ sub node_id($)
return checknodeid($self->{"DBROW"}->{'node_id'}, "node_id method");
}
sub phys_nodeid($)
{
my $self = shift;
return $self->{"DBROW"}->{'phys_nodeid'};
}
#
# Stringify for output.
#
......
......@@ -713,7 +713,8 @@ sub GetTicketAuxAux($$$$$$$$$)
my $node_nickname = GeniXML::GetVirtualId($ref);
my $colocate = GeniXML::GetColocate($ref);
my $component_id = GeniXML::GetNodeId($ref);
my $node = GeniUtil::LookupNode($component_id);
my $vnode_id = GeniXML::GetVnodeId($ref);
my $node = GeniUtil::LookupNode($vnode_id);
if (!defined($node)) {
$response = GeniResponse->Create(GENIRESPONSE_BADARGS, undef,
"Bad resource $component_id in ticket");
......@@ -744,6 +745,7 @@ sub GetTicketAuxAux($$$$$$$$$)
foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) {
my $component_id = GeniXML::GetNodeId($ref);
my $vnode_id = GeniXML::GetVnodeId($ref);
my $manager_id = GeniXML::GetManagerId($ref);
my $node_nickname = GeniXML::GetVirtualId($ref);
my $colocate = GeniXML::GetColocate($ref);
......@@ -939,7 +941,7 @@ sub GetTicketAuxAux($$$$$$$$$)
}
}
else {
$node = GeniUtil::LookupNode($component_id);
$node = GeniUtil::LookupNode($vnode_id);
if (!defined($node)) {
$response =
......@@ -1512,6 +1514,7 @@ sub GetTicketAuxAux($$$$$$$$$)
$solution)->get_nodelist()) {
my $virtual_id = GeniXML::GetVirtualId($ref);
my $component_id = GeniXML::GetNodeId($ref);
my $vnode_id = GeniXML::GetVnodeId($ref);
if (!(exists($nodemap{$virtual_id}) ||
exists($external_nodemap{$virtual_id}))) {
$response =
......@@ -1528,7 +1531,7 @@ sub GetTicketAuxAux($$$$$$$$$)
my $rspec = $nodemap{$virtual_id}->{'rspec'};
my $virtnode = $nodemap{$virtual_id}->{'virtnode'};
my $node = GeniUtil::LookupNode($component_id);
my $node = GeniUtil::LookupNode($vnode_id);
my $colocate = GeniXML::GetColocate($rspec);
my $subnode_of = GeniXML::GetSubnodeOf($rspec);
......@@ -1551,10 +1554,17 @@ sub GetTicketAuxAux($$$$$$$$$)
GeniXML::SetText("component_manager_urn", $rspec, $ENV{'MYURN'});
GeniXML::SetText("component_manager_uuid", $rspec, $ENV{'MYUUID'});
} else {
GeniXML::SetText("component_id", $rspec,
GeniHRN::Generate( $OURDOMAIN, "node",
$node->node_id() ));
GeniXML::SetText("component_id", $rspec,
GeniHRN::Generate( $OURDOMAIN, "node",
$node->phys_nodeid() ));
GeniXML::SetText("component_manager_id", $rspec, $ENV{'MYURN'});
my $vnoderef = GeniXML::FindNodesNS("n:vnode", $rspec,
$GeniXML::EMULAB_NS)->pop();
if (! defined($vnoderef)) {
$vnoderef = GeniXML::AddElement("vnode", $rspec,
$GeniXML::EMULAB_NS);
}
GeniXML::SetText("name", $vnoderef, $node->node_id());
}
GeniXML::SetExclusive($rspec, $exclusive);
......
......@@ -13,7 +13,7 @@ use vars qw(@ISA @EXPORT);
@ISA = "Exporter";
@EXPORT = qw(Parse ParseFile IsVersion0 FindNodes FindNodesNS
FindFirst FindElement FindAttr GetNodeByVirtualId GetLinkByVirtualId
IsLanNode IsLocalNode IsTunnel GetExpires GetBandwidth GetIp
IsLanNode IsLocalNode IsTunnel GetExpires GetBandwidth GetIp GetVnodeId
GetNodeId GetVirtualId GetInterfaceId GetInterfaceNodeId GetSliverId
GetManagerId GetColocate GetSubnodeOf GetStartupCommand GetTarball
GetVirtualizationType SetVirtualizationSubtype GetVirtualizationSubtype
......@@ -28,11 +28,13 @@ 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 $EMULAB_NS);
$RSPEC_0_1 = "0.1";
$RSPEC_0_2 = "0.2";
$RSPEC_2 = "2";
$EMULAB_NS = "http://www.protogeni.net/resources/rspec/ext/emulab/1";
# Configure variables
my $TB = "@prefix@";
my $TBOPS = "@TBOPSEMAIL@";
......@@ -338,6 +340,26 @@ sub GetIp($$)
return $result;
}
# Returns the vnode id in the emulab extension or failing that the component_id
sub GetVnodeId($)
{
my ($node) = @_;
my $result = undef;
if (IsVersion0($node)) {
$result = GetNodeId($node);
} else {
my $vnoderef = GeniXML::FindNodesNS("vnode", $node,
$EMULAB_NS)->pop();
if (defined($vnoderef)) {
$result = GetText("name", $vnoderef);
}
if (! defined($result)) {
$result = GetNodeId($node);
}
}
return $result;
}
# Returns the uuid or urn of an RSpec node or undef if it is not a node.
sub GetNodeId($)
{
......@@ -635,10 +657,13 @@ sub CreateDocument($$)
# Add a new element to a node. The new element will have the given
# name and be otherwise empty.
sub AddElement($$)
sub AddElement($$;$)
{
my ($name, $node) = @_;
my $ns = $node->namespaceURI();
my ($name, $node, $namespace) = @_;
my $ns = $namespace;
if (! defined($namespace)) {
$ns = $node->namespaceURI();
}
my $child = $node->addNewChild($ns, "rs:$name");
return $child;
}
......
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