diff --git a/include/Image.h b/include/Image.h
index 0468b50b99..838dc488af 100644
--- a/include/Image.h
+++ b/include/Image.h
@@ -546,6 +546,14 @@ public:
ds_name = name;
};
+ /**
+ * Set modification time to the current time
+ */
+ void update_modification_time()
+ {
+ modtime = time(nullptr);
+ }
+
/**
* Clones this image template including image specific attributes: NAME,
* TYPE, PATH, FORMAT, SIZE and PERSISTENT
@@ -610,6 +618,7 @@ public:
target_snapshot = -1;
};
+
/* ---------------------------------------------------------------------- */
/* Incremental backups interface */
/* ---------------------------------------------------------------------- */
@@ -677,6 +686,11 @@ private:
*/
time_t regtime;
+ /**
+ * Time of last modification
+ */
+ time_t modtime;
+
/**
* Path to the image
*/
diff --git a/share/doc/xsd/image.xsd b/share/doc/xsd/image.xsd
index ae0c93248a..99a4b1bdef 100644
--- a/share/doc/xsd/image.xsd
+++ b/share/doc/xsd/image.xsd
@@ -39,6 +39,7 @@
+
diff --git a/src/cli/etc/oneimage.yaml b/src/cli/etc/oneimage.yaml
index 99141127d6..22167444a2 100644
--- a/src/cli/etc/oneimage.yaml
+++ b/src/cli/etc/oneimage.yaml
@@ -38,6 +38,10 @@
:desc: Registration time of the Image
:size: 15
+:MODTIME:
+ :desc: Last modified
+ :size: 15
+
:PERSISTENT:
:desc: Whether the Image is persistent or not
:size: 3
diff --git a/src/cli/one_helper/oneimage_helper.rb b/src/cli/one_helper/oneimage_helper.rb
index 9157e35044..a7877e47e9 100644
--- a/src/cli/one_helper/oneimage_helper.rb
+++ b/src/cli/one_helper/oneimage_helper.rb
@@ -235,6 +235,11 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
OpenNebulaHelper.time_to_str(d['REGTIME'])
end
+ column :MODTIME, 'Last modification time of the Image',
+ :size=>15 do |d|
+ OpenNebulaHelper.time_to_str(d['MODTIME'])
+ end
+
column :PERSISTENT, 'Whether the Image is persistent or not',
:size=>3 do |d|
OpenNebulaHelper.boolean_to_str(d['PERSISTENT'])
@@ -307,6 +312,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
size = OpenNebulaHelper.unit_to_str(image['SIZE'].to_i, {}, 'M')
lock = OpenNebulaHelper.level_lock_to_str(image['LOCK/LOCKED'])
regtime = OpenNebulaHelper.time_to_str(image['REGTIME'])
+ modtime = OpenNebulaHelper.time_to_str(image['MODTIME'])
pers = OpenNebulaHelper.boolean_to_str(image['PERSISTENT'])
CLIHelper.print_header(str_h1 % "IMAGE #{image['ID']} INFORMATION")
@@ -318,6 +324,7 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
puts format(str, 'DATASTORE', image['DATASTORE'])
puts format(str, 'TYPE', image.type_str)
puts format(str, 'REGISTER TIME', regtime)
+ puts format(str, 'LAST MODIFIED', modtime)
puts format(str, 'PERSISTENT', pers)
puts format(str, 'SOURCE', image['SOURCE'])
puts format(str, 'PATH', path) if path && !path.empty?
diff --git a/src/image/Image.cc b/src/image/Image.cc
index 56e7d98e61..fdfa292e1b 100644
--- a/src/image/Image.cc
+++ b/src/image/Image.cc
@@ -45,6 +45,7 @@ Image::Image(int _uid,
type(OS),
disk_type(FILE),
regtime(time(0)),
+ modtime(time(0)),
source(""),
path(""),
format(""),
@@ -416,6 +417,7 @@ string& Image::to_xml(string& xml) const
"" << disk_type << "" <<
"" << persistent_img << "" <<
"" << regtime << "" <<
+ "" << modtime << "" <<
"" << one_util::escape_xml(source) << "" <<
"" << one_util::escape_xml(path) << "" <<
"" << one_util::escape_xml(format) << "" <<
@@ -473,6 +475,7 @@ int Image::from_xml(const string& xml)
rc += xpath(int_disk_type, "/IMAGE/DISK_TYPE", 0);
rc += xpath(persistent_img, "/IMAGE/PERSISTENT", 0);
rc += xpath(regtime, "/IMAGE/REGTIME", 0);
+ rc += xpath(modtime, "/IMAGE/MODTIME", 0);
rc += xpath(format, "/IMAGE/FORMAT", "");
rc += xpath(size_mb, "/IMAGE/SIZE", 0);
diff --git a/src/image/ImageManagerActions.cc b/src/image/ImageManagerActions.cc
index c5fc5235e5..f98c570263 100644
--- a/src/image/ImageManagerActions.cc
+++ b/src/image/ImageManagerActions.cc
@@ -255,6 +255,8 @@ void ImageManager::release_image(int vm_id, int iid, bool failed)
{
int num_vms = img->dec_running(vm_id);
+ img->update_modification_time();
+
if (failed)
{
img->set_state(Image::ERROR);
@@ -272,6 +274,8 @@ void ImageManager::release_image(int vm_id, int iid, bool failed)
{
int num_vms = img->dec_running(vm_id);
+ img->update_modification_time();
+
if (failed)
{
img->set_state(Image::ERROR);
diff --git a/src/oca/go/src/goca/schemas/image/image.go b/src/oca/go/src/goca/schemas/image/image.go
index 85d1ae872e..2ff147487b 100644
--- a/src/oca/go/src/goca/schemas/image/image.go
+++ b/src/oca/go/src/goca/schemas/image/image.go
@@ -44,6 +44,7 @@ type Image struct {
DiskType *int `xml:"DISK_TYPE,omitempty"`
Persistent *int `xml:"PERSISTENT,omitempty"`
RegTime int `xml:"REGTIME,omitempty"`
+ ModTime int `xml:"MODTIME,omitempty"`
Source string `xml:"SOURCE,omitempty"`
Path string `xml:"PATH,omitempty"`
Fs string `xml:"FS,omitempty"`