Ejemplo n.º 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'])
     })
Ejemplo n.º 2
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']
     })
Ejemplo n.º 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]
Ejemplo n.º 4
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})
Ejemplo n.º 5
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}))
Ejemplo n.º 6
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'])
     })
Ejemplo n.º 7
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}
Ejemplo n.º 8
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
Ejemplo n.º 9
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']
     })
Ejemplo n.º 10
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'])
Ejemplo n.º 11
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']
     })
Ejemplo n.º 12
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'],
     })
Ejemplo n.º 13
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']
        })
Ejemplo n.º 14
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
     ]
Ejemplo n.º 15
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'],
     })
Ejemplo n.º 16
0
def cv(module_org):
    """Create puppet repo and content view, and return the content view."""
    return publish_puppet_module(PUPPET_MODULES, CUSTOM_PUPPET_REPO, module_org.id)