Merge "Move to Mirantis owned docker images for tests - This is a temporary solution until we have our own images"
diff --git a/_modules/pankov2/__init__.py b/_modules/pankov2/__init__.py
new file mode 100644
index 0000000..31268b2
--- /dev/null
+++ b/_modules/pankov2/__init__.py
@@ -0,0 +1,23 @@
+try:
+ import os_client_config # noqa
+ from keystoneauth1 import exceptions as ka_exceptions # noqa
+ REQUIREMENTS_MET = True
+except ImportError:
+ REQUIREMENTS_MET = False
+
+from pankov2 import lists
+
+event_list = lists.event_list
+event_type_list = lists.event_type_list
+
+
+__all__ = ('event_list', 'event_type_list',)
+
+
+def __virtual__():
+ """Only load pankov2 if requirements are available."""
+ if REQUIREMENTS_MET:
+ return 'pankov2'
+ else:
+ return False, ("The pankov2 execution module cannot be loaded: "
+ "os_client_config or keystoneauth are unavailable.")
\ No newline at end of file
diff --git a/_modules/pankov2/common.py b/_modules/pankov2/common.py
new file mode 100644
index 0000000..fd51e25
--- /dev/null
+++ b/_modules/pankov2/common.py
@@ -0,0 +1,103 @@
+import logging
+import os_client_config
+
+log = logging.getLogger(__name__)
+
+
+class PankoException(Exception):
+
+ _msg = "Panko module exception occured."
+
+ def __init__(self, message=None, **kwargs):
+ super(PankoException, self).__init__(message or self._msg)
+
+
+class NoPankoEndpoint(PankoException):
+ _msg = "Panko endpoint not found in keystone catalog."
+
+
+class NoAuthPluginConfigured(PankoException):
+ _msg = ("You are using keystoneauth auth plugin that does not support "
+ "fetching endpoint list from token (noauth or admin_token).")
+
+
+class NoCredentials(PankoException):
+ _msg = "Please provide cloud name present in clouds.yaml."
+
+
+class ResourceNotFound(PankoException):
+ _msg = "Uniq resource: {resource} with name: {name} not found."
+
+ def __init__(self, resource, name, **kwargs):
+ super(PankoException, self).__init__(
+ self._msg.format(resource=resource, name=name))
+
+
+class MultipleResourcesFound(PankoException):
+ _msg = "Multiple resource: {resource} with name: {name} found."
+
+ def __init__(self, resource, name, **kwargs):
+ super(PankoException, self).__init__(
+ self._msg.format(resource=resource, name=name))
+
+
+def _get_raw_client(cloud_name):
+ service_type = 'event'
+ config = os_client_config.OpenStackConfig()
+ cloud = config.get_one_cloud(cloud_name)
+ api_version = 'v2'
+ try:
+ # NOTE(pas-ha) for Queens and later,
+ # 'version' kwarg in absent for Pike and older
+ adapter = cloud.get_session_client(service_type, version=api_version)
+ except TypeError:
+ adapter = cloud.get_session_client(service_type)
+ adapter.version = api_version
+ try:
+ access_info = adapter.session.auth.get_access(adapter.session)
+ endpoints = access_info.service_catalog.get_endpoints()
+ except (AttributeError, ValueError):
+ e = NoAuthPluginConfigured()
+ log.exception('%s' % e)
+ raise e
+ if service_type not in endpoints:
+ if not service_type:
+ e = NoPankoEndpoint()
+ log.error('%s' % e)
+ raise e
+ return adapter
+
+
+def send(method, microversion_header=None):
+ def wrap(func):
+ def wrapped_f(*args, **kwargs):
+ headers = kwargs.pop('headers', {})
+ if kwargs.get('microversion'):
+ headers.setdefault(microversion_header,
+ kwargs.get('microversion'))
+ cloud_name = kwargs.pop('cloud_name')
+ if not cloud_name:
+ e = NoCredentials()
+ log.error('%s' % e)
+ raise e
+ adapter = _get_raw_client(cloud_name)
+ # Remove salt internal kwargs
+ kwarg_keys = list(kwargs.keys())
+ for k in kwarg_keys:
+ if k.startswith('__'):
+ kwargs.pop(k)
+ url, json = func(*args, **kwargs)
+ if json:
+ response = getattr(adapter, method)(url, headers=headers,
+ json=json)
+ else:
+ response = getattr(adapter, method)(url, headers=headers)
+ if not response.content:
+ return {}
+ try:
+ resp = response.json()
+ except:
+ resp = response.content
+ return resp
+ return wrapped_f
+ return wrap
diff --git a/_modules/pankov2/lists.py b/_modules/pankov2/lists.py
new file mode 100644
index 0000000..44293ed
--- /dev/null
+++ b/_modules/pankov2/lists.py
@@ -0,0 +1,18 @@
+from pankov2.common import send
+
+try:
+ from urllib.parse import urlencode
+except ImportError:
+ from urllib import urlencode
+
+
+@send('get')
+def event_list(**kwargs):
+ url = '/events?{}'.format(urlencode(kwargs))
+ return url, None
+
+
+@send('get')
+def event_type_list(**kwargs):
+ url = '/event_types?{}'.format(urlencode(kwargs))
+ return url, None
diff --git a/panko/files/queens/panko.conf.Debian b/panko/files/queens/panko.conf.Debian
index e3b8863..76dd0df 100644
--- a/panko/files/queens/panko.conf.Debian
+++ b/panko/files/queens/panko.conf.Debian
@@ -65,6 +65,9 @@
{%- set _data = server.identity %}
{%- if 'cacert_file' not in _data.keys() %}{% do _data.update({'cacert_file': server.cacert_file}) %}{% endif %}
{%- set auth_type = _data.get('auth_type', 'password') %}
+{%- if server.get('cache',{}).members is defined and 'cache' not in _data.keys() %}
+{% do _data.update({'cache': server.cache}) %}
+{%- endif %}
{%- include "oslo_templates/files/queens/keystonemiddleware/_auth_token.conf" %}
{%- include "oslo_templates/files/queens/keystoneauth/_type_" + auth_type + ".conf" %}
diff --git a/panko/upgrade/verify/_api.sls b/panko/upgrade/verify/_api.sls
index 3ed0036..f152104 100644
--- a/panko/upgrade/verify/_api.sls
+++ b/panko/upgrade/verify/_api.sls
@@ -3,5 +3,14 @@
test.show_notification:
- text: "Running panko.upgrade.verify.api"
-# TODO: Implement api checks when panko salt
-# modules are implemented
+pankov2_event_list:
+ module.run:
+ - name: pankov2.event_list
+ - kwargs:
+ cloud_name: admin_identity
+
+pankov2_event_type_list:
+ module.run:
+ - name: pankov2.event_type_list
+ - kwargs:
+ cloud_name: admin_identity