def handle(self, request, data):
        project_id = data['project_id']
        # update project info
        try:
            api.tenant_update(request,
                              tenant_id=project_id,
                              tenant_name=data['name'],
                              description=data['description'],
                              enabled=data['enabled'])
        except:
            exceptions.handle(request, ignore=True)
            return False

        # update project members
        users_to_modify = 0
        try:
            available_roles = api.keystone.role_list(request)
            project_members = api.keystone.user_list(request,
                                                     tenant_id=project_id)
            users_to_modify = len(project_members)
            for user in project_members:
                current_roles = api.roles_for_user(self.request,
                                                   user.id,
                                                   project_id)
                for role in available_roles:
                    role_list = data["role_" + role.id]
                    if user.id in role_list:
                        if role not in current_roles:
                            # user role has changed
                            api.add_tenant_user_role(request,
                                                     tenant_id=project_id,
                                                     user_id=user.id,
                                                     role_id=role.id)
                        else:
                            # user role is unchanged
                            current_roles.pop(current_roles.index(role))
                # delete user's removed roles
                for to_delete in current_roles:
                    api.remove_tenant_user_role(request,
                                                tenant_id=project_id,
                                                user_id=user.id,
                                                role_id=to_delete.id)
                users_to_modify -= 1

            # add new roles to project
            for role in available_roles:
                # count how many users may be added for exception handling
                role_list = data["role_" + role.id]
                users_to_modify += len(role_list)
            for role in available_roles:
                role_list = data["role_" + role.id]
                users_added = 0
                for user in role_list:
                    if not filter(lambda x: user == x.id, project_members):
                        api.add_tenant_user_role(request,
                                                 tenant_id=project_id,
                                                 user_id=user,
                                                 role_id=role.id)
                    users_added += 1
                users_to_modify -= users_added
        except:
            exceptions.handle(request, _('Failed to modify %s project members '
                                         'and update project quotas.'
                                         % users_to_modify))
            return True

        # update the project quota
        ifcb = data['injected_file_content_bytes']
        try:
            api.tenant_quota_update(request,
                                    project_id,
                                    metadata_items=data['metadata_items'],
                                    injected_file_content_bytes=ifcb,
                                    volumes=data['volumes'],
                                    gigabytes=data['gigabytes'],
                                    ram=data['ram'],
                                    floating_ips=data['floating_ips'],
                                    instances=data['instances'],
                                    injected_files=data['injected_files'],
                                    cores=data['cores'])

            # jt
            # Update the custom quotas
            if data['images'] != 5:
                api.set_image_quota(project_id, data['images'])
            if data['expiration'] != 'Information not available.':
                api.set_expiration_date(project_id, data['expiration'])
            if data['object_mb'] != 204800:
                api.set_object_mb_quota(project_id, data['object_mb'])

            return True
        except:
            exceptions.handle(request, _('Modified project information and '
                                         'members, but unable to modify '
                                         'project quotas.'))
            return True
    def handle(self, request, data):
        # create the project
        try:
            desc = data['description']
            self.object = api.keystone.tenant_create(request,
                                                     tenant_name=data['name'],
                                                     description=desc,
                                                     enabled=data['enabled'])
        except:
            exceptions.handle(request, ignore=True)
            return False

        project_id = self.object.id

        # update project members
        users_to_add = 0
        try:
            available_roles = api.keystone.role_list(request)

            # count how many users are to be added
            for role in available_roles:
                role_list = data["role_" + role.id]
                users_to_add += len(role_list)
            # add new users to project
            for role in available_roles:
                role_list = data["role_" + role.id]
                users_added = 0
                for user in role_list:
                    api.add_tenant_user_role(request,
                                             tenant_id=project_id,
                                             user_id=user,
                                             role_id=role.id)
                    users_added += 1
                users_to_add -= users_added

            # jt
            # Make sure admin is added to the project as a ResellerAdmin
            users = api.keystone.user_list(request)
            admin_id = [user.id for user in users if user.name == 'admin'][0]
            reseller_admin_role_id = [role.id for role in available_roles if role.name == 'ResellerAdmin'][0]
            api.add_tenant_user_role(request,
                                     tenant_id=project_id,
                                     user_id=admin_id,
                                     role_id=reseller_admin_role_id)

        except:
            exceptions.handle(request, _('Failed to add %s project members '
                                         'and set project quotas.'
                                         % users_to_add))

        # update the project quota
        ifcb = data['injected_file_content_bytes']
        try:
            api.nova.tenant_quota_update(request,
                                         project_id,
                                         metadata_items=data['metadata_items'],
                                         injected_file_content_bytes=ifcb,
                                         volumes=data['volumes'],
                                         gigabytes=data['gigabytes'],
                                         ram=data['ram'],
                                         floating_ips=data['floating_ips'],
                                         instances=data['instances'],
                                         injected_files=data['injected_files'],
                                         cores=data['cores'])
            # jt
            # Update the custom quotas
            if data['images'] != 5:
                api.set_image_quota(project_id, data['images'])
            if data['expiration'] != 'Information not available.':
                api.set_expiration_date(project_id, data['expiration'])
            if data['object_mb'] != 204800:
                api.set_object_mb_quota(project_id, data['object_mb'])

        except:
            exceptions.handle(request, _('Unable to set project quotas.'))
        return True