コード例 #1
0
def start_watcher_thread():
    # Create monitor object that encapsulates monitoring activities
    watcher = watcherutil.Watcher(hutil.error, hutil.log, log_to_console=True)
    # Create an IMDS data logger and set it to the monitor object
    imds_logger = ImdsLogger(hutil.get_name(), hutil.get_extension_version(),
                             waagent.WALAEventOperation.HeartBeat, waagent.AddExtensionEvent)
    watcher.set_imds_logger(imds_logger)
    # Start a thread to perform periodic monitoring activity (e.g., /etc/fstab watcher, IMDS data logging)
    threadObj = threading.Thread(target=watcher.watch)
    threadObj.daemon = True
    threadObj.start()
コード例 #2
0
    def setUp(self):
        self._watcher = watcherutil.Watcher(sys.stderr, sys.stdout)

        try:
            os.mkdir(self._datapath)
        except OSError as e:
            if (e.errno != errno.EEXIST):
                raise
            pass

        # mount an overlay so that we can make changes to /etc/fstab
        subprocess.call(['sudo', 
            'mount', '-t', 'overlayfs', 'overlayfs',
            '-olowerdir=/etc,upperdir=' + self._datapath,
            '/etc'])
        pass