Ejemplo n.º 1
0
    def ip_listen_address(self):
        """Get ip_listen_address.

        Args:
            None

        Returns:
            result: result

        """
        # Get result
        key = PATTOO_API_AGENT_NAME
        sub_key = 'ip_listen_address'
        result = search(
            key, sub_key, self._server_yaml_configuration, die=False)

        # Default to 0.0.0.0
        if result is None:
            result = '0.0.0.0'
        return result
Ejemplo n.º 2
0
    def db_username(self):
        """Get db_username.

        Args:
            None

        Returns:
            result: result

        """
        # Initialize key variables
        key = 'pattoo_db'
        sub_key = 'db_username'

        # Process configuration
        result = configuration.search(key, sub_key,
                                      self._server_yaml_configuration)

        # Get result
        return result
Ejemplo n.º 3
0
def _polling_interval(key, _configuration):
    """Get targets.

    Args:
        None

    Returns:
        result: result

    """
    # Get result
    sub_key = 'polling_interval'
    value = configuration.search(key, sub_key, _configuration, die=False)

    # Default to 300
    if bool(value) is False:
        result = 300
    else:
        result = abs(int(value))
    return result
Ejemplo n.º 4
0
    def api_email_address(self):
        """GET API email address from yaml file.

        Args:
            None

        Returns:
            email (str): Email address of API
        """
        # Initialize key variables
        key = PATTOO_API_AGENT_NAME
        sub_key = 'api_encryption_email'

        result = search(key,
                        sub_key,
                        self._server_yaml_configuration,
                        die=False)
        if result is None:
            result = '*****@*****.**'
        return result
Ejemplo n.º 5
0
    def agent_ip_address(self):
        """Get list polling target information in configuration file..

        Args:
            None

        Returns:
            result: IP address

        """
        # Initialize key variables
        result = []

        # Get configuration snippet
        key = PATTOO_AGENT_BACNETIPD
        sub_key = 'agent_ip_address'
        result = configuration.search(key,
                                      sub_key,
                                      self._agent_config,
                                      die=True)
        return result
Ejemplo n.º 6
0
    def multiprocessing(self):
        """Get multiprocessing.

        Args:
            None

        Returns:
            result: result

        """
        # Get result
        key = PATTOO_INGESTERD_NAME
        sub_key = 'multiprocessing'
        _result = search(
            key, sub_key, self._server_yaml_configuration, die=False)

        # Return
        if _result is None:
            result = True
        else:
            result = bool(_result)
        return result
Ejemplo n.º 7
0
    def ip_bind_port(self):
        """Get ip_bind_port.

        Args:
            None

        Returns:
            result: result

        """
        # Initialize key variables
        key = PATTOO_API_AGENT_NAME
        sub_key = 'ip_bind_port'

        # Get result
        intermediate = search(
            key, sub_key, self._server_yaml_configuration, die=False)
        if intermediate is None:
            result = 20202
        else:
            result = int(intermediate)
        return result
Ejemplo n.º 8
0
    def db_max_overflow(self):
        """Get db_max_overflow.

        Args:
            None

        Returns:
            result: result

        """
        # Get result
        key = 'pattoo_db'
        sub_key = 'db_max_overflow'
        intermediate = search(
            key, sub_key, self._server_yaml_configuration, die=False)

        # Set default
        if intermediate is None:
            result = 10
        else:
            result = int(intermediate)
        return result
Ejemplo n.º 9
0
    def ip_listen_address(self):
        """Get ip_listen_address.

        Args:
            None

        Returns:
            result: result

        """
        # Get result
        key = PATTOO_AGENT_OS_SPOKED
        sub_key = 'ip_listen_address'
        result = configuration.search(key,
                                      sub_key,
                                      self._agent_config,
                                      die=False)

        # Default to 0.0.0.0
        if result is None:
            result = '0.0.0.0'
        return result
Ejemplo n.º 10
0
    def db_password(self):
        """Get db_password.

        Args:
            None

        Returns:
            result: result

        """
        # Initialize key variables
        key = 'pattoo_db'
        sub_key = 'db_password'

        # Process configuration
        if 'PATTOO_TRAVIS' in os.environ:
            result = ''
        else:
            result = search(key, sub_key, self._server_yaml_configuration)

        # Get result
        return result
Ejemplo n.º 11
0
    def target_polling_points(self):
        """Get list polling target information in configuration file.

        Args:
            group: Group name to filter results by

        Returns:
            result: List of IPTargetPollingPoints objects

        """
        # Initialize key variables
        result = []
        datapoint_key = 'points'

        # Get configuration snippet
        key = PATTOO_AGENT_BACNETIPD
        sub_key = 'polling_groups'
        groups = configuration.search(key,
                                      sub_key,
                                      self._agent_config,
                                      die=True)

        # Create snmp objects
        for group in groups:
            # Ignore bad values
            if isinstance(group, dict) is False:
                continue

            # Process data
            if 'ip_targets' and datapoint_key in group:
                for ip_target in group['ip_targets']:
                    poll_targets = configuration.get_polling_points(
                        group[datapoint_key])
                    dpt = IPTargetPollingPoints(ip_target)
                    dpt.add(poll_targets)
                    if dpt.valid is True:
                        result.append(dpt)
        return result
Ejemplo n.º 12
0
    def jwt_secret_key(self):
        """Get jwt_secret_key.

        Args:
            None

        Returns:
            result: result

        """
        # Initialize key variables
        key = PATTOO_API_WEB_NAME
        sub_key = 'jwt_secret_key'

        # Process configuration
        result = search(key, sub_key, self._server_yaml_configuration)

        # Ensures that jwt_secret_key is set
        if (result is None) or result.strip(' ') == '':
            raise Exception('Plese set JWT SECRET KEY in config file')

        # Get result
        return result
Ejemplo n.º 13
0
def _snmpvariables(key, _configuration):
    """Get list of dicts of SNMP information in configuration file.

    Args:
        group: Group name to filter results by

    Returns:
        result: List of SNMPVariable items

    """
    # Initialize key variables
    result = []

    # Get configuration snippet
    sub_key = 'auth_groups'
    sub_config = configuration.search(key, sub_key, _configuration, die=True)

    # Create snmp objects
    groups = _validate_snmp(sub_config)
    for group in groups:
        # Save the authentication parameters
        snmpauth = SNMPAuth(version=group.get('snmp_version', 2),
                            community=group.get('snmp_community', 'public'),
                            port=group.get('snmp_port', 161),
                            secname=group.get('snmp_secname'),
                            authprotocol=group.get('snmp_authprotocol'),
                            authpassword=group.get('snmp_authpassword'),
                            privprotocol=group.get('snmp_privprotocol'),
                            privpassword=group.get('snmp_privpassword'))

        # Create the SNMPVariableList
        snmpvariablelist = SNMPVariableList(snmpauth, group['ip_targets'])
        snmpvariables = snmpvariablelist.snmpvariables
        result.extend(snmpvariables)

    # Return
    return result
Ejemplo n.º 14
0
    def web_api_ip_bind_port(self):
        """Get web_api_ip_bind_port.

        Args:
            None

        Returns:
            result: result

        """
        # Initialize key variables
        key = 'pattoo_web_api'
        sub_key = 'ip_bind_port'

        # Get result
        intermediate = search(key,
                              sub_key,
                              self._base_yaml_configuration,
                              die=False)
        if intermediate is None:
            result = 20202
        else:
            result = int(intermediate)
        return result
Ejemplo n.º 15
0
    def polling_interval(self):
        """Get targets.

        Args:
            None

        Returns:
            result: result

        """
        # Get result
        key = PATTOO_AGENT_BACNETIPD
        sub_key = 'polling_interval'
        intermediate = configuration.search(key,
                                            sub_key,
                                            self._agent_config,
                                            die=False)

        # Default to 300
        if bool(intermediate) is False:
            result = 300
        else:
            result = abs(int(intermediate))
        return result
Ejemplo n.º 16
0
    def ip_bind_port(self):
        """Get ip_bind_port.

        Args:
            None

        Returns:
            result: result

        """
        # Get result
        key = PATTOO_AGENT_OS_SPOKED
        sub_key = 'ip_bind_port'
        intermediate = configuration.search(key,
                                            sub_key,
                                            self._agent_config,
                                            die=False)

        # Default to 6000
        if intermediate is None:
            result = 5000
        else:
            result = int(intermediate)
        return result