From 81e89807de5ad23ec1175c135a7bc7630ab26f8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=A9dric=20Le=20Ninivin?= <cedric.leninivin@nexedi.com>
Date: Mon, 9 Jan 2023 17:34:57 +0000
Subject: [PATCH] slapos_jio_api_style: WIP Continue Work on jIO API Revision

---
 ...lapos_update_jio_api_revision_template.xml | 202 ++++++++++++++++++
 ...aveInstance_calculatejIOAPIRevisionHash.py |   1 +
 ...eInstance_calculatejIOAPIRevisionHash.xml} |   2 +-
 .../SlaveInstance_getjIOAPIRevisionHash.py    |   1 -
 ...reInstance_calculatejIOAPIRevisionHash.py} |   2 +-
 ...eInstance_calculatejIOAPIRevisionHash.xml} |   2 +-
 .../bt/template_path_list                     |   1 +
 7 files changed, 207 insertions(+), 4 deletions(-)
 create mode 100644 master/bt5/slapos_jio_api_style/PathTemplateItem/portal_alarms/slapos_update_jio_api_revision_template.xml
 create mode 100644 master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_calculatejIOAPIRevisionHash.py
 rename master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/{SlaveInstance_getjIOAPIRevisionHash.xml => SlaveInstance_calculatejIOAPIRevisionHash.xml} (96%)
 delete mode 100644 master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_getjIOAPIRevisionHash.py
 rename master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/{SoftwareInstance_getjIOAPIRevisionHash.py => SoftwareInstance_calculatejIOAPIRevisionHash.py} (79%)
 rename master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/{SoftwareInstance_getjIOAPIRevisionHash.xml => SoftwareInstance_calculatejIOAPIRevisionHash.xml} (96%)

diff --git a/master/bt5/slapos_jio_api_style/PathTemplateItem/portal_alarms/slapos_update_jio_api_revision_template.xml b/master/bt5/slapos_jio_api_style/PathTemplateItem/portal_alarms/slapos_update_jio_api_revision_template.xml
new file mode 100644
index 000000000..a41669289
--- /dev/null
+++ b/master/bt5/slapos_jio_api_style/PathTemplateItem/portal_alarms/slapos_update_jio_api_revision_template.xml
@@ -0,0 +1,202 @@
+<?xml version="1.0"?>
+<ZopeData>
+  <record id="1" aka="AAAAAAAAAAE=">
+    <pickle>
+      <global name="Alarm" module="erp5.portal_type"/>
+    </pickle>
+    <pickle>
+      <dictionary>
+        <item>
+            <key> <string>_local_properties</string> </key>
+            <value>
+              <tuple>
+                <dictionary>
+                  <item>
+                      <key> <string>id</string> </key>
+                      <value> <string>configuration_form_id</string> </value>
+                  </item>
+                  <item>
+                      <key> <string>type</string> </key>
+                      <value> <string>string</string> </value>
+                  </item>
+                </dictionary>
+                <dictionary>
+                  <item>
+                      <key> <string>id</string> </key>
+                      <value> <string>catalog_query_string</string> </value>
+                  </item>
+                  <item>
+                      <key> <string>type</string> </key>
+                      <value> <string>string</string> </value>
+                  </item>
+                </dictionary>
+                <dictionary>
+                  <item>
+                      <key> <string>id</string> </key>
+                      <value> <string>module_list</string> </value>
+                  </item>
+                  <item>
+                      <key> <string>type</string> </key>
+                      <value> <string>lines</string> </value>
+                  </item>
+                </dictionary>
+                <dictionary>
+                  <item>
+                      <key> <string>id</string> </key>
+                      <value> <string>incremental_check</string> </value>
+                  </item>
+                  <item>
+                      <key> <string>type</string> </key>
+                      <value> <string>int</string> </value>
+                  </item>
+                </dictionary>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>active_sense_method_id</string> </key>
+            <value> <string>Alarm_activateUpdateJIOAPIRevision</string> </value>
+        </item>
+        <item>
+            <key> <string>automatic_solve</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>catalog_query_string</string> </key>
+            <value> <string>validation_state:!=deleted</string> </value>
+        </item>
+        <item>
+            <key> <string>categories</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>configuration_form_id</string> </key>
+            <value> <string>Alarm_viewConsistencyCheckConfiguration</string> </value>
+        </item>
+        <item>
+            <key> <string>description</string> </key>
+            <value> <string>Clone this alarm for you projects and configure it through the Configuration Tab</string> </value>
+        </item>
+        <item>
+            <key> <string>enabled</string> </key>
+            <value> <int>0</int> </value>
+        </item>
+        <item>
+            <key> <string>id</string> </key>
+            <value> <string>slapos_update_jio_api_revision_template</string> </value>
+        </item>
+        <item>
+            <key> <string>incremental_check</string> </key>
+            <value> <int>1</int> </value>
+        </item>
+        <item>
+            <key> <string>module_list</string> </key>
+            <value>
+              <tuple>
+                <string>software_instance_module</string>
+              </tuple>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_day_frequency</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_hour</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_hour_frequency</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_minute</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_minute_frequency</string> </key>
+            <value> <int>1</int> </value>
+        </item>
+        <item>
+            <key> <string>periodicity_month</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_month_day</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_start_date</string> </key>
+            <value>
+              <object>
+                <klass>
+                  <global name="DateTime" module="DateTime.DateTime"/>
+                </klass>
+                <tuple>
+                  <none/>
+                </tuple>
+                <state>
+                  <tuple>
+                    <float>1230768000.0</float>
+                    <string>GMT</string>
+                  </tuple>
+                </state>
+              </object>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_week</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_week_day</string> </key>
+            <value>
+              <tuple/>
+            </value>
+        </item>
+        <item>
+            <key> <string>periodicity_week_frequency</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>portal_type</string> </key>
+            <value> <string>Alarm</string> </value>
+        </item>
+        <item>
+            <key> <string>report_method_id</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>solve_method_id</string> </key>
+            <value>
+              <none/>
+            </value>
+        </item>
+        <item>
+            <key> <string>title</string> </key>
+            <value> <string>SlapOS Update JIO API Revision Template</string> </value>
+        </item>
+      </dictionary>
+    </pickle>
+  </record>
+</ZopeData>
diff --git a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_calculatejIOAPIRevisionHash.py b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_calculatejIOAPIRevisionHash.py
new file mode 100644
index 000000000..f7b6703a1
--- /dev/null
+++ b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_calculatejIOAPIRevisionHash.py
@@ -0,0 +1 @@
+return context.SoftwareInstance_calculatejIOAPIRevisionHash()
diff --git a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_getjIOAPIRevisionHash.xml b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_calculatejIOAPIRevisionHash.xml
similarity index 96%
rename from master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_getjIOAPIRevisionHash.xml
rename to master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_calculatejIOAPIRevisionHash.xml
index df75cfec9..3eec14dd5 100644
--- a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_getjIOAPIRevisionHash.xml
+++ b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_calculatejIOAPIRevisionHash.xml
@@ -54,7 +54,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>SlaveInstance_getjIOAPIRevisionHash</string> </value>
+            <value> <string>SlaveInstance_calculatejIOAPIRevisionHash</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_getjIOAPIRevisionHash.py b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_getjIOAPIRevisionHash.py
deleted file mode 100644
index 2fec3ec37..000000000
--- a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SlaveInstance_getjIOAPIRevisionHash.py
+++ /dev/null
@@ -1 +0,0 @@
-return context.SoftwareInstance_getjIOAPIRevisionHash()
diff --git a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_getjIOAPIRevisionHash.py b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_calculatejIOAPIRevisionHash.py
similarity index 79%
rename from master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_getjIOAPIRevisionHash.py
rename to master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_calculatejIOAPIRevisionHash.py
index a0ade0440..928fd8ef5 100644
--- a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_getjIOAPIRevisionHash.py
+++ b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_calculatejIOAPIRevisionHash.py
@@ -1,4 +1,4 @@
-if context.getValidationState() != "validated":
+if context.getValidationState() != "validated" or context.getSlapState() == "draft":
   return None
 import json
 import hashlib
diff --git a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_getjIOAPIRevisionHash.xml b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_calculatejIOAPIRevisionHash.xml
similarity index 96%
rename from master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_getjIOAPIRevisionHash.xml
rename to master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_calculatejIOAPIRevisionHash.xml
index e7a86e3f6..c9c657af3 100644
--- a/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_getjIOAPIRevisionHash.xml
+++ b/master/bt5/slapos_jio_api_style/SkinTemplateItem/portal_skins/slapos_jio_api_cache/SoftwareInstance_calculatejIOAPIRevisionHash.xml
@@ -54,7 +54,7 @@
         </item>
         <item>
             <key> <string>id</string> </key>
-            <value> <string>SoftwareInstance_getjIOAPIRevisionHash</string> </value>
+            <value> <string>SoftwareInstance_calculatejIOAPIRevisionHash</string> </value>
         </item>
       </dictionary>
     </pickle>
diff --git a/master/bt5/slapos_jio_api_style/bt/template_path_list b/master/bt5/slapos_jio_api_style/bt/template_path_list
index 17bcebb87..b0c6b8531 100644
--- a/master/bt5/slapos_jio_api_style/bt/template_path_list
+++ b/master/bt5/slapos_jio_api_style/bt/template_path_list
@@ -1,3 +1,4 @@
+portal_alarms/slapos_update_jio_api_revision_template
 portal_callables/ComputeNode_getFromJSON
 portal_callables/ComputeNode_updateFromJSON
 portal_callables/SoftwareInstallation_getFromJSON
-- 
2.30.9