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
c167fa49
Commit
c167fa49
authored
Aug 27, 2012
by
Leigh B Stoller
Browse files
Remove adminonly restriction from def_parentosid slot.
Add metadata_url and imagefile_url.
parent
fdd08bb4
Changes
1
Show whitespace changes
Inline
Side-by-side
backend/newimageid_ez.in
View file @
c167fa49
...
...
@@ -9,20 +9,22 @@ use strict;
use
Getopt::
Std
;
use
XML::
Simple
;
use
Data::
Dumper
;
use
URI::
Escape
;
#
# Back-end script to create new Image descriptors (EZ Form.)
#
sub
usage
()
{
print
("
Usage: newimageid [-v] [-a] <xmlfile>
\n
");
print
("
Usage: newimageid [-v] [-a]
[-s]
<xmlfile>
\n
");
exit
(
-
1
);
}
my
$optlist
=
"
dvfa
";
my
$optlist
=
"
dvfa
s
";
my
$debug
=
0
;
my
$force
=
0
;
my
$verify
=
0
;
# Check data and return status only.
my
$allpc
=
0
;
# insert mappings for all pc types.
my
$skipadmin
=
0
;
# Skip SLOT_ADMINONLY checks.
#
# Configure variables
...
...
@@ -81,6 +83,9 @@ if (defined($options{"f"})) {
if
(
defined
(
$options
{"
v
"}))
{
$verify
=
1
;
}
if
(
defined
(
$options
{"
s
"}))
{
$skipadmin
=
1
;
}
if
(
defined
(
$options
{"
a
"}))
{
$allpc
=
1
;
}
...
...
@@ -164,10 +169,12 @@ my %xmlfields =
"
shared
",
=>
["
shared
",
$SLOT_OPTIONAL
,
0
],
"
global
",
=>
["
global
",
$SLOT_ADMINONLY
,
0
],
"
mbr_version
",
=>
["
mbr_version
",
$SLOT_OPTIONAL
],
"
metadata_url
",
=>
["
metadata_url
",
$SLOT_ADMINONLY
],
"
imagefile_url
",
=>
["
imagefile_url
",
$SLOT_ADMINONLY
],
"
reboot_waittime
",
=>
["
reboot_waittime
",
$SLOT_ADMINONLY
],
"
hash
",
=>
["
hash
",
$SLOT_ADMINONLY
],
"
nextosid
",
=>
["
nextosid
",
$SLOT_ADMINONLY
],
"
def_parentosid
",
=>
["
def_parentosid
",
$SLOT_
ADMINONLY
],
"
def_parentosid
",
=>
["
def_parentosid
",
$SLOT_
OPTIONAL
],
);
#
...
...
@@ -278,7 +285,7 @@ foreach $key (keys(%{ $xmlparse->{'attribute'} })) {
$value
=
$default
;
}
}
if
(
$required
&
$SLOT_ADMINONLY
)
{
if
(
$required
&
$SLOT_ADMINONLY
&&
!
$skipadmin
)
{
# Admin implies optional, but thats probably not correct approach.
$errors
{
$key
}
=
"
Administrators only
"
if
(
!
$this_user
->
IsAdmin
());
...
...
@@ -379,10 +386,8 @@ my $isadmin = $this_user->IsAdmin();
my
$imagename
=
$newimageid_args
{"
imagename
"};
my
$OS
=
$newimageid_args
{"
OS
"};
# In this form, we make the images:imagename and the os_info:osname the same!
# Currently, TB_OSID_OSNAMELEN is shorter than TB_IMAGEID_IMAGENAMELEN
# and that causes problems since we use the same id for both tables. For
# now, test for the shorter of the two.
# In this form, we make the images:imagename and the os_info:osname the
# same.
if
(
length
(
$imagename
)
>
TB_OSID_OSNAMELEN
())
{
UserError
("
Descriptor Name: Too long!
"
.
"
Must be less than or equal to
"
.
TB_OSID_OSNAMELEN
());
...
...
@@ -415,7 +420,7 @@ if ($group &&
# Only admin types can set the global bit for an image. Ignore silently.
#
my
$global
=
0
;
if
(
$isadmin
&&
if
(
(
$isadmin
||
$skipadmin
)
&&
exists
(
$newimageid_args
{"
global
"})
&&
$newimageid_args
{"
global
"}
eq
"
1
")
{
$global
=
1
;
...
...
@@ -433,6 +438,15 @@ if ($global && $shared) {
UserError
("
Global: Image declared both shared and global
");
}
if
(
exists
(
$newimageid_args
{"
metadata_url
"}))
{
$newimageid_args
{"
metadata_url
"}
=
uri_unescape
(
$newimageid_args
{"
metadata_url
"})
}
if
(
exists
(
$newimageid_args
{"
imagefile_url
"}))
{
$newimageid_args
{"
imagefile_url
"}
=
uri_unescape
(
$newimageid_args
{"
imagefile_url
"})
}
# Nextosid check. Must exist. admin check done above.
if
(
exists
(
$newimageid_args
{"
nextosid
"}))
{
my
$nextos
=
OSinfo
->
Lookup
(
$newimageid_args
{"
nextosid
"});
...
...
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