Exemple #1
0
        self.logger.debug("removing BIRD control socket directory")
        if not self.dry_run:
            util.directory_remove(self.bird_ctl_dir)

        self.logger.debug("removing BIRD configuration directory")
        if not self.dry_run:
            util.directory_remove(self.bird_conf_dir)

        self.logger.debug("removing BIRD logging directory")
        if not self.dry_run:
            util.directory_remove(self.bird_log_dir)

        self.logger.debug("removing BIRD PID file directory")
        if not self.dry_run:
            util.directory_remove(self.bird_pid_dir)

        self.logger.info("finished stopping BGP process")

        self.set_stopped()

Worker.register(Process)


def create(daemon, overlay):
    '''
    Create a BGP process object.
    '''

    return Process(daemon, overlay)
Exemple #2
0
    def log(self, lvl, msg, *args, **kwargs):
        '''
        Log output of a given level to the logger.
        '''

        if not self.is_started():
            raise NotYetStartedError(self)

        self.logger.log(lvl, msg, *args, **kwargs)


    def exception(self, msg, *args, **kwargs):
        '''
        Exception output to the logger.
        '''

        if not self.is_started():
            raise NotYetStartedError(self)

        self.logger.exception(msg, *args, **kwargs)

Worker.register(Logger)


def create(log, log_level, logger_name, logger_section=None):
    '''
    Create a logger.
    '''

    return Logger(log, log_level, logger_name, logger_section)
Exemple #3
0
        if not self.is_started():
            raise NotYetStartedError(self)

        if self.dry_run:
            # Create a dummy NSPopen object with a
            # stub release() method, to be API compatible
            # with the real deal.
            class NSPopen(subprocess.Popen):
                def release(self):
                    pass

            return NSPopen(
                [util.command_path("true")],
                stdout=subprocess.DEVNULL,
                stderr=subprocess.DEVNULL,
            )
        else:
            return pyroute2.netns.process.proxy.NSPopen(self.name, *args, **kwargs)

Worker.register(NetNS)


def get(dry_run, logger, name):
    '''
    Get the network namespace runtime state for the given name, creating it
    if it doesn't exist.
    '''

    return NetNS(dry_run, logger, name)
Exemple #4
0
    def remove(self):
        '''
        Remove the overlay runtime state.
        '''

        if not self.enabled:
            return

        self.set_removing()

        self.logger.stop()

        self.set_removed()

Worker.register(Overlay)


def read(log, log_level, conf=None, config=None):
    '''
    Parse a configuration, file or dictionary, and return an overlay object.
    '''

    # If specified, read the overlay configuration file.
    if conf:
        config = util.config(conf)
    elif config:
        config = copy.deepcopy(config)
    else:
        raise NoOverlayConfigError()