Skip to content
GitLab
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
ad26f8d3
Commit
ad26f8d3
authored
Apr 09, 2010
by
Leigh B Stoller
Browse files
Minor tweaks to allow these scripts to be used during the install
process, to add the base descriptors.
parent
93bc37fe
Changes
3
Hide whitespace changes
Inline
Side-by-side
backend/newimageid.in
View file @
ad26f8d3
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2008 University of Utah and the Flux Group.
# Copyright (c) 2000-2008
, 2010
University of Utah and the Flux Group.
# All rights reserved.
#
use
English
;
...
...
@@ -18,8 +18,9 @@ sub usage()
print
("
Usage: newimageid [-v] <xmlfile>
\n
");
exit
(
-
1
);
}
my
$optlist
=
"
dv
";
my
$optlist
=
"
dv
f
";
my
$debug
=
0
;
my
$force
=
0
;
my
$verify
=
0
;
# Check data and return status only.
#
...
...
@@ -68,6 +69,9 @@ if (! getopts($optlist, \%options)) {
if
(
defined
(
$options
{"
d
"}))
{
$debug
=
1
;
}
if
(
defined
(
$options
{"
f
"}))
{
$force
=
1
;
}
if
(
defined
(
$options
{"
v
"}))
{
$verify
=
1
;
}
...
...
@@ -266,11 +270,32 @@ foreach $key (keys(%{ $xmlparse->{'attribute'} })) {
if
(
!
$this_user
->
IsAdmin
());
}
# Now check that the value is legal.
if
(
!
TBcheck_dbslot
(
$value
,
"
images
",
$dbslot
,
TBDB_CHECKDBSLOT_ERROR
))
{
$errors
{
$key
}
=
TBFieldErrorString
();
next
;
#
# Special case osids so they can be in pid,osname format.
#
if
((
$dbslot
eq
"
default_osid
"
||
$dbslot
=~
/^part\d/
)
&&
$value
=~
/^.+,.+$/
)
{
my
(
$pid
,
$osname
)
=
(
$value
=~
/^(.*),(.*)$/
);
# Now check that the value is legal.
if
(
!
TBcheck_dbslot
(
$pid
,
"
projects
",
"
pid
",
TBDB_CHECKDBSLOT_ERROR
))
{
$errors
{
$key
}
=
TBFieldErrorString
();
next
;
}
if
(
!
TBcheck_dbslot
(
$osname
,
"
os_info
",
"
osname
",
TBDB_CHECKDBSLOT_ERROR
))
{
$errors
{
$key
}
=
TBFieldErrorString
();
next
;
}
}
else
{
# Now check that the value is legal.
if
(
!
TBcheck_dbslot
(
$value
,
"
images
",
$dbslot
,
TBDB_CHECKDBSLOT_ERROR
))
{
$errors
{
$key
}
=
TBFieldErrorString
();
next
;
}
}
$newimageid_args
{
$key
}
=
$value
;
...
...
@@ -460,7 +485,7 @@ foreach $key (@mtype_keys) {
}
}
UserError
("
Node Types: Must select at least one node type
")
if
(
$node_types_selected
==
0
);
if
(
$node_types_selected
==
0
&&
!
$force
);
#
# Check sanity of node name and that user can create an image from it.
...
...
backend/newimageid_ez.in
View file @
ad26f8d3
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-200
8
University of Utah and the Flux Group.
# Copyright (c) 2000-20
1
0 University of Utah and the Flux Group.
# All rights reserved.
#
use
English
;
...
...
@@ -18,8 +18,9 @@ sub usage()
print
("
Usage: newimageid [-v] <xmlfile>
\n
");
exit
(
-
1
);
}
my
$optlist
=
"
dv
";
my
$optlist
=
"
dv
f
";
my
$debug
=
0
;
my
$force
=
0
;
my
$verify
=
0
;
# Check data and return status only.
#
...
...
@@ -68,6 +69,9 @@ if (! getopts($optlist, \%options)) {
if
(
defined
(
$options
{"
d
"}))
{
$debug
=
1
;
}
if
(
defined
(
$options
{"
f
"}))
{
$force
=
1
;
}
if
(
defined
(
$options
{"
v
"}))
{
$verify
=
1
;
}
...
...
@@ -487,7 +491,7 @@ foreach $key (@mtype_keys) {
}
}
UserError
("
Node Types: Must select at least one node type
")
if
(
$node_types_selected
==
0
);
if
(
$node_types_selected
==
0
&&
!
$force
);
#
# We perform a further check for non-admins. When a node to snapshot
...
...
backend/newosid.in
View file @
ad26f8d3
#!/usr/bin/perl -wT
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-200
7
University of Utah and the Flux Group.
# Copyright (c) 2000-20
1
0 University of Utah and the Flux Group.
# All rights reserved.
#
use
English
;
...
...
@@ -132,7 +132,7 @@ my %xmlfields =
# XML Field Name DB slot name Flags Default
("
description
"
=>
["
description
",
$SLOT_REQUIRED
],
"
osname
"
=>
["
osname
"
,
$SLOT_REQUIRED
],
"
p
roject
"
=>
["
pid
_idx
",
$SLOT_REQUIRED
],
"
p
id
"
=>
["
pid
",
$SLOT_REQUIRED
],
"
OS
"
=>
["
OS
",
$SLOT_REQUIRED
],
"
version
"
=>
["
version
",
$SLOT_OPTIONAL
,
""],
"
path
"
=>
["
path
",
$SLOT_OPTIONAL
,
"
NULL
"],
...
...
@@ -257,12 +257,32 @@ foreach $key (keys(%{ $xmlparse->{'attribute'} })) {
$errors
{
$key
}
=
"
Administrators only
"
if
(
!
$this_user
->
IsAdmin
());
}
#
# Special case nextosid so it can be in pid,osname format.
#
if
(
$dbslot
eq
"
nextosid
"
&&
$value
=~
/^.+,.+$/
)
{
my
(
$pid
,
$osname
)
=
(
$value
=~
/^(.*),(.*)$/
);
# Now check that the value is legal.
if
(
!
TBcheck_dbslot
(
$value
,
"
os_info
",
$dbslot
,
TBDB_CHECKDBSLOT_ERROR
))
{
$errors
{
$key
}
=
TBFieldErrorString
();
next
;
# Now check that the value is legal.
if
(
!
TBcheck_dbslot
(
$pid
,
"
projects
",
"
pid
",
TBDB_CHECKDBSLOT_ERROR
))
{
$errors
{
$key
}
=
TBFieldErrorString
();
next
;
}
if
(
!
TBcheck_dbslot
(
$osname
,
"
os_info
",
"
osname
",
TBDB_CHECKDBSLOT_ERROR
))
{
$errors
{
$key
}
=
TBFieldErrorString
();
next
;
}
}
else
{
# Now check that the value is legal.
if
(
!
TBcheck_dbslot
(
$value
,
"
os_info
",
$dbslot
,
TBDB_CHECKDBSLOT_ERROR
))
{
$errors
{
$key
}
=
TBFieldErrorString
();
next
;
}
}
$newosid_args
{
$key
}
=
$value
;
...
...
@@ -273,9 +293,9 @@ UserError()
#
# Now do special checks.
#
my
$project
=
Project
->
Lookup
(
$newosid_args
{"
p
roject
"});
my
$project
=
Project
->
Lookup
(
$newosid_args
{"
p
id
"});
if
(
!
defined
(
$project
))
{
UserError
("
Project: No such project
(
$project
)
");
UserError
("
Project: No such project
");
}
if
(
!
$project
->
AccessCheck
(
$this_user
,
TB_PROJECT_MAKEOSID
()))
{
UserError
("
Project: Not enough permission
");
...
...
@@ -297,6 +317,8 @@ if (exists($newosid_args{"nextosid"})) {
if
(
!
defined
(
$nextos
))
{
UserError
("
Nextosid: Does not exist
");
}
# Might be in pid,osname format.
$newosid_args
{"
nextosid
"}
=
$nextos
->
osid
();
}
# Mere users have to supply a version, but admin people do not.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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