Esempio 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': 'api_test_variables'},
     ]
     cls.org = entities.Organization().create()
     cv = publish_puppet_module(
         cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.org)
     cls.env = entities.Environment().search(
         query={'search': u'content_view="{0}"'.format(cv.name)}
     )[0]
     # Find imported puppet class
     cls.puppet_class = entities.PuppetClass().search(query={
         'search': u'name = "{0}" and environment = "{1}"'.format(
             cls.puppet_modules[0]['name'], cls.env.name)
     })[0]
     # And all its subclasses
     cls.puppet_subclasses = entities.PuppetClass().search(query={
         'search': u'name ~ "{0}::" and environment = "{1}"'.format(
             cls.puppet_modules[0]['name'], cls.env.name)
     })
 def setupScenario(self):
     """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.
     """
     self.puppet_modules = [
         {'author': 'robottelo', 'name': 'api_test_classparameters'},
     ]
     self.org = entities.Organization().create()
     cv = publish_puppet_module(
         self.puppet_modules, CUSTOM_PUPPET_REPO, self.org)
     self.env = entities.Environment().search(
         query={'search': u'content_view="{0}"'.format(cv.name)}
     )[0].read()
     self.puppet_class = entities.PuppetClass().search(query={
         'search': u'name = "{0}" and environment = "{1}"'.format(
             self.puppet_modules[0]['name'], self.env.name)
     })[0]
     self.sc_params_list = entities.SmartClassParameters().search(
         query={
             'search': 'puppetclass="{0}"'.format(self.puppet_class.name),
             'per_page': 1000
         })
     scenario_ents = {self.__class__.__name__: {
         'puppet_class': self.puppet_class.name}}
     create_dict(scenario_ents)
Esempio n. 3
0
def test_create_with_puppet_class(session, module_org, module_loc):
    """Create new host group with assigned puppet class to it

    :id: 166ca6a6-c0f7-4fa0-a3f2-b0d6980cf50d

    :expectedresults: Host group created and contains proper puppet class

    :CaseLevel: Integration

    :CaseImportance: High
    """
    name = gen_string('alpha')
    pc_name = 'generic_1'
    cv = publish_puppet_module(
        [{'author': 'robottelo', 'name': pc_name}],
        CUSTOM_PUPPET_REPO,
        organization_id=module_org.id
    )
    env = entities.Environment().search(query={
        'search': u'content_view="{0}" and organization_id={1}'.format(
            cv.name, module_org.id)})[0].read()
    env = entities.Environment(id=env.id, location=[module_loc]).update(['location'])
    with session:
        # Create host group with puppet class
        session.hostgroup.create({
            'host_group.name': name,
            'host_group.puppet_environment': env.name,
            'puppet_classes.classes.assigned': [pc_name],
        })
        hostgroup_values = session.hostgroup.read(name, widget_names='puppet_classes')
        assert len(hostgroup_values['puppet_classes']['classes']['assigned']) == 1
        assert hostgroup_values[
            'puppet_classes']['classes']['assigned'][0] == pc_name
Esempio n. 4
0
def test_positive_create_with_puppet_class(
        session, module_host_template, module_org, module_loc):
    """Create new Host with puppet class assigned to it

    :id: d883f169-1105-435c-8422-a7160055734a

    :expectedresults: Host is created and contains correct puppet class

    :CaseLevel: System
    """
    pc_name = 'generic_1'
    cv = publish_puppet_module(
        [{'author': 'robottelo', 'name': pc_name}],
        CUSTOM_PUPPET_REPO,
        organization_id=module_org.id
    )
    env = entities.Environment().search(query={
        'search': u'content_view="{0}" and organization_id={1}'.format(
            cv.name, module_org.id)})[0].read()
    env = entities.Environment(id=env.id, location=[module_loc]).update(['location'])
    with session:
        host_name = create_fake_host(
            session,
            module_host_template,
            extra_values={
                'host.puppet_environment': env.name,
                'puppet_classes.classes.assigned': [pc_name]
            }
        )
        assert session.host.search(host_name)[0]['Name'] == host_name
        values = session.host.read(host_name, widget_names='puppet_classes')
        assert len(values['puppet_classes']['classes']['assigned']) == 1
        assert values['puppet_classes']['classes']['assigned'][0] == pc_name
Esempio n. 5
0
def module_cv_with_puppet_module(module_org):
    """Returns content view entity created by publish_puppet_module with chosen
    name and author of puppet module, custom puppet repository and organization.
    """
    return publish_puppet_module(
        [{
            'author': 'robottelo',
            'name': 'generic_1'
        }],
        CUSTOM_PUPPET_REPO,
        organization_id=module_org.id,
    )
Esempio n. 6
0
def module_puppet():
    puppet_modules = [{'author': 'robottelo', 'name': 'api_test_classparameters'}]
    org = entities.Organization().create()
    cv = publish_puppet_module(puppet_modules, CUSTOM_PUPPET_REPO, org)
    env = entities.Environment().search(query={'search': f'content_view="{cv.name}"'})[0].read()
    puppet_class = entities.PuppetClass().search(
        query={'search': f'name = "{puppet_modules[0]["name"]}" and environment = "{env.name}"'}
    )[0]
    sc_params_list = entities.SmartClassParameters().search(
        query={'search': f'puppetclass="{puppet_class.name}"', 'per_page': '1000'}
    )
    yield {'env': env, 'class': puppet_class, 'sc_params': sc_params_list}
    delete_puppet_class(puppet_class.name)
Esempio n. 7
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': 'ui_test_variables'
            },
        ]
        cv = publish_puppet_module(cls.puppet_modules, CUSTOM_PUPPET_REPO,
                                   cls.session_org)
        cls.env = entities.Environment().search(
            query={'search': u'content_view="{0}"'.format(cv.name)})[0]
        # Find imported puppet class
        cls.puppet_class = entities.PuppetClass().search(
            query={
                'search':
                u'name = "{0}" and environment = "{1}"'.format(
                    cls.puppet_modules[0]['name'], cls.env.name)
            })[0]
        # And all its subclasses
        cls.puppet_subclasses = entities.PuppetClass().search(
            query={
                'search':
                u'name ~ "{0}::" and environment = "{1}"'.format(
                    cls.puppet_modules[0]['name'], cls.env.name)
            })

        lce = entities.LifecycleEnvironment().search(
            query={
                'search':
                'organization_id="{0}" and name="{1}"'.format(
                    cls.session_org.id, ENVIRONMENT)
            })[0]
        cls.host = entities.Host(organization=cls.session_org,
                                 content_facet_attributes={
                                     'content_view_id': cv.id,
                                     'lifecycle_environment_id': lce.id,
                                 }).create()
        cls.host.environment = cls.env
        cls.host.update(['environment'])
        cls.host.add_puppetclass(data={'puppetclass_id': cls.puppet_class.id})
        cls.domain_name = entities.Domain(id=cls.host.domain.id).read().name
Esempio n. 8
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': 'ui_test_variables'},
        ]
        cv = publish_puppet_module(
           cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.session_org)
        cls.env = entities.Environment().search(
           query={'search': u'content_view="{0}"'.format(cv.name)}
        )[0]
        # Find imported puppet class
        cls.puppet_class = entities.PuppetClass().search(query={
           'search': u'name = "{0}" and environment = "{1}"'.format(
               cls.puppet_modules[0]['name'], cls.env.name)
        })[0]
        # And all its subclasses
        cls.puppet_subclasses = entities.PuppetClass().search(query={
            'search': u'name ~ "{0}::" and environment = "{1}"'.format(
                cls.puppet_modules[0]['name'], cls.env.name)
        })

        lce = entities.LifecycleEnvironment().search(
            query={
                'search': 'organization_id="{0}" and name="{1}"'
                .format(cls.session_org.id, ENVIRONMENT)
            }
        )[0]
        cls.host = entities.Host(
            organization=cls.session_org,
            content_facet_attributes={
                'content_view_id': cv.id,
                'lifecycle_environment_id': lce.id,
            }
        ).create()
        cls.host.environment = cls.env
        cls.host.update(['environment'])
        cls.host.add_puppetclass(data={'puppetclass_id': cls.puppet_class.id})
        cls.domain_name = entities.Domain(id=cls.host.domain.id).read().name
Esempio n. 9
0
def test_create_with_puppet_class(session, module_org, module_loc):
    """Create new host group with assigned puppet class to it

    :id: 166ca6a6-c0f7-4fa0-a3f2-b0d6980cf50d

    :expectedresults: Host group created and contains proper puppet class

    :CaseLevel: Integration

    :CaseImportance: High
    """
    name = gen_string('alpha')
    pc_name = 'generic_1'
    cv = publish_puppet_module([{
        'author': 'robottelo',
        'name': pc_name
    }],
                               CUSTOM_PUPPET_REPO,
                               organization_id=module_org.id)
    env = entities.Environment().search(
        query={
            'search':
            u'content_view="{0}" and organization_id={1}'.format(
                cv.name, module_org.id)
        })[0].read()
    env = entities.Environment(id=env.id,
                               location=[module_loc]).update(['location'])
    with session:
        # Create host group with puppet class
        session.hostgroup.create({
            'host_group.name': name,
            'host_group.puppet_environment': env.name,
            'puppet_classes.classes.assigned': [pc_name],
        })
        hostgroup_values = session.hostgroup.read(
            name, widget_names='puppet_classes')
        assert len(
            hostgroup_values['puppet_classes']['classes']['assigned']) == 1
        assert hostgroup_values['puppet_classes']['classes']['assigned'][
            0] == pc_name
Esempio n. 10
0
def test_positive_create_with_puppet_class(session, module_host_template,
                                           module_org, module_loc):
    """Create new Host with puppet class assigned to it

    :id: d883f169-1105-435c-8422-a7160055734a

    :expectedresults: Host is created and contains correct puppet class

    :CaseLevel: System
    """
    pc_name = 'generic_1'
    cv = publish_puppet_module([{
        'author': 'robottelo',
        'name': pc_name
    }],
                               CUSTOM_PUPPET_REPO,
                               organization_id=module_org.id)
    env = entities.Environment().search(
        query={
            'search':
            u'content_view="{0}" and organization_id={1}'.format(
                cv.name, module_org.id)
        })[0].read()
    env = entities.Environment(id=env.id,
                               location=[module_loc]).update(['location'])
    with session:
        host_name = create_fake_host(session,
                                     module_host_template,
                                     extra_values={
                                         'host.puppet_environment':
                                         env.name,
                                         'puppet_classes.classes.assigned':
                                         [pc_name]
                                     })
        assert session.host.search(host_name)[0]['Name'] == host_name
        values = session.host.read(host_name, widget_names='puppet_classes')
        assert len(values['puppet_classes']['classes']['assigned']) == 1
        assert values['puppet_classes']['classes']['assigned'][0] == pc_name
Esempio n. 11
0
 def setupScenario(self):
     """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.
     """
     self.puppet_modules = [{'author': 'robottelo', 'name': 'api_test_classparameters'}]
     self.org = entities.Organization().create()
     cv = publish_puppet_module(self.puppet_modules, CUSTOM_PUPPET_REPO, self.org)
     self.env = (
         entities.Environment().search(query={'search': f'content_view="{cv.name}"'})[0].read()
     )
     self.puppet_class = entities.PuppetClass().search(
         query={
             'search': 'name = "{}" and environment = "{}"'.format(
                 self.puppet_modules[0]['name'], self.env.name
             )
         }
     )[0]
     self.sc_params_list = entities.SmartClassParameters().search(
         query={'search': f'puppetclass="{self.puppet_class.name}"', 'per_page': 1000}
     )
     scenario_ents = {self.__class__.__name__: {'puppet_class': self.puppet_class.name}}
     create_dict(scenario_ents)
Esempio n. 12
0
 def setUpClass(cls):
     """Import some parametrized puppet classes. This is required to make
     sure that we have smart class parameter 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': 'ui_test_classparameters'},
     ]
     cv = publish_puppet_module(
         cls.puppet_modules, CUSTOM_PUPPET_REPO, cls.session_org)
     cls.env = entities.Environment().search(
         query={'search': u'content_view="{0}"'.format(cv.name)}
     )[0].read()
     cls.puppet_class = entities.PuppetClass().search(query={
         'search': u'name = "{0}" and environment = "{1}"'.format(
             cls.puppet_modules[0]['name'], cls.env.name)
     })[0]
     cls.sc_params_list = entities.SmartClassParameters().search(
         query={
             'search': 'puppetclass="{0}"'.format(cls.puppet_class.name),
             'per_page': 1000
         })
Esempio n. 13
0
def content_view(module_org):
    return publish_puppet_module(PUPPET_MODULES, CUSTOM_PUPPET_REPO,
                                 module_org)
Esempio n. 14
0
def content_view(module_org):
    return publish_puppet_module(
        PUPPET_MODULES, CUSTOM_PUPPET_REPO, module_org)