Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
32ffef8d
Commit
32ffef8d
authored
Mar 13, 2015
by
Jonathon Duerig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add allocated addresses to the manifest when creating a pool.
parent
e12934a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
11 deletions
+73
-11
db/Experiment.pm.in
db/Experiment.pm.in
+24
-1
protogeni/lib/GeniCM.pm.in
protogeni/lib/GeniCM.pm.in
+46
-9
protogeni/lib/GeniXML.pm.in
protogeni/lib/GeniXML.pm.in
+3
-1
No files found.
db/Experiment.pm.in
View file @
32ffef8d
...
...
@@ -181,7 +181,8 @@ $EXPT_RESOURCESHOSED = 0;
"virt_client_service_hooks"
,
"virt_client_service_opts"
,
"virt_blockstores"
,
"virt_blockstore_attributes"
);
"virt_blockstore_attributes"
,
"virt_address_allocation"
);
%
physicalTables
=
(
"delays"
=>
[
"node_id"
,
"vname"
,
"vnode0"
,
"vnode1"
],
"v2pmap"
=>
[
"node_id"
,
"vname"
],
...
...
@@ -6360,5 +6361,27 @@ sub LookupBlockstore($$)
return $blockstore;
}
sub LookupAddressPools($$)
{
my ($self, $pool_id_arg) = @_;
my $result = [];
my $virtexp = $self->GetVirtExperiment();
my $eid = DBQuoteSpecial($self->eid());
my $pid = DBQuoteSpecial($self->pid());
my $pool_id = DBQuoteSpecial($pool_id_arg);
my $dbresult =
DBQueryWarn("select IP, mask ".
"from virt_node_public_addr ".
"where eid=$eid and ".
"pid=$pid and ".
"pool_id=$pool_id");
while (my ($ip, $mask) = $dbresult->fetchrow_array()) {
push(@{ $result },
{ "ip" => $ip, "netmask" => $mask });
}
return $result;
}
# _Always_ make sure that this 1 is at the end of the file...
1;
protogeni/lib/GeniCM.pm.in
View file @
32ffef8d
...
...
@@ -755,16 +755,20 @@ sub GetTicketAuxAux($$$$$$$$$$)
#
my $address_pools = GeniXML::GetAddressPools($rspec);
foreach my $pool (@{ $address_pools }) {
if ($pool->{'
type
'} ne "any") {
$response = GeniResponse->Create(GENIRESPONSE_ERROR, undef, "Only public address pools of type any are supported");
goto bad;
if (! defined($pool->{'
cmurn
'}) ||
$pool->{'
cmurn
'} eq $ENV{'
MYURN
'})
{
if ($pool->{'
type
'} ne "any") {
$response = GeniResponse->Create(GENIRESPONSE_ERROR, undef, "Only public address pools of type any are supported");
goto bad;
}
print STDERR '
DEBUG
:
Adding
row
to
virt_address_allocation
';
$virtexperiment->NewTableRow("virt_address_allocation",
{"pool_id" => $pool->{'
client_id
'},
"count" => $pool->{'
count
'},
"restriction" => $pool->{'
type
'},
"version" => "ipv4" });
}
print STDERR '
DEBUG
:
Adding
row
to
virt_address_allocation
';
$virtexperiment->NewTableRow("virt_address_allocation",
{"pool_id" => $pool->{'
client_id
'},
"count" => $pool->{'
count
'},
"restriction" => $pool->{'
type
'},
"version" => "ipv4" });
}
#
...
...
@@ -4195,6 +4199,8 @@ sub SliverWorkAux($$$$$$$$)
GeniXML
::
SetText
(
"latitude"
,
$
location
,
$
default_latitude
);
GeniXML
::
SetText
(
"longitude"
,
$
location
,
$
default_longitude
);
}
AnnotateAddressPools
($
manifest
,
$
experiment
);
#
#
Record
all
manifests
(
including
updates
)
in
the
history
.
...
...
@@ -7159,5 +7165,36 @@ sub HandleBlockstore($$$$$$@)
return
GeniResponse
->
Create
($
errorcode
,
undef
,
$
message
);
}
sub
AnnotateAddressPools
($$)
{
my
($
manifest
,
$
experiment
)
=
@
_
;
my
@
address_pools
=
GeniXML
::
FindNodesNS
(
'n:routable_pool'
,
$
manifest
,
$
GeniXML
::
EMULAB_NS
)->
get_nodelist
();
foreach
my
$
pool
(@
address_pools
)
{
#
Ignore
pools
from
other
CMs
my
$
cmurn
=
GetText
(
"component_manager_id"
,
$
pool
);
if
(
! defined($cmurn) ||
$
cmurn
eq
$
ENV
{
'MYURN'
})
{
#
Clear
out
any
address
that
might
have
been
there
#
before
.
Mostly
so
we
don
't do something dumb if they
# re-submit a manifest.
my @old_addresses = GeniXML::FindNodesNS('
n
:
ipv4
', $pool, $GeniXML::EMULAB_NS)->get_nodelist();
foreach my $old_address (@old_addresses) {
$pool->removeChild($old_address);
};
# Bind to this AM
GeniXML::SetText("component_manager_id",
$pool, $ENV{'
MYURN
'});
# Fill actual address assignment for all pools
my $pool_id = GetText("client_id", $pool);
my $addressList = $experiment->LookupAddressPools($pool_id);
foreach my $address (@{ $addressList }) {
my $newnode = GeniXML::AddElement('
ipv4
', $pool);
GeniXML::SetText("address", $newnode, $address->{"ip"});
GeniXML::SetText("netmask", $newnode, $address->{"netmask"});
}
}
}
}
# _Always_ make sure that this 1 is at the end of the file...
1;
protogeni/lib/GeniXML.pm.in
View file @
32ffef8d
...
...
@@ -997,11 +997,13 @@ sub GetAddressPools($)
my
$
client_id
=
GetText
(
"client_id"
,
$
pool
);
my
$
count
=
GetText
(
"count"
,
$
pool
);
my
$
type
=
GetText
(
"type"
,
$
pool
);
my
$
cmurn
=
GetText
(
"component_manager_id"
,
$
pool
);
push
(@{
$
result
},
{
"client_id"
=>
$
client_id
,
"count"
=>
$
count
,
"type"
=>
$
type
"type"
=>
$
type
,
"cmurn"
=>
$
cmurn
});
}
return
$
result
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment