def test_add(self): def target(p): pass path = '/tmp/file_' + chr(255) monitor = PathMonitor() monitor.add(path, target)
def plugin_loaded(): """ Initialize the plugin. Called (once) immediately after the plugin is loaded. - setup path monitoring. - validate registration. If registered: - setup plugin configuration. """ global path_monitor path = ConsumerIdentity.certpath() path_monitor = PathMonitor() path_monitor.add(path, certificate_changed) path_monitor.start() while True: try: validate_registration() if registered: update_settings() # DONE break except Exception as e: log.warn(str(e)) sleep(60)
def plugin_loaded(): """ Initialize the plugin. Called (once) immediately after the plugin is loaded. - setup path monitoring. - validate registration. If registered: - setup plugin configuration. """ global path_monitor path = ConsumerIdentity.certpath() path_monitor = PathMonitor() path_monitor.add(path, certificate_changed) path_monitor.add(REPOSITORY_PATH, send_enabled_report) path_monitor.start() while True: try: validate_registration() if registered: update_settings() # DONE break except Exception as e: log.warn(str(e)) sleep(60)
class RegistrationMonitor: """ Monitor the registration (consumer) certificate for changes. When a change is detected, the bus attachment is changed as appropriate. When removed, we set our UUID to None which will cause us to detach. When changed, our UUID is changed which causes a detach/attach to be sure we are attached with the correct UUID. @cvar pmon: A path monitor object. :type pmon: PathMonitor """ pmon = PathMonitor() @classmethod @action(days=0x8E94) def init(cls): """ Start path monitor to track changes in the pulp identity certificate. """ path = cfg.rest.clientcert cls.pmon.add(path, cls.changed) cls.pmon.start() @classmethod def changed(cls, path): """ A change in the pulp certificate has been detected. When deleted: disconnect from qpid by setting the UUID to None. When added/updated: reconnect to qpid. :param path: The changed file (ignored). :type path: str """ log.info('changed: %s', path) bundle = ConsumerX509Bundle() consumer_id = bundle.cn() plugin.setuuid(consumer_id)
from pulp.agent.lib.conduit import Conduit as HandlerConduit from pulp.bindings.server import PulpConnection from pulp.bindings.bindings import Bindings from pulp.bindings.exceptions import NotFoundException from pulp.client.consumer.config import read_config log = getLogger(__name__) # pulp consumer configuration # the graph (cfg) is provided for syntactic convenience pulp_conf = read_config() cfg = pulp_conf.graph() # monitor file paths path_monitor = PathMonitor() # this plugin object plugin = Plugin.find(__name__) # registration status registered = False class ValidateRegistrationFailed(Exception): """ The REST call to the server to validate registration failed. """ pass
def test_add(self): def target(p): pass path = '/tmp/file_' + chr(255) monitor = PathMonitor() monitor.add(path, target)