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
105f431a
Commit
105f431a
authored
Jun 07, 2017
by
Leigh B Stoller
Browse files
Add some unfinished code to handle finding the correct project for
an image.
parent
a3d10a00
Changes
2
Hide whitespace changes
Inline
Side-by-side
apt/ns2genilib.in
View file @
105f431a
#!/usr/bin/perl -w
#
# Copyright (c) 2000-201
6
University of Utah and the Flux Group.
# Copyright (c) 2000-201
7
University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
...
...
@@ -137,15 +137,15 @@ else {
my
$this_user
=
User
->
ThisUser
();
if
(
!
defined
(
$this_user
))
{
F
atal
("
You (
$UID
) do not exist!
");
f
atal
("
You (
$UID
) do not exist!
");
}
if
(
defined
(
$pid
))
{
my
$project
=
Project
->
Lookup
(
$pid
);
if
(
!
defined
(
$project
))
{
F
atal
("
No such project
");
f
atal
("
No such project
");
}
if
(
!
(
$this_user
->
IsAdmin
()
||
defined
(
$project
->
LookupUser
(
$this_user
))))
{
F
atal
("
No a member of project
$pid
");
f
atal
("
No
t
a member of project
$pid
");
}
}
...
...
@@ -247,7 +247,9 @@ if ($debug) {
# The next thing is to feed the IR output of the NS parser into
# our geni-lib converter which produces the rspec.
#
open
ERR
,
"
$NSGENILIB
$irfile
2>&1 >
$xmlfile
|
";
my
$opts
=
(
$anonmode
?
""
:
"
-p
$pid
");
open
ERR
,
"
$NSGENILIB
$opts
$irfile
2>&1 >
$xmlfile
|
";
$errs
=
"";
while
(
<
ERR
>
)
{
...
...
apt/nsgenilib.py.in
View file @
105f431a
...
...
@@ -36,6 +36,12 @@ import HTMLParser
TB
=
"@prefix@"
;
OURDOMAIN
=
"@OURDOMAIN@"
;
TBPATH
=
os
.
path
.
join
(
TB
,
"lib"
)
if
TBPATH
not
in
sys
.
path
:
sys
.
path
.
append
(
TBPATH
)
pass
import
libdb
# Testbed specific stuff
if
False
:
sys
.
path
.
append
(
TB
+
"/opsdir/lib/geni-lib"
)
...
...
@@ -70,11 +76,34 @@ def Usage():
sys
.
exit
(
-
1
);
pass
#
# Helper function to find find osname.
#
def
LookupImage
(
osname
):
res
=
libdb
.
DBQueryFatal
(
"select i.imagename from images as i "
"where i.pid=%s and i.imagename=%s"
,
(
PID
,
osname
))
if
len
(
res
)
==
0
:
return
"emulab-ops"
+
"//"
+
osname
return
PID
+
"//"
+
osname
pass
if
len
(
sys
.
argv
)
<
2
:
Usage
();
pass
NSfile
=
sys
.
argv
[
1
];
#
# Check for PID flag.
#
if
len
(
sys
.
argv
)
>
2
and
sys
.
argv
[
1
]
==
"-p"
:
PID
=
sys
.
argv
[
2
]
NSfile
=
sys
.
argv
[
3
]
else
:
PID
=
None
NSfile
=
sys
.
argv
[
1
]
try
:
tree
=
etree
.
parse
(
NSfile
);
...
...
@@ -133,10 +162,14 @@ for child in tree.getroot():
if
element
.
tag
==
"osname"
and
element
.
text
:
#
# Convert NS project/osname to rspec project//osname.
#
But if no project, add emulab-ops (clearly wrong).
#
osname
=
element
.
text
if
osname
.
find
(
"/"
)
<
0
:
osname
=
"emulab-ops//"
+
osname
if
PID
==
None
:
osname
=
"emulab-ops//"
+
osname
else
:
osname
=
LookupImage
(
osname
);
pass
elif
osname
.
find
(
"//"
)
<
0
:
osname
=
osname
.
replace
(
"/"
,
"//"
);
pass
...
...
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