def main():
    """Create an organization, print out its attributes and delete it."""
    server_config = ServerConfig(
        auth=('admin', 'changeme'),      # Use these credentials…
        url='https://sat1.example.com',  # …to talk to this server.
    )
    org = Organization(server_config, name='junk org').create()
    pprint(org.get_values())  # e.g. {'name': 'junk org', …}
    org.delete()
Example #2
0
def main():
    """Create an organization, print out its attributes and delete it."""
    server_config = ServerConfig(
        auth=('admin', 'changeme'),  # Use these credentials…
        url='https://sat1.example.com',  # …to talk to this server.
    )
    org = Organization(server_config, name='junk org').create()
    pprint(org.get_values())  # e.g. {'name': 'junk org', …}
    org.delete()
Example #3
0
def find_organization(module, name, failsafe=False):
    org = Organization(name=name).search(set(),
                                         {'search': 'name="{}"'.format(name)})
    return handle_find_response(module,
                                org,
                                message="No organization found for %s" % name,
                                failsafe=failsafe)
Example #4
0
    def setUpClass(cls):
        """Creates the pre-requisites for the Incremental updates that used in
        all test"""
        super(IncrementalUpdateTestCase, cls).setUpClass()
        # Create a new Organization
        cls.org = Organization(name=gen_alpha()).create()

        # Create two lifecycle environments - DEV, QE
        cls.dev_lce = LifecycleEnvironment(
            name='DEV',
            organization=cls.org
        ).create()
        cls.qe_lce = LifecycleEnvironment(
            name='QE',
            prior=cls.dev_lce,
            organization=cls.org
        ).create()

        # Upload manifest
        with manifests.clone() as manifest:
            upload_manifest(cls.org.id, manifest.content)

        # Enable repositories - RHE Virtualization Agents and rhel6 sat6tools
        rhva_6_repo_id = enable_rhrepo_and_fetchid(
            basearch=DEFAULT_ARCHITECTURE,
            org_id=cls.org.id,
            product=PRDS['rhel'],
            repo=REPOS['rhva6']['name'],
            reposet=REPOSET['rhva6'],
            releasever=DEFAULT_RELEASE_VERSION,
        )
        rhel6_sat6tools_repo_id = enable_rhrepo_and_fetchid(
            basearch=DEFAULT_ARCHITECTURE,
            org_id=cls.org.id,
            product=PRDS['rhel'],
            repo=REPOS['rhst6']['name'],
            reposet=REPOSET['rhst6'],
            releasever=None,
        )

        # Read the repositories
        cls.rhva_6_repo = Repository(id=rhva_6_repo_id).read()
        cls.rhel6_sat6tools_repo = Repository(
            id=rhel6_sat6tools_repo_id
        ).read()

        # Sync the enabled repositories
        try:
            cls.old_task_timeout = entity_mixins.TASK_TIMEOUT
            # Update timeout to 15 minutes to finish sync
            entity_mixins.TASK_TIMEOUT = 900
            for repo in [cls.rhva_6_repo, cls.rhel6_sat6tools_repo]:
                assert Repository(id=repo.id).sync()['result'] == u'success'
        finally:
            entity_mixins.TASK_TIMEOUT = cls.old_task_timeout
Example #5
0
def main():
    """Create an identical user account on a pair of satellites."""
    server_configs = ServerConfig.get('sat1'), ServerConfig.get('sat2')
    for server_config in server_configs:
        org = Organization(server_config).search(query={'search': 'name="Default_Organization"'})[
            0
        ]
        # The LDAP authentication source with an ID of 1 is internal. It is
        # nearly guaranteed to exist and be functioning.
        user = User(
            server_config,
            auth_source=1,  # or: AuthSourceLDAP(server_config, id=1),
            login='******',
            mail='*****@*****.**',
            organization=[org],
            password='******',
        ).create()
        pprint(user.get_values())  # e.g. {'login': '******', …}
def main():
    """Create an organization, print out its attributes and delete it."""
    org = Organization(name='junk org').create()
    pprint(org.get_values())  # e.g. {'name': 'junk org', …}
    org.delete()
Example #7
0
    def setUpClass(cls):
        """Creates all the pre-requisites for the Incremental updates test"""
        super(IncrementalUpdateTestCase, cls).setUpClass()
        # Step 1 - Create a new Organization
        cls.org = Organization(name=gen_alpha()).create()

        # Step 2 - Create two life cycle environments - DEV, QE
        cls.dev_lce = LifecycleEnvironment(name='DEV',
                                           organization=cls.org).create()
        cls.qe_lce = LifecycleEnvironment(name='QE',
                                          prior=cls.dev_lce,
                                          organization=cls.org).create()

        # Step 3: Upload manifest
        with manifests.clone() as manifest:
            upload_manifest(cls.org.id, manifest.content)

        # Step 4: Enable repositories - 6Server and rhel6 sat6tools
        rhel_66_repo_id = enable_rhrepo_and_fetchid(
            basearch=PRD_SETS['rhel_66']['arch'],
            org_id=cls.org.id,
            product=PRD_SETS['rhel_66']['product'],
            repo=PRD_SETS['rhel_66']['reponame'],
            reposet=PRD_SETS['rhel_66']['reposet'],
            releasever=PRD_SETS['rhel_66']['releasever'])
        rhel6_sat6tools_repo_id = enable_rhrepo_and_fetchid(
            basearch=PRD_SETS['rhel6_sat6tools']['arch'],
            org_id=cls.org.id,
            product=PRD_SETS['rhel6_sat6tools']['product'],
            repo=PRD_SETS['rhel6_sat6tools']['reponame'],
            reposet=PRD_SETS['rhel6_sat6tools']['reposet'],
            releasever=PRD_SETS['rhel6_sat6tools']['releasever'])

        # Step 5: Read the repositories
        cls.rhel_66_repo = Repository(id=rhel_66_repo_id).read()
        cls.rhel6_sat6tools_repo = Repository(
            id=rhel6_sat6tools_repo_id).read()

        # Step 6: Sync the enabled repositories
        try:
            cls.old_task_timeout = entity_mixins.TASK_TIMEOUT
            # Update timeout to 2 hours to finish sync
            entity_mixins.TASK_TIMEOUT = 7200
            for repo in [cls.rhel_66_repo, cls.rhel6_sat6tools_repo]:
                assert Repository(id=repo.id).sync()['result'] == u'success'
        finally:
            entity_mixins.TASK_TIMEOUT = cls.old_task_timeout

        # Step 7: Create two content views - one will be used with all erratas
        # and another with erratas filtered
        for cv_name in ('rhel_6_cv', 'rhel_6_partial_cv'):
            setattr(
                cls, cv_name,
                ContentView(
                    organization=cls.org,
                    name=cv_name,
                    repository=[cls.rhel_66_repo,
                                cls.rhel6_sat6tools_repo]).create())

        # Step 8: Create a content view filter to filter out errata
        rhel_6_partial_cvf = ErratumContentViewFilter(
            content_view=cls.rhel_6_partial_cv,
            type='erratum',
            name='rhel_6_partial_cv_filter',
            repository=[cls.rhel_66_repo]).create()

        # Step 9: Create a content view filter rule - filtering out errata in
        # the last 365 days
        start_date = (date.today() - timedelta(days=365)).strftime('%Y-%m-%d')
        ContentViewFilterRule(
            content_view_filter=rhel_6_partial_cvf,
            types=['security', 'enhancement', 'bugfix'],
            start_date=start_date,
            end_date=date.today().strftime('%Y-%m-%d')).create()

        # Step 10: Publish both the content views and re-read the content views

        # Changing the nailgun timeout time for the rest of the steps as
        # publish/promote of larger repos take more than 5 minutes
        entity_mixins.TASK_TIMEOUT = 3600
        for content_view in (cls.rhel_6_cv, cls.rhel_6_partial_cv):
            content_view.publish()
        cls.rhel_6_cv = cls.rhel_6_cv.read()
        cls.rhel_6_partial_cv = cls.rhel_6_partial_cv.read()

        # Step 11: Promote both content views to 'DEV' and 'QE'
        for content_view in (cls.rhel_6_cv, cls.rhel_6_partial_cv):
            assert len(content_view.version) == 1
            for env in (cls.dev_lce, cls.qe_lce):
                promote(content_view.version[0], env.id)

        # Step 12: Create host collections
        for hc_name in ('rhel_6_hc', 'rhel_6_partial_hc'):
            setattr(
                cls, hc_name,
                HostCollection(organization=cls.org,
                               name=hc_name,
                               max_content_hosts=5).create())

        # Step 13: Create activation keys for both content views
        kwargs = {'organization': cls.org, 'environment': cls.qe_lce.id}
        rhel_6_ak = ActivationKey(name=u'rhel_6_ak',
                                  content_view=cls.rhel_6_cv,
                                  host_collection=[cls.rhel_6_hc],
                                  **kwargs).create()
        rhel_6_partial_ak = ActivationKey(
            name=u'rhel_6_partial_ak',
            content_view=cls.rhel_6_partial_cv,
            host_collection=[cls.rhel_6_partial_hc],
            **kwargs).create()

        # Step 14: Assign subscriptions to activation keys
        # Fetch available subscriptions
        subs = Subscription(organization=cls.org).search()
        assert len(subs) > 0

        # Add subscriptions to activation key
        sub_found = False
        for sub in subs:
            if sub.read_json()['product_name'] == u'Employee SKU':
                for act_key in [rhel_6_ak, rhel_6_partial_ak]:
                    act_key.add_subscriptions(
                        data={u'subscription_id': sub.id})
                sub_found = True
        assert sub_found

        # Step 15: Enable product content in activation keys
        for act_key in [rhel_6_ak, rhel_6_partial_ak]:
            act_key.content_override(
                data={
                    'content_override': {
                        u'content_label': PRD_SETS['rhel6_sat6tools']['label'],
                        u'value': u'1'
                    }
                })

        # Step 16: Create three client machines and register them to satellite
        # Register the first vm with rhel_6_ak and the other two vms with
        # rhel_6_partial_ak
        cls.vm = [
            VirtualMachine(distro='rhel67', tag='incupdate') for _ in range(3)
        ]
        cls.setup_vm(cls.vm[0], rhel_6_ak.name, cls.org.label)
        for i in range(1, 3):
            cls.setup_vm(cls.vm[i], rhel_6_partial_ak.name, cls.org.label)

        # Find the content hosts (systems) and save them
        systems = System(organization=cls.org).search()
        cls.systems = []
        cls.partial_systems = []

        for system in systems:
            if system.content_view.read().name == cls.rhel_6_cv.name:
                cls.systems.append(system)
            else:
                cls.partial_systems.append(system)
def main():
    """Create an organization, print out its attributes and delete it."""
    org = Organization(name="junk org").create()
    pprint(org.get_values())  # e.g. {'name': 'junk org', …}
    org.delete()
def main():
    """Create an organization, print out its attributes and delete it."""
    org = Organization(name='junk org').create()
    PrettyPrinter().pprint(org.get_values())
    org.delete()