Merge "Drop Travis CI support"
diff --git a/README.rst b/README.rst
index b90b39a..ed605ca 100644
--- a/README.rst
+++ b/README.rst
@@ -51,6 +51,10 @@
user: openstack
password: pwd
virtual_host: '/openstack'
+ client:
+ connection_params:
+ connect_retries: 50
+ connect_retry_delay: 1
backend:
7k2_SAS:
engine: storwize
@@ -693,6 +697,9 @@
protocol: http
endpoint_type: internalURL
region_name: RegionOne
+ connection_params:
+ connect_retries: 5
+ connect_retry_delay: 1
backend:
ceph:
type_name: standard-iops
diff --git a/_modules/cinderv3/arg_converter.py b/_modules/cinderv3/arg_converter.py
index 3a57f8b..90445fd 100644
--- a/_modules/cinderv3/arg_converter.py
+++ b/_modules/cinderv3/arg_converter.py
@@ -11,10 +11,10 @@
return False
-def named_checker(resource, ref, cloud_name):
+def named_checker(resource, ref, cloud_name, **kwargs):
resp_key = response_keys[resource]
resp = resource_lists[resource](
- name=ref, cloud_name=cloud_name)[resp_key]
+ name=ref, cloud_name=cloud_name, **kwargs)[resp_key]
if len(resp) == 0:
raise common.ResourceNotFound(resp_key, ref)
elif len(resp) > 1:
@@ -22,10 +22,11 @@
return resp[0]['id']
-def nameless_checker(resource, ref, cloud_name):
+def nameless_checker(resource, ref, cloud_name, **kwargs):
item_id = None
resp_key = response_keys[resource]
- resp = resource_lists[resource](cloud_name=cloud_name)[resp_key]
+ resp = resource_lists[resource](
+ cloud_name=cloud_name, **kwargs)[resp_key]
for item in resp:
if item["name"] == ref:
if item_id is not None:
@@ -60,6 +61,7 @@
def wrapped_f(*args, **kwargs):
results = []
args_start = 0
+ connection_params = kwargs.pop('connection_params', {}) or {}
for index, (resource, arg_name) in enumerate(
resource_arg_name_pairs):
if arg_name in kwargs:
@@ -73,9 +75,10 @@
results.append(ref)
else:
# Then we have name not uuid
- res = name_checkers[resource](resource, ref, cloud_name)
+ res = name_checkers[resource](resource, ref, cloud_name,
+ connection_params=connection_params)
results.append(res)
results.extend(args[args_start:])
return func(*results, **kwargs)
return wrapped_f
- return wrap
\ No newline at end of file
+ return wrap
diff --git a/_modules/cinderv3/common.py b/_modules/cinderv3/common.py
index bc77cd9..df419e9 100644
--- a/_modules/cinderv3/common.py
+++ b/_modules/cinderv3/common.py
@@ -65,9 +65,11 @@
def send(method):
def wrap(func):
def wrapped_f(*args, **kwargs):
- connect_retries = 30
- connect_retry_delay = 1
cloud_name = kwargs.pop('cloud_name')
+ connection_params = kwargs.pop('connection_params', {}) or {}
+ connect_retries = connection_params.get('connect_retries', 60)
+ connect_retry_delay = connection_params.get('connect_retry_delay',
+ 1)
if not cloud_name:
e = NoCredentials()
log.error('%s' % e)
diff --git a/_states/cinderv3.py b/_states/cinderv3.py
index c954c12..511ec5f 100644
--- a/_states/cinderv3.py
+++ b/_states/cinderv3.py
@@ -20,7 +20,7 @@
try:
method_name = '{}_get_details'.format(resource)
exact_resource = _cinder_call(
- method_name, name, cloud_name=cloud_name
+ method_name, name, cloud_name=cloud_name, **kwargs
)[resource]
except Exception as e:
if 'ResourceNotFound' in repr(e):
@@ -56,11 +56,12 @@
return _succeeded('no_changes', name, resource)
-def _resource_absent(resource, name, cloud_name):
+def _resource_absent(resource, name, cloud_name, connection_params=None):
try:
method_name = '{}_get_details'.format(resource)
_cinder_call(
- method_name, name, cloud_name=cloud_name
+ method_name, name, cloud_name=cloud_name,
+ connection_params=connection_params
)[resource]
except Exception as e:
if 'ResourceNotFound' in repr(e):
@@ -70,7 +71,8 @@
try:
method_name = '{}_delete'.format(resource)
_cinder_call(
- method_name, name, cloud_name=cloud_name
+ method_name, name, cloud_name=cloud_name,
+ connection_params=connection_params
)
except Exception as e:
log.error('Cinder delete {0} failed with {1}'.format(resource, e))
@@ -78,32 +80,36 @@
return _succeeded('delete', name, resource)
-def service_enabled(name, binary, cloud_name):
+def service_enabled(name, binary, cloud_name, connection_params=None):
"""Ensures that the service is enabled on the host
- :param name: name of a host where service is running
- :param binary: name of the service have to be run
+ :param name: name of a host where service is running
+ :param binary: name of the service have to be run
+ :param connection_params: dictionary with salt internal connection params
"""
changes = {}
ret = []
- services = _cinder_call('service_list', host=name, binary=binary, cloud_name=cloud_name)['services']
+ services = _cinder_call('service_list', host=name, binary=binary, cloud_name=cloud_name,
+ connection_params=connection_params)['services']
disabled_service = [s for s in services if s['status'] == 'disabled']
if len(disabled_service):
for service in disabled_service:
- changes = _cinder_call('service_update', service['host'], binary, 'enable', cloud_name=cloud_name)
+ changes = _cinder_call('service_update', service['host'], binary, 'enable', cloud_name=cloud_name,
+ connection_params=connection_params)
ret.append(changes)
return _succeeded('update', name, binary, {'changes':ret})
return _succeeded('no_changes', name, binary)
-def service_disabled(name, binary, cloud_name, disabled_reason=None):
+def service_disabled(name, binary, cloud_name, disabled_reason=None, connection_params=None):
"""Ensures that the service is disabled on the host
:param name: name of a host where service is running
:param binary: name of the service have to be disabled
+ :param connection_params: dictionary with salt internal connection params
"""
kwargs = {}
ret = []
@@ -111,13 +117,16 @@
if disabled_reason:
kwargs['disabled_reason'] = disabled_reason
- services = _cinder_call('service_list', host=name, binary=binary, cloud_name=cloud_name)['services']
+ services = _cinder_call('service_list', host=name, binary=binary, cloud_name=cloud_name,
+ connection_params=connection_params)['services']
enabled_services = [s for s in services if s['status'] == 'enabled']
if len(enabled_services):
for service in enabled_services:
- changes = _cinder_call('service_update', service['host'], binary, 'disable', cloud_name=cloud_name, **kwargs)
+ changes = _cinder_call('service_update', service['host'], binary, 'disable',
+ cloud_name=cloud_name, connection_params=connection_params,
+ **kwargs)
ret.append(changes)
return _succeeded('update', name, binary, {'changes':ret})
return _succeeded('no_changes', name, binary)
@@ -127,8 +136,8 @@
return _resource_present('volume_type', name, cloud_name, **kwargs)
-def volume_type_absent(name, cloud_name):
- return _resource_absent('volume_type', name, cloud_name)
+def volume_type_absent(name, cloud_name, connection_params=None):
+ return _resource_absent('volume_type', name, cloud_name, connection_params)
def volume_present(name, cloud_name, size, **kwargs):
@@ -138,18 +147,20 @@
return _resource_present('volume', name, cloud_name, **kwargs)
-def volume_absent(name, cloud_name):
- return _resource_absent('volume', name, cloud_name)
+def volume_absent(name, cloud_name, connection_params=None):
+ return _resource_absent('volume', name, cloud_name, connection_params)
-def volume_type_key_present(name=None, key=None, value=None, cloud_name=None):
+def volume_type_key_present(name=None, key=None, value=None, cloud_name=None,
+ connection_params=None):
"""
Ensures that the extra specs are present on a volume type.
"""
keys = "{u'" + key + "': u'" + value + "'}"
keys = ast.literal_eval(keys)
signal_create = _cinder_call('keys_volume_type_set', name, keys=keys,
- cloud_name=cloud_name)
+ cloud_name=cloud_name,
+ connection_params=connection_params)
if signal_create["result"] is True:
ret = {
'name': name,
diff --git a/cinder/client.sls b/cinder/client.sls
index 233f31f..828743e 100644
--- a/cinder/client.sls
+++ b/cinder/client.sls
@@ -5,41 +5,15 @@
pkg.installed:
- names: {{ client.pkgs }}
-{% if client.identity is mapping %}
-{%- set identity = client.identity %}
-{%- else %}
-{%- set identity = salt['pillar.get']('keystone:client:server:'+client.identity) %}
-{%- endif %}
-
-{#- Keystone V3 is supported only from Ocata release (https://docs.openstack.org/releasenotes/python-cinderclient/ocata.html) #}
-{#- Therefore if api_version is not defined and OpenStack version is mitaka or newton use v2.0. #}
-{%- if 'api_version' in identity %}
-{%- set keystone_api_version = identity.get('api_version') %}
-{%- else %}
-{%- if 'version' in client and client.version in ['mitaka', 'newton'] %}
-{%- set keystone_api_version = 'v2.0' %}
-{%- else %}
-{%- set keystone_api_version = 'v3' %}
-{%- endif %}
-{%- endif %}
-
-{%- set credentials = {'host': identity.host,
- 'user': identity.user,
- 'password': identity.password,
- 'project_id': identity.project,
- 'port': identity.get('port', 35357),
- 'protocol': identity.get('protocol', 'http'),
- 'region_name': identity.get('region', 'RegionOne'),
- 'endpoint_type': identity.get('endpoint_type', 'internalURL'),
- 'certificate': identity.get('certificate', client.cacert_file),
- 'api_version': keystone_api_version} %}
-
{%- for backend_name, backend in client.get('backend', {}).items() %}
cinder_type_create_{{ backend_name }}:
cinderv3.volume_type_present:
- name: {{ backend.type_name }}
- cloud_name: admin_identity
+ {%- if client.connection_params is defined %}
+ - connection_params: {{ client.connection_params }}
+ {%- endif %}
- require:
- pkg: cinder_client_packages
@@ -49,6 +23,9 @@
- key: volume_backend_name
- value: {{ backend_name }}
- cloud_name: admin_identity
+ {%- if client.connection_params is defined %}
+ - connection_params: {{ client.connection_params }}
+ {%- endif %}
- require:
- cinderv3: cinder_type_create_{{ backend_name }}
@@ -60,6 +37,9 @@
- key: {{ key_name }}
- value: {{ key_value }}
- cloud_name: admin_identity
+ {%- if client.connection_params is defined %}
+ - connection_params: {{ client.connection_params }}
+ {%- endif %}
- require:
- cinderv3: cinder_type_create_{{ backend_name }}
diff --git a/cinder/controller.sls b/cinder/controller.sls
index f103550..8e7023c 100644
--- a/cinder/controller.sls
+++ b/cinder/controller.sls
@@ -363,6 +363,9 @@
{%- if controller.get('role', 'primary') == 'secondary' %}
- onlyif: /bin/false
{%- endif %}
+ {%- if controller.get('client', {}).connection_params is defined %}
+ - connection_params: {{ controller.client.connection_params }}
+ {%- endif %}
- require:
- service: cinder_controller_services
@@ -375,6 +378,9 @@
{%- if controller.get('role', 'primary') == 'secondary' %}
- onlyif: /bin/false
{%- endif %}
+ {%- if controller.get('client', {}).connection_params is defined %}
+ - connection_params: {{ controller.client.connection_params }}
+ {%- endif %}
- require:
- cinderv3: cinder_type_create_{{ backend_name }}