Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-stable
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
emulab
emulab-stable
Commits
2c2677b8
Commit
2c2677b8
authored
Mar 02, 2017
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up email sending to make sure that actual user gets the email
when deleting via the Geni path.
parent
8601701d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
6 deletions
+37
-6
utils/delete_image.in
utils/delete_image.in
+37
-6
No files found.
utils/delete_image.in
View file @
2c2677b8
...
...
@@ -59,6 +59,7 @@ my $TB = "@prefix@";
my
$PROJROOT
=
"
@PROJROOT_DIR
@
";
my
$TBOPS
=
"
@TBOPSEMAIL
@
";
my
$friskiller
=
"
$TB
/sbin/frisbeehelper
";
my
$PGENISUPPORT
=
@PROTOGENI_SUPPORT@
;
my
$WITHPROVENANCE
=
@IMAGEPROVENANCE@
;
my
$doprovenance
=
0
;
...
...
@@ -91,6 +92,12 @@ use libEmulab;
use
libtestbed
;
use
User
;
use
OSImage
;
if
(
$PGENISUPPORT
)
{
use
vars
qw($GENI_DBNAME)
;
$GENI_DBNAME
=
"
geni-cm
";
require
GeniHRN
;
require
GeniUser
;
}
# Protos
sub
fatal
($);
...
...
@@ -171,6 +178,30 @@ if ($versonly && defined($image->deleted())) {
fatal
("
Image version is already deleted
");
}
#
# We want to send email to the creator. Also, watch for an image created
# on the Geni path; the creator urn tells us who the creator is, rather
# then who is calling the script. When PROTOGENI_LOCALUSER=0 there is no
# local creator, but when set there is a local shadow user we can use.
#
my
$notifyuser
=
$image
->
GetCreator
();
if
(
!
defined
(
$notifyuser
))
{
$notifyuser
=
$this_user
;
}
if
(
defined
(
$image
->
creator_urn
()))
{
my
$geniuser
=
GeniUser
->
Lookup
(
$image
->
creator_urn
(),
1
);
if
(
defined
(
$geniuser
)
&&
$geniuser
->
IsLocal
())
{
$notifyuser
=
$geniuser
->
emulab_user
();
}
else
{
# This is okay, it is just for email below.
$notifyuser
=
$geniuser
;
}
}
if
(
$debug
)
{
print
STDERR
"
Will send email to
$notifyuser
\n
";
}
#
# Need root to delete the image file later.
#
...
...
@@ -393,9 +424,9 @@ if (!$versonly) {
if
(
$image
->
Delete
()
!=
0
)
{
fatal
("
Could not delete image!
");
}
$
this_
user
->
SendEmail
("
delete_image: Image has been deleted
",
"
Image
$imagepid
,
$imagename
(
$imageid
) has
"
.
"
been deleted by
$this_user
\n
");
$
notify
user
->
SendEmail
("
delete_image: Image has been deleted
",
"
Image
$imagepid
,
$imagename
(
$imageid
) has
"
.
"
been deleted by
$this_user
\n
");
}
else
{
if
(
$image
->
DeleteVersion
()
!=
0
)
{
...
...
@@ -403,9 +434,9 @@ else {
}
# I know, we are unlocking something we just deleted. Its okay, relax.
$image
->
Unlock
();
$
this_
user
->
SendEmail
("
delete_image: Image Version has been deleted
",
"
Version
$imagevers
of image
$imagepid
,
$imagename
"
.
"
(
$imageid
)
\n
has been deleted by
$this_user
\n
");
$
notify
user
->
SendEmail
("
delete_image: Image Version has been deleted
",
"
Version
$imagevers
of image
$imagepid
,
$imagename
"
.
"
(
$imageid
)
\n
has been deleted by
$this_user
\n
");
}
exit
(
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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