Esempio n. 1
0
 def test_parse_list_attributes(self):
     """Can parse list attributes"""
     output = [
         'Partition tables:', ' ptable1', ' ptable2', ' ptable3', ' ptable4'
     ]
     assert hammer.parse_info(output) == {
         'partition-tables': ['ptable1', 'ptable2', 'ptable3', 'ptable4']
     }
Esempio n. 2
0
    def version_info(cls, options):
        """Provides version info related to content-view's version."""
        cls.command_sub = 'version info'

        if options is None:
            options = {}

        return hammer.parse_info(cls.execute(cls._construct_command(options)))
Esempio n. 3
0
    def puppet_module_info(cls, options):
        """Provides puppet-module info related to content-view's version."""
        cls.command_sub = 'puppet-module info'

        if options is None:
            options = {}

        result = cls.execute(cls._construct_command(options))
        result.stdout = hammer.parse_info(result.stdout)
        return result
Esempio n. 4
0
 def test_parse_info(self):
     """Can parse info output"""
     output = [
         'Sync State:   not_synced',
         'Sync Plan ID:',
         'GPG:',
         '    GPG Key ID: 1',
         '    GPG Key: key name',
         'Organizations:',
         '    1) Org 1',
         '    2) Org 2',
         'Locations:',
         '    Loc 1',
         '    Loc 2',
         'Repositories:',
         ' 1) Repo Name: repo1',
         '    Repo ID:   10',
         ' 2) Repo Name: repo2',
         '    Repo ID:   20',
         ' 3) Repo Name => repo3',
         '    Repo ID =>   30',
     ]
     self.assertEqual(
         hammer.parse_info(output), {
             'sync-state':
             'not_synced',
             'sync-plan-id': {},
             'gpg': {
                 'gpg-key-id': '1',
                 'gpg-key': 'key name'
             },
             'organizations': [
                 'Org 1',
                 'Org 2',
             ],
             'locations': [
                 'Loc 1',
                 'Loc 2',
             ],
             'repositories': [
                 {
                     'repo-id': '10',
                     'repo-name': 'repo1'
                 },
                 {
                     'repo-id': '20',
                     'repo-name': 'repo2'
                 },
                 {
                     'repo-id': '30',
                     'repo-name': 'repo3'
                 },
             ],
         })
Esempio n. 5
0
    def version_info(cls, options, output_format=None):
        """Provides version info related to content-view's version."""
        cls.command_sub = 'version info'

        if options is None:
            options = {}

        result = cls.execute(cls._construct_command(options),
                             output_format=output_format)
        if output_format != 'json':
            result = hammer.parse_info(result)
        return result
Esempio n. 6
0
    def version_info(cls, options, output_format=None):
        """Provides version info related to content-view's version."""
        cls.command_sub = 'version info'

        if options is None:
            options = {}

        result = cls.execute(
            cls._construct_command(options), output_format=output_format)
        if output_format != 'json':
            result = hammer.parse_info(result)
        return result
Esempio n. 7
0
    def info(cls, options=None, output_format=None):
        """Reads the entity information."""
        cls.command_sub = 'info'

        if options is None:
            options = {}

        if cls.command_requires_org and 'organization-id' not in options:
            raise CLIError(
                'organization-id option is required for {0}.info'.format(
                    cls.__name__))

        result = cls.execute(command=cls._construct_command(options),
                             output_format=output_format)
        if output_format != 'json':
            result = hammer.parse_info(result)
        return result
Esempio n. 8
0
 def test_parse_list_attributes(self):
     """Can parse list attributes"""
     output = [
         'Partition tables:',
         ' ptable1',
         ' ptable2',
         ' ptable3',
         ' ptable4',
     ]
     self.assertDictEqual(hammer.parse_info(output), {
         'partition-tables': [
             'ptable1',
             'ptable2',
             'ptable3',
             'ptable4',
         ],
     })
Esempio n. 9
0
 def test_parse_info(self):
     """Can parse info output"""
     output = [
         'Sync State:   not_synced',
         'Sync Plan ID:',
         'GPG:',
         '    GPG Key ID: 1',
         '    GPG Key: key name',
         'Organizations:',
         '    1) Org 1',
         '    2) Org 2',
         'Locations:',
         '    Loc 1',
         '    Loc 2',
         'Repositories:',
         ' 1) Repo Name: repo1',
         '    Repo ID:   10',
         ' 2) Repo Name: repo2',
         '    Repo ID:   20',
         ' 3) Repo Name => repo3',
         '    Repo ID =>   30',
     ]
     self.assertEqual(
         hammer.parse_info(output),
         {
             'sync-state': 'not_synced',
             'sync-plan-id': {},
             'gpg': {
                 'gpg-key-id': '1',
                 'gpg-key': 'key name'
             },
             'organizations': [
                 'Org 1',
                 'Org 2',
             ],
             'locations': [
                 'Loc 1',
                 'Loc 2',
             ],
             'repositories': [
                 {'repo-id': '10', 'repo-name': 'repo1'},
                 {'repo-id': '20', 'repo-name': 'repo2'},
                 {'repo-id': '30', 'repo-name': 'repo3'},
             ],
         }
     )
Esempio n. 10
0
 def test_parse_dict_attributes(self):
     """Can parse dict attributes"""
     output = [
         'Content:',
         ' 1) Repo Name: repo1',
         '    URL:       /custom/url1',
         ' 2) Repo Name: repo2',
         '    URL:       /custom/url2',
     ]
     self.assertDictEqual(
         hammer.parse_info(output), {
             'content': [{
                 'repo-name': 'repo1',
                 'url': '/custom/url1',
             }, {
                 'repo-name': 'repo2',
                 'url': '/custom/url2',
             }],
         })
Esempio n. 11
0
 def test_parse_list_attributes(self):
     """Can parse list attributes"""
     output = [
         'Partition tables:',
         ' ptable1',
         ' ptable2',
         ' ptable3',
         ' ptable4',
     ]
     self.assertDictEqual(
         hammer.parse_info(output),
         {
             'partition-tables': [
                 'ptable1',
                 'ptable2',
                 'ptable3',
                 'ptable4',
             ],
         }
     )
Esempio n. 12
0
    def info(cls, options=None, output_format=None):
        """Reads the entity information."""
        cls.command_sub = 'info'

        if options is None:
            options = {}

        if cls.command_requires_org and 'organization-id' not in options:
            raise CLIError(
                'organization-id option is required for {0}.info'
                .format(cls.__name__)
            )

        result = cls.execute(
            command=cls._construct_command(options),
            output_format=output_format
        )
        if output_format != 'json':
            result = hammer.parse_info(result)
        return result
Esempio n. 13
0
 def test_parse_simple(self):
     """Can parse a simple info output"""
     output = [
         'Id:                 19',
         'Full name:          4iv01o2u 10.5',
         'Release name:',
         '',
         'Family:',
         'Name:               4iv01o2u',
         'Major version:      10',
         'Minor version:      5',
     ]
     assert hammer.parse_info(output) == {
         'id': '19',
         'full-name': '4iv01o2u 10.5',
         'release-name': {},
         'family': {},
         'name': '4iv01o2u',
         'major-version': '10',
         'minor-version': '5',
     }
Esempio n. 14
0
 def test_parse_dict_attributes(self):
     """Can parse dict attributes"""
     output = [
         'Content:',
         ' 1) Repo Name: repo1',
         '    URL:       /custom/url1',
         ' 2) Repo Name: repo2',
         '    URL:       /custom/url2',
     ]
     self.assertDictEqual(
         hammer.parse_info(output),
         {
             'content': [
                 {
                     'repo-name': 'repo1',
                     'url': '/custom/url1',
                 },
                 {
                     'repo-name': 'repo2',
                     'url': '/custom/url2',
                 }
             ],
         }
     )
Esempio n. 15
0
 def test_parse_simple(self):
     """Can parse a simple info output"""
     output = [
         'Id:                 19',
         'Full name:          4iv01o2u 10.5',
         'Release name:',
         '',
         'Family:',
         'Name:               4iv01o2u',
         'Major version:      10',
         'Minor version:      5',
     ]
     self.assertDictEqual(
         hammer.parse_info(output),
         {
             'id': '19',
             'full-name': '4iv01o2u 10.5',
             'release-name': {},
             'family': {},
             'name': '4iv01o2u',
             'major-version': '10',
             'minor-version': '5',
         }
     )
Esempio n. 16
0
 def test_parse(self):
     """Can parse actual host info"""
     output = [
         'Id: 31',
         'Name: name1',
         'Organization: org1',
         'Location: Default Location',
         'Cert name: cert name',
         'Managed: no',
         'Installed at:',
         'Last report:',
         'Uptime (seconds): 67',
         'Status:',
         '    Global Status: Error',
         'Network:',
         '    IPv4 address: ip1',
         '    MAC: mac1',
         '    Domain: domain1',
         'Network interfaces:',
         ' 1) Id: 34',
         '    Identifier: ens3',
         '    Type: interface (primary, provision)',
         '    MAC address: mac2',
         '    IPv4 address: ip2',
         '    FQDN: name1.domain',
         'Operating system:',
         '    Architecture: x86_64',
         '    Operating System: os1',
         '    Build: no',
         '    Custom partition table:',
         'Parameters:',
         '',
         'All parameters:',
         '    enable-puppet5 => true',
         '    enable-epel => false',
         'Additional info:',
         '    Owner: Anonymous Admin',
         '    Owner Type: User',
         '    Enabled: yes',
         '    Model: Standard PC (i440FX + PIIX, 1996)',
         '    Comment:',
         'OpenSCAP Proxy:',
         'Content Information:',
         '    Content View:',
         '        ID: 38',
         '        Name: content view1',
         '    Lifecycle Environment:',
         '        ID: 40',
         '        Name: lifecycle environment1',
         '    Content Source:',
         '        ID:',
         '        Name:',
         '    Kickstart Repository:',
         '        ID:',
         '        Name:',
         '    Applicable Packages: 0',
         '    Upgradable Packages: 0',
         '    Applicable Errata:',
         '        Enhancement: 0',
         '        Bug Fix: 0',
         '        Security: 0',
         'Subscription Information:',
         '    UUID: uuid1',
         '    Last Checkin: 2019-12-13 00:00:00 UTC',
         '    Release Version:',
         '    Autoheal: true',
         '    Registered To: tier3',
         '    Registered At: 2019-12-13 00:00:00 UTC',
         '    Registered by Activation Keys:',
         '     1) ak1',
         '    System Purpose:',
         '        Service Level:',
         '        Purpose Usage:',
         '        Purpose Role:',
         '        Purpose Addons:',
         'Host Collections:',
     ]
     assert hammer.parse_info(output) == {
         'id':
         '31',
         'name':
         'name1',
         'organization':
         'org1',
         'location':
         'Default Location',
         'cert-name':
         'cert name',
         'managed':
         'no',
         'installed-at': {},
         'last-report': {},
         'uptime-(seconds)':
         '67',
         'status': {
             'global-status': 'Error'
         },
         'network': {
             'ipv4-address': 'ip1',
             'mac': 'mac1',
             'domain': 'domain1'
         },
         'network-interfaces': [{
             'id': '34',
             'identifier': 'ens3',
             'type': 'interface (primary, provision)',
             'mac-address': 'mac2',
             'ipv4-address': 'ip2',
             'fqdn': 'name1.domain',
         }],
         'operating-system': {
             'architecture': 'x86_64',
             'operating-system': 'os1',
             'build': 'no',
             'custom-partition-table': '',
         },
         'parameters': {},
         'all-parameters': {
             'enable-puppet5': 'true',
             'enable-epel': 'false'
         },
         'additional-info': {
             'owner': 'Anonymous Admin',
             'owner-type': 'User',
             'enabled': 'yes',
             'model': 'Standard PC (i440FX + PIIX, 1996)',
             'comment': '',
         },
         'openscap-proxy': {},
         'content-information': {
             'content-view': {
                 'id': '38',
                 'name': 'content view1'
             },
             'lifecycle-environment': {
                 'id': '40',
                 'name': 'lifecycle environment1'
             },
             'content-source': {
                 'id': '',
                 'name': ''
             },
             'kickstart-repository': {
                 'id': '',
                 'name': ''
             },
             'applicable-packages': '0',
             'upgradable-packages': '0',
             'applicable-errata': {
                 'enhancement': '0',
                 'bug-fix': '0',
                 'security': '0'
             },
         },
         'subscription-information': {
             'uuid': 'uuid1',
             'last-checkin': '2019-12-13 00:00:00 UTC',
             'release-version': '',
             'autoheal': 'true',
             'registered-to': 'tier3',
             'registered-at': '2019-12-13 00:00:00 UTC',
             'registered-by-activation-keys': ['ak1'],
             'system-purpose': {
                 'service-level': '',
                 'purpose-usage': '',
                 'purpose-role': '',
                 'purpose-addons': '',
             },
         },
         'host-collections': {},
     }