Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
2991790f
Commit
2991790f
authored
Oct 26, 2009
by
Leigh B. Stoller
Browse files
Add lookup by urn (where the urn holds the internal index number).
Also add a GetManifest method to avoid code duplication.
parent
d57800c6
Changes
1
Hide whitespace changes
Inline
Side-by-side
protogeni/lib/GeniAggregate.pm.in
View file @
2991790f
...
...
@@ -29,6 +29,9 @@ use Data::Dumper;
use
English
;
use
overload
(
'""'
=>
'Stringify'
);
use
XML
::
Simple
;
use
POSIX
qw
(
strftime
);
use
Time
::
Local
;
use
Date
::
Parse
;
#
Configure
variables
my
$
TB
=
"@prefix@"
;
...
...
@@ -56,7 +59,14 @@ sub Lookup($$)
my
$
query_result
;
my
$
idx
;
if
($
token
=~
/^\
d
+$/)
{
if
(
GeniHRN
::
IsValid
($
token
))
{
return
undef
if
!GeniHRN::Authoritative($token, "@OURDOMAIN@");
my
($
authority
,
$
type
,
$
id
)
=
GeniHRN
::
Parse
($
token
);
return
undef
if
$
type
ne
"sliver"
;
$
idx
=
$
id
;
}
elsif
($
token
=~
/^\
d
+$/)
{
$
idx
=
$
token
;
}
elsif
($
token
=~
/^\
w
+\-\
w
+\-\
w
+\-\
w
+\-\
w
+$/)
{
...
...
@@ -514,6 +524,54 @@ sub NewCredential($$)
return
$
credential
;
}
#
#
Get
the
manifest
for
an
aggregate
.
Returns
the
XML
string
.
#
sub
GetManifest
($)
{
my
($
self
)
=
@
_
;
return
undef
if
(
! ref($self));
my
$
slice
=
$
self
->
GetSlice
();
return
undef
if
(
!defined($slice));
my
$
slice_uuid
=
$
slice
->
uuid
();
my
$
query_result
=
DBQueryWarn
(
"select manifest from geni_manifests "
.
"where slice_uuid='$slice_uuid'"
);
if
(
!$query_result || !$query_result->numrows) {
print
STDERR
"GetManifest: Could not locate manifest for $self
\n
"
;
return
undef
;
}
my
($
xml
)
=
$
query_result
->
fetchrow_array
();
my
$
manifest
=
eval
{
XMLin
($
xml
,
KeyAttr
=>
[],
ForceArray
=>
[
"node"
,
"link"
,
"interface"
,
"interface_ref"
,
"linkendpoints"
])
};
if
($@)
{
print
STDERR
"XMLin error reading manifest: $@
\n
"
;
return
undef
;
}
#
#
Update
the
manifest
ticket
to
reflect
the
current
expiration
time
.
#
$
manifest
->{
'valid_until'
}
=
POSIX
::
strftime
(
"20%y-%m-%dT%H:%M:%S"
,
gmtime
(
str2time
($
slice
->
expires
())));
$
xml
=
eval
{
XMLout
($
manifest
,
"NoAttr"
=>
1
,
RootName
=>
"manifest"
)
};
if
($@)
{
print
STDERR
"XMLout error on manifest: $@
\n
"
;
return
undef
;
}
return
$
xml
;
}
#
#
Process
the
manifest
.
Just
hand
off
to
the
slivers
.
#
...
...
Write
Preview
Supports
Markdown
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