How to use the towerlib.towerlibexceptions.InvalidProject 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
ask_tags_on_launch=False,
                         ask_skip_tags_on_launch=False,
                         ask_job_type_on_launch=False,
                         ask_verbosity_on_launch=False,
                         ask_inventory_on_launch=False,
                         ask_credential_on_launch=False,
                         survey_enabled=False,
                         become_enabled=False,
                         diff_mode=False,
                         allow_simultaneous=False)
        with self.recorder:
            with self.assertRaises(InvalidInventory):
                args = copy.deepcopy(arguments)
                args['inventory'] = 'Broken'
                _ = self.tower.create_job_template(**args)
            with self.assertRaises(InvalidProject):
                args = copy.deepcopy(arguments)
                args['project'] = 'Broken'
                _ = self.tower.create_job_template(**args)
            with self.assertRaises(InvalidPlaybook):
                args = copy.deepcopy(arguments)
                args['playbook'] = 'Broken'
                _ = self.tower.create_job_template(**args)
            with self.assertRaises(InvalidCredential):
                args = copy.deepcopy(arguments)
                args['credential'] = 'Broken'
                _ = self.tower.create_job_template(**args)
            with self.assertRaises(InvalidInstanceGroup):
                args = copy.deepcopy(arguments)
                args['instance_groups'] = 'Broken'
                _ = self.tower.create_job_template(**args)
            with self.assertRaises(InvalidJobType):
github schubergphilis / towerlib / tests / integration / test_team.py View on Github external
def test_mutating_projects(self):
        with self.recorder:
            project = 'Test project'
            project_broken = 'Test projectBroken'
            with self.assertRaises(InvalidProject):
                self.team.add_project_permission_admin(project_broken)
            self.assertTrue(self.team.add_project_permission_admin(project))
            with self.assertRaises(InvalidProject):
                self.team.remove_project_permission_admin(project_broken)
            self.assertTrue(self.team.remove_project_permission_admin(project))
            with self.assertRaises(InvalidProject):
                self.team.add_project_permission_update(project_broken)
            self.assertTrue(self.team.add_project_permission_update(project))
            with self.assertRaises(InvalidProject):
                self.team.remove_project_permission_update(project_broken)
            self.assertTrue(self.team.remove_project_permission_update(project))
            with self.assertRaises(InvalidProject):
                self.team.add_project_permission_use(project_broken)
            self.assertTrue(self.team.add_project_permission_use(project))
            with self.assertRaises(InvalidProject):
                self.team.remove_project_permission_use(project_broken)
github schubergphilis / towerlib / tests / integration / test_team.py View on Github external
def test_mutating_projects(self):
        with self.recorder:
            project = 'Test project'
            project_broken = 'Test projectBroken'
            with self.assertRaises(InvalidProject):
                self.team.add_project_permission_admin(project_broken)
            self.assertTrue(self.team.add_project_permission_admin(project))
            with self.assertRaises(InvalidProject):
                self.team.remove_project_permission_admin(project_broken)
            self.assertTrue(self.team.remove_project_permission_admin(project))
            with self.assertRaises(InvalidProject):
                self.team.add_project_permission_update(project_broken)
            self.assertTrue(self.team.add_project_permission_update(project))
            with self.assertRaises(InvalidProject):
                self.team.remove_project_permission_update(project_broken)
            self.assertTrue(self.team.remove_project_permission_update(project))
            with self.assertRaises(InvalidProject):
                self.team.add_project_permission_use(project_broken)
            self.assertTrue(self.team.add_project_permission_use(project))
            with self.assertRaises(InvalidProject):
                self.team.remove_project_permission_use(project_broken)
            self.assertTrue(self.team.remove_project_permission_use(project))
github schubergphilis / towerlib / towerlib / entities / team.py View on Github external
def _post_project_permission(self, project_name, permission_name, remove=False):
        project = self.organization.get_project_by_name(project_name)
        if not project:
            raise InvalidProject(project_name)
        return self._post_permission(project.object_roles, permission_name, remove)
github schubergphilis / towerlib / towerlib / towerlib.py View on Github external
organization: The organization the project belongs to.
            name: The name of the project to delete.

        Returns:
            bool: True on success, False otherwise.

        Raises:
            InvalidProject: The project provided as argument does not exist.

        """
        organization_ = self.get_organization_by_name(organization)
        if not organization_:
            raise InvalidOrganization(organization_)
        project = organization_.get_project_by_name(name)
        if not project:
            raise InvalidProject(name)
        return project.delete()
github schubergphilis / towerlib / towerlib / entities / inventory.py View on Github external
verbosity ():
            update_on_launch ():
            update_cache_timeout ():
            source_project ():
            update_on_project_update ():

        Returns:
            bool

        """
        credential_ = self.organization.get_credential_by_name(credential, credential_type)
        if not credential_:
            raise InvalidCredential(credential)
        project = self.organization.get_project_by_name(source_project)
        if not project:
            raise InvalidProject(source_project)
        url = '{api}/inventory_sources/'.format(api=self._tower.api)
        payload = {'name': name,
                   'description': description,
                   'source': source,
                   'source_path': source_path,
                   'source_script': source_script,
                   'source_vars': source_vars,
                   'credential': credential_.id,
                   'source_regions': source_regions,
                   'instance_filters': instance_filters,
                   'group_by': group_by,
                   'overwrite': overwrite,
                   'overwrite_vars': overwrite_vars,
                   'timeout': timeout,
                   'verbosity': verbosity,
                   'inventory': self.id,