# Path: blazar/context.py
# CONF = cfg.CONF
#     FROM_DICT_EXTRA_KEYS = ['service_catalog']
# class BlazarContext(context.RequestContext):
#     def __init__(self, service_catalog=None, **kwargs):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def current(cls):
#     def to_dict(self):
#     def admin(cls):
# def current():
# def admin():
# 
# Path: blazar/utils/openstack/base.py
# CONF = cfg.CONF
# def get_os_auth_host(conf):
# def url_for(service_catalog, service_type, admin=False,
#             endpoint_interface=None,
#             os_region_name=None):
# 
# Path: blazar/utils/openstack/keystone.py
# CONF = cfg.CONF
# class BlazarKeystoneClient(object):
#     def __init__(self, **kwargs):
#     def complement_auth_url(self, auth_url, version):
#     def __getattr__(self, name):


import functools
from oslo_config import cfg
from blazar import context
from blazar.utils.openstack import base
from blazar.utils.openstack import keystone
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.




CONF = cfg.CONF


def create_trust():
    """Creates trust via Keystone API v3 to use in plugins."""
    client = keystone.BlazarKeystoneClient()

    trustee_id = keystone.BlazarKeystoneClient(
        password=CONF.os_admin_password,
        ctx=context.admin()).user_id

    ctx = context.current()
    trust = client.trusts.create(trustor_user=ctx.user_id,
                                 trustee_user=trustee_id,
                                 impersonation=False,
                                 role_names=ctx.roles,
                                 project=ctx.project_id)
    return trust


def delete_trust(lease):
    """Deletes trust for the specified lease."""
    if lease.trust_id:

# Path: blazar/context.py
# CONF = cfg.CONF
#     FROM_DICT_EXTRA_KEYS = ['service_catalog']
# class BlazarContext(context.RequestContext):
#     def __init__(self, service_catalog=None, **kwargs):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_val, exc_tb):
#     def current(cls):
#     def to_dict(self):
#     def admin(cls):
# def current():
# def admin():
# 
# Path: blazar/utils/openstack/base.py
# CONF = cfg.CONF
# def get_os_auth_host(conf):
# def url_for(service_catalog, service_type, admin=False,
#             endpoint_interface=None,
#             os_region_name=None):
# 
# Path: blazar/utils/openstack/keystone.py
# CONF = cfg.CONF
# class BlazarKeystoneClient(object):
#     def __init__(self, **kwargs):
#     def complement_auth_url(self, auth_url, version):
#     def __getattr__(self, name):


# Path: blazar/utils/trusts.py
import functools
from oslo_config import cfg
from blazar import context
from blazar.utils.openstack import base
from blazar.utils.openstack import keystone

# implied.
# See the License for the specific language governing permissions and
# limitations under the License.




CONF = cfg.CONF


def create_trust():
    """Creates trust via Keystone API v3 to use in plugins."""
    client = keystone.BlazarKeystoneClient()

    trustee_id = keystone.BlazarKeystoneClient(
        password=CONF.os_admin_password,
        ctx=context.admin()).user_id

    ctx = context.current()
    trust = client.trusts.create(trustor_user=ctx.user_id,
                                 trustee_user=trustee_id,
                                 impersonation=False,
                                 role_names=ctx.roles,
                                 project=ctx.project_id)
    return trust


def delete_trust(lease):
    """Deletes trust for the specified lease."""
    if lease.trust_id:

        client = keystone.BlazarKeystoneClient(trust_id=lease.trust_id)