How to use the towerlib.entities.Organization function in towerlib

To help you get started, we’ve selected a few towerlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github schubergphilis / towerlib / tests / integration / test_towerlib.py View on Github external
def test_organizations(self):
        with self.recorder:
            self.assertIsInstance(self.tower.organizations, EntityManager)
            default_org = self.tower.get_organization_by_name('Default')
            self.assertIsInstance(default_org, Organization)
            self.assertTrue(default_org.name == self.tower.get_organization_by_id(default_org.id).name)
github schubergphilis / towerlib / tests / integration / test_towerlib.py View on Github external
def test_organization_lifecycle(self):
        with self.recorder:
            org = self.tower.create_organization('Test_Org', 'Test Org description')
            self.assertIsInstance(org, Organization)
            self.assertIsNone(self.tower.create_organization('Test_Org', 'Test Org description'))
            self.assertTrue(self.tower.delete_organization('Test_Org'))
            with self.assertRaises(InvalidOrganization):
                self.assertFalse(self.tower.delete_organization('Test_Org'))
github schubergphilis / towerlib / towerlib / __init__.py View on Github external
assert InvalidGroup
assert InvalidHost
assert InvalidProject
assert InvalidCredentialType
assert InvalidPlaybook
assert InvalidInstanceGroup
assert InvalidJobType
assert InvalidVerbosity
assert InvalidJobTemplate
assert PermissionNotFound
assert InvalidValue
assert InvalidRole

# assert objects
assert Tower
assert Organization
assert User
assert Role
assert Team
assert Project
assert Group
assert Inventory
assert Host
assert Instance
assert InstanceGroup
assert CredentialType
assert Credential
assert InventorySource
github schubergphilis / towerlib / towerlib / towerlib.py View on Github external
Args:
            name: The name of the organization to create.
            description: The description of the organization to create.

        Returns:
            Organization: The organization on success, None otherwise.

        """
        url = '{api}/organizations/'.format(api=self.api)
        payload = {'name': name,
                   'description': description}
        response = self.session.post(url, json=payload)
        if not response.ok:
            self._logger.error('Error creating organization, response was: "%s"', response.text)
        return Organization(self, response.json()) if response.ok else None
github schubergphilis / towerlib / towerlib / towerlib.py View on Github external
Raises:
            InvalidOrganization: The organization provided as argument does not exist.

        """
        organization_ = self.get_organization_by_name(organization)
        if not organization_:
            raise InvalidOrganization(organization)
        user = self.create_user(username,
                                password,
                                first_name=first_name,
                                last_name=last_name,
                                email=email)
        if not user:
            return False
        user.associate_with_organization_role(organization, Organization.DEFAULT_MEMBER_ROLE)
        return user