def on_get(self, req, resp, token_id): token_details = get_token_details(token_id, tenant_id=req.get_param('belongsTo')) client = Client(endpoint_url=cfg.CONF['softlayer']['endpoint']) client.auth = get_auth(token_details) user = client['Account'].getCurrentUser(mask='id, username') access = get_access(token_id, token_details, user) resp.status = 200 resp.body = {'access': access}
def hook_get_client(req, resp, kwargs): client = Client(endpoint_url=cfg.CONF['softlayer']['endpoint']) client.auth = None req.env['tenant_id'] = None if req.headers.get('X-AUTH-TOKEN'): if 'X-AUTH-TOKEN' in req.headers: tenant_id = kwargs.get('tenant_id', req.headers.get('X-AUTH-PROJECT-ID')) token_details = get_token_details(req.headers['X-AUTH-TOKEN'], tenant_id=tenant_id) client.auth = get_auth(token_details) req.env['tenant_id'] = token_details['tenant_id'] req.env['sl_client'] = client
def hook_get_client(req, resp, kwargs): endpoint = config.PARSER.get('softlayer', 'endpoint') client = SoftLayer.Client(endpoint_url=endpoint) client.auth = None req.env['tenant_id'] = None if req.headers.get('X-AUTH-TOKEN'): if 'X-AUTH-TOKEN' in req.headers: tenant_id = kwargs.get('tenant_id', req.headers.get('X-AUTH-PROJECT-ID')) token_details = auth.get_token_details(req.headers['X-AUTH-TOKEN'], tenant_id=tenant_id) client.auth = auth.get_auth(token_details) req.env['tenant_id'] = token_details['tenant_id'] req.sl_client = client