Commit 580fe797 authored by Jonathon Duerig's avatar Jonathon Duerig

ptopgen now emits 'role="control"' on each control interface definition. The...

ptopgen now emits 'role="control"' on each control interface definition. The rspec now validates against it.
parent ab537952
......@@ -187,10 +187,16 @@ sub Resolve($)
else {
$node= LookupNode($hrn);
}
if (!defined($node)) {
if (! defined($node)) {
return GeniResponse->Create(GENIRESPONSE_SEARCHFAILED,
undef, "Nothing here by that name");
}
my $rspec = GetAdvertisement(0, $node->node_id());
if (! defined($rspec)) {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Could not start avail");
}
# Return a blob.
my $blob = { "hrn" => "${PGENIDOMAIN}." . $node->node_id(),
......@@ -201,47 +207,10 @@ sub Resolve($)
Interface->LookupControl( $node->phys_nodeid() )->IP(),
"urn" => GeniHRN::Generate( $OURDOMAIN,
"node",
$node->node_id() )
$node->node_id() ),
"rspec" => $rspec
};
#
# Get the list of interfaces for the node.
#
my @interfaces;
if ($node->AllInterfaces(\@interfaces) != 0) {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Could not get interfaces for $uuid");
}
my @iblobs = ();
foreach my $interface (@interfaces) {
next
if (!defined($interface->switch_id()));
my $urn = GeniHRN::GenerateInterface( $OURDOMAIN, $node->node_id(),
$interface->iface() );
my $iblob = { "uuid" => $interface->uuid(),
"iface" => $interface->iface(),
"type" => $interface->type(),
"card" => $interface->card(),
"port" => $interface->port(),
"role" => $interface->role(),
"IP" => $interface->IP() || "",
"mask" => $interface->mask() || "",
"MAC" => $interface->mac(),
"switch_id" => "${OURDOMAIN}." .
$interface->switch_id(),
"switch_card" => $interface->switch_card(),
"switch_port" => $interface->switch_port(),
"wire_type" => $interface->wire_type(),
"urn" => $urn
};
push(@iblobs, $iblob);
}
$blob->{'interfaces'} = \@iblobs
if (@iblobs);
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $blob);
}
return GeniResponse->Create(GENIRESPONSE_UNSUPPORTED);
......@@ -293,19 +262,13 @@ sub DiscoverResources($)
}
#
# Use ptopgen in xml mode to spit back an xml file.
# Acquire the advertisement from ptopgen and compress it if requested.
#
my $invocation = "$PTOPGEN -x -g -r -p GeniSlices";
$invocation .= " -a" unless $available;
if (! open(AVAIL, "$invocation |")) {
my $xml = GetAdvertisement($available, undef);
if (! defined($xml)) {
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Could not start avail");
}
my $xml = "";
while (<AVAIL>) {
$xml .= $_;
}
close(AVAIL);
if( $compress ) {
my $coder = Frontier::RPC2->new();
......@@ -316,6 +279,29 @@ sub DiscoverResources($)
return GeniResponse->Create(GENIRESPONSE_SUCCESS, $xml);
}
#
# Use ptopgen in xml mode to spit back an xml file.
#
sub GetAdvertisement($$)
{
my ($available, $pc) = @_;
my $xml = undef;
my $invocation = "$PTOPGEN -x -g -r -p GeniSlices";
$invocation .= " -a" unless $available;
if (defined($pc)) {
$invocation .= " -1 $pc";
}
if (open(AVAIL, "$invocation |")) {
my $xml = "";
while (<AVAIL>) {
$xml .= $_;
}
close(AVAIL);
}
return $xml;
}
#
# Update a ticket with a new rspec.
#
......
......@@ -48,7 +48,8 @@ NodeTypeList = NodeTypeSpec+
NodeTypeContents &= TypeField*
LinkType = element link_type {
attribute name { text } &
attribute name { text }? &
attribute type_name { text }? &
TypeField*
}
......
......@@ -115,7 +115,8 @@
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="rspec:field"/>
</xs:sequence>
<xs:attribute name="name" use="required"/>
<xs:attribute name="name"/>
<xs:attribute name="type_name"/>
</xs:complexType>
</xs:element>
</xs:sequence>
......@@ -146,6 +147,13 @@
<xs:element minOccurs="0" ref="rspec:monitoring"/>
</xs:sequence>
<xs:attributeGroup ref="rspec:ComponentInterfaceDeclName"/>
<xs:attribute name="role">
<xs:simpleType>
<xs:restriction base="xs:token">
<xs:enumeration value="control"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:element name="monitoring">
<xs:complexType>
......
......@@ -44,7 +44,8 @@ LinkContents &=
InterfaceDecl &=
ComponentInterfaceDeclName &
element monitoring { attribute user_traffic { text }? }?
element monitoring { attribute user_traffic { text }? }? &
attribute role { "control" }?
InterfaceRef &=
ComponentInterfaceRefName
......
......@@ -114,7 +114,8 @@
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="rspec:field"/>
</xs:sequence>
<xs:attribute name="name" use="required"/>
<xs:attribute name="name"/>
<xs:attribute name="type_name"/>
</xs:complexType>
</xs:element>
</xs:sequence>
......
......@@ -196,19 +196,24 @@ usage()
print_header();
my %nodetointerface;
my %interfaceroles = ();
my %interfacetypes = ();
# Read interfaces
my $result =
DBQueryFatal("SELECT node_id,card,port,iface,interface_type" .
DBQueryFatal("SELECT node_id,card,port,iface,interface_type,role" .
" from interfaces " .
($genimode ? "where role!='gw'" : ""));
while (($node,$card,$port,$iface,$type) = $result->fetchrow_array) {
while (($node,$card,$port,$iface,$type, $role) = $result->fetchrow_array) {
push @{ $nodetointerface{"$node"} }, $iface;
$interfacemap{"$node:$card:$port"} = $iface;
if ((defined $type) && ($type ne "")) {
$interfacetypes{"$node:$card:$port"} = $type;
}
if ((defined $role) && ($role ne "")) {
$interfaceroles{"$node:$iface"} = $role;
}
}
my %nodetouuid;
......@@ -1591,7 +1596,16 @@ sub print_node_interfaces
for (; $i < scalar(@interfaces); ++$i) {
my $name = $interfaces[$i];
my $urn = GeniHRN::GenerateInterface($OURDOMAIN, $nodeName, $name);
print " <interface component_id=\"$urn\"/>\n";
print " <interface component_id=\"$urn\" ";
if (exists($interfaceroles{"$nodeName:$name"}))
{
my $role = $interfaceroles{"$nodeName:$name"};
if ($role eq "ctrl")
{
print "role=\"control\" ";
}
}
print "/>\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