コード例 #1
0
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity

        enabled = True
        if parsed_args.disable:
            enabled = False

        options = common.get_immutable_options(parsed_args)

        try:
            domain = identity_client.domains.create(
                name=parsed_args.name,
                description=parsed_args.description,
                options=options,
                enabled=enabled,
            )
        except ks_exc.Conflict:
            if parsed_args.or_show:
                domain = utils.find_resource(identity_client.domains,
                                             parsed_args.name)
                LOG.info(_('Returning existing domain %s'), domain.name)
            else:
                raise

        domain._info.pop('links')
        return zip(*sorted(domain._info.items()))
コード例 #2
0
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity

        domain_id = None
        if parsed_args.domain:
            domain_id = common.find_domain(identity_client,
                                           parsed_args.domain).id

        options = common.get_immutable_options(parsed_args)

        try:
            role = identity_client.roles.create(
                name=parsed_args.name, domain=domain_id,
                description=parsed_args.description, options=options)

        except ks_exc.Conflict:
            if parsed_args.or_show:
                role = utils.find_resource(identity_client.roles,
                                           parsed_args.name,
                                           domain_id=domain_id)
                LOG.info(_('Returning existing role %s'), role.name)
            else:
                raise

        role._info.pop('links')
        return zip(*sorted(role._info.items()))
コード例 #3
0
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity

        domain = None
        if parsed_args.domain:
            domain = common.find_domain(identity_client, parsed_args.domain).id

        parent = None
        if parsed_args.parent:
            parent = utils.find_resource(
                identity_client.projects,
                parsed_args.parent,
            ).id

        enabled = True
        if parsed_args.disable:
            enabled = False

        options = common.get_immutable_options(parsed_args)

        kwargs = {}
        if parsed_args.property:
            kwargs = parsed_args.property.copy()
        if 'is_domain' in kwargs.keys():
            if kwargs['is_domain'].lower() == "true":
                kwargs['is_domain'] = True
            elif kwargs['is_domain'].lower() == "false":
                kwargs['is_domain'] = False
            elif kwargs['is_domain'].lower() == "none":
                kwargs['is_domain'] = None

        kwargs['tags'] = list(set(parsed_args.tags))

        try:
            project = identity_client.projects.create(
                name=parsed_args.name,
                domain=domain,
                parent=parent,
                description=parsed_args.description,
                enabled=enabled,
                options=options,
                **kwargs)
        except ks_exc.Conflict:
            if parsed_args.or_show:
                project = utils.find_resource(identity_client.projects,
                                              parsed_args.name,
                                              domain_id=domain)
                LOG.info(_('Returning existing project %s'), project.name)
            else:
                raise

        project._info.pop('links')
        return zip(*sorted(project._info.items()))
コード例 #4
0
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity

        domain_id = None
        if parsed_args.domain:
            domain_id = common.find_domain(identity_client,
                                           parsed_args.domain).id

        options = common.get_immutable_options(parsed_args)
        role = utils.find_resource(identity_client.roles,
                                   parsed_args.role,
                                   domain_id=domain_id)

        identity_client.roles.update(role.id, name=parsed_args.name,
                                     description=parsed_args.description,
                                     options=options)
コード例 #5
0
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity
        domain = utils.find_resource(identity_client.domains,
                                     parsed_args.domain)
        kwargs = {}
        if parsed_args.name:
            kwargs['name'] = parsed_args.name
        if parsed_args.description:
            kwargs['description'] = parsed_args.description

        if parsed_args.enable:
            kwargs['enabled'] = True
        if parsed_args.disable:
            kwargs['enabled'] = False

        options = common.get_immutable_options(parsed_args)
        if options:
            kwargs['options'] = options

        identity_client.domains.update(domain.id, **kwargs)
コード例 #6
0
    def take_action(self, parsed_args):
        identity_client = self.app.client_manager.identity

        project = common.find_project(identity_client, parsed_args.project,
                                      parsed_args.domain)

        kwargs = {}
        if parsed_args.name:
            kwargs['name'] = parsed_args.name
        if parsed_args.description:
            kwargs['description'] = parsed_args.description
        if parsed_args.enable:
            kwargs['enabled'] = True
        if parsed_args.disable:
            kwargs['enabled'] = False
        options = common.get_immutable_options(parsed_args)
        if options:
            kwargs['options'] = options
        if parsed_args.property:
            kwargs.update(parsed_args.property)
        tag.update_tags_in_args(parsed_args, project, kwargs)

        identity_client.projects.update(project.id, **kwargs)