diff --git a/include/ScheduledAction.h b/include/ScheduledAction.h
index cc8fdb9b82..2961f31069 100644
--- a/include/ScheduledAction.h
+++ b/include/ScheduledAction.h
@@ -168,6 +168,8 @@ private:
std::string _message;
+ time_t _warning;
+
/**
* Rebuilds the object from an xml formatted string
* @param xml_str The xml-formatted string
diff --git a/share/doc/xsd/shared.xsd b/share/doc/xsd/shared.xsd
index 7ecdcad745..815b19baae 100644
--- a/share/doc/xsd/shared.xsd
+++ b/share/doc/xsd/shared.xsd
@@ -33,14 +33,15 @@
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/src/cli/one_helper.rb b/src/cli/one_helper.rb
index 0280c2ce57..af04818350 100644
--- a/src/cli/one_helper.rb
+++ b/src/cli/one_helper.rb
@@ -2556,7 +2556,12 @@ Bash symbols must be escaped on STDIN passing'
def self.scheduled_action_table(object)
CLIHelper::ShowTable.new(nil, object) do
column :ID, '', :adjust => true do |d|
- d['ID']
+ warn = d['WARNING'].to_i
+
+ prefix = ''
+ prefix = '*' if d['DONE'].to_i <= 0 && warn != 0 && warn < Time.now.to_i
+
+ prefix + d['ID']
end
column :ACTION, '', :adjust => true do |d|
diff --git a/src/cli/onevm b/src/cli/onevm
index 8a3d2fdc19..25f4a97b71 100755
--- a/src/cli/onevm
+++ b/src/cli/onevm
@@ -1486,7 +1486,6 @@ CommandParser::CmdParser.new(ARGV) do
end
acc_t = 0
- acc_w = 0
helper.perform_action(args[0], {}, 'Charter added') do |vm|
vm.info
@@ -1499,12 +1498,11 @@ CommandParser::CmdParser.new(ARGV) do
rc = helper.schedule_actions([args[0]].flatten,
{ :schedule => sched },
action.to_s,
- time[:warning][:time] + acc_w)
+ "+#{time[:warning][:time] + acc_t}")
exit(-1) if rc < 0
acc_t += time[:time].to_i
- acc_w += time[:warning][:time].to_i
end
end
diff --git a/src/oca/go/src/goca/schemas/shared/schedaction.go b/src/oca/go/src/goca/schemas/shared/schedaction.go
index 57fe8663a9..2783243a8c 100644
--- a/src/oca/go/src/goca/schemas/shared/schedaction.go
+++ b/src/oca/go/src/goca/schemas/shared/schedaction.go
@@ -42,6 +42,8 @@ const (
EndType SchedActionKeys = "END_TYPE"
EndValue SchedActionKeys = "END_VALUE"
Done SchedActionKeys = "DONE"
+ Message SchedActionKeys = "MESSAGE"
+ Warning SchedActionKeys = "WARNING"
)
// AddSchedAction returns a Scheduled Action structure
diff --git a/src/sam/ScheduledAction.cc b/src/sam/ScheduledAction.cc
index 131fd5ca56..e83164d69e 100644
--- a/src/sam/ScheduledAction.cc
+++ b/src/sam/ScheduledAction.cc
@@ -65,7 +65,7 @@ ScheduledAction::ScheduledAction(PoolObjectSQL::ObjectType type,
, _end_type(END_NONE)
, _end_value(-1)
, _done(-1)
- , _message("")
+ , _warning(0)
{
}
@@ -89,6 +89,7 @@ string& ScheduledAction::to_xml(string& xml) const
<< "" << _end_value << ""
<< "" << _done << ""
<< "" << _message << ""
+ << "" << _warning << ""
<< "";
xml = oss.str();
@@ -147,6 +148,17 @@ int ScheduledAction::parse(const VectorAttribute * va, time_t origin, string& er
return -1;
}
+ if (va->vector_value("WARNING", tmp_str) == 0 && !tmp_str.empty())
+ {
+ _warning = parse_time(tmp_str, origin);
+ }
+
+ if (_warning == -1)
+ {
+ error_str = "Unable to parse the warning value: " + tmp_str;
+ return -1;
+ }
+
int tmp_int;
if (va->vector_value("REPEAT", tmp_int) == 0)
@@ -443,6 +455,8 @@ time_t ScheduledAction::next_action()
_time += delta * 24 * 3600;
+ _warning = 0; // Reset warning for repeated action
+
return _time;
}
@@ -464,6 +478,7 @@ int ScheduledAction::rebuild_attributes()
rc += xpath(_days, "/SCHED_ACTION/DAYS", "");
rc += xpath(_message, "/SCHED_ACTION/MESSAGE", "");
rc += xpath(_end_value, "/SCHED_ACTION/END_VALUE", (time_t)-1);
+ rc += xpath(_warning, "/SCHED_ACTION/WARNING", (time_t)0);
rc += xpath(tmp_str, "/SCHED_ACTION/TYPE", "");
_type = str_to_type(tmp_str);