Esempio n. 1
0
    def __init__(self,
                 spec_file_name,
                 config_handler,
                 command_handler,
                 cc_session=None,
                 handle_logging_config=True,
                 socket_file=None):
        """Initialize a ModuleCCSession. This does *NOT* send the
           specification and request the configuration yet. Use start()
           for that once the ModuleCCSession has been initialized.

           specfile_name is the path to the specification file.

           config_handler and command_handler are callback functions,
           see set_config_handler and set_command_handler for more
           information on their signatures.

           cc_session can be used to pass in an existing CCSession,
           if it is None, one will be set up. This is mainly intended
           for testing purposes.

           handle_logging_config: if True, the module session will
           automatically handle logging configuration for the module;
           it will read the system-wide Logging configuration and call
           the logger manager to apply it. It will also inform the
           logger manager when the logging configuration gets updated.
           The module does not need to do anything except initializing
           its loggers, and provide log messages. Defaults to true.

           socket_file: If cc_session was none, this optional argument
           specifies which socket file to use to connect to msgq. It
           will be overridden by the environment variable
           MSGQ_SOCKET_FILE. If none, and no environment variable is
           set, it will use the system default.
        """
        module_spec = isc.config.module_spec_from_file(spec_file_name)
        ConfigData.__init__(self, module_spec)

        self._module_name = module_spec.get_module_name()

        self.set_config_handler(config_handler)
        self.set_command_handler(command_handler)

        if not cc_session:
            self._session = Session(socket_file)
        else:
            self._session = cc_session
        self._session.group_subscribe(self._module_name, CC_INSTANCE_WILDCARD)

        self._remote_module_configs = {}
        self._remote_module_callbacks = {}

        self._notification_callbacks = {}
        self._last_notif_id = 0

        if handle_logging_config:
            self.add_remote_config(
                path_search('logging.spec', bind10_config.PLUGIN_PATHS),
                default_logconfig_handler)
Esempio n. 2
0
    def __init__(self, spec_file_name, config_handler, command_handler,
                 cc_session=None, handle_logging_config=True,
                 socket_file = None):
        """Initialize a ModuleCCSession. This does *NOT* send the
           specification and request the configuration yet. Use start()
           for that once the ModuleCCSession has been initialized.

           specfile_name is the path to the specification file.

           config_handler and command_handler are callback functions,
           see set_config_handler and set_command_handler for more
           information on their signatures.

           cc_session can be used to pass in an existing CCSession,
           if it is None, one will be set up. This is mainly intended
           for testing purposes.

           handle_logging_config: if True, the module session will
           automatically handle logging configuration for the module;
           it will read the system-wide Logging configuration and call
           the logger manager to apply it. It will also inform the
           logger manager when the logging configuration gets updated.
           The module does not need to do anything except initializing
           its loggers, and provide log messages. Defaults to true.

           socket_file: If cc_session was none, this optional argument
           specifies which socket file to use to connect to msgq. It
           will be overridden by the environment variable
           MSGQ_SOCKET_FILE. If none, and no environment variable is
           set, it will use the system default.
        """
        module_spec = isc.config.module_spec_from_file(spec_file_name)
        ConfigData.__init__(self, module_spec)

        self._module_name = module_spec.get_module_name()

        self.set_config_handler(config_handler)
        self.set_command_handler(command_handler)

        if not cc_session:
            self._session = Session(socket_file)
        else:
            self._session = cc_session
        self._session.group_subscribe(self._module_name, CC_INSTANCE_WILDCARD)

        self._remote_module_configs = {}
        self._remote_module_callbacks = {}

        self._notification_callbacks = {}
        self._last_notif_id = 0

        if handle_logging_config:
            self.add_remote_config(path_search('logging.spec', bind10_config.PLUGIN_PATHS),
                                   default_logconfig_handler)
Esempio n. 3
0
 def __init__(self, data_path, database_filename, session=None,
              clear_config=False):
     """Initialize the configuration manager. The data_path string
        is the path to the directory where the configuration is
        stored (in <data_path>/<database_filename> or in
        <database_filename>, if it is absolute). The database_filename
        is the config file to load. Session is an optional
        cc-channel session. If this is not given, a new one is
        created. If clear_config is True, the configuration file is
        renamed and a new one is created."""
     self.data_path = data_path
     self.database_filename = database_filename
     self.module_specs = {}
     # Virtual modules are the ones which have no process running. The
     # checking of validity is done by functions presented here instead
     # of some other process
     self.virtual_modules = {}
     self.config = ConfigManagerData(data_path, database_filename)
     if clear_config:
         self.config.rename_config_file()
     if session:
         self.cc = session
     else:
         self.cc = isc.cc.Session()
     self.cc.group_subscribe("ConfigManager")
     self.cc.group_subscribe("Boss", "ConfigManager")
     self.running = False
     # As a core module, CfgMgr is different than other modules,
     # as it does not use a ModuleCCSession, and hence needs
     # to handle logging config on its own
     self.log_config_data = config_data.ConfigData(
         isc.config.module_spec_from_file(
             path_search('logging.spec',
             bind10_config.PLUGIN_PATHS)))
     # store the logging 'module' name for easier reference
     self.log_module_name = self.log_config_data.get_module_spec().get_module_name()
Esempio n. 4
0
 def __init__(self, data_path, database_filename, session=None,
              clear_config=False):
     """Initialize the configuration manager. The data_path string
        is the path to the directory where the configuration is
        stored (in <data_path>/<database_filename> or in
        <database_filename>, if it is absolute). The database_filename
        is the config file to load. Session is an optional
        cc-channel session. If this is not given, a new one is
        created. If clear_config is True, the configuration file is
        renamed and a new one is created."""
     self.data_path = data_path
     self.database_filename = database_filename
     self.module_specs = {}
     # Virtual modules are the ones which have no process running. The
     # checking of validity is done by functions presented here instead
     # of some other process
     self.virtual_modules = {}
     self.config = ConfigManagerData(data_path, database_filename)
     if clear_config:
         self.config.rename_config_file()
     if session:
         self.cc = session
     else:
         self.cc = isc.cc.Session()
     self.cc.group_subscribe("ConfigManager")
     self.cc.group_subscribe("Init", "ConfigManager")
     self.running = False
     # As a core module, CfgMgr is different than other modules,
     # as it does not use a ModuleCCSession, and hence needs
     # to handle logging config on its own
     self.log_config_data = config_data.ConfigData(
         isc.config.module_spec_from_file(
             path_search('logging.spec',
             bind10_config.PLUGIN_PATHS)))
     # store the logging 'module' name for easier reference
     self.log_module_name = self.log_config_data.get_module_spec().get_module_name()
Esempio n. 5
0
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# This is the configuration plugin for logging options
# The name is 'b10logging' because logging.py is an existing module
#
# For a technical background, see
# http://bind10.isc.org/wiki/LoggingCppApiDesign
#

from isc.config.module_spec import module_spec_from_file
from isc.util.file import path_search
from bind10_config import PLUGIN_PATHS
spec = module_spec_from_file(path_search('logging.spec', PLUGIN_PATHS))

ALLOWED_SEVERITIES = [ 'default',
                       'debug',
                       'info',
                       'warn',
                       'error',
                       'fatal',
                       'none' ]
ALLOWED_DESTINATIONS = [ 'console',
                         'file',
                         'syslog' ]
ALLOWED_STREAMS = [ 'stdout',
                    'stderr' ]

def check(config):
Esempio n. 6
0
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

from isc.config.module_spec import module_spec_from_file
from isc.util.file import path_search
from bind10_config import PLUGIN_PATHS
import isc.dns
import isc.datasrc
import json
import os.path
import copy

spec = module_spec_from_file(path_search('datasrc.spec', PLUGIN_PATHS))

def check(config):
    """
    Check the configuration.
    """
    # Check the data layout first
    errors=[]
    if not spec.validate_config(False, config, errors):
        return ' '.join(errors)

    classes = config.get('classes')
    # Nothing passed here
    if classes is None:
        return None
Esempio n. 7
0
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# This is the configuration plugin for logging options
# The name is 'b10logging' because logging.py is an existing module
#
# For a technical background, see
# http://bind10.isc.org/wiki/LoggingCppApiDesign
#

from isc.config.module_spec import module_spec_from_file
from isc.util.file import path_search
from bind10_config import PLUGIN_PATHS
spec = module_spec_from_file(path_search('logging.spec', PLUGIN_PATHS))

ALLOWED_SEVERITIES = [
    'default', 'debug', 'info', 'warn', 'error', 'fatal', 'none'
]
ALLOWED_DESTINATIONS = ['console', 'file', 'syslog']
ALLOWED_STREAMS = ['stdout', 'stderr']


def check(config):
    # Check the data layout first
    errors = []
    if not spec.validate_config(False, config, errors):
        return ' '.join(errors)
    # The 'layout' is ok, now check for specific values
    if 'loggers' in config:
Esempio n. 8
0
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# This is the plugin for tsig_keys configuration section. The TSIG keyring
# lives there (eg. all the shared secrets, with some exceptions where there
# are some TSIG keys elsewhere, but these should be removed soon). We do
# sanity checking of user configuration here, simply by trying to construct
# all the keys here.

from isc.config.module_spec import module_spec_from_file
from isc.util.file import path_search
from pydnspp import TSIGKey, InvalidParameter
from bind10_config import PLUGIN_PATHS
spec = module_spec_from_file(path_search('tsig_keys.spec', PLUGIN_PATHS))


def check(config):
    # Check the data layout first
    errors = []
    if not spec.validate_config(False, config, errors):
        return ' '.join(errors)
    # Get the list of keys, if any
    keys = config.get('keys', [])
    # Run through them, check they can be constructed and there are no
    # duplicates
    keyNames = set()
    for key in keys:
        try:
            name = str(TSIGKey(key).get_key_name())
Esempio n. 9
0
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

# This is the plugin for tsig_keys configuration section. The TSIG keyring
# lives there (eg. all the shared secrets, with some exceptions where there
# are some TSIG keys elsewhere, but these should be removed soon). We do
# sanity checking of user configuration here, simply by trying to construct
# all the keys here.

from isc.config.module_spec import module_spec_from_file
from isc.util.file import path_search
from pydnspp import TSIGKey, InvalidParameter
from bind10_config import PLUGIN_PATHS
spec = module_spec_from_file(path_search('tsig_keys.spec', PLUGIN_PATHS))

def check(config):
    # Check the data layout first
    errors=[]
    if not spec.validate_config(False, config, errors):
        return ' '.join(errors)
    # Get the list of keys, if any
    keys = config.get('keys', [])
    # Run through them, check they can be constructed and there are no
    # duplicates
    keyNames = set()
    for key in keys:
        try:
            name = str(TSIGKey(key).get_key_name())
        except InvalidParameter as e: