Commit ad26f8d3 authored by Leigh B Stoller's avatar 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
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# EMULAB-COPYRIGHT # 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. # All rights reserved.
# #
use English; use English;
...@@ -18,8 +18,9 @@ sub usage() ...@@ -18,8 +18,9 @@ sub usage()
print("Usage: newimageid [-v] <xmlfile>\n"); print("Usage: newimageid [-v] <xmlfile>\n");
exit(-1); exit(-1);
} }
my $optlist = "dv"; my $optlist = "dvf";
my $debug = 0; my $debug = 0;
my $force = 0;
my $verify = 0; # Check data and return status only. my $verify = 0; # Check data and return status only.
# #
...@@ -68,6 +69,9 @@ if (! getopts($optlist, \%options)) { ...@@ -68,6 +69,9 @@ if (! getopts($optlist, \%options)) {
if (defined($options{"d"})) { if (defined($options{"d"})) {
$debug = 1; $debug = 1;
} }
if (defined($options{"f"})) {
$force = 1;
}
if (defined($options{"v"})) { if (defined($options{"v"})) {
$verify = 1; $verify = 1;
} }
...@@ -266,11 +270,32 @@ foreach $key (keys(%{ $xmlparse->{'attribute'} })) { ...@@ -266,11 +270,32 @@ foreach $key (keys(%{ $xmlparse->{'attribute'} })) {
if (! $this_user->IsAdmin()); if (! $this_user->IsAdmin());
} }
# Now check that the value is legal. #
if (! TBcheck_dbslot($value, "images", # Special case osids so they can be in pid,osname format.
$dbslot, TBDB_CHECKDBSLOT_ERROR)) { #
$errors{$key} = TBFieldErrorString(); if (($dbslot eq "default_osid" || $dbslot =~ /^part\d/) &&
next; $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; $newimageid_args{$key} = $value;
...@@ -460,7 +485,7 @@ foreach $key (@mtype_keys) { ...@@ -460,7 +485,7 @@ foreach $key (@mtype_keys) {
} }
} }
UserError("Node Types: Must select at least one node type") 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. # Check sanity of node name and that user can create an image from it.
......
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2008 University of Utah and the Flux Group. # Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
...@@ -18,8 +18,9 @@ sub usage() ...@@ -18,8 +18,9 @@ sub usage()
print("Usage: newimageid [-v] <xmlfile>\n"); print("Usage: newimageid [-v] <xmlfile>\n");
exit(-1); exit(-1);
} }
my $optlist = "dv"; my $optlist = "dvf";
my $debug = 0; my $debug = 0;
my $force = 0;
my $verify = 0; # Check data and return status only. my $verify = 0; # Check data and return status only.
# #
...@@ -68,6 +69,9 @@ if (! getopts($optlist, \%options)) { ...@@ -68,6 +69,9 @@ if (! getopts($optlist, \%options)) {
if (defined($options{"d"})) { if (defined($options{"d"})) {
$debug = 1; $debug = 1;
} }
if (defined($options{"f"})) {
$force = 1;
}
if (defined($options{"v"})) { if (defined($options{"v"})) {
$verify = 1; $verify = 1;
} }
...@@ -487,7 +491,7 @@ foreach $key (@mtype_keys) { ...@@ -487,7 +491,7 @@ foreach $key (@mtype_keys) {
} }
} }
UserError("Node Types: Must select at least one node type") 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 # We perform a further check for non-admins. When a node to snapshot
......
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2007 University of Utah and the Flux Group. # Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
...@@ -132,7 +132,7 @@ my %xmlfields = ...@@ -132,7 +132,7 @@ my %xmlfields =
# XML Field Name DB slot name Flags Default # XML Field Name DB slot name Flags Default
("description" => ["description", $SLOT_REQUIRED], ("description" => ["description", $SLOT_REQUIRED],
"osname" => ["osname" , $SLOT_REQUIRED], "osname" => ["osname" , $SLOT_REQUIRED],
"project" => ["pid_idx", $SLOT_REQUIRED], "pid" => ["pid", $SLOT_REQUIRED],
"OS" => ["OS", $SLOT_REQUIRED], "OS" => ["OS", $SLOT_REQUIRED],
"version" => ["version", $SLOT_OPTIONAL, ""], "version" => ["version", $SLOT_OPTIONAL, ""],
"path" => ["path", $SLOT_OPTIONAL, "NULL"], "path" => ["path", $SLOT_OPTIONAL, "NULL"],
...@@ -257,12 +257,32 @@ foreach $key (keys(%{ $xmlparse->{'attribute'} })) { ...@@ -257,12 +257,32 @@ foreach $key (keys(%{ $xmlparse->{'attribute'} })) {
$errors{$key} = "Administrators only" $errors{$key} = "Administrators only"
if (! $this_user->IsAdmin()); 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. # Now check that the value is legal.
if (! TBcheck_dbslot($value, "os_info", if (! TBcheck_dbslot($pid, "projects",
$dbslot, TBDB_CHECKDBSLOT_ERROR)) { "pid", TBDB_CHECKDBSLOT_ERROR)) {
$errors{$key} = TBFieldErrorString(); $errors{$key} = TBFieldErrorString();
next; 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; $newosid_args{$key} = $value;
...@@ -273,9 +293,9 @@ UserError() ...@@ -273,9 +293,9 @@ UserError()
# #
# Now do special checks. # Now do special checks.
# #
my $project = Project->Lookup($newosid_args{"project"}); my $project = Project->Lookup($newosid_args{"pid"});
if (!defined($project)) { if (!defined($project)) {
UserError("Project: No such project ($project)"); UserError("Project: No such project");
} }
if (!$project->AccessCheck($this_user, TB_PROJECT_MAKEOSID())) { if (!$project->AccessCheck($this_user, TB_PROJECT_MAKEOSID())) {
UserError("Project: Not enough permission"); UserError("Project: Not enough permission");
...@@ -297,6 +317,8 @@ if (exists($newosid_args{"nextosid"})) { ...@@ -297,6 +317,8 @@ if (exists($newosid_args{"nextosid"})) {
if (!defined($nextos)) { if (!defined($nextos)) {
UserError("Nextosid: Does not exist"); 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. # Mere users have to supply a version, but admin people do not.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment