support user created conf_files for slices
[plcapi.git] / PLC / ConfFiles.py
index f15a574..5d8ae17 100644 (file)
@@ -36,7 +36,12 @@ class ConfFile(Row):
         'error_cmd': Parameter(str, "Shell command to execute if any error occurs", max = 1024, nullok = True),
         'ignore_cmd_errors': Parameter(bool, "Install file anyway even if an error occurs"),
         'always_update': Parameter(bool, "Always attempt to install file even if unchanged"),
-        'node_ids': Parameter(int, "List of nodes linked to this file"),
+       'site_id': Parameter(int, "Identifier of the site to which this conf file belongs"),
+       'creator_id': Parameter(int, "Identifer of the person who created this conf file"),
+        'last_modified_by_id': Parameter(int, "Identifier of the person who last updated this conf file"),
+       'date_created': Parameter(int, "Date and time when this conf file was created", ro = True), 
+       'last_modified': Parameter(int, "Date and time when this conf file was last modified", ro = True), 
+       'node_ids': Parameter(int, "List of nodes linked to this file"),
         'nodegroup_ids': Parameter(int, "List of node groups linked to this file"),
         }
 
@@ -134,6 +139,21 @@ class ConfFile(Row):
             self['nodegroup_ids'].remove(nodegroup_id)
             nodegroup['conf_file_ids'].remove(conf_file_id)
 
+    def update_last_modified():
+       """
+        Update last_updated field with current time
+        """
+
+        assert 'conf_file_id' in self
+        assert self.table_name
+
+        self.api.db.do("UPDATE %s SET last_modified = CURRENT_TIMESTAMP " % (self.table_name) + \
+                       " where conf_file_id = %d" % (self['conf_file_id']) )
+        self.sync(commit)
+
+    validate_date_created = Row.validate_timestamp
+    validate_last_updated = Row.validate_timestamp             
+
 class ConfFiles(Table):
     """
     Representation of the conf_files table in the database.