Commit f018d5a9 authored by Jonathon Duerig's avatar Jonathon Duerig

Added proper IP/Mac address annotation for manifest in rspec v2.

parent 0bf9af4d
......@@ -2322,6 +2322,7 @@ sub SliverWorkAux($$$$$$$)
my %slivers = ();
my @plabnodes = ();
my %ifacemap = ();
my %ifacexml = ();
my %rspecmap = ();
foreach my $ref (GeniXML::FindNodes("n:node", $rspec)->get_nodelist()) {
my $resource_id = GeniXML::GetNodeId($ref);
......@@ -2417,7 +2418,17 @@ sub SliverWorkAux($$$$$$$)
# And store into the new manifest.
my $oldnode = GeniXML::GetNodeByVirtualId($virtual_id, $manifest);
GeniXML::ReplaceNode($oldnode, $ref);
my $newnode = GeniXML::ReplaceNode($oldnode, $ref);
# If using rspec v2, save the interface xml node for later
# annotation when iterating through links.
if (! GeniXML::IsVersion0($newnode)) {
foreach my $linkref (GeniXML::FindNodes("n:interface",
$newnode)->get_nodelist()) {
my $virtual_iface_id = GeniXML::GetInterfaceId($linkref);
$ifacexml{$virtual_iface_id} = $linkref;
}
}
}
#
......@@ -2675,28 +2686,41 @@ sub SliverWorkAux($$$$$$$)
"$iface_name in $linkname";
goto bad;
}
my $outref;
my $sliverName = "sliver_urn";
my $macName = "MAC";
my $ipAddress;
if (defined($vinterface)) {
$ipAddress = $vinterface->IP();
} else {
$ipAddress = $interface->IP();
}
# Manifest goes back to the user.
if (GeniXML::IsVersion0($ifaceref)) {
GeniXML::SetText("sliver_urn", $ifaceref,
$sliver->sliver_urn());
GeniXML::SetText("MAC", $ifaceref, $interface->mac())
if (defined($interface));
$outref = $ifaceref;
GeniXML::SetText("VMAC", $ifaceref, $vinterface->mac())
if (defined($vinterface));
if (defined($vinterface)) {
GeniXML::SetText("IP", $ifaceref, $vinterface->IP())
if (defined($vinterface->IP())
&& $vinterface->IP() ne "");
if (defined($ipAddress) && $ipAddress ne "") {
GeniXML::SetText("IP", $outref, $ipAddress);
}
else {
GeniXML::SetText("IP", $ifaceref, $interface->IP())
if (defined($interface) &&
defined($interface->IP())
&& $interface->IP() ne "");
} elsif (exists($ifacexml{$iface_id})) {
$outref = $ifacexml{$iface_id};
$sliverName = "sliver_id";
$macName = "mac_address";
if (defined($ipAddress) && $ipAddress ne "") {
my $child = GeniXML::AddElement("ip", $outref);
GeniXML::SetText("address", $child, $ipAddress);
GeniXML::SetText("type", $child, "ipv4");
}
} else {
GeniXML::SetText("sliver_id", $ifaceref,
GeniXML::SetText($sliverName, $ifaceref,
$sliver->sliver_urn());
}
if (defined($outref)) {
GeniXML::SetText($sliverName, $outref,
$sliver->sliver_urn());
GeniXML::SetText($macName, $outref, $interface->mac())
if (defined($interface));
}
if ($sliver->SetAggregate($linkaggregate) != 0) {
......
......@@ -564,6 +564,7 @@ sub ReplaceNode($$)
my ($oldnode, $newnode) = @_;
my $copy = $newnode->cloneNode(1);
$oldnode->replaceNode($copy);
return $copy;
}
# checks for the existense of policy in extensions of the given
......
......@@ -72,7 +72,11 @@ InterfaceContents &=
attribute component_id { text } &
attribute component_name { text }? &
element monitoring { MonitoringContents }? &
attribute role { "control" | "experimental" | "mixed" }? &
# role should usually be one of:
# 'control' (interface used to communicate with CM and/or the world)
# 'experimental' (interface used to communicate within the topology
# 'mixed' (interface used for both of the above
attribute role { text }? &
attribute public_ipv4 { text }?
MonitoringContents &=
......@@ -101,12 +105,15 @@ ServiceContents &=
InstallServiceContents &=
AnyExtension &
# Type(s) of archives supported
attribute file_type { "tar.gz" | "tar.bz2" }
# file_type should usually be one of 'tar.gz' or 'tar.bz2' for tarballs
attribute file_type { text }
ExecuteServiceContents &=
AnyExtension &
# Shell environment allowed
attribute shell { "sh" }
# Should usually be 'sh' to indicate a generic unix shell
# environment for the script.
attribute shell { text }
TypeRelationContents &=
AnyExtension &
......
......@@ -68,7 +68,9 @@ ServiceContents &=
LoginServiceContents &=
AnyExtension &
# Authentication mechanism
attribute authentication { "ssh-keys" } &
# 'ssh-keys' is used to denote an ssh connection accessed via the
# ssh keys passed to CreateSliver or RedeemTicket.
attribute authentication { text } &
# Access mechanism
attribute hostname { text }? &
attribute port { text }?
......@@ -86,7 +88,16 @@ LocationContents =
attribute longitude { text }? &
attribute latitude { text }?
InterfaceContents = AnyExtension
InterfaceContents =
AnyExtension &
element ip { IpContents }*
IpContents =
AnyExtention &
attribute address { text } &
attribute netmask { text }? &
# type should usually be 'ipv4' or 'ipv6'. If absent, defaults to ipv4.
attribute type { text }? &
LinkContents =
AnyExtension &
......
......@@ -96,7 +96,3 @@ InterfaceMapping = element interface_ref {
}
start = RSpec
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