Skip to content
Snippets Groups Projects
Commit ee2d1d5e authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

method field in log database not required anymore.

added method to update method field.
parent 2db20c02
No related branches found
No related tags found
No related merge requests found
......@@ -50,14 +50,14 @@ class Database(object):
def add_log(self, uuid, submitted,
origin, module,
module_version, module_path,
method, message):
message):
try:
host_module = self._get_host_module(module, module_version)
if host_module is None:
self._create_host_module(module, module_version, module_path)
host_module = self._get_host_module(module, module_version)
self._create_log(uuid, submitted, origin, host_module[0], method, message)
self._create_log(uuid, submitted, origin, host_module[0], message)
except Exception as ex:
logger.error('Error while adding log to database: %s', str(ex))
self.connection.rollback()
......@@ -65,6 +65,18 @@ class Database(object):
self.connection.commit()
def update_log_method(self, uuid, method):
try:
self.connection.execute("""
UPDATE log SET method = ? WHERE uuid = ?
""", (method, uuid))
except Exception as ex:
logger.error("Error while updating method of log '%s'", uuid)
self.connection.rollback()
raise
self.connection.commit()
def get_log(self, uuid):
curs = self.connection.execute("""
SELECT log.uuid AS 'uuid', log.submitted AS 'submitted',
......@@ -229,12 +241,12 @@ class Database(object):
return tuple(data)
def _create_log(self, uuid, submitted, origin, module_id, method, message):
def _create_log(self, uuid, submitted, origin, module_id, message):
self.connection.execute("""
INSERT INTO log
(uuid,submitted,origin,module_id,method,message)
VALUES (?,?,?,?,?,?)
""", (uuid, submitted, origin, module_id, method, message))
(uuid,submitted,origin,module_id,message)
VALUES (?,?,?,?,?)
""", (uuid, submitted, origin, module_id, message))
def _create_status_log(self, log_id, agent_id,
agent_module_id,
......@@ -259,7 +271,7 @@ class Database(object):
submitted TEXT NOT NULL,
origin TEXT NOT NULL,
module_id INTEGER NOT NULL,
method TEXT NOT NULL,
method TEXT DEFAULT NULL,
message TEXT NOT NULL,
CONSTRAINT log_module_id_fkey FOREIGN KEY (module_id) REFERENCES managementhost_module (id) ON UPDATE RESTRICT ON DELETE RESTRICT
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment