Commit 3723bbac authored by Jonathon Duerig's avatar Jonathon Duerig

Bugfix: tunnels, virtualization_types, bandwidth, vlantags for rspecv2

parent 195d87c8
......@@ -1474,8 +1474,8 @@ sub Create($$$$$$)
my $iface2ref = $interfaces[1];
# These are the ips of the tunnel.
my $ip1 = GeniXML::GetText("tunnel_ip", $iface1ref);
my $ip2 = GeniXML::GetText("tunnel_ip", $iface2ref);
my $ip1 = GeniXML::GetIp($iface1ref, $node1rspec);
my $ip2 = GeniXML::GetIp($iface2ref, $node2rspec);
my $virtid1 = GeniXML::GetInterfaceNodeId($iface1ref);
my $virtid2 = GeniXML::GetInterfaceNodeId($iface2ref);
my $ctrlip1;
......
......@@ -872,7 +872,7 @@ sub GetTicketAuxAux($$$$$$$$$)
goto bad;
}
$exclusive = 1;
if (! GeniXML::SetVirtualizationType($ref, "raw")) {
if (! GeniXML::SetVirtualizationSubtype($ref, "raw")) {
$response = GeniResponse->Create(GENIRESPONSE_BADARGS,
undef,
"Malformed rspec: Cannot set virtualization_type to raw");
......@@ -1318,8 +1318,9 @@ sub GetTicketAuxAux($$$$$$$$$)
my $member = "$node_nickname:$iface_vport";
my $bandwidth = 100000;
# TODO: Allow asymmetric bandwidths
# Let user override.
my $user_bandwidth = GeniXML::GetText("bandwidth", $linkref);
my $user_bandwidth = GeniXML::GetBandwidth($linkref);
if (defined($user_bandwidth)) {
$bandwidth = $user_bandwidth;
}
......@@ -2530,10 +2531,25 @@ sub SliverWorkAux($$$$$$$)
$iface1ref);
my $node2_id = GeniXML::GetText("virtual_node_id",
$iface2ref);
my $node1sliver = $nodemap{$node1_id};
my $node2sliver = $nodemap{$node2_id};
my $node1rspec = $rspecmap{$node1_id};
my $node2rspec = $rspecmap{$node2_id};
if (! GeniXML::IsVersion0($linkref)) {
my $iface1_id = GeniXML::GetInterfaceId($iface1ref);
$node1_id = $iface2node{$iface1_id}
if (defined($iface1_id));
my $iface2_id = GeniXML::GetInterfaceId($iface2ref);
$node2_id = $iface2node{$iface2_id}
if (defined($iface2_id));
}
my $node1sliver;
my $node2sliver;
my $node1rspec;
my $node2rspec;
if (defined($node1_id) && defined($node2_id)) {
$node1sliver = $nodemap{$node1_id};
$node2sliver = $nodemap{$node2_id};
$node1rspec = $rspecmap{$node1_id};
$node2rspec = $rspecmap{$node2_id};
}
if (! (defined($node1sliver) || (defined($node2sliver)))) {
$message = "$linkname: No local nodes for tunnel";
......
......@@ -940,7 +940,7 @@ sub ProcessManifest($$)
my $sliver_urn = GeniXML::GetSliverId($ref);
if (defined($sliver_urn) && $sliver_urn eq $self->sliver_urn()) {
# startup command.
my $startupcmd = GeniXML::GetText("startup_command", $ref);
my $startupcmd = GeniXML::GetStartupCommand($ref);
if (defined($startupcmd)) {
if (! TBcheck_dbslot($startupcmd, "virt_nodes",
"startupcmd",
......
......@@ -13,10 +13,10 @@ use vars qw(@ISA @EXPORT);
@ISA = "Exporter";
@EXPORT = qw(Parse ParseFile IsVersion0 FindNodes FindNodesNS
FindFirst FindElement FindAttr GetNodeByVirtualId GetLinkByVirtualId
IsLanNode IsLocalNode IsTunnel GetExpires
IsLanNode IsLocalNode IsTunnel GetExpires GetBandwidth GetIp
GetNodeId GetVirtualId GetInterfaceId GetInterfaceNodeId GetSliverId
GetManagerId GetColocate GetSubnodeOf GetStartupCommand GetTarball
GetVirtualizationType SetVirtualizationType GetVirtualizationSubtype
GetVirtualizationType SetVirtualizationSubtype GetVirtualizationSubtype
GetExclusive SetExclusive GetLinkManager SetText GetText Serialize
CreateDocument AddElement RemoveChild PolicyExists);
......@@ -300,6 +300,42 @@ sub SetExpires($$)
}
}
sub GetBandwidth($)
{
my ($link) = @_;
my $result = undef;
if (IsVersion0($link)) {
$result = GeniXML::GetText("bandwidth", $link);
} else {
my $prop = FindFirst("n:property", $link);
$result = GeniXML::GetText("capacity", $prop);
}
return $result;
}
sub GetIp($$)
{
my ($ifaceref, $node) = @_;
my $result = undef;
if (IsVersion0($ifaceref)) {
$result = GetText("tunnel_ip", $ifaceref);
} else {
my $id = GetInterfaceId($ifaceref);
my @ifaces = FindNodes("n:interface", $node)->get_nodelist();
foreach my $iface (@ifaces) {
my $testid = GetInterfaceId($iface);
if (defined($id) && defined($testid) && $testid eq $id) {
my $ip = FindFirst("n:ip", $iface);
if (defined($ip)) {
$result = GetText("address", $ip);
}
last;
}
}
}
return $result;
}
# Returns the uuid or urn of an RSpec node or undef if it is not a node.
sub GetNodeId($)
{
......@@ -426,12 +462,18 @@ sub GetVirtualizationType($)
return $result;
}
sub SetVirtualizationType($$)
sub SetVirtualizationSubtype($$)
{
my ($node, $arg) = @_;
my $result = 1;
if (IsVersion0($node)) {
$result = SetText("virtualization_type", $node, $arg);
$result = SetText("virtualization_subtype", $node, $arg);
} else {
my $type = FindFirst("n:sliver_type", $node);
if (! defined($type)) {
$type = AddElement("sliver_type", $node);
}
SetText("name", $type, $arg);
}
return $result;
}
......
......@@ -14,7 +14,9 @@ NodeContents &=
attribute sliver_id { text }
LinkContents &=
attribute sliver_id { text }
attribute sliver_id { text } &
# vlan tag number used for stitching
attribute vlantag { text }
InterfaceContents &=
attribute mac_address { text } ?
......
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