Remove tox unit test warnings
There have been changes to oslo_context which are producing a lot of annoying warning messages. This patch is an attempt to silent them. Change-Id: I7c47daebe093ca814a14c972d9d5d53e8103afc9
This commit is contained in:
parent
756c336568
commit
66e8486c27
|
@ -35,17 +35,17 @@ class ContextMiddleware(wsgi.Middleware):
|
|||
auth_token = headers.get('X-Auth-Token')
|
||||
auth_token_info = environ.get('keystone.token_info')
|
||||
|
||||
project = headers.get('X-Project-Id')
|
||||
project_id = headers.get('X-Project-Id')
|
||||
project_name = headers.get('X-Project-Name')
|
||||
project_domain = headers.get('X-Project-Domain-Id')
|
||||
project_domain_name = headers.get('X-Project-Domain-Name')
|
||||
|
||||
user = headers.get('X-User-Id')
|
||||
user_id = headers.get('X-User-Id')
|
||||
user_name = headers.get('X-User-Name')
|
||||
user_domain = headers.get('X-User-Domain-Id')
|
||||
user_domain_name = headers.get('X-User-Domain-Name')
|
||||
|
||||
domain = headers.get('X-Domain-Id')
|
||||
domain_id = headers.get('X-Domain-Id')
|
||||
domain_name = headers.get('X-Domain-Name')
|
||||
|
||||
region_name = headers.get('X-Region-Name')
|
||||
|
@ -66,9 +66,9 @@ class ContextMiddleware(wsgi.Middleware):
|
|||
api_version = str(req.version_request)
|
||||
req.context = context.RequestContext(
|
||||
auth_token=auth_token,
|
||||
user=user,
|
||||
project=project,
|
||||
domain=domain,
|
||||
user_id=user_id,
|
||||
project_id=project_id,
|
||||
domain_id=domain_id,
|
||||
user_domain=user_domain,
|
||||
project_domain=project_domain,
|
||||
request_id=request_id,
|
||||
|
|
|
@ -33,7 +33,7 @@ class TrustMiddleware(wsgi.Middleware):
|
|||
rpcc = rpc.EngineClient()
|
||||
|
||||
ctx = req.context
|
||||
params = {'user': ctx.user, 'project': ctx.project}
|
||||
params = {'user': ctx.user_id, 'project': ctx.project_id}
|
||||
obj = util.parse_request('CredentialGetRequest', req, params)
|
||||
res = rpcc.call(ctx, 'credential_get', obj)
|
||||
if res:
|
||||
|
@ -44,14 +44,15 @@ class TrustMiddleware(wsgi.Middleware):
|
|||
params = {
|
||||
'auth_url': ctx.auth_url,
|
||||
'token': ctx.auth_token,
|
||||
'project_id': ctx.project,
|
||||
'user_id': ctx.user,
|
||||
'project_id': ctx.project_id,
|
||||
'user_id': ctx.user_id,
|
||||
}
|
||||
kc = driver_base.SenlinDriver().identity(params)
|
||||
service_cred = context.get_service_credentials()
|
||||
admin_id = kc.get_user_id(**service_cred)
|
||||
try:
|
||||
trust = kc.trust_get_by_trustor(ctx.user, admin_id, ctx.project)
|
||||
trust = kc.trust_get_by_trustor(ctx.user_id, admin_id,
|
||||
ctx.project_id)
|
||||
except exception.InternalError as ex:
|
||||
if ex.code == 400:
|
||||
trust = None
|
||||
|
@ -59,7 +60,8 @@ class TrustMiddleware(wsgi.Middleware):
|
|||
raise
|
||||
if not trust:
|
||||
# Create a trust if no existing one found
|
||||
trust = kc.trust_create(ctx.user, admin_id, ctx.project, ctx.roles)
|
||||
trust = kc.trust_create(ctx.user_id, admin_id, ctx.project_id,
|
||||
ctx.roles)
|
||||
|
||||
# If credential not exists, create it, otherwise update it.
|
||||
cred = {'openstack': {'trust': trust.id}}
|
||||
|
|
|
@ -24,8 +24,8 @@ class RequestContext(base_context.RequestContext):
|
|||
system, as well as additional request information.
|
||||
'''
|
||||
|
||||
def __init__(self, auth_token=None, user=None, project=None,
|
||||
domain=None, user_domain=None, project_domain=None,
|
||||
def __init__(self, auth_token=None, user_id=None, project_id=None,
|
||||
domain_id=None, user_domain_id=None, project_domain_id=None,
|
||||
is_admin=None, read_only=False, show_deleted=False,
|
||||
request_id=None, auth_url=None, trusts=None,
|
||||
user_name=None, project_name=None, domain_name=None,
|
||||
|
@ -36,9 +36,9 @@ class RequestContext(base_context.RequestContext):
|
|||
'''Initializer of request context.'''
|
||||
# We still have 'tenant' param because oslo_context still use it.
|
||||
super(RequestContext, self).__init__(
|
||||
auth_token=auth_token, user=user, tenant=project,
|
||||
domain=domain, user_domain=user_domain,
|
||||
project_domain=project_domain,
|
||||
auth_token=auth_token, user_id=user_id, project_id=project_id,
|
||||
domain_id=domain_id, user_domain_id=user_domain_id,
|
||||
project_domain_id=project_domain_id,
|
||||
read_only=read_only, show_deleted=show_deleted,
|
||||
request_id=request_id,
|
||||
roles=roles)
|
||||
|
@ -46,14 +46,14 @@ class RequestContext(base_context.RequestContext):
|
|||
# request_id might be a byte array
|
||||
self.request_id = encodeutils.safe_decode(self.request_id)
|
||||
|
||||
# we save an additional 'project' internally for use
|
||||
self.project = project
|
||||
|
||||
self.auth_url = auth_url
|
||||
self.trusts = trusts
|
||||
|
||||
self.user_id = user_id
|
||||
self.user_name = user_name
|
||||
self.project_id = project_id
|
||||
self.project_name = project_name
|
||||
self.domain_id = domain_id
|
||||
self.domain_name = domain_name
|
||||
self.user_domain_name = user_domain_name
|
||||
self.project_domain_name = project_domain_name
|
||||
|
@ -66,21 +66,27 @@ class RequestContext(base_context.RequestContext):
|
|||
# Check user is admin or not
|
||||
if is_admin is None:
|
||||
self.is_admin = policy.enforce(self, 'context_is_admin',
|
||||
target={'project': self.project},
|
||||
target={'project': self.project_id},
|
||||
do_raise=False)
|
||||
else:
|
||||
self.is_admin = is_admin
|
||||
|
||||
def to_dict(self):
|
||||
# This to_dict() method is not producing 'project_id', 'user_id' or
|
||||
# 'domain_id' which can be used in from_dict(). This is the reason
|
||||
# why we are keeping our own copy of user_id, project_id and
|
||||
# domain_id.
|
||||
d = super(RequestContext, self).to_dict()
|
||||
d.update({
|
||||
'auth_url': self.auth_url,
|
||||
'auth_token_info': self.auth_token_info,
|
||||
'user_id': self.user_id,
|
||||
'user_name': self.user_name,
|
||||
'user_domain_name': self.user_domain_name,
|
||||
'project': self.project,
|
||||
'project_id': self.project_id,
|
||||
'project_name': self.project_name,
|
||||
'project_domain_name': self.project_domain_name,
|
||||
'domain_id': self.domain_id,
|
||||
'domain_name': self.domain_name,
|
||||
'trusts': self.trusts,
|
||||
'region_name': self.region_name,
|
||||
|
|
|
@ -85,7 +85,7 @@ def query_by_short_id(context, model, short_id, project_safe=True):
|
|||
q = q.filter(model.id.like('%s%%' % short_id))
|
||||
|
||||
if project_safe:
|
||||
q = q.filter_by(project=context.project)
|
||||
q = q.filter_by(project=context.project_id)
|
||||
|
||||
if q.count() == 1:
|
||||
return q.first()
|
||||
|
@ -100,7 +100,7 @@ def query_by_name(context, model, name, project_safe=True):
|
|||
q = q.filter_by(name=name)
|
||||
|
||||
if project_safe:
|
||||
q = q.filter_by(project=context.project)
|
||||
q = q.filter_by(project=context.project_id)
|
||||
|
||||
if q.count() == 1:
|
||||
return q.first()
|
||||
|
@ -126,7 +126,7 @@ def cluster_get(context, cluster_id, project_safe=True):
|
|||
return None
|
||||
|
||||
if project_safe:
|
||||
if context.project != cluster.project:
|
||||
if context.project_id != cluster.project:
|
||||
return None
|
||||
return cluster
|
||||
|
||||
|
@ -145,7 +145,7 @@ def _query_cluster_get_all(context, project_safe=True):
|
|||
query = model_query(context, models.Cluster)
|
||||
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
return query
|
||||
|
||||
|
||||
|
@ -230,7 +230,7 @@ def node_get(context, node_id, project_safe=True):
|
|||
return None
|
||||
|
||||
if project_safe:
|
||||
if context.project != node.project:
|
||||
if context.project_id != node.project:
|
||||
return None
|
||||
|
||||
return node
|
||||
|
@ -252,7 +252,7 @@ def _query_node_get_all(context, project_safe=True, cluster_id=None):
|
|||
query = query.filter_by(cluster_id=cluster_id)
|
||||
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
return query
|
||||
|
||||
|
@ -299,7 +299,7 @@ def node_count_by_cluster(context, cluster_id, **kwargs):
|
|||
query = query.filter_by(cluster_id=cluster_id)
|
||||
query = query.filter_by(**kwargs)
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
return query.count()
|
||||
|
||||
|
@ -539,7 +539,7 @@ def policy_get(context, policy_id, project_safe=True):
|
|||
return None
|
||||
|
||||
if project_safe:
|
||||
if context.project != policy.project:
|
||||
if context.project_id != policy.project:
|
||||
return None
|
||||
|
||||
return policy
|
||||
|
@ -560,7 +560,7 @@ def policy_get_all(context, limit=None, marker=None, sort=None, filters=None,
|
|||
query = model_query(context, models.Policy)
|
||||
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
if filters:
|
||||
query = utils.exact_filter(query, models.Policy, filters)
|
||||
|
@ -767,7 +767,7 @@ def profile_get(context, profile_id, project_safe=True):
|
|||
return None
|
||||
|
||||
if project_safe:
|
||||
if context.project != profile.project:
|
||||
if context.project_id != profile.project:
|
||||
return None
|
||||
|
||||
return profile
|
||||
|
@ -788,7 +788,7 @@ def profile_get_all(context, limit=None, marker=None, sort=None, filters=None,
|
|||
query = model_query(context, models.Profile)
|
||||
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
if filters:
|
||||
query = utils.exact_filter(query, models.Profile, filters)
|
||||
|
@ -880,7 +880,7 @@ def event_create(context, values):
|
|||
def event_get(context, event_id, project_safe=True):
|
||||
event = model_query(context, models.Event).get(event_id)
|
||||
if project_safe and event is not None:
|
||||
if event.project != context.project:
|
||||
if event.project != context.project_id:
|
||||
return None
|
||||
|
||||
return event
|
||||
|
@ -907,7 +907,7 @@ def event_get_all(context, limit=None, marker=None, sort=None, filters=None,
|
|||
project_safe=True):
|
||||
query = model_query(context, models.Event)
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
return _event_filter_paginate_query(context, query, filters=filters,
|
||||
limit=limit, marker=marker, sort=sort)
|
||||
|
@ -917,7 +917,7 @@ def event_count_by_cluster(context, cluster_id, project_safe=True):
|
|||
query = model_query(context, models.Event)
|
||||
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
count = query.filter_by(cluster_id=cluster_id).count()
|
||||
|
||||
return count
|
||||
|
@ -929,7 +929,7 @@ def event_get_all_by_cluster(context, cluster_id, limit=None, marker=None,
|
|||
query = query.filter_by(cluster_id=cluster_id)
|
||||
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
return _event_filter_paginate_query(context, query, filters=filters,
|
||||
limit=limit, marker=marker, sort=sort)
|
||||
|
@ -940,7 +940,7 @@ def event_prune(context, cluster_id, project_safe=True):
|
|||
query = session.query(models.Event).with_for_update()
|
||||
query = query.filter_by(cluster_id=cluster_id)
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
return query.delete(synchronize_session='fetch')
|
||||
|
||||
|
@ -989,7 +989,7 @@ def action_get(context, action_id, project_safe=True, refresh=False):
|
|||
return None
|
||||
|
||||
if project_safe:
|
||||
if action.project != context.project:
|
||||
if action.project != context.project_id:
|
||||
return None
|
||||
|
||||
session.refresh(action)
|
||||
|
@ -1017,7 +1017,7 @@ def action_get_all(context, filters=None, limit=None, marker=None, sort=None,
|
|||
|
||||
query = model_query(context, models.Action)
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
if filters:
|
||||
query = utils.exact_filter(query, models.Action, filters)
|
||||
|
@ -1316,7 +1316,7 @@ def action_delete_by_target(context, target, action=None,
|
|||
filter_by(target=target)
|
||||
|
||||
if project_safe:
|
||||
q = q.filter_by(project=context.project)
|
||||
q = q.filter_by(project=context.project_id)
|
||||
|
||||
if action:
|
||||
q = q.filter(models.Action.action.in_(action))
|
||||
|
@ -1342,7 +1342,7 @@ def receiver_get(context, receiver_id, project_safe=True):
|
|||
return None
|
||||
|
||||
if project_safe:
|
||||
if context.project != receiver.project:
|
||||
if context.project_id != receiver.project:
|
||||
return None
|
||||
|
||||
return receiver
|
||||
|
@ -1352,7 +1352,7 @@ def receiver_get_all(context, limit=None, marker=None, filters=None, sort=None,
|
|||
project_safe=True):
|
||||
query = model_query(context, models.Receiver)
|
||||
if project_safe:
|
||||
query = query.filter_by(project=context.project)
|
||||
query = query.filter_by(project=context.project_id)
|
||||
|
||||
if filters:
|
||||
query = utils.exact_filter(query, models.Receiver, filters)
|
||||
|
|
|
@ -66,7 +66,7 @@ class Action(object):
|
|||
'CANCEL', 'SUSPEND', 'RESUME',
|
||||
)
|
||||
|
||||
def __new__(cls, target, action, context, **kwargs):
|
||||
def __new__(cls, target, action, ctx, **kwargs):
|
||||
if (cls != Action):
|
||||
return super(Action, cls).__new__(cls)
|
||||
|
||||
|
@ -83,17 +83,17 @@ class Action(object):
|
|||
|
||||
return super(Action, cls).__new__(ActionClass)
|
||||
|
||||
def __init__(self, target, action, context, **kwargs):
|
||||
def __init__(self, target, action, ctx, **kwargs):
|
||||
# context will be persisted into database so that any worker thread
|
||||
# can pick the action up and execute it on behalf of the initiator
|
||||
|
||||
self.id = kwargs.get('id', None)
|
||||
self.name = kwargs.get('name', '')
|
||||
|
||||
self.context = context
|
||||
self.user = context.user
|
||||
self.project = context.project
|
||||
self.domain = context.domain
|
||||
self.context = ctx
|
||||
self.user = ctx.user_id
|
||||
self.project = ctx.project_id
|
||||
self.domain = ctx.domain_id
|
||||
|
||||
self.action = action
|
||||
self.target = target
|
||||
|
@ -136,10 +136,10 @@ class Action(object):
|
|||
|
||||
self.data = kwargs.get('data', {})
|
||||
|
||||
def store(self, context):
|
||||
def store(self, ctx):
|
||||
"""Store the action record into database table.
|
||||
|
||||
:param context: An instance of the request context.
|
||||
:param ctx: An instance of the request context.
|
||||
:return: The ID of the stored object.
|
||||
"""
|
||||
|
||||
|
@ -171,11 +171,11 @@ class Action(object):
|
|||
if self.id:
|
||||
self.updated_at = timestamp
|
||||
values['updated_at'] = timestamp
|
||||
ao.Action.update(context, self.id, values)
|
||||
ao.Action.update(ctx, self.id, values)
|
||||
else:
|
||||
self.created_at = timestamp
|
||||
values['created_at'] = timestamp
|
||||
action = ao.Action.create(context, values)
|
||||
action = ao.Action.create(ctx, values)
|
||||
self.id = action.id
|
||||
|
||||
return self.id
|
||||
|
@ -187,7 +187,7 @@ class Action(object):
|
|||
:param obj: a DB action object that contains all fields.
|
||||
:return: An `Action` object deserialized from the DB action object.
|
||||
"""
|
||||
context = req_context.RequestContext.from_dict(obj.context)
|
||||
ctx = req_context.RequestContext.from_dict(obj.context)
|
||||
kwargs = {
|
||||
'id': obj.id,
|
||||
'name': obj.name,
|
||||
|
@ -206,19 +206,19 @@ class Action(object):
|
|||
'data': obj.data,
|
||||
}
|
||||
|
||||
return cls(obj.target, obj.action, context, **kwargs)
|
||||
return cls(obj.target, obj.action, ctx, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def load(cls, context, action_id=None, db_action=None, project_safe=True):
|
||||
def load(cls, ctx, action_id=None, db_action=None, project_safe=True):
|
||||
"""Retrieve an action from database.
|
||||
|
||||
:param context: Instance of request context.
|
||||
:param ctx: Instance of request context.
|
||||
:param action_id: An UUID for the action to deserialize.
|
||||
:param db_action: An action object for the action to deserialize.
|
||||
:return: A `Action` object instance.
|
||||
"""
|
||||
if db_action is None:
|
||||
db_action = ao.Action.get(context, action_id,
|
||||
db_action = ao.Action.get(ctx, action_id,
|
||||
project_safe=project_safe)
|
||||
if db_action is None:
|
||||
raise exception.ResourceNotFound(type='action', id=action_id)
|
||||
|
@ -226,36 +226,36 @@ class Action(object):
|
|||
return cls._from_object(db_action)
|
||||
|
||||
@classmethod
|
||||
def create(cls, context, target, action, **kwargs):
|
||||
def create(cls, ctx, target, action, **kwargs):
|
||||
"""Create an action object.
|
||||
|
||||
:param context: The requesting context.
|
||||
:param ctx: The requesting context.
|
||||
:param target: The ID of the target cluster/node.
|
||||
:param action: Name of the action.
|
||||
:param dict kwargs: Other keyword arguments for the action.
|
||||
:return: ID of the action created.
|
||||
"""
|
||||
params = {
|
||||
'user': context.user,
|
||||
'project': context.project,
|
||||
'domain': context.domain,
|
||||
'is_admin': context.is_admin,
|
||||
'request_id': context.request_id,
|
||||
'trusts': context.trusts,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
'is_admin': ctx.is_admin,
|
||||
'request_id': ctx.request_id,
|
||||
'trusts': ctx.trusts,
|
||||
}
|
||||
ctx = req_context.RequestContext.from_dict(params)
|
||||
obj = cls(target, action, ctx, **kwargs)
|
||||
return obj.store(context)
|
||||
c = req_context.RequestContext.from_dict(params)
|
||||
obj = cls(target, action, c, **kwargs)
|
||||
return obj.store(ctx)
|
||||
|
||||
@classmethod
|
||||
def delete(cls, context, action_id):
|
||||
def delete(cls, ctx, action_id):
|
||||
"""Delete an action from database.
|
||||
|
||||
:param context: An instance of the request context.
|
||||
:param ctx: An instance of the request context.
|
||||
:param action_id: The UUID of the target action to be deleted.
|
||||
:return: Nothing.
|
||||
"""
|
||||
ao.Action.delete(context, action_id)
|
||||
ao.Action.delete(ctx, action_id)
|
||||
|
||||
def signal(self, cmd):
|
||||
"""Send a signal to the action.
|
||||
|
@ -473,11 +473,11 @@ class Action(object):
|
|||
return action_dict
|
||||
|
||||
|
||||
def ActionProc(context, action_id):
|
||||
def ActionProc(ctx, action_id):
|
||||
'''Action process.'''
|
||||
|
||||
# Step 1: materialize the action object
|
||||
action = Action.load(context, action_id=action_id, project_safe=False)
|
||||
action = Action.load(ctx, action_id=action_id, project_safe=False)
|
||||
if action is None:
|
||||
LOG.error('Action "%s" could not be found.', action_id)
|
||||
return False
|
||||
|
|
|
@ -68,11 +68,11 @@ class Node(object):
|
|||
|
||||
if context is not None:
|
||||
if self.user == '':
|
||||
self.user = context.user
|
||||
self.user = context.user_id
|
||||
if self.project == '':
|
||||
self.project = context.project
|
||||
self.project = context.project_id
|
||||
if self.domain == '':
|
||||
self.domain = context.domain
|
||||
self.domain = context.domain_id
|
||||
self._load_runtime_data(context)
|
||||
|
||||
def _load_runtime_data(self, context):
|
||||
|
|
|
@ -116,9 +116,9 @@ class Receiver(object):
|
|||
cdata['trust_id'] = context.trusts
|
||||
|
||||
kwargs['actor'] = cdata
|
||||
kwargs['user'] = context.user
|
||||
kwargs['project'] = context.project
|
||||
kwargs['domain'] = context.domain
|
||||
kwargs['user'] = context.user_id
|
||||
kwargs['project'] = context.project_id
|
||||
kwargs['domain'] = context.domain_id
|
||||
kwargs['id'] = uuidutils.generate_uuid()
|
||||
cluster_id = cluster.id if cluster else None
|
||||
obj = cls(rtype, cluster_id, action, **kwargs)
|
||||
|
|
|
@ -192,9 +192,9 @@ class Message(base.Receiver):
|
|||
raise exc.InternalError(message=msg)
|
||||
|
||||
# Use receiver owner context to build action
|
||||
context.user = self.user
|
||||
context.project = self.project
|
||||
context.domain = self.domain
|
||||
context.user_id = self.user
|
||||
context.project_id = self.project
|
||||
context.domain_id = self.domain
|
||||
|
||||
# Action name check
|
||||
if action not in consts.CLUSTER_ACTION_NAMES:
|
||||
|
|
|
@ -214,8 +214,8 @@ class EngineService(service.Service):
|
|||
:return: A dictionary containing the persistent credential.
|
||||
"""
|
||||
values = {
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'cred': req.cred
|
||||
}
|
||||
cred_obj.Credential.update_or_create(ctx, values)
|
||||
|
@ -249,7 +249,7 @@ class EngineService(service.Service):
|
|||
:param req: An instance of the CredentialUpdateRequest.
|
||||
:return: A dictionary containing the persistent credential.
|
||||
"""
|
||||
cred_obj.Credential.update(ctx, ctx.user, ctx.project,
|
||||
cred_obj.Credential.update(ctx, ctx.user_id, ctx.project_id,
|
||||
{'cred': req.cred})
|
||||
return {'cred': req.cred}
|
||||
|
||||
|
@ -330,11 +330,11 @@ class EngineService(service.Service):
|
|||
profiles = profile_obj.Profile.get_all(ctx, **query)
|
||||
return [p.to_dict() for p in profiles]
|
||||
|
||||
def _validate_profile(self, context, spec, name=None,
|
||||
def _validate_profile(self, ctx, spec, name=None,
|
||||
metadata=None, validate_props=False):
|
||||
"""Validate a profile.
|
||||
|
||||
:param context: An instance of the request context.
|
||||
:param ctx: An instance of the request context.
|
||||
:param name: The name of the profile to be validated.
|
||||
:param spec: A dictionary containing the spec for the profile.
|
||||
:param metadata: A dictionary containing optional key-value pairs to
|
||||
|
@ -348,9 +348,9 @@ class EngineService(service.Service):
|
|||
plugin = environment.global_env().get_profile(type_str)
|
||||
|
||||
kwargs = {
|
||||
'user': context.user,
|
||||
'project': context.project,
|
||||
'domain': context.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
'metadata': metadata
|
||||
}
|
||||
if name is None:
|
||||
|
@ -534,10 +534,10 @@ class EngineService(service.Service):
|
|||
|
||||
return [p.to_dict() for p in policy_obj.Policy.get_all(ctx, **query)]
|
||||
|
||||
def _validate_policy(self, context, spec, name=None, validate_props=False):
|
||||
def _validate_policy(self, ctx, spec, name=None, validate_props=False):
|
||||
"""Validate a policy.
|
||||
|
||||
:param context: An instance of the request context.
|
||||
:param ctx: An instance of the request context.
|
||||
:param spec: A dictionary containing the spec for the policy.
|
||||
:param name: The name of the policy to be validated.
|
||||
:param validate_props: Whether to validate the value of property.
|
||||
|
@ -550,16 +550,16 @@ class EngineService(service.Service):
|
|||
plugin = environment.global_env().get_policy(type_str)
|
||||
|
||||
kwargs = {
|
||||
'user': context.user,
|
||||
'project': context.project,
|
||||
'domain': context.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
}
|
||||
if name is None:
|
||||
name = 'validated_policy'
|
||||
policy = plugin(name, spec, **kwargs)
|
||||
|
||||
try:
|
||||
policy.validate(context, validate_props=validate_props)
|
||||
policy.validate(ctx, validate_props=validate_props)
|
||||
except exception.InvalidSpec as ex:
|
||||
msg = six.text_type(ex)
|
||||
LOG.error("Failed in validating policy: %s", msg)
|
||||
|
@ -769,9 +769,9 @@ class EngineService(service.Service):
|
|||
'metadata': req.metadata or {},
|
||||
'dependents': {},
|
||||
'config': req.config or {},
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'domain': ctx.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
}
|
||||
cluster = co.Cluster.create(ctx, values)
|
||||
|
||||
|
@ -1391,9 +1391,9 @@ class EngineService(service.Service):
|
|||
LOG.info("Checking cluster '%s'.", req.identity)
|
||||
db_cluster = co.Cluster.find(ctx, req.identity)
|
||||
# cope with cluster check request from engine internal
|
||||
if not ctx.user or not ctx.project:
|
||||
ctx.user = db_cluster.user
|
||||
ctx.project = db_cluster.project
|
||||
if not ctx.user_id or not ctx.project_id:
|
||||
ctx.user_id = db_cluster.user
|
||||
ctx.project_id = db_cluster.project
|
||||
|
||||
kwargs = {
|
||||
'name': 'cluster_check_%s' % db_cluster.id[:8],
|
||||
|
@ -1428,9 +1428,9 @@ class EngineService(service.Service):
|
|||
db_cluster = co.Cluster.find(ctx, req.identity)
|
||||
|
||||
# cope with cluster check request from engine internal
|
||||
if not ctx.user or not ctx.project:
|
||||
ctx.user = db_cluster.user
|
||||
ctx.project = db_cluster.project
|
||||
if not ctx.user_id or not ctx.project_id:
|
||||
ctx.user_id = db_cluster.user
|
||||
ctx.project_id = db_cluster.project
|
||||
|
||||
inputs = {}
|
||||
if req.obj_attr_is_set('params') and req.params:
|
||||
|
@ -1624,9 +1624,9 @@ class EngineService(service.Service):
|
|||
'data': {},
|
||||
'dependents': {},
|
||||
'init_at': timeutils.utcnow(True),
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'domain': ctx.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
}
|
||||
node = node_obj.Node.create(ctx, values)
|
||||
|
||||
|
@ -1863,9 +1863,9 @@ class EngineService(service.Service):
|
|||
'status_reason': 'Node adopted successfully',
|
||||
'init_at': timeutils.utcnow(True),
|
||||
'created_at': timeutils.utcnow(True),
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'domain': ctx.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
}
|
||||
node = node_obj.Node.create(ctx, values)
|
||||
|
||||
|
@ -2345,14 +2345,14 @@ class EngineService(service.Service):
|
|||
raise exception.BadRequest(msg=msg)
|
||||
|
||||
# permission checking
|
||||
if not ctx.is_admin and ctx.user != cluster.user:
|
||||
if not ctx.is_admin and ctx.user_id != cluster.user:
|
||||
raise exception.Forbidden()
|
||||
|
||||
kwargs = {
|
||||
'name': req.name,
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'domain': ctx.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
'params': req.params
|
||||
}
|
||||
|
||||
|
@ -2438,7 +2438,7 @@ class EngineService(service.Service):
|
|||
"""
|
||||
db_receiver = receiver_obj.Receiver.find(ctx, req.identity)
|
||||
# permission checking
|
||||
if not ctx.is_admin and ctx.user != db_receiver.user:
|
||||
if not ctx.is_admin and ctx.user_id != db_receiver.user:
|
||||
raise exception.Forbidden()
|
||||
|
||||
# Receiver type check
|
||||
|
|
|
@ -52,8 +52,8 @@ class DBEvent(base.EventBackend):
|
|||
'otype': otype,
|
||||
'oname': entity.name,
|
||||
'cluster_id': cluster_id,
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'action': action_name,
|
||||
'status': status,
|
||||
'status_reason': reason,
|
||||
|
|
|
@ -117,7 +117,7 @@ class AffinityPolicy(base.Policy):
|
|||
|
||||
az_name = self.properties.get(self.AVAILABILITY_ZONE)
|
||||
if az_name:
|
||||
nc = self.nova(context.user, context.project)
|
||||
nc = self.nova(context.user_id, context.project_id)
|
||||
valid_azs = nc.validate_azs([az_name])
|
||||
if not valid_azs:
|
||||
msg = _("The specified %(key)s '%(value)s' could not be "
|
||||
|
|
|
@ -296,8 +296,8 @@ class LoadBalancingPolicy(base.Policy):
|
|||
if not validate_props:
|
||||
return True
|
||||
|
||||
nc = self.network(context.user, context.project)
|
||||
oc = self.octavia(context.user, context.project)
|
||||
nc = self.network(context.user_id, context.project_id)
|
||||
oc = self.octavia(context.user_id, context.project_id)
|
||||
|
||||
# validate pool subnet
|
||||
name_or_id = self.pool_spec.get(self.POOL_SUBNET)
|
||||
|
|
|
@ -107,7 +107,7 @@ class RegionPlacementPolicy(base.Policy):
|
|||
if not validate_props:
|
||||
return True
|
||||
|
||||
kc = self.keystone(context.user, context.project)
|
||||
kc = self.keystone(context.user_id, context.project_id)
|
||||
input_regions = sorted(self.regions.keys())
|
||||
valid_regions = kc.validate_regions(input_regions)
|
||||
invalid_regions = sorted(set(input_regions) - set(valid_regions))
|
||||
|
|
|
@ -101,7 +101,7 @@ class ZonePlacementPolicy(base.Policy):
|
|||
if not validate_props:
|
||||
return True
|
||||
|
||||
nc = self.nova(context.user, context.project)
|
||||
nc = self.nova(context.user_id, context.project_id)
|
||||
input_azs = sorted(self.zones.keys())
|
||||
valid_azs = nc.validate_azs(input_azs)
|
||||
invalid_azs = sorted(set(input_azs) - set(valid_azs))
|
||||
|
|
|
@ -174,8 +174,8 @@ class Profile(object):
|
|||
metadata = {}
|
||||
|
||||
try:
|
||||
profile = cls(name, spec, metadata=metadata, user=ctx.user,
|
||||
project=ctx.project)
|
||||
profile = cls(name, spec, metadata=metadata, user=ctx.user_id,
|
||||
project=ctx.project_id)
|
||||
profile.validate(True)
|
||||
except (exc.ResourceNotFound, exc.ESchema) as ex:
|
||||
error = _("Failed in creating profile %(name)s: %(error)s"
|
||||
|
|
|
@ -45,8 +45,8 @@ class TestTrustMiddleware(base.SenlinTestCase):
|
|||
mock.ANY)
|
||||
request = x_rpc.call.call_args[0][2]
|
||||
self.assertIsInstance(request, vorc.CredentialGetRequest)
|
||||
self.assertEqual(self.context.user, request.user)
|
||||
self.assertEqual(self.context.project, request.project)
|
||||
self.assertEqual(self.context.user_id, request.user)
|
||||
self.assertEqual(self.context.project_id, request.project)
|
||||
|
||||
@mock.patch.object(context, "get_service_credentials")
|
||||
@mock.patch("senlin.drivers.base.SenlinDriver")
|
||||
|
@ -75,8 +75,8 @@ class TestTrustMiddleware(base.SenlinTestCase):
|
|||
x_rpc.call.assert_has_calls(mock_calls)
|
||||
request = x_rpc.call.call_args_list[0][0][2]
|
||||
self.assertIsInstance(request, vorc.CredentialGetRequest)
|
||||
self.assertEqual(self.context.user, request.user)
|
||||
self.assertEqual(self.context.project, request.project)
|
||||
self.assertEqual(self.context.user_id, request.user)
|
||||
self.assertEqual(self.context.project_id, request.project)
|
||||
request = x_rpc.call.call_args_list[1][0][2]
|
||||
self.assertIsInstance(request, vorc.CredentialCreateRequest)
|
||||
expected_cred = {
|
||||
|
@ -86,15 +86,15 @@ class TestTrustMiddleware(base.SenlinTestCase):
|
|||
mock_driver.assert_called_once_with()
|
||||
x_driver.identity.assert_called_once_with({
|
||||
'auth_url': self.context.auth_url,
|
||||
'project_id': self.context.project,
|
||||
'user_id': self.context.user,
|
||||
'project_id': self.context.project_id,
|
||||
'user_id': self.context.user_id,
|
||||
'token': self.context.auth_token,
|
||||
})
|
||||
mock_creds.assert_called_once_with()
|
||||
mock_keystone.get_user_id.assert_called_once_with(
|
||||
uid='FAKE_ID', passwd='FAKE_PASS')
|
||||
mock_keystone.trust_get_by_trustor.assert_called_once_with(
|
||||
self.context.user, 'FAKE_ADMIN_ID', self.context.project)
|
||||
self.context.user_id, 'FAKE_ADMIN_ID', self.context.project_id)
|
||||
|
||||
@mock.patch.object(context, "get_service_credentials")
|
||||
@mock.patch("senlin.drivers.base.SenlinDriver")
|
||||
|
@ -124,15 +124,15 @@ class TestTrustMiddleware(base.SenlinTestCase):
|
|||
mock_driver.assert_called_once_with()
|
||||
x_driver.identity.assert_called_once_with({
|
||||
'auth_url': self.context.auth_url,
|
||||
'project_id': self.context.project,
|
||||
'user_id': self.context.user,
|
||||
'project_id': self.context.project_id,
|
||||
'user_id': self.context.user_id,
|
||||
'token': self.context.auth_token,
|
||||
})
|
||||
mock_creds.assert_called_once_with()
|
||||
mock_keystone.get_user_id.assert_called_once_with(
|
||||
uid='FAKE_ID', passwd='FAKE_PASS')
|
||||
mock_keystone.trust_get_by_trustor.assert_called_once_with(
|
||||
self.context.user, 'FAKE_ADMIN_ID', self.context.project)
|
||||
self.context.user_id, 'FAKE_ADMIN_ID', self.context.project_id)
|
||||
|
||||
@mock.patch.object(context, "get_service_credentials")
|
||||
@mock.patch("senlin.drivers.base.SenlinDriver")
|
||||
|
@ -163,17 +163,17 @@ class TestTrustMiddleware(base.SenlinTestCase):
|
|||
mock_driver.assert_called_once_with()
|
||||
x_driver.identity.assert_called_once_with({
|
||||
'auth_url': self.context.auth_url,
|
||||
'project_id': self.context.project,
|
||||
'user_id': self.context.user,
|
||||
'project_id': self.context.project_id,
|
||||
'user_id': self.context.user_id,
|
||||
'token': self.context.auth_token,
|
||||
})
|
||||
mock_creds.assert_called_once_with()
|
||||
mock_keystone.get_user_id.assert_called_once_with(
|
||||
uid='FAKE_ID', passwd='FAKE_PASS')
|
||||
mock_keystone.trust_get_by_trustor.assert_called_once_with(
|
||||
self.context.user, 'FAKE_ADMIN_ID', self.context.project)
|
||||
self.context.user_id, 'FAKE_ADMIN_ID', self.context.project_id)
|
||||
mock_keystone.trust_create.assert_called_once_with(
|
||||
self.context.user, 'FAKE_ADMIN_ID', self.context.project,
|
||||
self.context.user_id, 'FAKE_ADMIN_ID', self.context.project_id,
|
||||
self.context.roles)
|
||||
|
||||
@mock.patch.object(context, "get_service_credentials")
|
||||
|
@ -206,12 +206,12 @@ class TestTrustMiddleware(base.SenlinTestCase):
|
|||
mock_driver.assert_called_once_with()
|
||||
x_driver.identity.assert_called_once_with({
|
||||
'auth_url': self.context.auth_url,
|
||||
'project_id': self.context.project,
|
||||
'user_id': self.context.user,
|
||||
'project_id': self.context.project_id,
|
||||
'user_id': self.context.user_id,
|
||||
'token': self.context.auth_token,
|
||||
})
|
||||
mock_creds.assert_called_once_with()
|
||||
mock_keystone.get_user_id.assert_called_once_with(
|
||||
uid='FAKE_ID', passwd='FAKE_PASS')
|
||||
mock_keystone.trust_get_by_trustor.assert_called_once_with(
|
||||
self.context.user, 'FAKE_ADMIN_ID', self.context.project)
|
||||
self.context.user_id, 'FAKE_ADMIN_ID', self.context.project_id)
|
||||
|
|
|
@ -53,8 +53,8 @@ def dummy_context(user=None, project=None, password=None, roles=None,
|
|||
|
||||
roles = roles or []
|
||||
return context.RequestContext.from_dict({
|
||||
'project': project or 'test_project_id',
|
||||
'user': user_id or 'test_user_id',
|
||||
'project_id': project or 'test_project_id',
|
||||
'user_id': user_id or 'test_user_id',
|
||||
'user_name': user or 'test_username',
|
||||
'password': password or 'password',
|
||||
'roles': roles or [],
|
||||
|
@ -63,7 +63,7 @@ def dummy_context(user=None, project=None, password=None, roles=None,
|
|||
'auth_token': 'abcd1234',
|
||||
'trust_id': trust_id or 'trust_id',
|
||||
'region_name': region_name or 'region_one',
|
||||
'domain': domain or '',
|
||||
'domain_id': domain or '',
|
||||
'api_version': api_version or '1.2',
|
||||
})
|
||||
|
||||
|
@ -79,8 +79,8 @@ def create_profile(context, profile_id):
|
|||
'version': '1.0',
|
||||
},
|
||||
'created_at': timeutils.utcnow(True),
|
||||
'user': context.user,
|
||||
'project': context.project
|
||||
'user': context.user_id,
|
||||
'project': context.project_id,
|
||||
}
|
||||
return objects.Profile.create(context, values)
|
||||
|
||||
|
@ -96,8 +96,8 @@ def create_cluster(context, cluster_id, profile_id, **kwargs):
|
|||
'desired_capacity': 3,
|
||||
'status': 'ACTIVE',
|
||||
'init_at': timeutils.utcnow(True),
|
||||
'user': context.user,
|
||||
'project': context.project,
|
||||
'user': context.user_id,
|
||||
'project': context.project_id,
|
||||
}
|
||||
values.update(kwargs)
|
||||
return objects.Cluster.create(context, values)
|
||||
|
@ -115,8 +115,8 @@ def create_node(context, node_id, profile_id, cluster_id, physical_id=None):
|
|||
'created_at': timeutils.utcnow(True),
|
||||
'role': 'test_node',
|
||||
'status': 'ACTIVE',
|
||||
'user': context.user,
|
||||
'project': context.project,
|
||||
'user': context.user_id,
|
||||
'project': context.project_id,
|
||||
}
|
||||
return objects.Node.create(context, values)
|
||||
|
||||
|
@ -135,7 +135,7 @@ def create_policy(context, policy_id, name=None):
|
|||
}
|
||||
},
|
||||
'created_at': timeutils.utcnow(True),
|
||||
'user': context.user,
|
||||
'project': context.project,
|
||||
'user': context.user_id,
|
||||
'project': context.project_id,
|
||||
}
|
||||
return objects.Policy.create(context, values)
|
||||
|
|
|
@ -53,9 +53,9 @@ UUIDs = (UUID1, UUID2, UUID3) = sorted([uuidutils.generate_uuid()
|
|||
|
||||
def create_profile(context, profile=sample_profile, **kwargs):
|
||||
data = parser.simple_parse(profile)
|
||||
data['user'] = context.user
|
||||
data['project'] = context.project
|
||||
data['domain'] = context.domain
|
||||
data['user'] = context.user_id
|
||||
data['project'] = context.project_id
|
||||
data['domain'] = context.domain_id
|
||||
data.update(kwargs)
|
||||
return db_api.profile_create(context, data)
|
||||
|
||||
|
@ -64,8 +64,8 @@ def create_cluster(ctx, profile, **kwargs):
|
|||
values = {
|
||||
'name': 'db_test_cluster_name',
|
||||
'profile_id': profile.id,
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': 'unknown',
|
||||
'parent': None,
|
||||
'next_index': 1,
|
||||
|
@ -97,7 +97,7 @@ def create_node(ctx, cluster, profile, **kwargs):
|
|||
'physical_id': UUID1,
|
||||
'cluster_id': cluster_id,
|
||||
'profile_id': profile.id,
|
||||
'project': ctx.project,
|
||||
'project': ctx.project_id,
|
||||
'index': index,
|
||||
'role': None,
|
||||
'created_at': None,
|
||||
|
@ -115,9 +115,9 @@ def create_node(ctx, cluster, profile, **kwargs):
|
|||
def create_webhook(ctx, obj_id, obj_type, action, **kwargs):
|
||||
values = {
|
||||
'name': 'test_webhook_name',
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'domain': ctx.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
'created_at': None,
|
||||
'obj_id': obj_id,
|
||||
'obj_type': obj_type,
|
||||
|
@ -151,9 +151,9 @@ def create_policy(ctx, **kwargs):
|
|||
values = {
|
||||
'name': 'test_policy',
|
||||
'type': 'senlin.policy.scaling',
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'domain': ctx.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
'spec': {
|
||||
'type': 'senlin.policy.scaling',
|
||||
'version': '1.0',
|
||||
|
@ -177,8 +177,8 @@ def create_event(ctx, **kwargs):
|
|||
'obj_type': 'CLUSTER',
|
||||
'cluster_id': 'FAKE_CLUSTER',
|
||||
'level': '20',
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'action': 'DANCE',
|
||||
'status': 'READY',
|
||||
'status_reason': 'Just created.',
|
||||
|
|
|
@ -25,9 +25,9 @@ from senlin.tests.unit.db import shared
|
|||
|
||||
def _create_action(context, action_json=shared.sample_action, **kwargs):
|
||||
data = parser.simple_parse(action_json)
|
||||
data['user'] = context.user
|
||||
data['project'] = context.project
|
||||
data['domain'] = context.domain
|
||||
data['user'] = context.user_id
|
||||
data['project'] = context.project_id
|
||||
data['domain'] = context.domain_id
|
||||
data.update(kwargs)
|
||||
return db_api.action_create(context, data)
|
||||
|
||||
|
@ -50,9 +50,9 @@ class DBAPIActionTest(base.SenlinTestCase):
|
|||
self.assertEqual(data['status'], action.status)
|
||||
self.assertEqual(data['status_reason'], action.status_reason)
|
||||
self.assertEqual(10, action.inputs['max_size'])
|
||||
self.assertEqual(self.ctx.user, action.user)
|
||||
self.assertEqual(self.ctx.project, action.project)
|
||||
self.assertEqual(self.ctx.domain, action.domain)
|
||||
self.assertEqual(self.ctx.user_id, action.user)
|
||||
self.assertEqual(self.ctx.project_id, action.project)
|
||||
self.assertEqual(self.ctx.domain_id, action.domain)
|
||||
self.assertIsNone(action.outputs)
|
||||
|
||||
def test_action_update(self):
|
||||
|
|
|
@ -37,8 +37,8 @@ class DBAPIClusterTest(base.SenlinTestCase):
|
|||
self.assertIsNotNone(cluster.id)
|
||||
self.assertEqual('db_test_cluster_name', cluster.name)
|
||||
self.assertEqual(self.profile.id, cluster.profile_id)
|
||||
self.assertEqual(self.ctx.user, cluster.user)
|
||||
self.assertEqual(self.ctx.project, cluster.project)
|
||||
self.assertEqual(self.ctx.user_id, cluster.user)
|
||||
self.assertEqual(self.ctx.project_id, cluster.project)
|
||||
self.assertEqual('unknown', cluster.domain)
|
||||
self.assertIsNone(cluster.parent)
|
||||
self.assertEqual(1, cluster.next_index)
|
||||
|
@ -66,7 +66,7 @@ class DBAPIClusterTest(base.SenlinTestCase):
|
|||
|
||||
def test_cluster_get_from_different_project(self):
|
||||
cluster = shared.create_cluster(self.ctx, self.profile)
|
||||
self.ctx.project = 'abc'
|
||||
self.ctx.project_id = 'abc'
|
||||
ret_cluster = db_api.cluster_get(self.ctx, cluster.id,
|
||||
project_safe=False)
|
||||
self.assertEqual(cluster.id, ret_cluster.id)
|
||||
|
@ -96,7 +96,7 @@ class DBAPIClusterTest(base.SenlinTestCase):
|
|||
|
||||
self.assertIsNone(db_api.cluster_get_by_name(self.ctx, 'abc'))
|
||||
|
||||
self.ctx.project = 'abc'
|
||||
self.ctx.project_id = 'abc'
|
||||
self.assertIsNone(db_api.cluster_get_by_name(self.ctx, cluster.name))
|
||||
|
||||
def test_cluster_get_by_name_diff_project(self):
|
||||
|
@ -112,11 +112,11 @@ class DBAPIClusterTest(base.SenlinTestCase):
|
|||
res = db_api.cluster_get_by_name(self.ctx, 'cluster_A')
|
||||
self.assertIsNone(res)
|
||||
|
||||
self.ctx.project = UUID3
|
||||
self.ctx.project_id = UUID3
|
||||
self.assertIsNone(db_api.cluster_get_by_name(self.ctx,
|
||||
'cluster_A'))
|
||||
|
||||
self.ctx.project = UUID2
|
||||
self.ctx.project_id = UUID2
|
||||
res = db_api.cluster_get_by_name(self.ctx, 'cluster_A')
|
||||
self.assertEqual(cluster1.id, res.id)
|
||||
|
||||
|
@ -189,15 +189,15 @@ class DBAPIClusterTest(base.SenlinTestCase):
|
|||
]
|
||||
[shared.create_cluster(self.ctx, self.profile, **v) for v in values]
|
||||
|
||||
self.ctx.project = UUID1
|
||||
self.ctx.project_id = UUID1
|
||||
clusters = db_api.cluster_get_all(self.ctx)
|
||||
self.assertEqual(2, len(clusters))
|
||||
|
||||
self.ctx.project = UUID2
|
||||
self.ctx.project_id = UUID2
|
||||
clusters = db_api.cluster_get_all(self.ctx)
|
||||
self.assertEqual(3, len(clusters))
|
||||
|
||||
self.ctx.project = UUID3
|
||||
self.ctx.project_id = UUID3
|
||||
self.assertEqual([], db_api.cluster_get_all(self.ctx))
|
||||
|
||||
def test_cluster_get_all_with_project_safe_false(self):
|
||||
|
@ -339,10 +339,10 @@ class DBAPIClusterTest(base.SenlinTestCase):
|
|||
]
|
||||
[shared.create_cluster(self.ctx, self.profile, **v) for v in values]
|
||||
|
||||
self.ctx.project = UUID1
|
||||
self.ctx.project_id = UUID1
|
||||
self.assertEqual(2, db_api.cluster_count_all(self.ctx))
|
||||
|
||||
self.ctx.project = UUID2
|
||||
self.ctx.project_id = UUID2
|
||||
self.assertEqual(3, db_api.cluster_count_all(self.ctx))
|
||||
|
||||
def test_cluster_count_all_with_project_safe_false(self):
|
||||
|
@ -441,8 +441,8 @@ class DBAPIClusterTest(base.SenlinTestCase):
|
|||
policy_data = {
|
||||
'name': 'test_policy',
|
||||
'type': 'ScalingPolicy',
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'spec': {'foo': 'bar'},
|
||||
'data': None,
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ class DBAPIClusterPolicyTest(base.SenlinTestCase):
|
|||
data = {
|
||||
'name': 'test_policy',
|
||||
'type': 'ScalingPolicy',
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'domain': self.ctx.domain,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'domain': self.ctx.domain_id,
|
||||
'spec': {
|
||||
'min_size': 1,
|
||||
'max_size': 10,
|
||||
|
|
|
@ -62,8 +62,8 @@ class DBAPIEventTest(base.SenlinTestCase):
|
|||
'action': action or '',
|
||||
'status': status or '',
|
||||
'status_reason': status_reason or '',
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
}
|
||||
|
||||
# Make sure all fields can be customized
|
||||
|
@ -85,8 +85,8 @@ class DBAPIEventTest(base.SenlinTestCase):
|
|||
self.assertEqual('', ret_event.action)
|
||||
self.assertEqual('', ret_event.status)
|
||||
self.assertEqual('', ret_event.status_reason)
|
||||
self.assertEqual(self.ctx.user, ret_event.user)
|
||||
self.assertEqual(self.ctx.project, ret_event.project)
|
||||
self.assertEqual(self.ctx.user_id, ret_event.user)
|
||||
self.assertEqual(self.ctx.project_id, ret_event.project)
|
||||
|
||||
def test_event_get_diff_project(self):
|
||||
event = self.create_event(self.ctx)
|
||||
|
@ -228,11 +228,11 @@ class DBAPIEventTest(base.SenlinTestCase):
|
|||
self.assertEqual(event3.id, events[2].id)
|
||||
|
||||
def test_event_get_all_project_safe(self):
|
||||
self.ctx.project = 'project_1'
|
||||
self.ctx.project_id = 'project_1'
|
||||
cluster1 = shared.create_cluster(self.ctx, self.profile,
|
||||
name='cluster1')
|
||||
self.create_event(self.ctx, entity=cluster1)
|
||||
self.ctx.project = 'project_2'
|
||||
self.ctx.project_id = 'project_2'
|
||||
cluster2 = shared.create_cluster(self.ctx, self.profile,
|
||||
name='cluster2')
|
||||
self.create_event(self.ctx, entity=cluster2, action='CLUSTER_CREATE')
|
||||
|
@ -261,11 +261,11 @@ class DBAPIEventTest(base.SenlinTestCase):
|
|||
self.assertIn(cluster2.name, onames)
|
||||
|
||||
def test_event_get_all_admin_context(self):
|
||||
self.ctx.project = 'project_1'
|
||||
self.ctx.project_id = 'project_1'
|
||||
cluster1 = shared.create_cluster(self.ctx, self.profile,
|
||||
name='cluster1')
|
||||
self.create_event(self.ctx, entity=cluster1)
|
||||
self.ctx.project = 'project_2'
|
||||
self.ctx.project_id = 'project_2'
|
||||
cluster2 = shared.create_cluster(self.ctx, self.profile,
|
||||
name='cluster2')
|
||||
self.create_event(self.ctx, entity=cluster2, action='CLUSTER_CREATE')
|
||||
|
|
|
@ -242,7 +242,7 @@ class GCByEngineTest(base.SenlinTestCase):
|
|||
engine_id = UUID1
|
||||
action = shared.create_action(self.ctx, target=self.cluster.id,
|
||||
status='RUNNING', owner=engine_id,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
db_api.cluster_lock_acquire(self.cluster.id, action.id, -1)
|
||||
|
||||
# do it
|
||||
|
@ -271,7 +271,7 @@ class GCByEngineTest(base.SenlinTestCase):
|
|||
engine_id = UUID1
|
||||
action = shared.create_action(self.ctx, target=self.node.id,
|
||||
status='RUNNING', owner=engine_id,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
db_api.cluster_lock_acquire(self.cluster.id, action.id, 1)
|
||||
db_api.node_lock_acquire(self.cluster.id, action.id)
|
||||
|
||||
|
@ -306,7 +306,7 @@ class GCByEngineTest(base.SenlinTestCase):
|
|||
engine_id = UUID1
|
||||
action = shared.create_action(self.ctx, target=self.node.id,
|
||||
status='RUNNING', owner=engine_id,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
db_api.cluster_lock_acquire(self.cluster.id, action.id, 1)
|
||||
db_api.cluster_lock_acquire(self.cluster.id, UUID2, 1)
|
||||
db_api.node_lock_acquire(self.node.id, action.id)
|
||||
|
@ -350,7 +350,7 @@ class DummyGCByEngineTest(base.SenlinTestCase):
|
|||
engine_id = UUID1
|
||||
action = shared.create_action(self.ctx, target=self.cluster.id,
|
||||
status='RUNNING', owner=engine_id,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
db_api.cluster_lock_acquire(self.cluster.id, action.id, -1)
|
||||
|
||||
# do it
|
||||
|
@ -379,7 +379,7 @@ class DummyGCByEngineTest(base.SenlinTestCase):
|
|||
engine_id = UUID1
|
||||
action = shared.create_action(self.ctx, target=self.node.id,
|
||||
status='RUNNING', owner=engine_id,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
db_api.cluster_lock_acquire(self.cluster.id, action.id, 1)
|
||||
db_api.node_lock_acquire(self.cluster.id, action.id)
|
||||
|
||||
|
@ -414,7 +414,7 @@ class DummyGCByEngineTest(base.SenlinTestCase):
|
|||
engine_id = UUID1
|
||||
action = shared.create_action(self.ctx, target=self.node.id,
|
||||
status='RUNNING', owner=engine_id,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
db_api.cluster_lock_acquire(self.cluster.id, action.id, 1)
|
||||
db_api.cluster_lock_acquire(self.cluster.id, UUID2, 1)
|
||||
db_api.node_lock_acquire(self.node.id, action.id)
|
||||
|
@ -445,15 +445,15 @@ class DummyGCByEngineTest(base.SenlinTestCase):
|
|||
|
||||
c_action = shared.create_action(self.ctx, target=self.cluster.id,
|
||||
status='WAITING', owner=engine1,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
|
||||
n_action_1 = shared.create_action(self.ctx, target=self.node.id,
|
||||
status='RUNNING', owner=engine1,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
|
||||
n_action_2 = shared.create_action(self.ctx, target=node2.id,
|
||||
status='RUNNING', owner=engine2,
|
||||
project=self.ctx.project)
|
||||
project=self.ctx.project_id)
|
||||
|
||||
db_api.dependency_add(self.ctx, [n_action_1.id, n_action_2.id],
|
||||
c_action.id)
|
||||
|
|
|
@ -351,11 +351,11 @@ class DBAPINodeTest(base.SenlinTestCase):
|
|||
shared.create_node(self.ctx, None, self.profile, name='node1')
|
||||
shared.create_node(self.ctx, None, self.profile, name='node2')
|
||||
|
||||
self.ctx.project = 'a-different-project'
|
||||
self.ctx.project_id = 'a-different-project'
|
||||
results = db_api.node_get_all(self.ctx, project_safe=False)
|
||||
self.assertEqual(2, len(results))
|
||||
|
||||
self.ctx.project = 'a-different-project'
|
||||
self.ctx.project_id = 'a-different-project'
|
||||
results = db_api.node_get_all(self.ctx)
|
||||
self.assertEqual(0, len(results))
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ class DBAPIPolicyTest(base.SenlinTestCase):
|
|||
data = {
|
||||
'name': 'test_policy',
|
||||
'type': 'ScalingPolicy',
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'domain': self.ctx.domain,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'domain': self.ctx.domain_id,
|
||||
'spec': sample_spec,
|
||||
'data': None,
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ class DBAPIReceiverTest(base.SenlinTestCase):
|
|||
values = {
|
||||
'name': 'test_receiver',
|
||||
'type': type or self.type,
|
||||
'user': ctx.user,
|
||||
'project': ctx.project,
|
||||
'domain': ctx.domain,
|
||||
'user': ctx.user_id,
|
||||
'project': ctx.project_id,
|
||||
'domain': ctx.domain_id,
|
||||
'created_at': None,
|
||||
'updated_at': None,
|
||||
'cluster_id': cluster_id or self.cluster_id,
|
||||
|
@ -55,9 +55,9 @@ class DBAPIReceiverTest(base.SenlinTestCase):
|
|||
self.assertEqual(self.cluster_id, r.cluster_id)
|
||||
self.assertEqual('test_receiver', r.name)
|
||||
self.assertEqual(self.type, r.type)
|
||||
self.assertEqual(self.ctx.user, r.user)
|
||||
self.assertEqual(self.ctx.project, r.project)
|
||||
self.assertEqual(self.ctx.domain, r.domain)
|
||||
self.assertEqual(self.ctx.user_id, r.user)
|
||||
self.assertEqual(self.ctx.project_id, r.project)
|
||||
self.assertEqual(self.ctx.domain_id, r.domain)
|
||||
self.assertIsNone(r.created_at)
|
||||
self.assertIsNone(r.updated_at)
|
||||
self.assertEqual(self.action, r.action)
|
||||
|
@ -277,11 +277,11 @@ class DBAPIReceiverTest(base.SenlinTestCase):
|
|||
self._create_receiver(self.ctx, name='receiver1')
|
||||
self._create_receiver(self.ctx, name='receiver2')
|
||||
|
||||
self.ctx.project = 'a-different-project'
|
||||
self.ctx.project_id = 'a-different-project'
|
||||
results = db_api.receiver_get_all(self.ctx, project_safe=False)
|
||||
self.assertEqual(2, len(results))
|
||||
|
||||
self.ctx.project = 'a-different-project'
|
||||
self.ctx.project_id = 'a-different-project'
|
||||
results = db_api.receiver_get_all(self.ctx)
|
||||
self.assertEqual(0, len(results))
|
||||
|
||||
|
|
|
@ -71,8 +71,6 @@ class ActionBaseTest(base.SenlinTestCase):
|
|||
'created_at': timeutils.utcnow(True),
|
||||
'updated_at': None,
|
||||
'data': {'data_key': 'data_value'},
|
||||
'user': USER_ID,
|
||||
'project': PROJECT_ID,
|
||||
}
|
||||
|
||||
def _verify_new_action(self, obj, target, action):
|
||||
|
@ -630,8 +628,8 @@ class ActionPolicyCheckTest(base.SenlinTestCase):
|
|||
|
||||
def _create_policy(self):
|
||||
values = {
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
}
|
||||
policy = fakes.TestPolicy('DummyPolicy', 'test-policy', **values)
|
||||
policy.store(self.ctx)
|
||||
|
|
|
@ -55,9 +55,9 @@ class TestReceiver(base.SenlinTestCase):
|
|||
'type': 'webhook',
|
||||
'cluster_id': CLUSTER_ID,
|
||||
'action': 'test-action',
|
||||
'user': self.context.user,
|
||||
'project': self.context.project,
|
||||
'domain': self.context.domain,
|
||||
'user': self.context.user_id,
|
||||
'project': self.context.project_id,
|
||||
'domain': self.context.domain_id,
|
||||
'created_at': timeutils.utcnow(True),
|
||||
'updated_at': None,
|
||||
'actor': self.actor,
|
||||
|
@ -121,7 +121,7 @@ class TestReceiver(base.SenlinTestCase):
|
|||
def test_receiver_store(self):
|
||||
receiver = rb.Receiver('webhook', CLUSTER_ID, 'test-action',
|
||||
name='test_receiver_123456',
|
||||
project=self.context.project)
|
||||
project=self.context.project_id)
|
||||
self.assertIsNone(receiver.id)
|
||||
|
||||
receiver_id = receiver.store(self.context)
|
||||
|
@ -162,9 +162,9 @@ class TestReceiver(base.SenlinTestCase):
|
|||
'FAKE_ACTION',
|
||||
name='test_receiver_2234')
|
||||
|
||||
self.assertEqual(ctx.user, receiver.user)
|
||||
self.assertEqual(ctx.project, receiver.project)
|
||||
self.assertEqual(ctx.domain, receiver.domain)
|
||||
self.assertEqual(ctx.user_id, receiver.user)
|
||||
self.assertEqual(ctx.project_id, receiver.project)
|
||||
self.assertEqual(ctx.domain_id, receiver.domain)
|
||||
self.assertEqual('123abc', receiver.actor['trust_id'])
|
||||
mock_c_get.assert_called_once_with(ctx, 'user1', 'project1')
|
||||
|
||||
|
@ -177,9 +177,9 @@ class TestReceiver(base.SenlinTestCase):
|
|||
'FAKE_ACTION',
|
||||
name='test_receiver_2234')
|
||||
|
||||
self.assertEqual(ctx.user, receiver.user)
|
||||
self.assertEqual(ctx.project, receiver.project)
|
||||
self.assertEqual(ctx.domain, receiver.domain)
|
||||
self.assertEqual(ctx.user_id, receiver.user)
|
||||
self.assertEqual(ctx.project_id, receiver.project)
|
||||
self.assertEqual(ctx.domain_id, receiver.domain)
|
||||
self.assertIsNone(receiver.actor['trust_id'])
|
||||
|
||||
@mock.patch.object(rm.Message, 'initialize_channel')
|
||||
|
@ -187,9 +187,9 @@ class TestReceiver(base.SenlinTestCase):
|
|||
receiver = rb.Receiver.create(self.context, 'message', None,
|
||||
None, name='test_receiver_2234')
|
||||
|
||||
self.assertEqual(self.context.user, receiver.user)
|
||||
self.assertEqual(self.context.project, receiver.project)
|
||||
self.assertEqual(self.context.domain, receiver.domain)
|
||||
self.assertEqual(self.context.user_id, receiver.user)
|
||||
self.assertEqual(self.context.project_id, receiver.project)
|
||||
self.assertEqual(self.context.domain_id, receiver.domain)
|
||||
|
||||
def _verify_receiver(self, receiver, result):
|
||||
self.assertEqual(receiver.id, result.id)
|
||||
|
|
|
@ -145,8 +145,8 @@ class ClusterTest(base.SenlinTestCase):
|
|||
min_size=0, max_size=-1, timeout=3600, metadata={},
|
||||
dependents={}, data={}, next_index=1, status='INIT',
|
||||
config={},
|
||||
status_reason='Initializing', user=self.ctx.user,
|
||||
project=self.ctx.project, domain=self.ctx.domain))
|
||||
status_reason='Initializing', user=self.ctx.user_id,
|
||||
project=self.ctx.project_id, domain=self.ctx.domain_id))
|
||||
mock_action.assert_called_once_with(
|
||||
self.ctx,
|
||||
'12345678ABC', 'CLUSTER_CREATE',
|
||||
|
@ -189,8 +189,8 @@ class ClusterTest(base.SenlinTestCase):
|
|||
min_size=1, max_size=5, timeout=3600, metadata={},
|
||||
dependents={}, data={}, next_index=1, status='INIT',
|
||||
config={'k1': 'v1'},
|
||||
status_reason='Initializing', user=self.ctx.user,
|
||||
project=self.ctx.project, domain=self.ctx.domain))
|
||||
status_reason='Initializing', user=self.ctx.user_id,
|
||||
project=self.ctx.project_id, domain=self.ctx.domain_id))
|
||||
mock_action.assert_called_once_with(
|
||||
self.ctx,
|
||||
'12345678ABC', 'CLUSTER_CREATE',
|
||||
|
|
|
@ -55,21 +55,21 @@ class CredentialTest(base.SenlinTestCase):
|
|||
x_data = {'openstack': {'foo': 'bar'}}
|
||||
x_cred = mock.Mock(cred=x_data)
|
||||
mock_get.return_value = x_cred
|
||||
req = vorc.CredentialGetRequest(user=self.ctx.user,
|
||||
project=self.ctx.project,
|
||||
req = vorc.CredentialGetRequest(user=self.ctx.user_id,
|
||||
project=self.ctx.project_id,
|
||||
query={'k1': 'v1'})
|
||||
|
||||
result = self.eng.credential_get(self.ctx, req.obj_to_primitive())
|
||||
|
||||
self.assertEqual({'foo': 'bar'}, result)
|
||||
mock_get.assert_called_once_with(
|
||||
self.ctx, 'fake_user_id', 'fake_project_id')
|
||||
self.ctx, u'fake_user_id', u'fake_project_id')
|
||||
|
||||
@mock.patch.object(co.Credential, 'get')
|
||||
def test_credential_get_not_found(self, mock_get):
|
||||
mock_get.return_value = None
|
||||
req = vorc.CredentialGetRequest(user=self.ctx.user,
|
||||
project=self.ctx.project)
|
||||
req = vorc.CredentialGetRequest(user=self.ctx.user_id,
|
||||
project=self.ctx.project_id)
|
||||
|
||||
result = self.eng.credential_get(self.ctx, req.obj_to_primitive())
|
||||
|
||||
|
@ -81,8 +81,8 @@ class CredentialTest(base.SenlinTestCase):
|
|||
def test_credential_get_data_not_match(self, mock_get):
|
||||
x_cred = mock.Mock(cred={'bogkey': 'bogval'})
|
||||
mock_get.return_value = x_cred
|
||||
req = vorc.CredentialGetRequest(user=self.ctx.user,
|
||||
project=self.ctx.project)
|
||||
req = vorc.CredentialGetRequest(user=self.ctx.user_id,
|
||||
project=self.ctx.project_id)
|
||||
|
||||
result = self.eng.credential_get(self.ctx, req.obj_to_primitive())
|
||||
|
||||
|
|
|
@ -166,9 +166,9 @@ class NodeTest(base.SenlinTestCase):
|
|||
'index': -1,
|
||||
'role': '',
|
||||
'metadata': {},
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'domain': self.ctx.domain,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'domain': self.ctx.domain_id,
|
||||
'data': {},
|
||||
'init_at': mock.ANY,
|
||||
'dependents': {},
|
||||
|
@ -220,9 +220,9 @@ class NodeTest(base.SenlinTestCase):
|
|||
'index': 12345,
|
||||
'role': '',
|
||||
'metadata': {},
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'domain': self.ctx.domain,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'domain': self.ctx.domain_id,
|
||||
'data': {},
|
||||
'init_at': mock.ANY,
|
||||
'dependents': {},
|
||||
|
@ -282,9 +282,9 @@ class NodeTest(base.SenlinTestCase):
|
|||
'metadata': {},
|
||||
'status': 'INIT',
|
||||
'status_reason': 'Initializing',
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'domain': self.ctx.domain,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'domain': self.ctx.domain_id,
|
||||
'data': {},
|
||||
'dependents': {},
|
||||
'init_at': mock.ANY,
|
||||
|
@ -845,9 +845,9 @@ class NodeTest(base.SenlinTestCase):
|
|||
'status_reason': 'Node adopted successfully',
|
||||
'init_at': mock.ANY,
|
||||
'created_at': mock.ANY,
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'domain': self.ctx.domain
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'domain': self.ctx.domain_id
|
||||
}
|
||||
mock_create.assert_called_once_with(self.ctx, attrs)
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ class ReceiverTest(base.SenlinTestCase):
|
|||
@mock.patch.object(rb.Receiver, 'create')
|
||||
def test_receiver_create_webhook_succeed(self, mock_create, mock_find):
|
||||
fake_cluster = mock.Mock()
|
||||
fake_cluster.user = self.ctx.user
|
||||
fake_cluster.user = self.ctx.user_id
|
||||
mock_find.return_value = fake_cluster
|
||||
|
||||
fake_receiver = mock.Mock(id='FAKE_RECEIVER')
|
||||
|
@ -117,8 +117,8 @@ class ReceiverTest(base.SenlinTestCase):
|
|||
mock_find.assert_called_once_with(self.ctx, 'C1')
|
||||
mock_create.assert_called_once_with(
|
||||
self.ctx, 'webhook', fake_cluster, consts.CLUSTER_RESIZE,
|
||||
name='r1', user=self.ctx.user, project=self.ctx.project,
|
||||
domain=self.ctx.domain, params={})
|
||||
name='r1', user=self.ctx.user_id, project=self.ctx.project_id,
|
||||
domain=self.ctx.domain_id, params={})
|
||||
|
||||
# test params passed
|
||||
mock_create.reset_mock()
|
||||
|
@ -129,8 +129,8 @@ class ReceiverTest(base.SenlinTestCase):
|
|||
self.eng.receiver_create(self.ctx, req.obj_to_primitive())
|
||||
mock_create.assert_called_once_with(
|
||||
self.ctx, 'webhook', fake_cluster, consts.CLUSTER_RESIZE,
|
||||
name='r1', user=self.ctx.user, project=self.ctx.project,
|
||||
domain=self.ctx.domain, params={'FOO': 'BAR'})
|
||||
name='r1', user=self.ctx.user_id, project=self.ctx.project_id,
|
||||
domain=self.ctx.domain_id, params={'FOO': 'BAR'})
|
||||
|
||||
@mock.patch.object(ro.Receiver, 'get_by_name')
|
||||
def test_receiver_create_name_duplicated(self, mock_get):
|
||||
|
@ -210,7 +210,7 @@ class ReceiverTest(base.SenlinTestCase):
|
|||
@mock.patch.object(co.Cluster, 'find')
|
||||
def test_receiver_create_webhook_cluster_not_specified(self, mock_find):
|
||||
fake_cluster = mock.Mock()
|
||||
fake_cluster.user = self.ctx.user
|
||||
fake_cluster.user = self.ctx.user_id
|
||||
mock_find.return_value = fake_cluster
|
||||
req1 = orro.ReceiverCreateRequestBody(name='r1', type='webhook',
|
||||
action='CLUSTER_RESIZE')
|
||||
|
@ -230,7 +230,7 @@ class ReceiverTest(base.SenlinTestCase):
|
|||
@mock.patch.object(co.Cluster, 'find')
|
||||
def test_receiver_create_webhook_action_not_specified(self, mock_find):
|
||||
fake_cluster = mock.Mock()
|
||||
fake_cluster.user = self.ctx.user
|
||||
fake_cluster.user = self.ctx.user_id
|
||||
mock_find.return_value = fake_cluster
|
||||
req1 = orro.ReceiverCreateRequestBody(name='r1', type='webhook',
|
||||
cluster_id='C1')
|
||||
|
@ -260,8 +260,8 @@ class ReceiverTest(base.SenlinTestCase):
|
|||
self.assertIsInstance(result, dict)
|
||||
self.assertEqual('FAKE_RECEIVER', result['id'])
|
||||
mock_create.assert_called_once_with(
|
||||
self.ctx, 'message', None, None, name='r1', user=self.ctx.user,
|
||||
project=self.ctx.project, domain=self.ctx.domain, params={})
|
||||
self.ctx, 'message', None, None, name='r1', user=self.ctx.user_id,
|
||||
project=self.ctx.project_id, domain=self.ctx.domain_id, params={})
|
||||
|
||||
@mock.patch.object(ro.Receiver, 'find')
|
||||
def test_receiver_get(self, mock_find):
|
||||
|
@ -380,7 +380,7 @@ class ReceiverTest(base.SenlinTestCase):
|
|||
fake_obj = mock.Mock()
|
||||
fake_obj.id = 'FAKE_ID'
|
||||
fake_obj.type = 'message'
|
||||
fake_obj.user = self.ctx.user
|
||||
fake_obj.user = self.ctx.user_id
|
||||
fake_receiver = mock.Mock()
|
||||
mock_find.return_value = fake_obj
|
||||
mock_load.return_value = fake_receiver
|
||||
|
@ -421,7 +421,7 @@ class ReceiverTest(base.SenlinTestCase):
|
|||
def test_receiver_notify_incorrect_type(self, mock_find):
|
||||
fake_obj = mock.Mock()
|
||||
fake_obj.id = 'FAKE_ID'
|
||||
fake_obj.user = self.ctx.user
|
||||
fake_obj.user = self.ctx.user_id
|
||||
fake_obj.type = 'not_message'
|
||||
mock_find.return_value = fake_obj
|
||||
|
||||
|
|
|
@ -135,8 +135,8 @@ class TestCluster(base.SenlinTestCase):
|
|||
|
||||
def test_store_for_create(self):
|
||||
cluster = cm.Cluster('test-cluster', 0, PROFILE_ID,
|
||||
user=self.context.user,
|
||||
project=self.context.project)
|
||||
user=self.context.user_id,
|
||||
project=self.context.project_id)
|
||||
mock_load = self.patchobject(cluster, '_load_runtime_data')
|
||||
self.assertIsNone(cluster.id)
|
||||
|
||||
|
@ -149,9 +149,9 @@ class TestCluster(base.SenlinTestCase):
|
|||
self.assertIsNotNone(result)
|
||||
self.assertEqual('test-cluster', result.name)
|
||||
self.assertEqual(PROFILE_ID, result.profile_id)
|
||||
self.assertEqual(self.context.user, result.user)
|
||||
self.assertEqual(self.context.project, result.project)
|
||||
self.assertEqual(self.context.domain, result.domain)
|
||||
self.assertEqual(self.context.user_id, result.user)
|
||||
self.assertEqual(self.context.project_id, result.project)
|
||||
self.assertEqual(self.context.domain_id, result.domain)
|
||||
|
||||
self.assertIsNotNone(result.init_at)
|
||||
self.assertIsNone(result.created_at)
|
||||
|
@ -169,8 +169,8 @@ class TestCluster(base.SenlinTestCase):
|
|||
|
||||
def test_store_for_update(self):
|
||||
cluster = cm.Cluster('test-cluster', 0, PROFILE_ID,
|
||||
user=self.context.user,
|
||||
project=self.context.project)
|
||||
user=self.context.user_id,
|
||||
project=self.context.project_id)
|
||||
mock_load = self.patchobject(cluster, '_load_runtime_data')
|
||||
self.assertIsNone(cluster.id)
|
||||
|
||||
|
@ -197,8 +197,8 @@ class TestCluster(base.SenlinTestCase):
|
|||
self.assertIsNotNone(result)
|
||||
|
||||
self.assertEqual('test-cluster-1', result.name)
|
||||
self.assertEqual(self.context.user, result.user)
|
||||
self.assertEqual(self.context.project, result.project)
|
||||
self.assertEqual(self.context.user_id, result.user)
|
||||
self.assertEqual(self.context.project_id, result.project)
|
||||
|
||||
self.assertEqual(1, result.min_size)
|
||||
self.assertEqual(3, result.max_size)
|
||||
|
|
|
@ -78,9 +78,9 @@ class TestNode(base.SenlinTestCase):
|
|||
self.assertIsNone(node_info.physical_id)
|
||||
self.assertEqual(CLUSTER_ID, node_info.cluster_id)
|
||||
self.assertEqual(PROFILE_ID, node_info.profile_id)
|
||||
self.assertEqual(self.context.user, node_info.user)
|
||||
self.assertEqual(self.context.project, node_info.project)
|
||||
self.assertEqual(self.context.domain, node_info.domain)
|
||||
self.assertEqual(self.context.user_id, node_info.user)
|
||||
self.assertEqual(self.context.project_id, node_info.project)
|
||||
self.assertEqual(self.context.domain_id, node_info.domain)
|
||||
self.assertEqual(1, node_info.index)
|
||||
self.assertEqual('first_node', node.role)
|
||||
|
||||
|
@ -94,8 +94,8 @@ class TestNode(base.SenlinTestCase):
|
|||
self.assertEqual({}, node_info.data)
|
||||
|
||||
def test_node_store_update(self):
|
||||
node = nodem.Node('node1', PROFILE_ID, "", user=self.context.user,
|
||||
project=self.context.project)
|
||||
node = nodem.Node('node1', PROFILE_ID, "", user=self.context.user_id,
|
||||
project=self.context.project_id)
|
||||
node_id = node.store(self.context)
|
||||
|
||||
node.name = 'new_name'
|
||||
|
|
|
@ -50,8 +50,8 @@ class TestDatabase(testtools.TestCase):
|
|||
'otype': 'CLUSTER',
|
||||
'oname': 'cluster1',
|
||||
'cluster_id': 'CLUSTER_ID',
|
||||
'user': self.context.user,
|
||||
'project': self.context.project,
|
||||
'user': self.context.user_id,
|
||||
'project': self.context.project_id,
|
||||
'action': 'ACTION',
|
||||
'status': 'STATUS',
|
||||
'status_reason': 'REASON',
|
||||
|
@ -83,8 +83,8 @@ class TestDatabase(testtools.TestCase):
|
|||
'otype': 'NODE',
|
||||
'oname': 'node1',
|
||||
'cluster_id': 'CLUSTER_ID',
|
||||
'user': self.context.user,
|
||||
'project': self.context.project,
|
||||
'user': self.context.user_id,
|
||||
'project': self.context.project_id,
|
||||
'action': 'ACTION',
|
||||
'status': 'S1',
|
||||
'status_reason': 'R1',
|
||||
|
@ -113,8 +113,8 @@ class TestDatabase(testtools.TestCase):
|
|||
'otype': 'CLUSTER',
|
||||
'oname': 'cluster1',
|
||||
'cluster_id': 'CLUSTER_ID',
|
||||
'user': self.context.user,
|
||||
'project': self.context.project,
|
||||
'user': self.context.user_id,
|
||||
'project': self.context.project_id,
|
||||
'action': 'dance',
|
||||
'status': 'STATUS',
|
||||
'status_reason': 'REASON',
|
||||
|
|
|
@ -76,13 +76,13 @@ class TestMessageEvent(testtools.TestCase):
|
|||
'inputs': '{}',
|
||||
'name': 'fake_name',
|
||||
'outputs': '{}',
|
||||
'project': self.ctx.project,
|
||||
'project': self.ctx.project_id,
|
||||
'start_time': 1.23,
|
||||
'status': 'RUNNING',
|
||||
'status_reason': 'Good',
|
||||
'target': cluster_id,
|
||||
'timeout': 3600,
|
||||
'user': self.ctx.user,
|
||||
'user': self.ctx.user_id,
|
||||
},
|
||||
'senlin_object.name': 'ActionPayload',
|
||||
'senlin_object.namespace': 'senlin',
|
||||
|
@ -169,13 +169,13 @@ class TestMessageEvent(testtools.TestCase):
|
|||
'inputs': '{}',
|
||||
'name': 'fake_name',
|
||||
'outputs': '{}',
|
||||
'project': self.ctx.project,
|
||||
'project': self.ctx.project_id,
|
||||
'start_time': 1.23,
|
||||
'status': 'RUNNING',
|
||||
'status_reason': 'Good',
|
||||
'target': node_id,
|
||||
'timeout': 3600,
|
||||
'user': self.ctx.user,
|
||||
'user': self.ctx.user_id,
|
||||
},
|
||||
'senlin_object.name': 'ActionPayload',
|
||||
'senlin_object.namespace': 'senlin',
|
||||
|
|
|
@ -110,8 +110,8 @@ class TestCluster(base.SenlinTestCase):
|
|||
'max_size': -1,
|
||||
'min_size': 0,
|
||||
'timeout': cfg.CONF.default_action_timeout,
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
}
|
||||
cluster = co.Cluster.create(self.ctx, values)
|
||||
fake_profile = mock.Mock()
|
||||
|
|
|
@ -100,8 +100,8 @@ class TestNode(base.SenlinTestCase):
|
|||
'name': 'test_node',
|
||||
'profile_id': PROFILE_ID,
|
||||
'cluster_id': CLUSTER_ID,
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'index': -1,
|
||||
'init_at': timeutils.utcnow(True),
|
||||
'status': 'Initializing',
|
||||
|
|
|
@ -69,9 +69,9 @@ class TestPolicyBase(base.SenlinTestCase):
|
|||
|
||||
def _create_policy(self, policy_name, policy_id=None):
|
||||
policy = pb.Policy(policy_name, self.spec,
|
||||
user=self.ctx.user,
|
||||
project=self.ctx.project,
|
||||
domain=self.ctx.domain)
|
||||
user=self.ctx.user_id,
|
||||
project=self.ctx.project_id,
|
||||
domain=self.ctx.domain_id)
|
||||
if policy_id:
|
||||
policy.id = policy_id
|
||||
|
||||
|
@ -83,9 +83,9 @@ class TestPolicyBase(base.SenlinTestCase):
|
|||
'type': 'senlin.policy.dummy-1.0',
|
||||
'spec': self.spec,
|
||||
'created_at': timeutils.utcnow(True),
|
||||
'user': self.ctx.user,
|
||||
'project': self.ctx.project,
|
||||
'domain': self.ctx.domain,
|
||||
'user': self.ctx.user_id,
|
||||
'project': self.ctx.project_id,
|
||||
'domain': self.ctx.domain_id,
|
||||
}
|
||||
|
||||
values.update(kwargs)
|
||||
|
@ -98,9 +98,9 @@ class TestPolicyBase(base.SenlinTestCase):
|
|||
self.assertEqual('test-policy', policy.name)
|
||||
self.assertEqual(self.spec, policy.spec)
|
||||
self.assertEqual('senlin.policy.dummy-1.0', policy.type)
|
||||
self.assertEqual(self.ctx.user, policy.user)
|
||||
self.assertEqual(self.ctx.project, policy.project)
|
||||
self.assertEqual(self.ctx.domain, policy.domain)
|
||||
self.assertEqual(self.ctx.user_id, policy.user)
|
||||
self.assertEqual(self.ctx.project_id, policy.project)
|
||||
self.assertEqual(self.ctx.domain_id, policy.domain)
|
||||
self.assertEqual({}, policy.data)
|
||||
self.assertIsNone(policy.created_at)
|
||||
self.assertIsNone(policy.updated_at)
|
||||
|
|
|
@ -88,9 +88,9 @@ class TestProfileBase(base.SenlinTestCase):
|
|||
|
||||
def _create_profile(self, name, pid=None, context=None):
|
||||
profile = pb.Profile(name, self.spec,
|
||||
user=self.ctx.user,
|
||||
project=self.ctx.project,
|
||||
domain=self.ctx.domain,
|
||||
user=self.ctx.user_id,
|
||||
project=self.ctx.project_id,
|
||||
domain=self.ctx.domain_id,
|
||||
context=context)
|
||||
if pid:
|
||||
profile.id = pid
|
||||
|
@ -109,9 +109,9 @@ class TestProfileBase(base.SenlinTestCase):
|
|||
self.assertEqual('os.dummy', profile.type_name)
|
||||
self.assertEqual('1.0', profile.version)
|
||||
self.assertEqual('os.dummy-1.0', profile.type)
|
||||
self.assertEqual(self.ctx.user, profile.user)
|
||||
self.assertEqual(self.ctx.project, profile.project)
|
||||
self.assertEqual(self.ctx.domain, profile.domain)
|
||||
self.assertEqual(self.ctx.user_id, profile.user)
|
||||
self.assertEqual(self.ctx.project_id, profile.project)
|
||||
self.assertEqual(self.ctx.domain_id, profile.domain)
|
||||
self.assertEqual({}, profile.metadata)
|
||||
self.assertIsNone(profile.created_at)
|
||||
self.assertIsNone(profile.updated_at)
|
||||
|
@ -563,9 +563,9 @@ class TestProfileBase(base.SenlinTestCase):
|
|||
"key2": 2,
|
||||
}
|
||||
}
|
||||
profile = DummyProfile("p-bad-ctx", spec, user=self.ctx.user,
|
||||
project=self.ctx.project,
|
||||
domain=self.ctx.domain)
|
||||
profile = DummyProfile("p-bad-ctx", spec, user=self.ctx.user_id,
|
||||
project=self.ctx.project_id,
|
||||
domain=self.ctx.domain_id)
|
||||
|
||||
self.assertRaises(exception.ESchema, profile.validate)
|
||||
|
||||
|
@ -836,9 +836,9 @@ class TestProfileBase(base.SenlinTestCase):
|
|||
new_spec['properties']['key1'] = 'new_v1'
|
||||
new_spec['properties']['key2'] = 3
|
||||
new_profile = pb.Profile('new-profile', new_spec,
|
||||
user=self.ctx.user,
|
||||
project=self.ctx.project,
|
||||
domain=self.ctx.domain,
|
||||
user=self.ctx.user_id,
|
||||
project=self.ctx.project_id,
|
||||
domain=self.ctx.domain_id,
|
||||
context=None)
|
||||
res = profile.validate_for_update(new_profile)
|
||||
self.assertTrue(res)
|
||||
|
@ -850,9 +850,9 @@ class TestProfileBase(base.SenlinTestCase):
|
|||
new_spec = copy.deepcopy(self.spec)
|
||||
new_spec['properties']['key3'] = 'new_v3'
|
||||
new_profile = pb.Profile('new-profile', new_spec,
|
||||
user=self.ctx.user,
|
||||
project=self.ctx.project,
|
||||
domain=self.ctx.domain,
|
||||
user=self.ctx.user_id,
|
||||
project=self.ctx.project_id,
|
||||
domain=self.ctx.domain_id,
|
||||
context=None)
|
||||
|
||||
res = profile.validate_for_update(new_profile)
|
||||
|
|
|
@ -22,7 +22,7 @@ class TestRequestContext(base.SenlinTestCase):
|
|||
'auth_token_info': {'123info': 'woop'},
|
||||
'user_name': 'mick',
|
||||
'user_domain_name': 'user-domain-name',
|
||||
'project': 'project-id',
|
||||
'project_id': 'project-id',
|
||||
'project_name': 'a project',
|
||||
'project_domain_name': 'a project domain',
|
||||
'domain_name': 'this domain',
|
||||
|
@ -40,7 +40,7 @@ class TestRequestContext(base.SenlinTestCase):
|
|||
auth_token_info=self.ctx.get('auth_token_info'),
|
||||
user_name=self.ctx.get('user_name'),
|
||||
user_domain_name=self.ctx.get('user_domain_name'),
|
||||
project=self.ctx.get('project'),
|
||||
project_id=self.ctx.get('project_id'),
|
||||
project_name=self.ctx.get('project_name'),
|
||||
project_domain_name=self.ctx.get('project_domain_name'),
|
||||
domain_name=self.ctx.get('domain_name'),
|
||||
|
|
Loading…
Reference in New Issue