Commit ad26f8d3 authored by Leigh Stoller's avatar Leigh Stoller

Minor tweaks to allow these scripts to be used during the install

process, to add the base descriptors.
parent 93bc37fe
#!/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 = "dvf";
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.
......
#!/usr/bin/perl -wT
#
# 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.
#
use English;
......@@ -18,8 +18,9 @@ sub usage()
print("Usage: newimageid [-v] <xmlfile>\n");
exit(-1);
}
my $optlist = "dv";
my $optlist = "dvf";
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
......
#!/usr/bin/perl -wT
#
# 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.
#
use English;
......@@ -132,7 +132,7 @@ my %xmlfields =
# XML Field Name DB slot name Flags Default
("description" => ["description", $SLOT_REQUIRED],
"osname" => ["osname" , $SLOT_REQUIRED],
"project" => ["pid_idx", $SLOT_REQUIRED],
"pid" => ["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{"project"});
my $project = Project->Lookup($newosid_args{"pid"});
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.
......
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