From e980e2ea1d56ae5e5cc2247737529af38403595c Mon Sep 17 00:00:00 2001 From: Leigh B Stoller Date: Tue, 3 Feb 2015 10:35:22 -0700 Subject: [PATCH] More tweaks for global images. --- apt/manage_instance.in | 1 + backend/newimageid_ez.in | 8 ++++---- utils/clone_image.in | 13 +++++++------ 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/apt/manage_instance.in b/apt/manage_instance.in index a0e092a2d..66149da7d 100644 --- a/apt/manage_instance.in +++ b/apt/manage_instance.in @@ -301,6 +301,7 @@ sub DoSnapshot() "slice_urn" => $slice->urn(), "imagename" => $imagename, "sliver_urn" => $sliver_urn, + "global" => 1, "credentials" => [$slice_credential->asString(), $speaksfor_credential->asString()], }; diff --git a/backend/newimageid_ez.in b/backend/newimageid_ez.in index 38c9238e4..b973a7a5f 100644 --- a/backend/newimageid_ez.in +++ b/backend/newimageid_ez.in @@ -1,6 +1,6 @@ #!/usr/bin/perl -wT # -# Copyright (c) 2000-2014 University of Utah and the Flux Group. +# Copyright (c) 2000-2015 University of Utah and the Flux Group. # # {{{EMULAB-LICENSE # @@ -517,7 +517,7 @@ if (!exists($newimageid_args{"path"}) || elsif (! $isadmin) { my $pdef = ""; - if (!$shared && + if (!($shared || $global) && exists($newimageid_args{"gid"}) && $newimageid_args{"gid"} ne "" && $newimageid_args{"gid"} ne $newimageid_args{"pid"}) { @@ -711,8 +711,8 @@ $newimageid_args{"ezid"} = 1; # OSInfo->Create args not quite the same as Image->Create ones so copy # newimageid_args into a new hash and fix up values. my %newosid_args = %newimageid_args; -$newosid_args{"shared"} = $newimageid_args{"global"} - if exists $newimageid_args{"global"}; +$newosid_args{"shared"} = $newimageid_args{"global"} = 1 + if ($global); my $usrerr; my $new_osinfo = OSinfo->Create($project, $this_user, $imagename, \%newosid_args, \$usrerr); diff --git a/utils/clone_image.in b/utils/clone_image.in index cbe5202bd..5c3db0fbb 100644 --- a/utils/clone_image.in +++ b/utils/clone_image.in @@ -65,8 +65,8 @@ my $nosnapshot = 0; my $isvirtnode = 0; my $waitmode = 0; my $nodelta = 0; # To pass to create_image. -my $global; -my $shared; +my $global = 0; +my $shared = 0; # # Configure variables @@ -376,8 +376,9 @@ if (Image->LookupByName($imagename) && !$this_user->IsAdmin()) { fatal("Not allowed to shadow snapshot a system image"); } -# Subgroups change the path -my $path = ($experiment->pid() eq $experiment->gid() ? +# Subgroups change the path, but a global image should still +# go into the project image directory. +my $path = ($experiment->pid() eq $experiment->gid() || $global ? "$PROJROOT/$pid/images/${imagename}.ndz" : "$GROUPROOT/$pid/$gid/images/${imagename}.ndz"); @@ -405,10 +406,10 @@ $xmlfields{"reboot_waittime"} = $base_osinfo->reboot_waittime() $xmlfields{"osfeatures"} = $base_osinfo->osfeatures() if (defined($base_osinfo->osfeatures()) && $base_osinfo->osfeatures() ne ""); -if (defined($global) && $global) { +if ($global) { $xmlfields{"global"} = 1; } -elsif (defined($shared) && $shared) { +elsif ($shared) { $xmlfields{"shared"} = 1; } -- GitLab