Пример #1
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have data to be able to perform interactions with smart
     class variables.
     """
     super(SmartVariablesTestCase, cls).setUpClass()
     cls.puppet_modules = [
         {
             'author': 'robottelo',
             'name': 'cli_test_variables'
         },
     ]
     cls.org = make_org()
     cls.loc = make_location()
     cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                cls.org['id'])
     cls.env = Environment.list(
         {'search': u'content_view="{0}"'.format(cv['name'])})[0]
     Environment.update({
         'name': cls.env['name'],
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
     })
     # Find imported puppet class
     cls.puppet_class = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
     # And all its subclasses
     cls.puppet_subclasses = Puppet.list({
         'search':
         "name ~ {0}:: and environment = {1}".format(
             cls.puppet_class['name'], cls.env['name'])
     })
Пример #2
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have data to be able to perform interactions with smart
     class variables.
     """
     super(SmartVariablesTestCase, cls).setUpClass()
     cls.puppet_modules = [
         {'author': 'robottelo', 'name': 'cli_test_variables'},
     ]
     cls.org = make_org()
     cv = publish_puppet_module(
         cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.org['id'])
     cls.env = Environment.list({
         'search': u'content_view="{0}"'.format(cv['name'])
     })[0]
     # Find imported puppet class
     cls.puppet_class = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
     # And all its subclasses
     cls.puppet_subclasses = Puppet.list({
         'search': "name ~ {0}:: and environment = {1}".format(
             cls.puppet_class['name'], cls.env['name'])
     })
Пример #3
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.puppet_modules = [
         {'author': 'robottelo', 'name': 'cli_test_classparameters'},
     ]
     cls.org = make_org()
     cv = publish_puppet_module(
         cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.org['id'])
     cls.env = Environment.list({
         'search': u'content_view="{0}"'.format(cv['name'])
     })[0]
     cls.puppet_class = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
     cls.sc_params_list = SmartClassParameter.list({
         'environment': cls.env['name'],
         'search': u'puppetclass="{0}"'.format(cls.puppet_class['name'])
     })
     cls.sc_params_ids_list = [
         sc_param['id'] for sc_param in cls.sc_params_list]
Пример #4
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test. Raise an
     exception and skip all tests in case not enough parameters returned.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force puppetlabs/ntp')
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
     sc_params_list = SmartClassParameter.list({
         'environment':
         cls.env['name'],
         'search':
         'puppetclass=ntp'
     })
     if len(sc_params_list) < 45:
         raise RuntimeError('There are not enough smart class parameters to'
                            ' work with in provided puppet class')
     cls.sc_params_ids_list = [
         sc_param['id'] for sc_param in sc_params_list
     ]
Пример #5
0
 def setUpClass(cls):
     super(HostGroupTestCase, cls).setUpClass()
     cls.org = make_org()
     # Setup for puppet class related tests
     puppet_modules = [
         {
             'author': 'robottelo',
             'name': 'generic_1'
         },
         {
             'author': 'robottelo',
             'name': 'generic_2'
         },
     ]
     cls.cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO,
                                    cls.org['id'])
     cls.env = Environment.list(
         {'search': 'content_view="{0}"'.format(cls.cv['name'])})[0]
     cls.puppet_classes = [
         Puppet.info({
             'name': mod['name'],
             'puppet-environment': cls.env['name']
         }) for mod in puppet_modules
     ]
     cls.content_source = Proxy.list({
         'search':
         'url = https://{0}:9090'.format(settings.server.hostname)
     })[0]
     cls.hostgroup = make_hostgroup({
         'content-source-id':
         cls.content_source['id'],
         'organization-ids':
         cls.org['id']
     })
Пример #6
0
    def test_positive_import_twice_list_by_puppetclass_id(
            self, module_org, module_puppet):
        """Import same puppet class twice (e.g. into different Content Views)
        but list class parameters only for specific puppet class.

        :id: 79a33641-54af-4e04-89ff-3b7f9a4e3ec2

        :expectedresults: Parameters listed for specific Puppet class.

        BZ: 1385351

        :CaseImportance: Low
        """
        cv = publish_puppet_module(module_puppet['modules'],
                                   CUSTOM_PUPPET_REPO, module_org.id)
        env = Environment.list({'search': f'content_view="{cv["name"]}"'})[0]
        puppet_class = Puppet.info({
            'name': module_puppet['modules'][0]['name'],
            'environment': env['name']
        })
        sc_params = SmartClassParameter.list({
            'environment':
            env['name'],
            'puppet-class-id':
            puppet_class['id'],
            'per-page':
            1000
        })
        assert len(sc_params) > 0
        # Check that only unique results are returned
        assert len(sc_params) == len({scp['id'] for scp in sc_params})
Пример #7
0
    def test_positive_update_variable_puppet_class(self):
        """Update Smart Variable's puppet class.

        @id: 0f2d617b-c9ec-46e9-ac84-7a0d59a84811

        @steps:

        1. Create a smart variable with valid name.
        2. Update the puppet class associated to the smart variable created in
        step1.

        @assert: The variable is updated with new puppet class.
        """
        smart_variable = make_smart_variable({
            'puppet-class': self.puppet_class['name']})
        self.assertEqual(
            smart_variable['puppet-class'], self.puppet_class['name'])
        new_puppet = Puppet.info(
            {u'name': choice(self.puppet_subclasses)['name']})
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'puppet-class': new_puppet['name']
        })
        updated_sv = SmartVariable.info(
            {'variable': smart_variable['variable']})
        self.assertEqual(updated_sv['puppet-class'], new_puppet['name'])
Пример #8
0
    def test_positive_CRUD(self):
        """Create, Update, and Delete Smart Variable.

        :id: 8be9ed26-9a27-42a8-8edd-b255637f205e

        :steps: Create a smart Variable with Valid name.

        :expectedresults: The smart Variable is created successfully.

        :CaseImportance: Critical
        """
        name = valid_data_list()[0]
        smart_variable = make_smart_variable(
            {'variable': name, 'puppet-class': self.puppet_class['name']}
        )
        self.assertEqual(smart_variable['variable'], name)

        # Update name and puppet class
        new_name = valid_data_list()[0]
        new_puppet = Puppet.info({'name': choice(self.puppet_subclasses)['name']})
        SmartVariable.update(
            {
                'id': smart_variable['id'],
                'new-variable': new_name,
                'puppet-class': new_puppet['name'],
            }
        )
        updated_sv = SmartVariable.info({'id': smart_variable['id']})
        self.assertEqual(updated_sv['puppet-class'], new_puppet['name'])
        self.assertEqual(updated_sv['variable'], new_name)

        # Delete
        SmartVariable.delete({'variable': updated_sv['variable']})
        with self.assertRaises(CLIReturnCodeError):
            SmartVariable.info({'variable': updated_sv['variable']})
Пример #9
0
    def test_positive_import_twice_list_by_puppetclass_id(self):
        """Import same puppet class twice (e.g. into different Content Views)
        but list class parameters only for specific puppet class.

        :id: 79a33641-54af-4e04-89ff-3b7f9a4e3ec2

        :expectedresults: Parameters listed for specific Puppet class.

        BZ: 1385351

        :CaseImportance: Low
        """
        cv = publish_puppet_module(self.puppet_modules, CUSTOM_PUPPET_REPO,
                                   self.org['id'])
        env = Environment.list(
            {'search': u'content_view="{0}"'.format(cv['name'])})[0]
        puppet_class = Puppet.info({
            'name': self.puppet_modules[0]['name'],
            'environment': env['name'],
        })
        sc_params = SmartClassParameter.list({
            'environment':
            env['name'],
            'puppet-class-id':
            puppet_class['id'],
            'per-page':
            1000,
        })
        self.assertGreater(len(sc_params), 0)
        # Check that only unique results are returned
        self.assertEqual(len(sc_params), len({scp['id'] for scp in sc_params}))
Пример #10
0
def puppet_classes(env):
    """Return puppet classes."""
    return [
        Puppet.info({
            'name': mod['name'],
            'puppet-environment': env['name']
        }) for mod in PUPPET_MODULES
    ]
Пример #11
0
def module_puppet(module_org, module_locs):
    puppet_modules = [{'author': 'robottelo', 'name': 'generic_1'}]
    cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO,
                               module_org.id)
    env = Environment.list({'search': f'content_view="{cv["name"]}"'})[0]
    puppet_class = Puppet.info({
        'name': puppet_modules[0]['name'],
        'environment': env['name']
    })
    return {'env': env, 'puppet_class': puppet_class}
Пример #12
0
    def test_positive_list_smart_class_parameters(self):
        """List smart class parameters associated with the puppet class.

        @id: 56b370c2-8fc6-49be-9676-242178cc709a

        @assert: Smart class parameters listed for the class.
        """
        class_sc_parameters = Puppet.sc_params({
            u'puppet-class': self.puppet['name']})
        self.assertGreater(len(class_sc_parameters), 0)
Пример #13
0
def test_positive_list_smart_class_parameters(make_puppet):
    """List smart class parameters associated with the puppet class.

    :id: 56b370c2-8fc6-49be-9676-242178cc709a

    :expectedresults: Smart class parameters listed for the class.
    """
    class_sc_parameters = Puppet.sc_params(
        {'puppet-class': make_puppet['name']})
    assert len(class_sc_parameters) == 200
Пример #14
0
    def test_positive_list_smart_class_parameters(self):
        """List smart class parameters associated with the puppet class.

        :id: 56b370c2-8fc6-49be-9676-242178cc709a

        :expectedresults: Smart class parameters listed for the class.
        """
        class_sc_parameters = Puppet.sc_params(
            {u'puppet-class': self.puppet['name']})
        self.assertGreater(len(class_sc_parameters), 0)
Пример #15
0
def make_puppet():
    """Import a parametrized puppet class."""
    puppet_modules = [{'author': 'robottelo', 'name': 'generic_1'}]
    org = make_org()
    cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO, org['id'])
    env = Environment.list({'search': f'content_view="{cv["name"]}"'})[0]
    puppet = Puppet.info({
        'name': puppet_modules[0]['name'],
        'environment': env['name']
    })
    return puppet
Пример #16
0
    def test_positive_list_smart_variables(self):
        """List smart variables associated with the puppet class.

        @id: cb2b41c0-29cc-4c0b-a7c8-38403d6dda5b

        @assert: Smart variables listed for the class.
        """
        make_smart_variable({'puppet-class': self.puppet['name']})
        class_smart_variables = Puppet.smart_variables({
            u'puppet-class': self.puppet['name']})
        self.assertGreater(len(class_smart_variables), 0)
Пример #17
0
    def test_positive_list_smart_variables(self):
        """List smart variables associated with the puppet class.

        :id: cb2b41c0-29cc-4c0b-a7c8-38403d6dda5b

        :expectedresults: Smart variables listed for the class.
        """
        make_smart_variable({'puppet-class': self.puppet['name']})
        class_smart_variables = Puppet.smart_variables(
            {u'puppet-class': self.puppet['name']})
        self.assertGreater(len(class_smart_variables), 0)
Пример #18
0
 def setUpClass(cls):
     """Import a parametrized puppet class.
     """
     super(PuppetClassTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force puppetlabs/ntp')
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
Пример #19
0
def module_puppet(default_sat, module_org, module_location):
    puppet_class = 'cli_test_classparameters'
    env_name = default_sat.create_custom_environment(repo=puppet_class)
    Environment.update({
        'name': env_name,
        'organization-ids': module_org.id,
        'location-ids': module_location.id,
    })
    puppet_class = Puppet.info({'name': puppet_class, 'environment': env_name})
    env = entities.Environment().search(
        query={'search': f'name="{env_name}"'})[0].read()
    yield {'env': env, 'class': puppet_class}
    delete_puppet_class(puppet_class['name'])
Пример #20
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.puppet_modules = [
         {
             'author': 'robottelo',
             'name': 'cli_test_classparameters'
         },
     ]
     cls.org = make_org()
     cls.loc = make_location()
     cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                cls.org['id'])
     cls.env = Environment.list(
         {'search': u'content_view="{0}"'.format(cv['name'])})[0]
     Environment.update({
         'name': cls.env['name'],
         'organization-ids': cls.org['id'],
         'location-ids': cls.loc['id'],
     })
     cls.puppet_class = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
     cls.sc_params_list = SmartClassParameter.list({
         'environment':
         cls.env['name'],
         'search':
         u'puppetclass="{0}"'.format(cls.puppet_class['name'])
     })
     cls.sc_params_ids_list = [
         sc_param['id'] for sc_param in cls.sc_params_list
     ]
     cls.host = entities.Host(
         organization=cls.org['id'],
         location=cls.loc['id'],
         environment=cls.env['name'],
     ).create()
     cls.host.add_puppetclass(
         data={'puppetclass_id': cls.puppet_class['id']})
     cls.hostgroup = make_hostgroup({
         'environment-id':
         cls.env['id'],
         'puppet-class-ids':
         cls.puppet_class['id']
     })
Пример #21
0
def module_puppet(module_org, module_location):
    puppet_modules = [{'author': 'robottelo', 'name': 'cli_test_classparameters'}]
    cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO, module_org.id)
    env = Environment.list({'search': f'content_view="{cv["name"]}"'})[0]
    Environment.update(
        {
            'name': env['name'],
            'organization-ids': module_org.id,
            'location-ids': module_location.id,
        }
    )
    puppet_class = Puppet.info({'name': puppet_modules[0]['name'], 'environment': env['name']})
    yield {'modules': puppet_modules, 'env': env, 'class': puppet_class}
    delete_puppet_class(puppet_class['name'])
Пример #22
0
 def setUpClass(cls):
     """Import a parametrized puppet class.
     """
     super(PuppetClassTestCase, cls).setUpClass()
     cls.puppet_modules = [{'author': 'robottelo', 'name': 'generic_1'}]
     cls.org = make_org()
     cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                cls.org['id'])
     cls.env = Environment.list(
         {'search': 'content_view="{0}"'.format(cv['name'])})[0]
     cls.puppet = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name']
     })
Пример #23
0
 def setUpClass(cls):
     super(EnvironmentTestCase, cls).setUpClass()
     cls.org = make_org()
     # Setup for puppet class related tests
     puppet_modules = [
         {'author': 'robottelo', 'name': 'generic_1'},
     ]
     cls.cv = publish_puppet_module(
         puppet_modules, CUSTOM_PUPPET_REPO, cls.org['id'])
     cls.env = Environment.list({
         'search': u'content_view="{0}"'.format(cls.cv['name'])})[0]
     cls.puppet_class = Puppet.info({
         'name': puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
Пример #24
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have data to be able to perform interactions with smart
     class variables.
     """
     super(SmartVariablesTestCase, cls).setUpClass()
     cls.puppet_module = "puppetlabs/ntp"
     cls.host_name = settings.server.hostname
     ssh.command('puppet module install --force {0}'.format(
         cls.puppet_module))
     cls.env = Environment.info({u'name': 'production'})
     Proxy.importclasses({
         u'environment': cls.env['name'],
         u'name': cls.host_name,
     })
     cls.puppet = Puppet.info({u'name': 'ntp'})
Пример #25
0
 def setUpClass(cls):
     super(HostGroupTestCase, cls).setUpClass()
     cls.org = make_org()
     # Setup for puppet class related tests
     puppet_modules = [
         {'author': 'robottelo', 'name': 'generic_1'},
         {'author': 'robottelo', 'name': 'generic_2'},
     ]
     cls.cv = publish_puppet_module(
         puppet_modules, CUSTOM_PUPPET_REPO, cls.org['id'])
     cls.env = Environment.list({
         'search': u'content_view="{0}"'.format(cls.cv['name'])})[0]
     cls.puppet_classes = [
         Puppet.info({'name': mod['name'], 'environment': cls.env['name']})
         for mod in puppet_modules
     ]
Пример #26
0
    def setUpClass(cls):
        super(EnvironmentTestCase, cls).setUpClass()
        cls.org = entities.Organization().create()
        cls.loc = entities.Location().create()
        cls.loc2 = entities.Location().create()

        # Setup for puppet class related tests
        puppet_modules = [{'author': 'robottelo', 'name': 'generic_1'}]
        cls.cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO,
                                       cls.org.id)
        cls.env = Environment.list(
            {'search': 'content_view="{0}"'.format(cls.cv['name'])})[0]
        cls.puppet_class = Puppet.info({
            'name': puppet_modules[0]['name'],
            'environment': cls.env['name']
        })
Пример #27
0
 def setUpClass(cls):
     """Import a parametrized puppet class.
     """
     super(PuppetClassTestCase, cls).setUpClass()
     cls.puppet_modules = [
         {'author': 'robottelo', 'name': 'generic_1'},
     ]
     cls.org = make_org()
     cv = publish_puppet_module(
         cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.org['id'])
     cls.env = Environment.list({
         'search': u'content_view="{0}"'.format(cv['name'])
     })[0]
     cls.puppet = Puppet.info({
         'name': cls.puppet_modules[0]['name'],
         'environment': cls.env['name'],
     })
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class variable available.
     Read all available smart class parameters for imported puppet class to
     be able to work with unique entity for each specific test. Raise an
     exception and skip all tests in case not enough parameters returned.
     """
     super(SmartClassParametersTestCase, cls).setUpClass()
     cls.host_name = settings.server.hostname
     ssh.command("puppet module install --force puppetlabs/ntp")
     cls.env = Environment.info({u"name": "production"})
     Proxy.importclasses({u"environment": cls.env["name"], u"name": cls.host_name})
     cls.puppet = Puppet.info({u"name": "ntp"})
     sc_params_list = SmartClassParameter.list({"environment": cls.env["name"], "search": "puppetclass=ntp"})
     if len(sc_params_list) < 45:
         raise RuntimeError("There are not enough smart class parameters to" " work with in provided puppet class")
     cls.sc_params_ids_list = [sc_param["id"] for sc_param in sc_params_list]
Пример #29
0
    def test_positive_update_variable_puppet_class(self):
        """Update Smart Variable's puppet class.

        @id: 0f2d617b-c9ec-46e9-ac84-7a0d59a84811

        @steps:

        1. Create a smart variable with valid name.
        2. Update the puppet class associated to the smart variable created in
        step1.

        @assert: The variable is updated with new puppet class.
        """
        smart_variable = make_smart_variable(
            {'puppet-class': self.puppet['name']})
        self.assertEqual(smart_variable['puppet-class'], self.puppet['name'])
        new_puppet = Puppet.info({u'name': 'ntp::config'})
        SmartVariable.update({
            'variable': smart_variable['variable'],
            'puppet-class': new_puppet['name']
        })
        updated_sv = SmartVariable.info(
            {'variable': smart_variable['variable']})
        self.assertEqual(updated_sv['puppet-class'], new_puppet['name'])
Пример #30
0
def puppet_classes(env):
    """Return puppet classes."""
    return [Puppet.info({'name': pc_name, 'puppet-environment': env.name})]