Use v2 designate client instead of v1
* Module designateclient.v1 doesn't exist anymore after python-designateclient 3.0.0 is out. The new client requires a keystone session so all other parameters were dropped. Since this service now requires a a session the generator test now mocks the method _get_fake_client() for this action. * Minor style changes. Change-Id: Ida722828e3f1481e08f52257405ddfa2175733fa
This commit is contained in:
parent
86ae8a7e20
commit
efc4cf078e
|
@ -53,7 +53,7 @@ aodhclient = _try_import('aodhclient.v2.client')
|
|||
barbicanclient = _try_import('barbicanclient.client')
|
||||
cinderclient = _try_import('cinderclient.client')
|
||||
cinder_api_versions = _try_import('cinderclient.api_versions')
|
||||
designateclient = _try_import('designateclient.v1')
|
||||
designateclient = _try_import('designateclient.v2.client')
|
||||
glanceclient = _try_import('glanceclient')
|
||||
glareclient = _try_import('glareclient.v1.client')
|
||||
gnocchiclient = _try_import('gnocchiclient.v1.client')
|
||||
|
@ -395,7 +395,6 @@ class BaremetalIntrospectionAction(base.OpenStackAction):
|
|||
return cls._get_client_class()()
|
||||
|
||||
def _create_client(self, context):
|
||||
|
||||
LOG.debug(
|
||||
"Baremetal introspection action security context: %s", context)
|
||||
|
||||
|
@ -474,7 +473,6 @@ class ZaqarAction(base.OpenStackAction):
|
|||
return zaqarclient.Client
|
||||
|
||||
def _create_client(self, context):
|
||||
|
||||
LOG.debug("Zaqar action security context: %s", context)
|
||||
|
||||
zaqar_endpoint = self.get_service_endpoint()
|
||||
|
@ -610,7 +608,6 @@ class BarbicanAction(base.OpenStackAction):
|
|||
return barbicanclient.Client
|
||||
|
||||
def _create_client(self, context):
|
||||
|
||||
LOG.debug("Barbican action security context: %s", context)
|
||||
|
||||
barbican_endpoint = self.get_service_endpoint()
|
||||
|
@ -721,28 +718,14 @@ class DesignateAction(base.OpenStackAction):
|
|||
return designateclient.Client
|
||||
|
||||
def _create_client(self, context):
|
||||
|
||||
LOG.debug("Designate action security context: %s", context)
|
||||
|
||||
designate_endpoint = self.get_service_endpoint()
|
||||
|
||||
designate_url = keystone_utils.format_url(
|
||||
designate_endpoint.url,
|
||||
{'tenant_id': context.project_id}
|
||||
)
|
||||
session_and_auth = self.get_session_and_auth(context)
|
||||
|
||||
client = self._get_client_class()(
|
||||
endpoint=designate_url,
|
||||
tenant_id=context.project_id,
|
||||
auth_url=context.auth_uri,
|
||||
region_name=designate_endpoint.region,
|
||||
service_type='dns',
|
||||
insecure=context.insecure
|
||||
session=session_and_auth['session']
|
||||
)
|
||||
|
||||
client.client.auth_token = context.auth_token
|
||||
client.client.management_url = designate_url
|
||||
|
||||
return client
|
||||
|
||||
@classmethod
|
||||
|
|
|
@ -94,7 +94,7 @@ class OpenStackAction(actions.Action):
|
|||
service_name=self._service_name,
|
||||
service_type=self._service_type,
|
||||
region_name=self.action_region,
|
||||
context=context)
|
||||
ctx=context)
|
||||
|
||||
def get_service_endpoint(self):
|
||||
"""Get OpenStack service endpoint.
|
||||
|
|
|
@ -85,6 +85,15 @@ class GeneratorTest(base.BaseTest):
|
|||
self.baremetal_patch.start()
|
||||
self.addCleanup(self.baremetal_patch.stop)
|
||||
|
||||
# Do the same for the Designate client.
|
||||
self.designate_patch = mock.patch.object(
|
||||
actions.DesignateAction,
|
||||
"get_fake_client_method",
|
||||
return_value=lambda x: None)
|
||||
|
||||
self.designate_patch.start()
|
||||
self.addCleanup(self.designate_patch.stop)
|
||||
|
||||
def test_generator(self):
|
||||
for generator_cls in generator_factory.all_generators():
|
||||
action_classes = generator_cls.create_actions()
|
||||
|
|
|
@ -55,35 +55,35 @@ def _determine_verify(ctx):
|
|||
return True
|
||||
|
||||
|
||||
def get_session_and_auth(context, **kwargs):
|
||||
"""Get session and auth parameters
|
||||
def get_session_and_auth(ctx, **kwargs):
|
||||
"""Get session and auth parameters.
|
||||
|
||||
:param context: action context
|
||||
:return: dict to be used as kwargs for client serviceinitialization
|
||||
:param ctx: action context
|
||||
:return: dict to be used as kwargs for client service initialization
|
||||
"""
|
||||
|
||||
if not context:
|
||||
if not ctx:
|
||||
raise AssertionError('context is mandatory')
|
||||
|
||||
project_endpoint = get_endpoint_for_project(**kwargs)
|
||||
endpoint = format_url(
|
||||
project_endpoint.url,
|
||||
{
|
||||
'tenant_id': context.project_id,
|
||||
'project_id': context.project_id
|
||||
'tenant_id': ctx.project_id,
|
||||
'project_id': ctx.project_id
|
||||
}
|
||||
)
|
||||
|
||||
auth = Token(endpoint=endpoint, token=context.auth_token)
|
||||
auth = Token(endpoint=endpoint, token=ctx.auth_token)
|
||||
|
||||
auth_uri = context.auth_uri or CONF.keystone_authtoken.www_authenticate_uri
|
||||
auth_uri = ctx.auth_uri or CONF.keystone_authtoken.www_authenticate_uri
|
||||
ks_auth = Token(
|
||||
endpoint=auth_uri,
|
||||
token=context.auth_token
|
||||
token=ctx.auth_token
|
||||
)
|
||||
session = ks_session.Session(
|
||||
auth=ks_auth,
|
||||
verify=_determine_verify(context)
|
||||
verify=_determine_verify(ctx)
|
||||
)
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue