示例#1
0
    def __init__(self, root_directory):
        """Function for intializing the class.

        Args:
            root_directory: Root configuration directory

        Returns:
            None

        """
        # Update the configuration directory
        common_directory = ('%s/common') % (root_directory)
        directories = [common_directory]

        # Return
        self.config_dict = jm_general.read_yaml_files(directories)
示例#2
0
def insert_oids(directory=None):
    """Update the database with certain key data.

    Args:
        directory: Directory to add to list

    Returns:
        None

    """
    # Initialize key variables
    root_dir = jm_general.root_directory()
    oids_directories = [('%s/infoset/metadata/oids') % (root_dir)]

    # Create a list of existing agent labels, that are unique by definition
    agent_labels = []
    all_oids = db_oid.all_oids()
    for item in all_oids:
        agent_labels.append(item['agent_label'])

    # Add directory to the search path if required
    if directory is not None:
        if os.path.isdir(directory) is True:
            oids_directories.extend(directory)

    # Read in the oid data
    oids_yaml = jm_general.read_yaml_files(oids_directories)

    # Get a list of all labels
    for item in oids_yaml:
        oid_values = item['oid_values']
        oid_labels = item['oid_labels']
        agent_label = item['agent_label']
        base_type = item['base_type']
        multiplier = item['multiplier']

        if db_oid.oid_values_exists(oid_values) is False:
            if agent_label not in agent_labels:
                # Prepare SQL query to read a record from the database.
                record = OID(
                    oid_values=jm_general.encode(oid_values),
                    oid_labels=jm_general.encode(oid_labels),
                    agent_label=jm_general.encode(agent_label),
                    base_type=base_type,
                    multiplier=multiplier)
                database = db.Database()
                database.add(record, 1091)
示例#3
0
    def __init__(self):
        """Function for intializing the class.

        Args:
            None

        Returns:
            None

        """
        # Update the configuration directory
        # 'INFOSET_CONFIGDIR' is used for unittesting
        if 'INFOSET_CONFIGDIR' in os.environ:
            config_directory = os.environ['INFOSET_CONFIGDIR']
        else:
            config_directory = ('%s/etc') % (jm_general.root_directory())
        directories = [config_directory]

        # Return
        self.config_dict = jm_general.read_yaml_files(directories)
示例#4
0
    def __init__(self, agent_name):
        """Function for intializing the class.

        Args:
            agent_name: Name of agent used to get descriptions
                from configuration subdirectory

        Returns:
            None

        """
        # Update the configuration directory
        # 'INFOSET_CONFIGDIR' is used for unittesting
        if 'INFOSET_CONFIGDIR' in os.environ:
            config_directory = os.environ['INFOSET_CONFIGDIR']
        else:
            config_directory = ('%s/etc') % (jm_general.root_directory())
        directories = [config_directory]

        # Return
        self.config_dict = jm_general.read_yaml_files(directories)
        self.name = agent_name
示例#5
0
    def __init__(self, root_directory, agent_name):
        """Function for intializing the class.

        Args:
            root_directory: Root configuration directory
            agent_name: Name of agent used to get descriptions
                from configuration subdirectory

        Returns:
            None

        """
        # Update the configuration directory
        agent_directory = ('%s/agents') % (root_directory)
        descriptions_directory = ('%s/%s') % (agent_directory, agent_name)
        common_directory = ('%s/common') % (root_directory)
        directories = [
            agent_directory, descriptions_directory, common_directory]

        # Return
        self.config_dict = jm_general.read_yaml_files(directories)
        self.name = agent_name