コード例 #1
0
ファイル: test_cli_set.py プロジェクト: gill876/pattoo
    def test__process_language(self):
        "Tests _process_language"
        current_name = 'Spanish'
        expected = {'code': 'cn', 'name': 'Chinese'}
        cmd_args = ['set', 'language', '--code', expected['code'], '--name',
                    expected['name']]

        # Inserting test language entry into Language table
        language.insert_row(expected['code'], current_name)

        # Asserting that updates were made in Language table
        self.set_fn(current_name, expected, cmd_args, Language,
                    _process_language, False)

        # Asserting that if a language is not found an appropirate log message
        # is shown
        args = self.parser.parse_args([])
        args.code = 'random_code'
        expected_included_str = 'Language code "{}" not found'.format(args.code)

        with self.assertLogs(self.log_obj.stdout(), level='INFO') as cm:
            print('Exception thrown testing test__process_language: ')
            with self.assertRaises(SystemExit):
                _process_language(args)
        self.assertIn(expected_included_str, cm.output[0])
コード例 #2
0
ファイル: test_cli_set.py プロジェクト: gill876/pattoo
    def setUpClass(self):
        """Setup tables in pattoo_unittest database"""

        # Setting up parsing for cli_set module
        subparser = self.parser.add_subparsers(dest='action')
        _Set(subparser)

        # Logger
        self.log_obj = log._GetLog()

        # Skips class setup if using travis-ci
        if not self.travis_ci:
            # Create test tables for Import test
            self.tables = [PairXlateGroup.__table__, Language.__table__]

            # Returns engine object
            self.engine = create_tables(self.tables)

            # Creating test data in Language and PairXlateGroup tables
            language.insert_row('en', 'English')
            pair_xlate_group.insert_row('Pattoo Default')

        # Getting number of entries in PairXlateGroup table
        self.idx_pair_xlate_group_count = 1
        with db.db_query(30004) as session:
            result = session.query(PairXlateGroup)
            self.idx_pair_xlate_group_count += result.count()
コード例 #3
0
ファイル: test_language.py プロジェクト: bonnie-23/pattoo
    def test_update_name(self):
        """Testing method / function update_name."""
        # Add an entry to the database
        code = data.hashstring(str(random()))
        name = data.hashstring(str(random()))
        language.insert_row(code, name)

        # Get current name
        with db.db_query(20003) as session:
            result = session.query(
                Language.name).filter(Language.code == code.encode()).one()

        # Test
        self.assertEqual(name, result.name.decode())

        # Update the name
        new_name = data.hashstring(str(random()))
        language.update_name(code, new_name)

        # Get current name
        with db.db_query(20045) as session:
            result = session.query(
                Language.name).filter(Language.code == code.encode()).one()

        # Test
        self.assertEqual(new_name, result.name.decode())
コード例 #4
0
    def test_update_row(self):
        """Testing method / function update_row."""
        # Add a language entry to the database
        code = data.hashstring(str(random()))
        _translation = data.hashstring(str(random()))
        language.insert_row(code, _translation)
        idx_language = language.exists(code)

        # Make sure row does not exist
        translation = data.hashstring(str(random()))
        key = data.hashstring(str(random()))
        result = agent_xlate.agent_xlate_exists(idx_language, key)
        self.assertFalse(result)

        # Add an entry to the database
        agent_xlate.insert_row(key, translation, idx_language)

        # Test existence
        result = agent_xlate.agent_xlate_exists(idx_language, key)
        self.assertTrue(result)

        # Test update
        new_translation = data.hashstring(str(random()))
        agent_xlate.update_row(key, new_translation, idx_language)

        with db.db_query(20134) as session:
            row = session.query(AgentXlate).filter(
                and_(AgentXlate.agent_program == key.encode(),
                     AgentXlate.idx_language == idx_language)).one()
        self.assertEqual(row.translation.decode(), new_translation)
コード例 #5
0
    def test_insert_row(self):
        """Testing method / function insert_row."""
        # Add a language and pair_xlate_group entry to the database
        code = data.hashstring(str(random()))
        _translation = data.hashstring(str(random()))
        language.insert_row(code, _translation)
        idx_language = language.exists(code)
        pair_xlate_group.insert_row(_translation)
        idx_pair_xlate_group = pair_xlate_group.exists(_translation)

        # Make sure row does not exist
        translation = data.hashstring(str(random()))
        key = data.hashstring(str(random()))
        units = data.hashstring(str(random()))
        result = pair_xlate.pair_xlate_exists(idx_pair_xlate_group,
                                              idx_language, key)
        self.assertFalse(result)

        # Add an entry to the database
        pair_xlate.insert_row(key, translation, units, idx_language,
                              idx_pair_xlate_group)

        # Test
        result = pair_xlate.pair_xlate_exists(idx_pair_xlate_group,
                                              idx_language, key)
        self.assertTrue(result)
コード例 #6
0
ファイル: test_language.py プロジェクト: bonnie-23/pattoo
    def test_exists(self):
        """Testing method / function exists."""
        # Add an entry to the database
        code = data.hashstring(str(random()))
        name = data.hashstring(str(random()))
        language.insert_row(code, name)

        # Make sure it exists
        result = language.exists(code)
        self.assertTrue(bool(result))
コード例 #7
0
def _insert_language():
    """Insert starting default entries into the Language table.

    Args:
        None

    Returns:
        None

    """
    # Insert into Language
    if language.idx_exists(1) is False:
        language.insert_row('en', 'English')
コード例 #8
0
ファイル: test_language.py プロジェクト: bonnie-23/pattoo
    def test_insert_row(self):
        """Testing method / function insert_row."""
        # Add an entry to the database
        code = data.hashstring(str(random()))
        name = data.hashstring(str(random()))
        language.insert_row(code, name)

        # Make sure it exists
        idx_language = language.exists(code)

        # Verify the index exists
        result = language.idx_exists(idx_language)
        self.assertTrue(result)
コード例 #9
0
ファイル: test___init__.py プロジェクト: gill876/pattoo
    def test_main(self):
        """Testing method / function main."""
        #
        # NOTE!
        #
        # This test is to verify that multiprocessing is supported without
        # hanging. We don't want database hanging if there is a large load of
        # connections to the database. This is a very important test. It MUST
        # pass for pattoo to be reliable.

        # Initialize key variables
        loops = 10
        process_count = 100
        timeout = 600
        code = data.hashstring(str(random()))
        names = [data.hashstring(str(random())) for _ in range(loops)]
        Arguments = namedtuple('Arguments', 'loops process_count code names')

        # Add an entry to the database
        language.insert_row(code, names[0])

        # Make sure it exists
        idx_language = language.exists(code)

        # Verify the index exists
        result = language.idx_exists(idx_language)
        self.assertTrue(result)

        # Create arguments
        arguments = Arguments(code=code,
                              loops=loops,
                              names=names,
                              process_count=process_count)

        # Spawn a single process with a timeout
        process = multiprocessing.Process(target=run_, args=(arguments, ))
        process.start()
        process.join(timeout)

        # Test if timing out
        if process.is_alive():
            # Multiprocessing is failing if this times out. I could be due to
            # the loops taking too long (unlikely, but should be checked), or
            # it could be a general failure in the database engine code in
            # pattoo.db.__init__.py.
            print('''\
Test for multiprocessing database update is hanging. Please check possible \
causes.''')
            sys.exit(2)
コード例 #10
0
    def test_update(self):
        """Testing method / function update."""
        # Add a language and pair_xlate_group entry to the database
        code = data.hashstring(str(random()))
        _translation = data.hashstring(str(random()))
        language.insert_row(code, _translation)
        idx_language = language.exists(code)
        pair_xlate_group.insert_row(_translation)
        idx_pair_xlate_group = pair_xlate_group.exists(_translation)

        # Create data
        _data = []
        for key in range(0, 10):
            _data.append(
                [code, str(key), '_{}_'.format(key), '0{}0'.format(key)])
        _df0 = pd.DataFrame(
            _data, columns=['language', 'key', 'translation', 'units'])
        pair_xlate.update(_df0, idx_pair_xlate_group)

        # Update data
        _data = []
        for key in range(0, 10):
            _data.append(
                [code, str(key), '|{}|'.format(key), '1{}1'.format(key)])
        _df = pd.DataFrame(_data,
                           columns=['language', 'key', 'translation', 'units'])
        pair_xlate.update(_df, idx_pair_xlate_group)

        # Test updated data
        for key in range(0, 10):
            with db.db_query(20125) as session:
                row = session.query(PairXlate).filter(
                    and_(
                        PairXlate.idx_pair_xlate_group == idx_pair_xlate_group,
                        PairXlate.key == str(key).encode(),
                        PairXlate.idx_language == idx_language)).one()
            self.assertEqual(row.translation.decode(), _df['translation'][key])
            self.assertEqual(row.units.decode(), _df['units'][key])

        # Old translations should not exist
        for translation in _df0['translation']:
            with db.db_query(20126) as session:
                row = session.query(PairXlate).filter(
                    and_(
                        PairXlate.idx_pair_xlate_group == idx_pair_xlate_group,
                        PairXlate.translation == translation.encode(),
                        PairXlate.idx_language == idx_language))
            self.assertEqual(row.count(), 0)
コード例 #11
0
def _process_language(args):
    """Process language cli arguments.

    Args:
        args: CLI argparse parser arguments

    Returns:
        None

    """
    # Initialize key variables
    if bool(language.exists(args.code)) is True:
        log_message = 'Language code "{}" already exists.'.format(args.code)
        log.log2die(20044, log_message)
    else:
        language.insert_row(args.code, args.name)
コード例 #12
0
ファイル: test_language.py プロジェクト: bonnie-23/pattoo
    def test_cli_show_dump(self):
        """Testing method / function cli_show_dump."""
        # Add an entry to the database
        code = data.hashstring(str(random()))
        name = data.hashstring(str(random()))
        language.insert_row(code, name)

        # Make sure it exists
        idx_language = language.exists(code)

        result = language.cli_show_dump()
        for item in result:
            if item.idx_language == idx_language:
                self.assertEqual(item.name, name)
                self.assertEqual(item.code, code)
                break
コード例 #13
0
ファイル: test_cli_create.py プロジェクト: gill876/pattoo
    def setUpClass(self):
        """Setup tables in pattoo_unittest database"""

        # Setting up arpser to be able to parse import cli commands
        subparser = self.parser.add_subparsers(dest='action')
        _Create(subparser)

        # Skips class setup if using travis-ci
        if not self.travis_ci:
            # Create test tables for Import test
            self.tables = [PairXlateGroup.__table__, Language.__table__]

            # Returns engine object
            self.engine = create_tables(self.tables)

            # Inserting default entries
            language.insert_row('en', 'English')
            pair_xlate_group.insert_row('pair_1')
コード例 #14
0
ファイル: test_cli_set.py プロジェクト: gill876/pattoo
    def test_process(self):
        """Test import argument process function"""

        # Testing for invalid args.qualifier
        args = self.parser.parse_args([])
        args.qualifier = ''
        self.assertIsNone(process(args))

        ####################################################################
        #
        # Testing for proper _process_language execution
        #
        ####################################################################
        current_name = 'Chinese'
        expected = {'code': 'fr', 'name': 'French'}
        cmd_args = ['set', 'language', '--code', expected['code'], '--name',
                    expected['name']]

        # Inserting test language entry into Language table
        language.insert_row(expected['code'], current_name)

        # Asserting that updates were made in Language table
        self.set_fn(current_name, expected, cmd_args, Language, process, True)

        ####################################################################
        #
        # Testing for proper _process_pair_xlate_group execution
        #
        ####################################################################
        current_name = 'TEST GROUP'
        expected = {'name': 'TEST GROUP NAME CHANGE', 'idx_pair_xlate_group':
                    self.idx_pair_xlate_group_count}
        cmd_args = ['set', 'key_translation_group', '--idx_pair_xlate_group',
                    str(expected['idx_pair_xlate_group']), '--name',
                     expected['name']]

        self.idx_pair_xlate_group_count += 1

        # Inserting test pair_xlate_group entry into PairXlateGroup table
        pair_xlate_group.insert_row(current_name)

        # Asserting that updates were made in the PairXlateGroup table
        self.set_fn(current_name, expected, cmd_args, PairXlateGroup, process,
                    True)
コード例 #15
0
    def test_insert_row(self):
        """Testing method / function insert_row."""
        # Add a language entry to the database
        code = data.hashstring(str(random()))
        _translation = data.hashstring(str(random()))
        language.insert_row(code, _translation)
        idx_language = language.exists(code)

        # Make sure row does not exist
        translation = data.hashstring(str(random()))
        key = data.hashstring(str(random()))
        result = agent_xlate.agent_xlate_exists(idx_language, key)
        self.assertFalse(result)

        # Add an entry to the database
        agent_xlate.insert_row(key, translation, idx_language)

        # Test
        result = agent_xlate.agent_xlate_exists(idx_language, key)
        self.assertTrue(result)
コード例 #16
0
    def test_update_row(self):
        """Testing method / function update_row."""
        # Add a language and pair_xlate_group entry to the database
        code = data.hashstring(str(random()))
        _translation = data.hashstring(str(random()))
        language.insert_row(code, _translation)
        idx_language = language.exists(code)
        pair_xlate_group.insert_row(_translation)
        idx_pair_xlate_group = pair_xlate_group.exists(_translation)

        # Make sure row does not exist
        translation = data.hashstring(str(random()))
        key = data.hashstring(str(random()))
        units = data.hashstring(str(random()))
        result = pair_xlate.pair_xlate_exists(idx_pair_xlate_group,
                                              idx_language, key)
        self.assertFalse(result)

        # Add an entry to the database
        pair_xlate.insert_row(key, translation, units, idx_language,
                              idx_pair_xlate_group)

        # Test existence
        result = pair_xlate.pair_xlate_exists(idx_pair_xlate_group,
                                              idx_language, key)
        self.assertTrue(result)

        # Test update
        new_translation = data.hashstring(str(random()))
        pair_xlate.update_row(key, new_translation, units, idx_language,
                              idx_pair_xlate_group)

        with db.db_query(20071) as session:
            row = session.query(PairXlate).filter(
                and_(PairXlate.idx_pair_xlate_group == idx_pair_xlate_group,
                     PairXlate.key == key.encode(),
                     PairXlate.idx_language == idx_language)).one()
        self.assertEqual(row.translation.decode(), new_translation)
コード例 #17
0
    def test_cli_show_dump(self):
        """Testing method / function cli_show_dump."""
        # Add an entry to the database
        # Add a language entry to the database
        code = data.hashstring(str(random()))
        _translation = data.hashstring(str(random()))
        language.insert_row(code, _translation)
        idx_language = language.exists(code)

        # Make sure row does not exist
        translation = data.hashstring(str(random()))
        key = data.hashstring(str(random()))
        result = agent_xlate.agent_xlate_exists(idx_language, key)
        self.assertFalse(result)

        # Add an entry to the database
        agent_xlate.insert_row(key, translation, idx_language)

        result = agent_xlate.cli_show_dump()
        for item in result:
            if item.agent_program == key:
                self.assertEqual(item.translation, translation)
                break
コード例 #18
0
    def test_update(self):
        """Testing method / function update."""
        # Add a language entry to the database
        code = data.hashstring(str(random()))
        _translation = data.hashstring(str(random()))
        language.insert_row(code, _translation)
        idx_language = language.exists(code)

        # Create data
        _data = []
        for key in range(0, 10):
            _data.append([code, str(key), '_{}_'.format(key)])
        _df0 = pd.DataFrame(_data, columns=['language', 'key', 'translation'])
        agent_xlate.update(_df0)

        # Update data
        _data = []
        for key in range(0, 10):
            _data.append([code, str(key), '|{}|'.format(key)])
        _df = pd.DataFrame(_data, columns=['language', 'key', 'translation'])
        agent_xlate.update(_df)

        # Test updated data
        for key in range(0, 10):
            with db.db_query(20135) as session:
                row = session.query(AgentXlate).filter(
                    and_(AgentXlate.agent_program == str(key).encode(),
                         AgentXlate.idx_language == idx_language)).one()
            self.assertEqual(row.translation.decode(), _df['translation'][key])

        # Old translations should not exist
        for translation in _df0['translation']:
            with db.db_query(20136) as session:
                row = session.query(AgentXlate).filter(
                    and_(AgentXlate.translation == translation.encode(),
                         AgentXlate.idx_language == idx_language))
            self.assertEqual(row.count(), 0)
コード例 #19
0
ファイル: _check_database.py プロジェクト: bonnie-23/pattoo
def insertions():
    """Insert the necessary table ForeignKey values to satisfy defaults.

    Args:
        None

    Returns:
        None

    """
    # Initialize key variables
    default_name = 'Pattoo Default'
    idx_agent_groups = {}
    idx_pair_xlate_groups = {}
    language_dict = {}
    agent_xlate_data = [
        ('en', 'pattoo_agent_os_autonomousd',
         'Pattoo Standard OS Autonomous Agent'),
        ('en', 'pattoo_agent_os_spoked', 'Pattoo Standard OS Spoked Agent'),
        ('en', 'pattoo_agent_snmpd', 'Pattoo Standard SNMP Agent'),
        ('en', 'pattoo_agent_snmp_ifmibd', 'Pattoo Standard IfMIB SNMP Agent'),
        ('en', 'pattoo_agent_modbustcpd', 'Pattoo Standard Modbus TCP Agent'),
        ('en', 'pattoo_agent_opcuad', 'Pattoo Standard OPC UA Agent'),
        ('en', 'pattoo_agent_bacnetipd', 'Pattoo Standard BACnet IP Agent')
    ]
    pair_xlate_data = [
        ('OPC UA Agents', [('en', 'pattoo_agent_opcuad_opcua_server',
                            'OPC UA Server', '')]),
        ('IfMIB Agents',
         [('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.9',
           'Interface Broadcast Packets (HC inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.8',
           'Interface Multicast Packets (HC inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.6',
           'Interface Traffic (HC inbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.7',
           'Interface Unicast Packets (inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.13',
           'Interface Broadcast Packets (HC outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.12',
           'Interface Multicast Packets (HC outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.10',
           'Interface Traffic (HC outbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.11',
           'Interface Unicast Packets (HC outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.3',
           'Interface Broadcast Packets (inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.2.2.1.13',
           'Interface Discard Errors (inbound)', 'Errors / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.2.2.1.14',
           'Interface Errors (inbound)', 'Errors / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.2',
           'Interface Multicast Packets (inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.2.2.1.10',
           'Interface Traffic (inbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.2.2.1.11',
           'Interface Traffic (inbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.5',
           'Interface Broadcast Packets (outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.2.2.1.19',
           'Interface Discard Errors (outbound)', 'Errors / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.2.2.1.20',
           'Interface Errors (outbound)', 'Errors / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.31.1.1.1.4',
           'Interface Multicast Packets (outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.2.2.1.16',
           'Interface Traffic (outbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmpd_.1.3.6.1.2.1.2.2.1.17',
           'Interface Unicast Packets (outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifalias', 'Interface Alias', ''),
          ('en', 'pattoo_agent_snmp_ifmibd_ifdescr', 'Interface Description',
           ''),
          ('en', 'pattoo_agent_snmp_ifmibd_ifhcinbroadcastpkts',
           'Interface Broadcast Packets (HC inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifhcinmulticastpkts',
           'Interface Multicast Packets (HC inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifhcinoctets',
           'Interface Traffic (HC inbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifhcinucastpkts',
           'Interface Unicast Packets (HC inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifhcoutbroadcastpkts',
           'Interface Broadcast Packets (HC outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifhcoutmulticastpkts',
           'Interface Multicast Packets (HC outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifhcoutoctets',
           'Interface Traffic (HC outbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifhcoutucastpkts',
           'Interface Unicast Packets (HC outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifinbroadcastpkts',
           'Interface Broadcast Packets (inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifinmulticastpkts',
           'Interface Multicast Packets (inbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifinoctets',
           'Interface Traffic (inbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifname', 'Interface Name', ''),
          ('en', 'pattoo_agent_snmp_ifmibd_ifoutbroadcastpkts',
           'Interface Broadcast Packets (outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifoutmulticastpkts',
           'Interface Multicast Packets (outbound)', 'Packets / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_ifoutoctets',
           'Interface Traffic (outbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_snmp_ifmibd_oid', 'SNMP OID', ''),
          ('en', 'pattoo_agent_snmpd_ifalias', 'Interface Alias', ''),
          ('en', 'pattoo_agent_snmpd_ifdescr', 'Interface Description', ''),
          ('en', 'pattoo_agent_snmpd_ifname', 'Interface Name', ''),
          ('en', 'pattoo_agent_snmpd_oid', 'SNMP OID', '')]),
        ('OS Agents',
         [('en', 'pattoo_agent_os_autonomousd_processor',
           'Processor Type', ''),
          ('en', 'pattoo_agent_os_autonomousd_release', 'OS Release', ''),
          ('en', 'pattoo_agent_os_autonomousd_type', 'OS Type', ''),
          ('en', 'pattoo_agent_os_autonomousd_version', 'OS Version', ''),
          ('en', 'pattoo_agent_os_autonomousd_cpus', 'OS CPU Count', ''),
          ('en', 'pattoo_agent_os_autonomousd_hostname', 'Hostname', ''),
          ('en', 'pattoo_agent_os_autonomousd_disk_partition_device',
           'Disk Partition', ''),
          ('en', 'pattoo_agent_os_autonomousd_disk_partition_fstype',
           'Filesystem Type', ''),
          ('en', 'pattoo_agent_os_autonomousd_disk_partition_mountpoint',
           'Mount Point', ''),
          ('en', 'pattoo_agent_os_autonomousd_disk_partition_opts',
           'Partition Options', ''),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_user',
           'User (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_nice',
           'Nice (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_system',
           'System (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_idle',
           'Idle (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_iowait',
           'IO Wait (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_irq',
           'IRQ (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_softirq',
           'Soft IRQ (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_steal',
           'Steal (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_guest',
           'Guest (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_percent_guest_nice',
           'Guest / Nice (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_user',
           'User (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_nice',
           'Nice (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_system',
           'System (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_idle',
           'Idle (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_iowait',
           'IO Wait (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_irq',
           'IRQ (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_softirq',
           'Soft IRQ (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_steal',
           'Steal (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_guest',
           'Guest (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_times_guest_nice',
           'Guest / Nice (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_stats_ctx_switches',
           'CPU (Context Switches)', 'Events / Second'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_stats_interrupts',
           'CPU (Context Switches)', 'Events / Second'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_stats_soft_interrupts',
           'CPU (Soft Interrupts)', 'Events / Second'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_stats_syscalls',
           'CPU (System Calls)', 'Events / Second'),
          ('en', 'pattoo_agent_os_autonomousd_memory_total', 'Memory (Total)',
           'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_available',
           'Memory (Available)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_percent',
           'Memory (Percent)', 'Percentage Utilization'),
          ('en', 'pattoo_agent_os_autonomousd_memory_used', 'Memory (Used)',
           'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_free', 'Memory (Free)',
           'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_active',
           'Memory (Active)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_inactive',
           'Memory (Inactive)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_buffers',
           'Memory (Buffers)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_cached',
           'Memory (Cached)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_shared',
           'Memory (Shared)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_memory_slab', 'Memory (Slab)',
           'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_swap_memory_total',
           'Swap Memory (Total)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_swap_memory_used',
           'Swap Memory (Used)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_swap_memory_free',
           'Swap Memory (Free)', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_swap_memory_percent',
           'Swap Memory (Percent)', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_swap_memory_sin',
           'Swap Memory (In)', 'Bytes / Second'),
          ('en', 'pattoo_agent_os_autonomousd_swap_memory_sout',
           'Swap Memory (Out)', 'Bytes / Second'),
          ('en', 'pattoo_agent_os_autonomousd_disk_partition_disk_usage_total',
           'Disk size', 'Bytes'),
          ('en', 'pattoo_agent_os_autonomousd_disk_partition_disk_usage_used',
           'Disk Utilization', 'Percent'),
          ('en', 'pattoo_agent_os_autonomousd_disk_partition_disk_usage_free',
           'Disk Free', 'Bytes'),
          ('en',
           'pattoo_agent_os_autonomousd_disk_partition_disk_usage_percent',
           'Disk Percentage Utilization', ''),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_read_count',
           'Disk I/O (Read Count)', 'Reads / Second'),
          ('en', 'pattoo_agent_os_autonomousd_disk_partition',
           'Disk Partition', ''),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_write_count',
           'Disk I/O (Write Count)', 'Writes / Second'),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_read_bytes',
           'Disk I/O (Bytes Read)', 'Bytes / Second'),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_write_bytes',
           'Disk I/O (Bytes Written)', 'Bytes / Second'),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_read_time',
           'Disk I/O (Read Time)', ''),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_write_time',
           'Disk I/O (Write Time)', ''),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_read_merged_count',
           'Disk I/O (Read Merged Count)', 'Reads / Second'),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_write_merged_count',
           'Disk I/O (Write Merged Count)', 'Writes / Second'),
          ('en', 'pattoo_agent_os_autonomousd_disk_io_busy_time',
           'Disk I/O (Busy Time)', ''),
          ('en', 'pattoo_agent_os_autonomousd_network_io_bytes_sent',
           'Network I/O (Bandwidth Inbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_os_autonomousd_network_io_interface',
           'Network Interface', ''),
          ('en', 'pattoo_agent_os_autonomousd_network_io_bytes_recv',
           'Network I/O (Bandwidth Outbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_os_autonomousd_network_io_packets_sent',
           'Network I/O (Packets Sent)', 'Packets / Second'),
          ('en', 'pattoo_agent_os_autonomousd_network_io_packets_recv',
           'Network I/O (Packets Received)', 'Packets / Second'),
          ('en', 'pattoo_agent_os_autonomousd_network_io_errin',
           'Network I/O (Errors Inbound)', 'Errors / Second'),
          ('en', 'pattoo_agent_os_autonomousd_network_io_errout',
           'Network I/O (Errors Outbound)', 'Errors / Second'),
          ('en', 'pattoo_agent_os_autonomousd_network_io_dropin',
           'Network I/O (Drops Inbound)', 'Drops / Second'),
          ('en', 'pattoo_agent_os_autonomousd_network_io_dropout',
           'Network I/O (Drops Outbound)', 'Drops / Second'),
          ('en', 'pattoo_agent_os_autonomousd_cpu_frequency', 'CPU Frequency',
           'Frequency'),
          ('en', 'pattoo_agent_os_spoked_processor', 'Processor Type', ''),
          ('en', 'pattoo_agent_os_spoked_release', 'OS Release', ''),
          ('en', 'pattoo_agent_os_spoked_type', 'OS Type', ''),
          ('en', 'pattoo_agent_os_spoked_version', 'OS Version', ''),
          ('en', 'pattoo_agent_os_spoked_cpus', 'OS CPU Count', ''),
          ('en', 'pattoo_agent_os_spoked_hostname', 'Hostname', ''),
          ('en', 'pattoo_agent_os_spoked_disk_partition_device',
           'Disk Partition', ''),
          ('en', 'pattoo_agent_os_spoked_disk_partition_fstype',
           'Filesystem Type', ''),
          ('en', 'pattoo_agent_os_spoked_disk_partition_mountpoint',
           'Mount Point', ''),
          ('en', 'pattoo_agent_os_spoked_disk_partition_opts',
           'Partition Options', ''),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_user',
           'User (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_nice',
           'Nice (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_system',
           'System (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_idle',
           'Idle (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_iowait',
           'IO Wait (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_irq',
           'IRQ (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_softirq',
           'Soft IRQ (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_steal',
           'Steal (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_guest',
           'Guest (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_percent_guest_nice',
           'Guest / Nice (Percent CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_user', 'User (CPU Usage)',
           'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_nice', 'Nice (CPU Usage)',
           'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_system',
           'System (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_idle', 'Idle (CPU Usage)',
           'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_iowait',
           'IO Wait (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_irq', 'IRQ (CPU Usage)',
           'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_softirq',
           'Soft IRQ (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_steal', 'Steal (CPU Usage)',
           'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_guest', 'Guest (CPU Usage)',
           'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_times_guest_nice',
           'Guest / Nice (CPU Usage)', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_cpu_stats_ctx_switches',
           'CPU (Context Switches)', 'Events / Second'),
          ('en', 'pattoo_agent_os_spoked_cpu_stats_interrupts',
           'CPU (Context Switches)', 'Events / Second'),
          ('en', 'pattoo_agent_os_spoked_cpu_stats_soft_interrupts',
           'CPU (Soft Interrupts)', 'Events / Second'),
          ('en', 'pattoo_agent_os_spoked_cpu_stats_syscalls',
           'CPU (System Calls)', 'Events / Second'),
          ('en', 'pattoo_agent_os_spoked_memory_total', 'Memory (Total)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_available',
           'Memory (Available)', 'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_percent', 'Memory (Percent)',
           ''),
          ('en', 'pattoo_agent_os_spoked_memory_used', 'Memory (Used)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_free', 'Memory (Free)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_active', 'Memory (Active)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_inactive', 'Memory (Inactive)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_buffers', 'Memory (Buffers)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_cached', 'Memory (Cached)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_shared', 'Memory (Shared)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_memory_slab', 'Memory (Slab)',
           'Bytes'),
          ('en', 'pattoo_agent_os_spoked_swap_memory_total',
           'Swap Memory (Total)', 'Bytes'),
          ('en', 'pattoo_agent_os_spoked_swap_memory_used',
           'Swap Memory (Used)', 'Bytes'),
          ('en', 'pattoo_agent_os_spoked_swap_memory_free',
           'Swap Memory (Free)', 'Bytes'),
          ('en', 'pattoo_agent_os_spoked_swap_memory_percent',
           'Swap Memory (Percent)', ''),
          ('en', 'pattoo_agent_os_spoked_swap_memory_sin', 'Swap Memory (In)',
           'Bytes / Second'),
          ('en', 'pattoo_agent_os_spoked_swap_memory_sout',
           'Swap Memory (Out)', 'Bytes / Second'),
          ('en', 'pattoo_agent_os_spoked_disk_partition_disk_usage_total',
           'Disk size', 'Bytes'),
          ('en', 'pattoo_agent_os_spoked_disk_partition_disk_usage_used',
           'Disk Utilization', 'Percent'),
          ('en', 'pattoo_agent_os_spoked_disk_partition_disk_usage_free',
           'Disk Free', 'Bytes'),
          ('en', 'pattoo_agent_os_spoked_disk_partition_disk_usage_percent',
           'Disk Percentage Utilization', ''),
          ('en', 'pattoo_agent_os_spoked_disk_io_read_count',
           'Disk I/O (Read Count)', 'Reads / Second'),
          ('en', 'pattoo_agent_os_spoked_disk_partition', 'Disk Partition',
           ''),
          ('en', 'pattoo_agent_os_spoked_disk_io_write_count',
           'Disk I/O (Write Count)', 'Writes / Second'),
          ('en', 'pattoo_agent_os_spoked_disk_io_read_bytes',
           'Disk I/O (Bytes Read)', 'Bytes / Second'),
          ('en', 'pattoo_agent_os_spoked_disk_io_write_bytes',
           'Disk I/O (Bytes Written)', 'Bytes / Second'),
          ('en', 'pattoo_agent_os_spoked_disk_io_read_time',
           'Disk I/O (Read Time)', ''),
          ('en', 'pattoo_agent_os_spoked_disk_io_write_time',
           'Disk I/O (Write Time)', ''),
          ('en', 'pattoo_agent_os_spoked_disk_io_read_merged_count',
           'Disk I/O (Read Merged Count)', 'Reads / Second'),
          ('en', 'pattoo_agent_os_spoked_disk_io_write_merged_count',
           'Disk I/O (Write Merged Count)', 'Writes / Second'),
          ('en', 'pattoo_agent_os_spoked_disk_io_busy_time',
           'Disk I/O (Busy Time)', ''),
          ('en', 'pattoo_agent_os_spoked_network_io_bytes_sent',
           'Network I/O (Bandwidth Inbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_os_spoked_network_io_interface',
           'Network Interface', ''),
          ('en', 'pattoo_agent_os_spoked_network_io_bytes_recv',
           'Network I/O (Bandwidth Outbound)', 'Bits / Second'),
          ('en', 'pattoo_agent_os_spoked_network_io_packets_sent',
           'Network I/O (Packets Sent)', 'Packets / Second'),
          ('en', 'pattoo_agent_os_spoked_network_io_packets_recv',
           'Network I/O (Packets Received)', 'Packets / Second'),
          ('en', 'pattoo_agent_os_spoked_network_io_errin',
           'Network I/O (Errors Inbound)', 'Errors / Second'),
          ('en', 'pattoo_agent_os_spoked_network_io_errout',
           'Network I/O (Errors Outbound)', 'Errors / Second'),
          ('en', 'pattoo_agent_os_spoked_network_io_dropin',
           'Network I/O (Drops Inbound)', 'Drops / Second'),
          ('en', 'pattoo_agent_os_spoked_network_io_dropout',
           'Network I/O (Drops Outbound)', 'Drops / Second'),
          ('en', 'pattoo_agent_os_spoked_cpu_frequency', 'CPU Frequency', '')])
    ]

    print('??: Attempting to insert default database table entries.')

    # Insert into Language
    if language.idx_exists(1) is False:
        language.insert_row('en', 'English')

    # Insert into PairXlateGroup
    if pair_xlate_group.idx_exists(1) is False:
        # Create the default PairXlateGroup
        pair_xlate_group.insert_row(default_name)

        # Create PairXlateGroup for some pattoo agents
        for name, rows in pair_xlate_data:
            # Get PairXlateGroup index value after creating an entry
            pair_xlate_group.insert_row(name)
            idx_pair_xlate_group = pair_xlate_group.exists(name)
            idx_pair_xlate_groups[name] = idx_pair_xlate_group

            # Insert values into the PairXlate table for PairXlateGroup
            for row in rows:
                if len(row) != 4:
                    log_message = (
                        'Translation line "{}" is invalid.'.format(row))
                    log.log2die_safe(20140, log_message)
                (code, _key, _value, _units) = row
                idx_language = language_dict.get(language)
                if bool(idx_language) is False:
                    idx_language = language.exists(code)
                    language_dict[code] = idx_language
                pair_xlate.insert_row(_key, _value, _units, idx_language,
                                      idx_pair_xlate_group)

    # Insert into AgentGroup
    if agent_group.idx_exists(1) is False:
        agent_group.insert_row(default_name)
        for name, _ in pair_xlate_data:
            agent_group.insert_row(name)
            index = agent_group.exists(name)
            idx_agent_groups[name] = index

    # Assign agent groups to pair_xlate_groups
    for name, idx_agent_group in idx_agent_groups.items():
        index = idx_pair_xlate_groups.get(name)
        if bool(index) is True:
            agent_group.assign(idx_agent_group, index)

    # Insert into AgentXlate
    if agent_xlate.agent_xlate_exists(1,
                                      'pattoo_agent_os_autonomousd') is False:
        for row in agent_xlate_data:
            _key = row[1]
            _value = row[2]
            agent_xlate.insert_row(_key, _value, 1)

    print('OK: Database table entries inserted.')