[Oval-commits] r377 - in trunk/oval-infrastructure: . debian.agent docs src src/ovalClient
Pavel Vinogradov
blaze-guest at alioth.debian.org
Tue Sep 23 17:20:09 UTC 2008
Author: blaze-guest
Date: 2008-09-23 17:20:09 +0000 (Tue, 23 Sep 2008)
New Revision: 377
Added:
trunk/oval-infrastructure/agent.conf
trunk/oval-infrastructure/debian.agent/
trunk/oval-infrastructure/docs/AGENT.BUGS
trunk/oval-infrastructure/docs/AGENT.README
trunk/oval-infrastructure/docs/OvalAgent.TODO
trunk/oval-infrastructure/oval-agent.1
trunk/oval-infrastructure/src/agent-setup.py
trunk/oval-infrastructure/src/oval-agent.py
trunk/oval-infrastructure/src/ovalClient/
Log:
Move oval-agent to oval-infrastructure
Copied: trunk/oval-infrastructure/agent.conf (from rev 372, trunk/oval-agent/agent.conf)
===================================================================
--- trunk/oval-infrastructure/agent.conf (rev 0)
+++ trunk/oval-infrastructure/agent.conf 2008-09-23 17:20:09 UTC (rev 377)
@@ -0,0 +1,16 @@
+[server]
+baseurl = /
+check_interval = 1
+server = 127.0.0.1
+port = 8989
+descr = laptop.home.nixdev.net
+
+[general]
+# Directory where log files are kept
+log_dir = /var/log/oval
+log_file = oval-agent.log
+#log_level = CRITICAL | ERROR | WARNING (default) | INFO | DEBUG | NOTSET
+log_level = DEBUG
+# This is the working directory where definitions are downloaded
+workdir = /var/cache/oval-agent/definitions
+
Property changes on: trunk/oval-infrastructure/agent.conf
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/oval-infrastructure/debian.agent (from rev 372, trunk/oval-agent/debian)
Property changes on: trunk/oval-infrastructure/debian.agent
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/oval-infrastructure/docs/AGENT.BUGS (from rev 372, trunk/oval-agent/BUGS)
===================================================================
--- trunk/oval-infrastructure/docs/AGENT.BUGS (rev 0)
+++ trunk/oval-infrastructure/docs/AGENT.BUGS 2008-09-23 17:20:09 UTC (rev 377)
@@ -0,0 +1,12 @@
+
+- Does not check for all its directories on startup
+ (definitions)
+
+- Does not check if 'ovaldi' (the program) exists before starting
+
+- It is incapable of telling when it might not have results due to
+ 'ovaldi' failing. Notice that ovaldi does not generate an error on exit (it
+ seems to always exit with 0) so it might be difficult to detect when it
+ fails.
+ To reproduce: mv /etc/hosts to /etc/hosts.BREAK in a chroot, ovaldi
+ fails to work (does not resolv the local host name) in this situation
Property changes on: trunk/oval-infrastructure/docs/AGENT.BUGS
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/oval-infrastructure/docs/AGENT.README (from rev 372, trunk/oval-agent/README)
===================================================================
--- trunk/oval-infrastructure/docs/AGENT.README (rev 0)
+++ trunk/oval-infrastructure/docs/AGENT.README 2008-09-23 17:20:09 UTC (rev 377)
@@ -0,0 +1 @@
+Currently None
Property changes on: trunk/oval-infrastructure/docs/AGENT.README
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/oval-infrastructure/docs/OvalAgent.TODO (from rev 372, trunk/oval-agent/OvalAgent.TODO)
===================================================================
--- trunk/oval-infrastructure/docs/OvalAgent.TODO (rev 0)
+++ trunk/oval-infrastructure/docs/OvalAgent.TODO 2008-09-23 17:20:09 UTC (rev 377)
@@ -0,0 +1,3 @@
+Check ovaldi output for errors
+Check definitions hash before download definition file from server
+Fix loop in get-evaluate-send
Property changes on: trunk/oval-infrastructure/docs/OvalAgent.TODO
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/oval-infrastructure/oval-agent.1 (from rev 372, trunk/oval-agent/oval-agent.1)
===================================================================
--- trunk/oval-infrastructure/oval-agent.1 (rev 0)
+++ trunk/oval-infrastructure/oval-agent.1 2008-09-23 17:20:09 UTC (rev 377)
@@ -0,0 +1,49 @@
+.TH oval-agent 1 "August 31, 2007"
+.\" Please adjust this date whenever revising the manpage.
+.\"
+.\" Some roff macros, for reference:
+.\" .nh disable hyphenation
+.\" .hy enable hyphenation
+.\" .ad l left justify
+.\" .ad b justify to both left and right margins
+.\" .nf disable filling
+.\" .fi enable filling
+.\" .br insert line break
+.\" .sp <n> insert n+1 empty lines
+.\" for manpage-specific macros, see man(7)
+.SH NAME
+oval-agent \- program that receive OVAL definitions, query them and send result to oval-server
+.SH SYNOPSIS
+.B oval-agent
+[\-h] [\-c filename] [\-v]
+.SH DESCRIPTION
+.B oval-agent
+daemon was developed to automize interaction with oval-server. It
+download new OVAL definitions, query it with
+.B ovaldi
+and send results back to server. All received results was stored in
+.B oval-server
+database and may examined with
+.B oval-monitor
+tool.
+.PP
+.SH OPTIONS
+.TP
+.B \-h
+Show summary of options.
+.TP
+.B \-c filename
+Path to configuration file
+.TP
+.B \-v
+Show version of program.
+.SH SEE ALSO
+.BR oval-server (1),
+.BR oval-monitor (1),
+.BR ovaldi (1).
+.br
+.SH AUTHOR
+oval-agent was written by Pavel Vinogradov <Pavel.Vinogradov at nixdev.net>.
+.PP
+This manual page was written by Pavel Vinogradov <Pavel.Vinogradov at nixdev.net>,
+for the Debian project (but may be used by others).
Property changes on: trunk/oval-infrastructure/oval-agent.1
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/oval-infrastructure/src/agent-setup.py (from rev 372, trunk/oval-agent/setup.py)
===================================================================
--- trunk/oval-infrastructure/src/agent-setup.py (rev 0)
+++ trunk/oval-infrastructure/src/agent-setup.py 2008-09-23 17:20:09 UTC (rev 377)
@@ -0,0 +1,30 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Written by Pavel Vinogradov <Pavel.Vinogradov at nixdev.net>
+# Licensed under the GNU General Public License version 2.
+
+"""The oval-agent program for interact with oval-server daemon.
+
+This program used to interact with oval-server deamon, download OVAL
+definitions, quering it and send reports back to server.
+
+"""
+
+import sys
+assert sys.version >= '2.4', "Install Python 2.4 or greater"
+from distutils.core import setup, Extension
+import ovalClient
+
+setup(
+ name = "ovalClient",
+ version = "%s" % ovalClient.__version__,
+ author = "Pavel Vinogradov",
+ author_email = "<oval-devel at lists.alioth.debian.org>",
+ url = "http://oval.alioth.debian.org",
+ license = "GPL2",
+
+ packages = ["ovalClient"],
+
+ scripts = ["oval-agent.py"]
+ )
Property changes on: trunk/oval-infrastructure/src/agent-setup.py
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mergeinfo
+
Copied: trunk/oval-infrastructure/src/oval-agent.py (from rev 372, trunk/oval-agent/oval-agent.py)
===================================================================
--- trunk/oval-infrastructure/src/oval-agent.py (rev 0)
+++ trunk/oval-infrastructure/src/oval-agent.py 2008-09-23 17:20:09 UTC (rev 377)
@@ -0,0 +1,136 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Written by Pavel Vinogradov <Pavel.Vinogradov at nixdev.net>
+# Licensed under the GNU General Public License version 2.
+
+""" Agent package that interact with oval-server and evaluate local machine
+ with received definitions.
+
+ Interact with oval-server over HTTP protocol and use ovaldi package for
+ evaluate definitions. Don't present any statistic.
+"""
+
+from ConfigParser import SafeConfigParser
+import os, logging, sys
+import getopt
+import traceback, exceptions
+sys.path = ['/usr/share/oval-agent'] + sys.path
+from ovalClient import ovalHttpClient
+
+class configNotFoundError (Exception):
+ pass
+
+logLevels = {'CRITICAL' : 50, 'ERROR' : 40, 'WARNING' : 30, 'INFO' : 20, 'DEBUG' : 10, 'NOTSET' : 0}
+
+def usage (prog = 'oval-agent.py'):
+ """Print information about script flags and options"""
+
+ print """usage: python %s [-h] [-c <config>]
+\t-h\tthis help
+\t-c\tpath to config file (by default /etc/oval/agent.conf""" % prog
+
+class agentThread:
+ config = SafeConfigParser()
+ logger = logging.getLogger()
+
+ def __init__(self, cfgfile):
+ try:
+ if not self.config.read(cfgfile):
+ raise configNotFoundError, 'Config file %s not found.\n' % cfgfile
+
+ # Read general options from config file
+ self.workdir = self.config.get('general', 'workdir')
+ logdirname = self.config.get('general', 'log_dir')
+ logfilename = self.config.get('general', 'log_file')
+ self.log_level = self.config.get('general', 'log_level')
+ outfilename = os.path.join(logdirname, logfilename)
+
+ # Create the root handler (removing any others)
+ hdlr = logging.FileHandler(outfilename, 'a')
+ hdlr.setFormatter(logging.Formatter('%(asctime)s %(threadName)s %(name)s %(levelname)s %(message)s'))
+ for h in logging.root.handlers:
+ logging.root.removeHandler(h)
+ logging.root.addHandler(hdlr)
+
+ if logLevels.has_key(self.log_level):
+ logging.root.setLevel(logLevels[self.log_level])
+ else:
+ logging.root.setLevel(logging.WARNING)
+ self.logger.warning('Wrong value of log_level key in config. Use WARNING as default.')
+
+ self.logger.info('Logging begins')
+
+ except IOError, e:
+ sys.stderr.write("Can't create logger handler: " + str(e) + "\n")
+ logging.shutdown()
+ sys.exit(2)
+
+
+ def readConfigSection (self, section):
+ """ Parse section of config file into dict
+
+ @type section: C(string)
+ @param section: name of config file section
+ @rtype: C(dict)
+ @return: content of config section in dict format
+
+ """
+ conf = {}
+
+ if self.config.has_section(section):
+ data = self.config.items(section)
+ for opts in data:
+ conf[opts[0]] = opts[1]
+ return conf
+
+ def run(self):
+ """Run agent instance
+
+ Create instance of OvalHttpClient class and run it
+
+ """
+ self.logger.info('clientThread.RUN')
+
+ config = self.readConfigSection('server')
+ config['workdir'] = self.workdir
+
+ client = ovalHttpClient.OvalHttpClient(config, self.logger)
+
+ client.run()
+
+if __name__ == "__main__":
+ #Parse command line options.
+ #By default we search for config file in global configuration directory
+ opts = {'-c' : '/etc/oval/agent.conf'}
+
+ try:
+ opt, args = getopt.getopt (sys.argv[1:], 'vhc:')
+ except getopt.GetoptError:
+ usage (sys.argv[0])
+ sys.exit(1)
+
+ for key, value in opt:
+ opts[key] = value
+
+ if opts.has_key ('-h'):
+ usage(sys.argv[0])
+ sys.exit(0)
+
+ if opts.has_key ('-v'):
+ print 'oval-agent version: 0.2'
+ sys.exit(0)
+
+ #Crate agent instance and run it
+ try:
+ client = agentThread(opts['-c'])
+ client.run ()
+ except configNotFoundError, e:
+ sys.stderr.write (str(e))
+ except KeyboardInterrupt, e:
+ sys.stderr.write ('Execution interrupted by keyboard.\n')
+ except exceptions.SystemExit, e:
+ raise e
+ except Exception, e:
+ sys.stderr.write('Unhandled error during execution: %s : %s.' % (e.__class__, str(e)) + "\n")
+ traceback.print_exc()
Property changes on: trunk/oval-infrastructure/src/oval-agent.py
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/oval-infrastructure/src/ovalClient (from rev 372, trunk/oval-agent/ovalClient)
Property changes on: trunk/oval-infrastructure/src/ovalClient
___________________________________________________________________
Name: svn:mergeinfo
+
More information about the Oval-commits
mailing list