Commit 87352e99 authored by Jonathon Duerig's avatar Jonathon Duerig

Bugfixes. Interesting fact. "foo" eq undef throws a perl exception rather than returning false.

parent f8bfa5dd
......@@ -606,7 +606,8 @@ sub GetTicketAuxAux($$$$$$$$)
# This changes what tmcd returns to the local nodes.
#
my $generated_by = GeniXML::GetText("generated_by", $rspec);
if ($generated_by eq "libvtop") {
if (defined($generated_by) &&
$generated_by eq "libvtop") {
$slice_experiment->Update({"geniflags" =>
$Experiment::EXPT_GENIFLAGS_EXPT|
$Experiment::EXPT_GENIFLAGS_COOKED});
......@@ -915,7 +916,6 @@ sub GetTicketAuxAux($$$$$$$$)
foreach my $linkref (GeniXML::FindNodes("n:interface",
$ref)->get_nodelist()) {
my $component_id = GeniXML::GetText("component_id", $linkref);
my $virtual_id = GeniXML::GetText("virtual_id", $linkref);
if (!defined($virtual_id)) {
......@@ -951,7 +951,8 @@ sub GetTicketAuxAux($$$$$$$$)
foreach my $linkref (GeniXML::FindNodes("n:link",
$rspec)->get_nodelist()) {
my $lanname = GeniXML::GetVirtualId($linkref);
my $istunnel = (GeniXML::GetText("link_type", $linkref) eq "tunnel");
my $link_type = GeniXML::GetText("link_type", $linkref);
my $istunnel = (defined($link_type) && $link_type eq "tunnel");
my @interfaces = GeniXML::FindNodes("n:linkendpoints | ".
"n:interface_ref",
$linkref)->get_nodelist();
......@@ -1179,11 +1180,12 @@ sub GetTicketAuxAux($$$$$$$$)
$exclusive = 0
if (!defined($exclusive));
$rspec->{'component_urn'} = GeniHRN::Generate( $OURDOMAIN, "node",
$node->node_id() );
$rspec->{'component_uuid'} = $component_uuid;
$rspec->{'component_manager_urn'} = $ENV{'MYURN'};
$rspec->{'component_manager_uuid'} = $ENV{'MYUUID'};
GeniXML::SetText("component_urn", $rspec,
GeniHRN::Generate( $OURDOMAIN, "node",
$node->node_id() ));
GeniXML::SetText("component_uuid", $rspec, $component_uuid);
GeniXML::SetText("component_manager_urn", $rspec, $ENV{'MYURN'});
GeniXML::SetText("component_manager_uuid", $rspec, $ENV{'MYUUID'});
# Also update the virtexperiment table row.
# Do not update subnodes; they are fixed to the parent,
......
......@@ -358,12 +358,12 @@ sub GetTicket($$$$)
#
my $valid_until = GeniXML::GetText("valid_until", $rspec);
if (! defined($valid_until)) {
GeniXML::SetText("valid_until",
GeniXML::SetText("valid_until", $rspec,
POSIX::strftime("20%y-%m-%dT%H:%M:%S",
gmtime(time() + (3600*6))));
}
my $rspec_string = $rspec_nodes->toString();
my $rspec_string = $rspec->toString();
#
# Load the SA cert to act as caller context.
......
......@@ -629,7 +629,7 @@ sub Create($$$$$$)
}
}
my $nickname = GeniXML::GetVirtualId($rspec);
if (!defined($virtual_id_xml)) {
if (!defined($nickname)) {
print STDERR "Node does not contain a virtual_id\n";
return undef;
}
......@@ -720,6 +720,7 @@ sub Provision($;$)
my $virt_type = GeniXML::GetText("virtualization_type", $self->rspec());
if (!$node->isremotenode() &&
defined($virt_type) &&
$virt_type eq "emulab-vnode") {
my $pnode = Node->Lookup($node->phys_nodeid());
if (!defined($pnode)) {
......@@ -812,6 +813,7 @@ sub UnProvision($;$)
my $virt_type = GeniXML::GetText("virtualization_type",
$self->rspec());
if (!$node->isremotenode() &&
defined($virt_type) &&
$virt_type eq "emulab-vnode") {
my $pnode_id = $node->phys_nodeid();
my $pnode = Node->Lookup($pnode_id);
......@@ -908,7 +910,7 @@ sub ProcessManifest($$)
foreach my $ref (GeniXML::FindNodes("n:node",
$manifest)->get_nodelist()) {
my $sliver_id = GeniXML::GetText("sliver_uuid", $ref);
if ($sliver_id eq $uuid) {
if (defined($sliver_id) && $sliver_id eq $uuid) {
# startup command.
my $startupcmd = GeniXML::GetText("startup_command", $ref);
if (defined($startupcmd)) {
......
......@@ -73,8 +73,6 @@ sub FindNodes($$)
} else {
$path =~ s/\bn://g;
}
$path = $path . '[node()]';
print STDERR $path."\n";
$result = $xc->findnodes($path, $node);
};
if ($@) {
......@@ -192,14 +190,17 @@ sub SetText($$$)
{
my ($name, $node, $text) = @_;
my $result = 0;
my $child = FindFirst("@n:".$name, $node);
my $child = FindFirst('@n:'.$name, $node);
if (! defined($child)) {
$child = FindFirst('@'.$name, $node);
}
if (defined($child)) {
if ($child->nodeType() == XML_ATTRIBUTE_NODE) {
$child->setValue($text);
$result = 1;
}
} else {
$child = FindFirst("n:".$name, $node);
$child = FindFirst('n:'.$name, $node);
if (defined($child)) {
my @grand = $child->childNodes();
if (scalar(@grand) == 1
......@@ -223,11 +224,14 @@ sub GetText($$)
{
my ($name, $node) = @_;
my $result = undef;
my $child = FindFirst("@n:".$name, $node);
my $child = FindFirst('@n:'.$name, $node);
if (! defined($child)) {
$child = FindFirst('@'.$name, $node);
}
if (defined($child)) {
$result = $child->textContent();
} else {
$child = FindFirst("n:".$name, $node);
$child = FindFirst('n:'.$name, $node);
}
return $result;
}
......
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