<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>File Monitor Development — Bcfg2 1.3.0 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '1.3.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="shortcut icon" href="../_static/favicon.ico"/> <link rel="top" title="Bcfg2 1.3.0 documentation" href="../index.html" /> <link rel="up" title="Bcfg2 Development" href="index.html" /> <link rel="next" title="Developing for Packages" href="packages.html" /> <link rel="prev" title="Documentation" href="documentation.html" /> <link rel="stylesheet" href="../_static/bcfg2.css" type=""/> </head> <body> <div style="text-align: left; padding: 10px 10px 15px 15px"> <a href="../index.html"><img src="../_static/bcfg2_logo.png" border="0" alt="sampledoc"/></a> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="packages.html" title="Developing for Packages" accesskey="N">next</a> |</li> <li class="right" > <a href="documentation.html" title="Documentation" accesskey="P">previous</a> |</li> <li><a href="../index.html">home</a> | </li> <!--<li><a href="../search.html">search</a> | </li>--> <li><a href="../help/index.html">help</a> | </li> <li><a href="../contents.html">documentation </a> »</li> <li><a href="../contents.html" >Bcfg2 documentation 1.3.0</a> »</li> <li><a href="index.html" accesskey="U">Bcfg2 Development</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="file-monitor-development"> <span id="development-fam"></span><h1>File Monitor Development<a class="headerlink" href="#file-monitor-development" title="Permalink to this headline">¶</a></h1> <p>Bcfg2 depends heavily on file activity monitoring (FAM) to reload data from disk when it changes. A number of FAM backends are supported (documented thoroughly below), but you may wish to develop additional backends. For instance, the current best FAM backend on Linux is INotify, but if you are running a non-Linux system that lacks INotify support you may wish to write a backend for your OS (e.g., a kqueue backend for BSD-based Bcfg2 servers). This page documents the FAM API and the existing FAM backends.</p> <div class="section" id="event-codes"> <span id="development-fam-event-codes"></span><h2>Event Codes<a class="headerlink" href="#event-codes" title="Permalink to this headline">¶</a></h2> <p>Five event codes are generally understood:</p> <table border="1" class="docutils"> <colgroup> <col width="14%" /> <col width="86%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head">Event</th> <th class="head">Description</th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>exists</td> <td>Produced when a monitor is added to a file or directory that exists, and produced for all files or directories inside a directory that is monitored (non-recursively).</td> </tr> <tr class="row-odd"><td>endExist</td> <td>Produced immediately after <tt class="docutils literal"><span class="pre">exists</span></tt>. No plugins should process this event meaningfully, so FAM backends do not need to produce it.</td> </tr> <tr class="row-even"><td>created</td> <td>Produced when a file is created inside a monitored directory.</td> </tr> <tr class="row-odd"><td>changed</td> <td>Produced when a monitored file, or a file inside a monitored directory, is changed.</td> </tr> <tr class="row-even"><td>deleted</td> <td>Produced when a monitored file, or a file inside a monitored directory, is deleted.</td> </tr> </tbody> </table> </div> <div class="section" id="module-Bcfg2.Server.FileMonitor"> <span id="basics"></span><h2>Basics<a class="headerlink" href="#module-Bcfg2.Server.FileMonitor" title="Permalink to this headline">¶</a></h2> <p>Bcfg2.Server.FileMonitor provides the support for monitoring files. The FAM acts as a dispatcher for events: An event is detected on a file (e.g., the file content is changed), and then that event is dispatched to the <tt class="docutils literal"><span class="pre">HandleEvent</span></tt> method of an object that knows how to handle the event. Consequently, <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.AddMonitor" title="Bcfg2.Server.FileMonitor.FileMonitor.AddMonitor"><tt class="xref py py-func docutils literal"><span class="pre">Bcfg2.Server.FileMonitor.FileMonitor.AddMonitor()</span></tt></a> takes two arguments: the path to monitor, and the object that handles events detected on that event.</p> <p><tt class="docutils literal"><span class="pre">HandleEvent</span></tt> is called with a single argument, the <a class="reference internal" href="#Bcfg2.Server.FileMonitor.Event" title="Bcfg2.Server.FileMonitor.Event"><tt class="xref py py-class docutils literal"><span class="pre">Bcfg2.Server.FileMonitor.Event</span></tt></a> object to be handled.</p> <div class="section" id="assumptions"> <h3>Assumptions<a class="headerlink" href="#assumptions" title="Permalink to this headline">¶</a></h3> <p>The FAM API Bcfg2 uses is based on the API of SGI’s <a class="reference external" href="http://oss.sgi.com/projects/fam/">File Alteration Monitor</a> (also called “FAM”). Consequently, a few assumptions apply:</p> <ul class="simple"> <li>When a file or directory is monitored for changes, we call that a “monitor”; other backends my use the term “watch,” but for consistency we will use “monitor.”</li> <li>Monitors can be set on files or directories.</li> <li>A monitor set on a directory monitors all files within that directory, non-recursively. If the object that requested the monitor wishes to monitor recursively, it must implement that itself.</li> <li>Setting a monitor immediately produces “exists” and “endExist” events for the monitored file or directory and all files or directories contained within it (non-recursively).</li> <li>An event on a file or directory that is monitored directly yields the full path to the file or directory.</li> <li>An event on a file or directory that is <em>only</em> contained within a monitored directory yields the relative path to the file or directory within the monitored parent. It is the responsibility of the handler to reconstruct full paths as necessary.</li> <li>Each monitor that is set must have a unique ID that identifies it, in order to make it possible to reconstruct full paths as necessary. This ID will be stored in <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.handles" title="Bcfg2.Server.FileMonitor.FileMonitor.handles"><tt class="xref py py-attr docutils literal"><span class="pre">Bcfg2.Server.FileMonitor.FileMonitor.handles</span></tt></a>. It may be any hashable value; some FAM backends use monotonically increasing integers, while others use the path to the monitor.</li> </ul> </div> <div class="section" id="base-classes"> <h3>Base Classes<a class="headerlink" href="#base-classes" title="Permalink to this headline">¶</a></h3> <dl class="class"> <dt id="Bcfg2.Server.FileMonitor.Event"> <em class="property">class </em><tt class="descclassname">Bcfg2.Server.FileMonitor.</tt><tt class="descname">Event</tt><big>(</big><em>request_id</em>, <em>filename</em>, <em>code</em><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#Event"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.Event" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p> <p>Base class for all FAM events.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> <li><strong>request_id</strong> (<em>Varies</em>) – The handler ID of the monitor that produced this event</li> <li><strong>filename</strong> (<em>string</em>) – The file or directory on which the event was detected. An event on a file or directory that is monitored directly yields the full path to the file or directory; an event on a file or directory that is <em>only</em> contained within a monitored directory yields the relative path to the file or directory within the monitored parent.</li> <li><strong>code</strong> (<em>string</em>) – The <a class="reference internal" href="#development-fam-event-codes"><em>event code</em></a> produced. I.e., the type of event.</li> </ul> </td> </tr> </tbody> </table> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.Event.action"> <tt class="descname">action</tt><em class="property"> = None</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.Event.action" title="Permalink to this definition">¶</a></dt> <dd><p>The <a class="reference internal" href="#development-fam-event-codes"><em>event code</em></a> produced. I.e., the type of event.</p> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.Event.code2str"> <tt class="descname">code2str</tt><big>(</big><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#Event.code2str"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.Event.code2str" title="Permalink to this definition">¶</a></dt> <dd><p>Return the <a class="reference internal" href="#development-fam-event-codes"><em>event code</em></a> for this event. This is just an alias for <a class="reference internal" href="#Bcfg2.Server.FileMonitor.Event.action" title="Bcfg2.Server.FileMonitor.Event.action"><tt class="xref py py-attr docutils literal"><span class="pre">action</span></tt></a>.</p> </dd></dl> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.Event.filename"> <tt class="descname">filename</tt><em class="property"> = None</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.Event.filename" title="Permalink to this definition">¶</a></dt> <dd><p>The file or directory on which the event was detected. An event on a file or directory that is monitored directly yields the full path to the file or directory; an event on a file or directory that is <em>only</em> contained within a monitored directory yields the relative path to the file or directory within the monitored parent.</p> </dd></dl> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.Event.requestID"> <tt class="descname">requestID</tt><em class="property"> = None</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.Event.requestID" title="Permalink to this definition">¶</a></dt> <dd><p>The handler ID of the monitor that produced this event</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor"> <em class="property">class </em><tt class="descclassname">Bcfg2.Server.FileMonitor.</tt><tt class="descname">FileMonitor</tt><big>(</big><em>ignore=None</em>, <em>debug=False</em><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="plugins.html#Bcfg2.Server.Plugin.base.Debuggable" title="Bcfg2.Server.Plugin.base.Debuggable"><tt class="xref py py-class docutils literal"><span class="pre">Bcfg2.Server.Plugin.base.Debuggable</span></tt></a></p> <p>The base class that all FAM implementions must inherit.</p> <p>The simplest instance of a FileMonitor subclass needs only to add monitor objects to <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.handles" title="Bcfg2.Server.FileMonitor.FileMonitor.handles"><tt class="xref py py-attr docutils literal"><span class="pre">handles</span></tt></a> and received events to <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.events" title="Bcfg2.Server.FileMonitor.FileMonitor.events"><tt class="xref py py-attr docutils literal"><span class="pre">events</span></tt></a>; the basic interface will handle the rest.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> <li><strong>ignore</strong> (<em>list of strings (filename globs)</em>) – A list of filename globs describing events that should be ignored (i.e., not processed by any object)</li> <li><strong>debug</strong> (<em>bool</em>) – Produce debugging information about the events received and handled.</li> </ul> </td> </tr> </tbody> </table> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.__priority__"> <tt class="descname">__priority__</tt><em class="property"> = -1</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.__priority__" title="Permalink to this definition">¶</a></dt> <dd><p>The relative priority of this FAM backend. Better backends should have higher priorities.</p> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.AddMonitor"> <tt class="descname">AddMonitor</tt><big>(</big><em>path</em>, <em>obj</em>, <em>handleID=None</em><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.AddMonitor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.AddMonitor" title="Permalink to this definition">¶</a></dt> <dd><p>Monitor the specified path, alerting obj to events. This method must be overridden by a subclass of <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor" title="Bcfg2.Server.FileMonitor.FileMonitor"><tt class="xref py py-class docutils literal"><span class="pre">Bcfg2.Server.FileMonitor.FileMonitor</span></tt></a>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple"> <li><strong>path</strong> (<em>string</em>) – The path to monitor</li> <li><strong>obj</strong> (<em>Varies</em>) – The object whose <tt class="docutils literal"><span class="pre">HandleEvent</span></tt> method will be called when an event is produced.</li> <li><strong>handleID</strong> (<em>Varies</em>) – The handle ID to use for the monitor. This is useful when requests to add a monitor must be enqueued and the actual monitors added after <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.start" title="Bcfg2.Server.FileMonitor.FileMonitor.start"><tt class="xref py py-func docutils literal"><span class="pre">start()</span></tt></a> is called.</li> </ul> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">Varies - The handler ID for the newly created monitor</p> </td> </tr> </tbody> </table> </dd></dl> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.events"> <tt class="descname">events</tt><em class="property"> = None</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.events" title="Permalink to this definition">¶</a></dt> <dd><p>Queue of events to handle</p> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.fileno"> <tt class="descname">fileno</tt><big>(</big><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.fileno"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.fileno" title="Permalink to this definition">¶</a></dt> <dd><p>Get the file descriptor of the file monitor thread.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">int - The FD number</td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.get_event"> <tt class="descname">get_event</tt><big>(</big><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.get_event"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.get_event" title="Permalink to this definition">¶</a></dt> <dd><p>Get the oldest pending event in <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.events" title="Bcfg2.Server.FileMonitor.FileMonitor.events"><tt class="xref py py-attr docutils literal"><span class="pre">events</span></tt></a>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body"><a class="reference internal" href="#Bcfg2.Server.FileMonitor.Event" title="Bcfg2.Server.FileMonitor.Event"><tt class="xref py py-class docutils literal"><span class="pre">Bcfg2.Server.FileMonitor.Event</span></tt></a></td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.handle_event_set"> <tt class="descname">handle_event_set</tt><big>(</big><em>lock=None</em><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.handle_event_set"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.handle_event_set" title="Permalink to this definition">¶</a></dt> <dd><p>Handle all pending events.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>lock</strong> (<em>threading.Lock</em>) – A thread lock to use while handling events. If None, then no thread locking will be performed. This can possibly lead to race conditions in event handling, although it’s unlikely to cause any real problems.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.handle_events_in_interval"> <tt class="descname">handle_events_in_interval</tt><big>(</big><em>interval</em><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.handle_events_in_interval"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.handle_events_in_interval" title="Permalink to this definition">¶</a></dt> <dd><p>Handle events for the specified period of time (in seconds). This call will block for <tt class="docutils literal"><span class="pre">interval</span></tt> seconds and handle all events received during that period by calling <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.handle_event_set" title="Bcfg2.Server.FileMonitor.FileMonitor.handle_event_set"><tt class="xref py py-func docutils literal"><span class="pre">handle_event_set()</span></tt></a>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>interval</strong> (<em>int</em>) – The interval, in seconds, during which events should be handled. Any events that are already pending when <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.handle_events_in_interval" title="Bcfg2.Server.FileMonitor.FileMonitor.handle_events_in_interval"><tt class="xref py py-func docutils literal"><span class="pre">handle_events_in_interval()</span></tt></a> is called will also be handled.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.handle_one_event"> <tt class="descname">handle_one_event</tt><big>(</big><em>event</em><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.handle_one_event"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.handle_one_event" title="Permalink to this definition">¶</a></dt> <dd><p>Handle the given event by dispatching it to the object that handles it. This is only called by <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.handle_event_set" title="Bcfg2.Server.FileMonitor.FileMonitor.handle_event_set"><tt class="xref py py-func docutils literal"><span class="pre">handle_event_set()</span></tt></a>, so if a backend overrides that method it does not necessarily need to implement this function.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>event</strong> (<a class="reference internal" href="#Bcfg2.Server.FileMonitor.Event" title="Bcfg2.Server.FileMonitor.Event"><em>Bcfg2.Server.FileMonitor.Event</em></a>) – The event to handle.</td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">None</td> </tr> </tbody> </table> </dd></dl> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.handles"> <tt class="descname">handles</tt><em class="property"> = None</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.handles" title="Permalink to this definition">¶</a></dt> <dd><p>A dict that records which objects handle which events. Keys are monitor handle IDs and values are objects whose <tt class="docutils literal"><span class="pre">HandleEvent</span></tt> method will be called to handle an event</p> </dd></dl> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.ignore"> <tt class="descname">ignore</tt><em class="property"> = None</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.ignore" title="Permalink to this definition">¶</a></dt> <dd><p>List of filename globs to ignore events for. For events that include the full path, both the full path and the bare filename will be checked against <tt class="docutils literal"><span class="pre">ignore</span></tt>.</p> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.pending"> <tt class="descname">pending</tt><big>(</big><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.pending"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.pending" title="Permalink to this definition">¶</a></dt> <dd><p>Returns True if there are pending events (i.e., events in <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.events" title="Bcfg2.Server.FileMonitor.FileMonitor.events"><tt class="xref py py-attr docutils literal"><span class="pre">events</span></tt></a> that have not been processed), False otherwise.</p> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.should_ignore"> <tt class="descname">should_ignore</tt><big>(</big><em>event</em><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.should_ignore"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.should_ignore" title="Permalink to this definition">¶</a></dt> <dd><p>Returns True if an event should be ignored, False otherwise. For events that include the full path, both the full path and the bare filename will be checked against <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.ignore" title="Bcfg2.Server.FileMonitor.FileMonitor.ignore"><tt class="xref py py-attr docutils literal"><span class="pre">ignore</span></tt></a>. If the event is ignored, a debug message will be logged with <tt class="xref py py-func docutils literal"><span class="pre">debug_log()</span></tt>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>event</strong> (<a class="reference internal" href="#Bcfg2.Server.FileMonitor.Event" title="Bcfg2.Server.FileMonitor.Event"><em>Bcfg2.Server.FileMonitor.Event</em></a>) – Check if this event matches <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.ignore" title="Bcfg2.Server.FileMonitor.FileMonitor.ignore"><tt class="xref py py-attr docutils literal"><span class="pre">ignore</span></tt></a></td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">bool - Whether not to ignore the event</td> </tr> </tbody> </table> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.shutdown"> <tt class="descname">shutdown</tt><big>(</big><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.shutdown"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.shutdown" title="Permalink to this definition">¶</a></dt> <dd><p>Handle any tasks required to shut down the monitor.</p> </dd></dl> <dl class="method"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.start"> <tt class="descname">start</tt><big>(</big><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor.html#FileMonitor.start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.start" title="Permalink to this definition">¶</a></dt> <dd><p>Start threads or anything else that needs to be done after the server forks and daemonizes. Note that monitors may (and almost certainly will) be added before <tt class="docutils literal"><span class="pre">start()</span></tt> is called, so if a backend depends on being started to add monitors, those requests will need to be enqueued and added after <tt class="docutils literal"><span class="pre">start()</span></tt>. See <tt class="xref py py-class docutils literal"><span class="pre">Bcfg2.Server.FileMonitor.Inotify.Inotify</span></tt> for an example of this.</p> </dd></dl> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.FileMonitor.started"> <tt class="descname">started</tt><em class="property"> = None</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.FileMonitor.started" title="Permalink to this definition">¶</a></dt> <dd><p>Whether or not the FAM has been started. See <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.start" title="Bcfg2.Server.FileMonitor.FileMonitor.start"><tt class="xref py py-func docutils literal"><span class="pre">start()</span></tt></a>.</p> </dd></dl> </dd></dl> <dl class="data"> <dt id="Bcfg2.Server.FileMonitor.available"> <tt class="descclassname">Bcfg2.Server.FileMonitor.</tt><tt class="descname">available</tt><em class="property"> = {'default': <class 'Bcfg2.Server.FileMonitor.Pseudo.Pseudo'>, 'pseudo': <class 'Bcfg2.Server.FileMonitor.Pseudo.Pseudo'>}</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.available" title="Permalink to this definition">¶</a></dt> <dd><p>A dict of all available FAM backends. Keys are the human-readable names of the backends, which are used in bcfg2.conf to select a backend; values are the backend classes. In addition, the <tt class="docutils literal"><span class="pre">default</span></tt> key will be set to the best FAM backend as determined by <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor.__priority__" title="Bcfg2.Server.FileMonitor.FileMonitor.__priority__"><tt class="xref py py-attr docutils literal"><span class="pre">Bcfg2.Server.FileMonitor.FileMonitor.__priority__</span></tt></a></p> </dd></dl> </div> </div> <div class="section" id="existing-fam-backends"> <h2>Existing FAM Backends<a class="headerlink" href="#existing-fam-backends" title="Permalink to this headline">¶</a></h2> <div class="section" id="module-Bcfg2.Server.FileMonitor.Pseudo"> <span id="pseudo"></span><h3>Pseudo<a class="headerlink" href="#module-Bcfg2.Server.FileMonitor.Pseudo" title="Permalink to this headline">¶</a></h3> <p>Pseudo provides static monitor support for file alteration events. That is, it only produces “exists” and “endExist” events and does not monitor for ongoing changes.</p> <dl class="class"> <dt id="Bcfg2.Server.FileMonitor.Pseudo.Pseudo"> <em class="property">class </em><tt class="descclassname">Bcfg2.Server.FileMonitor.Pseudo.</tt><tt class="descname">Pseudo</tt><big>(</big><em>ignore=None</em>, <em>debug=False</em><big>)</big><a class="reference internal" href="../_modules/Bcfg2/Server/FileMonitor/Pseudo.html#Pseudo"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#Bcfg2.Server.FileMonitor.Pseudo.Pseudo" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="#Bcfg2.Server.FileMonitor.FileMonitor" title="Bcfg2.Server.FileMonitor.FileMonitor"><tt class="xref py py-class docutils literal"><span class="pre">Bcfg2.Server.FileMonitor.FileMonitor</span></tt></a></p> <p>File monitor that only produces events on server startup and doesn’t actually monitor for ongoing changes at all.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple"> <li><strong>ignore</strong> (<em>list of strings (filename globs)</em>) – A list of filename globs describing events that should be ignored (i.e., not processed by any object)</li> <li><strong>debug</strong> (<em>bool</em>) – Produce debugging information about the events received and handled.</li> </ul> </td> </tr> </tbody> </table> <dl class="attribute"> <dt id="Bcfg2.Server.FileMonitor.Pseudo.Pseudo.__priority__"> <tt class="descname">__priority__</tt><em class="property"> = 1</em><a class="headerlink" href="#Bcfg2.Server.FileMonitor.Pseudo.Pseudo.__priority__" title="Permalink to this definition">¶</a></dt> <dd><p>The <tt class="docutils literal"><span class="pre">Pseudo</span></tt> monitor should only be used if no other FAM backends are available.</p> </dd></dl> </dd></dl> </div> <div class="section" id="fam"> <h3>Fam<a class="headerlink" href="#fam" title="Permalink to this headline">¶</a></h3> </div> <div class="section" id="gamin"> <h3>Gamin<a class="headerlink" href="#gamin" title="Permalink to this headline">¶</a></h3> </div> <div class="section" id="inotify"> <h3>Inotify<a class="headerlink" href="#inotify" title="Permalink to this headline">¶</a></h3> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">File Monitor Development</a><ul> <li><a class="reference internal" href="#event-codes">Event Codes</a></li> <li><a class="reference internal" href="#module-Bcfg2.Server.FileMonitor">Basics</a><ul> <li><a class="reference internal" href="#assumptions">Assumptions</a></li> <li><a class="reference internal" href="#base-classes">Base Classes</a></li> </ul> </li> <li><a class="reference internal" href="#existing-fam-backends">Existing FAM Backends</a><ul> <li><a class="reference internal" href="#module-Bcfg2.Server.FileMonitor.Pseudo">Pseudo</a></li> <li><a class="reference internal" href="#fam">Fam</a></li> <li><a class="reference internal" href="#gamin">Gamin</a></li> <li><a class="reference internal" href="#inotify">Inotify</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="documentation.html" title="previous chapter">Documentation</a></p> <h4>Next topic</h4> <p class="topless"><a href="packages.html" title="next chapter">Developing for Packages</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../_sources/development/fam.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="packages.html" title="Developing for Packages" >next</a> |</li> <li class="right" > <a href="documentation.html" title="Documentation" >previous</a> |</li> <li><a href="../index.html">home</a> | </li> <!--<li><a href="../search.html">search</a> | </li>--> <li><a href="../help/index.html">help</a> | </li> <li><a href="../contents.html">documentation </a> »</li> <li><a href="../contents.html" >Bcfg2 documentation 1.3.0</a> »</li> <li><a href="index.html" >Bcfg2 Development</a> »</li> </ul> </div> <div class="footer"> © Copyright 2009-2013, Narayan Desai. Last updated on Mar 20, 2013. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>