예제 #1
0
 def create_trust(self, trustee_user, role_names, impersonation=True):
     trustor_user_id = self.client.auth_ref.user_id
     trustor_project_id = self.client.auth_ref.project_id
     try:
         trust = self.client.trusts.create(
             trustor_user=trustor_user_id,
             project=trustor_project_id,
             trustee_user=trustee_user,
             impersonation=impersonation,
             role_names=role_names)
     except Exception:
         LOG.exception(_LE('Failed to create trust'))
         raise exception.TrustCreateFailed(
             trustee_user_id=trustee_user)
     return trust
예제 #2
0
    def create_trust(self, trustee_user):
        trustor_user_id = self.session.get_user_id()
        trustor_project_id = self.session.get_project_id()

        # inherit the role of the trustor, unless set CONF.trust.roles
        if CONF.trust.roles:
            roles = CONF.trust.roles
        else:
            roles = self.context.roles

        try:
            trust = self.client.trusts.create(trustor_user=trustor_user_id,
                                              project=trustor_project_id,
                                              trustee_user=trustee_user,
                                              impersonation=True,
                                              role_names=roles)
        except Exception:
            LOG.exception(_LE('Failed to create trust'))
            raise exception.TrustCreateFailed(trustee_user_id=trustee_user)
        return trust