Commit c167fa49 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Remove adminonly restriction from def_parentosid slot.

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