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
5fbcaba1
Commit
5fbcaba1
authored
May 30, 2018
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add utility functions to map URNs to local users and projects.
parent
35891d8f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
1 deletion
+41
-1
apt/APT_Utility.pm.in
apt/APT_Utility.pm.in
+41
-1
No files found.
apt/APT_Utility.pm.in
View file @
5fbcaba1
#
!/usr/bin/perl -wT
#
#
Copyright
(
c
)
2007
-
2016
University
of
Utah
and
the
Flux
Group
.
#
Copyright
(
c
)
2007
-
2016
,
2018
University
of
Utah
and
the
Flux
Group
.
#
#
{{{
EMULAB
-
LICENSE
#
...
...
@@ -42,11 +42,14 @@ use libtestbed;
use
APT_Instance
;
use
Project
;
use
Group
;
use
GeniHRN
;
use
GeniUser
;
#
Configure
variables
my
$
TB
=
"@prefix@"
;
my
$
MAINSITE
=
@
TBMAINSITE
@;
my
$
TBOPS
=
"@TBOPSEMAIL@"
;
my
$
OURDOMAIN
=
"@OURDOMAIN@"
;
#
#
Find
all
of
the
instances
a
user
has
(
should
have
)
an
account
on
,
and
...
...
@@ -86,3 +89,40 @@ sub UpdateInstancesByUser($)
}
return
0
;
}
#
#
Map
project
urn
to
local
project
.
Since
these
URNs
are
coming
from
#
remote
clusters
,
it
might
not
actually
refer
to
a
local
#
sub
MapProjectURN
($)
{
my
($
urn
)
=
@
_
;
my
$
hrn
=
GeniHRN
->
new
($
urn
);
if
(
!defined($hrn)) {
print
STDERR
"MapProjectURN: Could not parse $urn
\n
"
;
return
undef
;
}
if
($
hrn
->
domain
()
eq
$
OURDOMAIN
&&
defined
($
hrn
->
project
()))
{
my
$
project
=
Project
->
Lookup
($
hrn
->
project
());
return
$
project
if
(
defined
($
project
));
}
return
undef
;
}
#
#
Same
as
above
,
but
for
users
.
#
sub
MapUserURN
($)
{
my
($
urn
)
=
@
_
;
my
$
hrn
=
GeniHRN
->
new
($
urn
);
if
(
!defined($hrn)) {
print
STDERR
"MapUserURN: Could not parse $urn
\n
"
;
return
undef
;
}
my
$
geniuser
=
GeniUser
->
Lookup
($
urn
,
1
);
return
$
geniuser
if
(
defined
($
geniuser
)
&&
$
geniuser
->
IsLocal
());
return
undef
;
}
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