diff options
author | Remi Collet <fedora@famillecollet.com> | 2010-12-30 10:52:20 +0100 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2010-12-30 10:52:20 +0100 |
commit | 207af2b6a0b357e7b0ba0ed3046bac5e3dafc9c4 (patch) | |
tree | 62594e1c049d154994e5d04ef0921d432d58292d /fusioninventory-agent.py | |
parent | 327080382391f09d33baf4a4b36ea7b6b5b2b5f7 (diff) |
add fusioninventory-agent-yum-plugin
Diffstat (limited to 'fusioninventory-agent.py')
-rw-r--r-- | fusioninventory-agent.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/fusioninventory-agent.py b/fusioninventory-agent.py new file mode 100644 index 0000000..08081d4 --- /dev/null +++ b/fusioninventory-agent.py @@ -0,0 +1,39 @@ +# A plugin for yum which notifies the FusionInventory Agent to send a inventory +# +# Copyright (c) 2010 Remi Collet <Fedora@FamilleCollet.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# version 0.1 + +from yum.plugins import TYPE_CORE +from urlgrabber.grabber import urlread +from urlgrabber.grabber import URLGrabError + +requires_api_version = '2.5' +plugin_type = TYPE_CORE + +def posttrans_hook(conduit): + """ + Tell FusionInventory Agent to send an inventory + Run only after an rpm transaction. + """ + try: + res = urlread('http://localhost:62354/now', 2048) + except URLGrabError, e: + conduit.info(4, "Unable to send connect to FusionInventory service") + conduit.info(6, "%s" %(e,)) + return + if res and 'Done.' in res: + conduit.info(2, "FusionInventory agent asked to run an inventory") + else: + conduit.info(4, "Bad anwser from FusionInventory agent") + |