Commit 23ad8819 authored by Leigh Stoller's avatar Leigh Stoller

Add creator_urn to images table so we can track actual creator

when created via the ProtoGeni interface; we run everything as
GeniUser and so lose that info. We want to know this for history
information and so we can manage permissions on image deletion
effectively.

Also add updater, updater_idx, and updater_urn to track last change
to the image.

CAVEAT: For system images, we do not actually overwrite the image, but
store it out in /proj/$pid/images and then sometime later maybe we
copy it back to boss. This wrecks the tracking info quite effectively
since the image may never be copied back. Needs more thought.
parent f6bea05f
......@@ -1803,7 +1803,8 @@ CREATE TABLE `image_history` (
KEY `node_id` (`node_id`,`history_id`),
KEY `stamp` (`stamp`),
KEY `rsrcidx` (`rsrcidx`),
KEY `node_history_id` (`node_history_id`)
KEY `node_history_id` (`node_history_id`),
KEY `imagestamp` (`imageid`,`stamp`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
......@@ -1837,7 +1838,11 @@ CREATE TABLE `images` (
`old_imageid` varchar(45) NOT NULL default '',
`creator` varchar(8) default NULL,
`creator_idx` mediumint(8) unsigned NOT NULL default '0',
`creator_urn` varchar(128) default NULL,
`created` datetime default NULL,
`updater` varchar(8) default NULL,
`updater_idx` mediumint(8) unsigned NOT NULL default '0',
`updater_urn` varchar(128) default NULL,
`description` tinytext NOT NULL,
`loadpart` tinyint(4) NOT NULL default '0',
`loadlength` tinyint(4) NOT NULL default '0',
......
#
# Add 'creator_urn' to images so we remember who actually created
# an image on the protogeni path. Currently, geniuser gets credit
# for all images.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
DBQueryFatal("alter table images add ".
" `creator_urn` varchar(128) default NULL after creator_idx")
if (!DBSlotExists("images", "creator_urn"));
DBQueryFatal("alter table images add ".
" `updater` varchar(8) default NULL after creator_urn")
if (!DBSlotExists("images", "updater"));
DBQueryFatal("alter table images add ".
" `updater_idx` mediumint(8) unsigned NOT NULL default '0' ".
" after updater")
if (!DBSlotExists("images", "updater_idx"));
DBQueryFatal("alter table images add ".
" `updater_urn` varchar(128) default NULL after updater_idx")
if (!DBSlotExists("images", "updater_urn"));
DBQueryFatal("alter table image_history add ".
" KEY `imagestamp` (`imageid`,`stamp`)")
if (!DBKeyExists("image_history", "imagestamp"));
return 0;
}
1;
# Local Variables:
# mode:perl
# End:
#!/usr/bin/perl -wT
#
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# Copyright (c) 2000-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -450,7 +450,10 @@ if (!$isvirtnode) {
# Record when this image was updated, so that we can figure out which
# revision of the testbed image it was based off.
#
$image->MarkUpdateTime() == 0 or
# Makes no sense to do this when writing a global image to a different path.
# We need a better way to make new images live.
#
$image->MarkUpdate(this_user) == 0 or
fatal("Could not mark the update time in $image");
#
......
#!/usr/bin/perl -w
#
# Copyright (c) 2003-2012 University of Utah and the Flux Group.
# Copyright (c) 2003-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -67,6 +67,7 @@ my $NEWIMAGE_EZ = "$TB/bin/newimageid_ez";
#
use lib "@prefix@/lib";
use emdb;
use User;
use Image;
use OSinfo;
use libaudit;
......@@ -123,6 +124,11 @@ if ($UID && !$impotent) {
# Record output in case of error.
LogStart(0, undef, LIBAUDIT_LOGTBOPS());
#
# We use elabman user below for marking the image update.
#
my $elabman = User->Lookup(PROTOUSER());
#
# Fetch the metadata, which tells what to do.
#
......@@ -220,7 +226,7 @@ foreach my $imageid (keys(%{ $xmlparse->{'image'} })) {
print "Image hash has not changed, skipping ...\n"
if ($debug);
# Update the timestamp to avoid repeat.
$image->MarkUpdateTime($newtime);
$image->MarkUpdate($elabman, $newtime);
next;
}
}
......@@ -297,7 +303,7 @@ foreach my $imageid (keys(%{ $xmlparse->{'image'} })) {
#
# Mark this too, so that we do not repeat the first test above.
#
$image->MarkUpdateTime($newtime);
$image->MarkUpdate($elabman, $newtime);
}
exit(0);
......
<?php
#
# Copyright (c) 2006-2012 University of Utah and the Flux Group.
# Copyright (c) 2006-2013 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -341,6 +341,7 @@ class Image
function uuid() { return $this->field("uuid"); }
function creator() { return $this->field("creator"); }
function creator_idx() { return $this->field("creator_idx"); }
function creator_urn() { return $this->field("creator_urn"); }
function created() { return $this->field("created"); }
function description() { return $this->field("description"); }
function loadpart() { return $this->field("loadpart"); }
......@@ -356,6 +357,8 @@ class Image
function shared() { return $this->field("shared"); }
function isglobal() { return $this->field("global"); }
function updated() { return $this->field("updated"); }
function updater() { return $this->field("updater"); }
function updater_urn() { return $this->field("updater_urn"); }
function mbr_version() { return $this->field("mbr_version"); }
function hash() { return $this->field("hash"); }
function metadata_url() { return $this->field("metadata_url"); }
......@@ -523,8 +526,11 @@ class Image
$shared = $this->shared();
$globalid = $this->isglobal();
$creator = $this->creator();
$creator_urn = $this->creator_urn();
$created = $this->created();
$updated = $this->updated();
$updater = $this->updater();
$updater_urn = $this->updater_urn();
$uuid = $this->uuid();
$mbr_version = $this->mbr_version();
$hash = $this->hash();
......@@ -556,6 +562,13 @@ class Image
<td class=\"left\">$imagename</td>
</tr>\n";
echo "<tr>
<td>Description: </td>
<td class=left>\n";
echo "$description";
echo " </td>
</tr>\n";
echo "<tr>
<td>Project: </td>
<td class=\"left\">
......@@ -568,29 +581,57 @@ class Image
<a href='showgroup.php3?pid=$pid&gid=$gid'>$gid</a></td>
</tr>\n";
echo "<tr>
<td>Creator: </td>
<td class=left>$creator</td>
</tr>\n";
echo "<tr>
<td>Created: </td>
<td class=left>$created</td>
</tr>\n";
echo "<tr>
<td>Creator: </td>
<td class=left>$creator</td>
</tr>\n";
if ($creator_urn) {
echo "<tr>
<td>Creator URN: </td>
<td class=left>$creator_urn</td>
</tr>\n";
}
if ($updated) {
echo "<tr>
<td>Updated: </td>
<td class=left>$updated</td>
</tr>\n";
echo "<tr>
<td>Updated By: </td>
<td class=left>$updater</td>
</tr>\n";
if ($updater_urn) {
echo "<tr>
<td>Updater URN: </td>
<td class=left>$updater_urn</td>
</tr>\n";
}
}
echo "<tr>
<td>Description: </td>
<td class=left>\n";
echo "$description";
echo " </td>
</tr>\n";
#
# Find the last time this image was used.
#
$usage_result =
DBQueryFatal("select FROM_UNIXTIME(stamp) as lastused ".
" from image_history ".
"where action='os_setup' and imageid='$imageid' ".
"order by stamp desc limit 1");
if (mysql_num_rows($usage_result)) {
$urow = mysql_fetch_array($usage_result);
$lastused = $urow['lastused'];
echo "<tr>
<td>Last Used: </td>
<td class=\"left\">$lastused</td>
</tr>\n";
}
echo "<tr>
<td>Load Partition: </td>
......
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