update build spec to remove etc and share, fix warnings
- remove /etc and /usr/share refs in build spec - suppress warning when deleting eggs - if no message on failed ansible playbook, show entire ugly results structure - if lock file is not present, throw error Jira-Issue: OPENSTACK-781 Fixed py34 safe_decode dict issue Jira-Issue: OSTACKDEV-19
This commit is contained in:
parent
6338975d90
commit
c96c508b01
|
@ -133,7 +133,7 @@ esac
|
||||||
|
|
||||||
if [[ "${inst_type}" == "update" ]]
|
if [[ "${inst_type}" == "update" ]]
|
||||||
then
|
then
|
||||||
rm -rf %{python_sitelib}/kollacli-*egg-info
|
rm -rf %{python_sitelib}/kollacli-*egg-info 2> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
%post
|
%post
|
||||||
|
@ -160,21 +160,21 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# disable ansible retry files (bug 22806271)
|
# disable ansible retry files (bug 22806271)
|
||||||
sed -i "s/#retry_files_enabled = False/retry_files_enabled = False/" /etc/ansible/ansible.cfg
|
sed -i "s/#retry_files_enabled = False/retry_files_enabled = False/" %{ansible_cfg}
|
||||||
|
|
||||||
/usr/bin/kollacli complete >/etc/bash_completion.d/kollacli 2>/dev/null
|
/usr/bin/kollacli complete >%{_sysconfdir}/bash_completion.d/kollacli 2>/dev/null
|
||||||
|
|
||||||
# Update the sudoers file
|
# Update the sudoers file
|
||||||
if ! grep -q 'kollacli/tools/kolla_actions' /etc/sudoers.d/%{kolla_user}
|
if ! grep -q 'kollacli/tools/kolla_actions' %{_sysconfdir}/sudoers.d/%{kolla_user}
|
||||||
then
|
then
|
||||||
sed -i \
|
sed -i \
|
||||||
'/^Cmnd_Alias.*KOLLA_CMDS/ s:$:, %{_datadir}/kolla/kollacli/tools/kolla_actions.py:'\
|
'/^Cmnd_Alias.*KOLLA_CMDS/ s:$:, %{_datadir}/kolla/kollacli/tools/kolla_actions.py:'\
|
||||||
/etc/sudoers.d/%{kolla_user}
|
%{_sysconfdir}/sudoers.d/%{kolla_user}
|
||||||
fi
|
fi
|
||||||
# remove obsolete password editor from sudoers file
|
# remove obsolete password editor from sudoers file
|
||||||
sed -i \
|
sed -i \
|
||||||
'/^Cmnd_Alias.*KOLLA_CMDS/ s:, /usr/share/kolla/kollacli/tools/passwd_editor.py::'\
|
'/^Cmnd_Alias.*KOLLA_CMDS/ s:, %{_datadir}/kolla/kollacli/tools/passwd_editor.py::'\
|
||||||
/etc/sudoers.d/%{kolla_user}
|
%{_sysconfdir}/sudoers.d/%{kolla_user}
|
||||||
|
|
||||||
# remove obsolete json_generator script
|
# remove obsolete json_generator script
|
||||||
if test -f %{_datadir}/kolla/kollacli/tools/json_generator.py
|
if test -f %{_datadir}/kolla/kollacli/tools/json_generator.py
|
||||||
|
@ -240,11 +240,11 @@ then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Wed Apr 13 2016 - Steve Noyes <steve.noyes@oracle.com>
|
* Wed Apr 13 2016 - Steve Noyes <steve.noyes@oracle.com>
|
||||||
- add kolla-ansible-plugin subpackage
|
- add kolla-ansible-plugin subpackage
|
||||||
|
- suppress warning on egg removal
|
||||||
|
- remove etc and usr/share refs
|
||||||
|
|
||||||
* Thu Apr 07 2016 - Borne Mace <borne.mace@oracle.com>
|
* Thu Apr 07 2016 - Borne Mace <borne.mace@oracle.com>
|
||||||
- added ansible.lock file to coordinate ansible synchronization
|
- added ansible.lock file to coordinate ansible synchronization
|
||||||
|
|
|
@ -23,12 +23,12 @@ import time
|
||||||
import kollacli.i18n as u
|
import kollacli.i18n as u
|
||||||
|
|
||||||
from kollacli.common.inventory import remove_temp_inventory
|
from kollacli.common.inventory import remove_temp_inventory
|
||||||
from kollacli.common.utils import PidManager
|
|
||||||
from kollacli.common.utils import get_kolla_actions_path
|
|
||||||
from kollacli.common.utils import get_admin_uids
|
from kollacli.common.utils import get_admin_uids
|
||||||
from kollacli.common.utils import get_admin_user
|
from kollacli.common.utils import get_admin_user
|
||||||
from kollacli.common.utils import get_ansible_lock_path
|
from kollacli.common.utils import get_ansible_lock_path
|
||||||
|
from kollacli.common.utils import get_kolla_actions_path
|
||||||
from kollacli.common.utils import Lock
|
from kollacli.common.utils import Lock
|
||||||
|
from kollacli.common.utils import PidManager
|
||||||
from kollacli.common.utils import run_cmd
|
from kollacli.common.utils import run_cmd
|
||||||
from kollacli.common.utils import safe_decode
|
from kollacli.common.utils import safe_decode
|
||||||
|
|
||||||
|
@ -128,7 +128,8 @@ class AnsibleJob(object):
|
||||||
# job has completed
|
# job has completed
|
||||||
if self._kill_uname:
|
if self._kill_uname:
|
||||||
status = 2
|
status = 2
|
||||||
msg = u._('Job killed by user (%s)' % self._kill_uname)
|
msg = (u._('Job killed by user ({name})')
|
||||||
|
.format(name=self._kill_uname))
|
||||||
self._errors = [msg]
|
self._errors = [msg]
|
||||||
else:
|
else:
|
||||||
status = self._process.returncode
|
status = self._process.returncode
|
||||||
|
@ -335,7 +336,7 @@ class AnsibleJob(object):
|
||||||
if sub_errs:
|
if sub_errs:
|
||||||
err_msg = ''.join([err_msg, ' [', sub_errs, ']'])
|
err_msg = ''.join([err_msg, ' [', sub_errs, ']'])
|
||||||
|
|
||||||
if not err_msg:
|
if not err_msg or not err_msg.strip():
|
||||||
# sometimes the error message is in std_out
|
# sometimes the error message is in std_out
|
||||||
# eg- "stdout": 'localhost | FAILED! => {"changed": false,
|
# eg- "stdout": 'localhost | FAILED! => {"changed": false,
|
||||||
# "failed": true, "msg": "...msg..."}'
|
# "failed": true, "msg": "...msg..."}'
|
||||||
|
@ -346,6 +347,12 @@ class AnsibleJob(object):
|
||||||
if not err_msg:
|
if not err_msg:
|
||||||
err_msg = stdout
|
err_msg = stdout
|
||||||
|
|
||||||
|
if not err_msg or not err_msg.strip():
|
||||||
|
# if still no err_msg, provide entire result
|
||||||
|
try:
|
||||||
|
err_msg = json.dumps(results)
|
||||||
|
except Exception as e:
|
||||||
|
LOG.debug('unable to convert results to string' % str(e))
|
||||||
msg = ('Host: %s, Task: %s, Status: %s, Message: %s' %
|
msg = ('Host: %s, Task: %s, Status: %s, Message: %s' %
|
||||||
(host, taskname, status, err_msg))
|
(host, taskname, status, err_msg))
|
||||||
return msg
|
return msg
|
||||||
|
|
|
@ -260,7 +260,7 @@ def sync_read_file(path, mode='r'):
|
||||||
finally:
|
finally:
|
||||||
if lock:
|
if lock:
|
||||||
lock.release()
|
lock.release()
|
||||||
return data
|
return safe_decode(data)
|
||||||
|
|
||||||
|
|
||||||
def sync_write_file(path, data, mode='w'):
|
def sync_write_file(path, data, mode='w'):
|
||||||
|
@ -295,9 +295,9 @@ def sync_write_file(path, data, mode='w'):
|
||||||
|
|
||||||
|
|
||||||
def safe_decode(obj_to_decode):
|
def safe_decode(obj_to_decode):
|
||||||
"""Convert bytes or string to unicode string
|
"""Convert bytes or strings to unicode string
|
||||||
|
|
||||||
Convert either a string or list of strings to
|
Converts strings, lists, or dictionaries to
|
||||||
unicode.
|
unicode.
|
||||||
"""
|
"""
|
||||||
if obj_to_decode is None:
|
if obj_to_decode is None:
|
||||||
|
@ -307,22 +307,15 @@ def safe_decode(obj_to_decode):
|
||||||
if isinstance(obj_to_decode, list):
|
if isinstance(obj_to_decode, list):
|
||||||
new_obj = []
|
new_obj = []
|
||||||
for text in obj_to_decode:
|
for text in obj_to_decode:
|
||||||
try:
|
text = safe_decode(text)
|
||||||
text = text.decode('utf-8')
|
|
||||||
except AttributeError: # nosec
|
|
||||||
# py3 will raise if text is already a string
|
|
||||||
pass
|
|
||||||
new_obj.append(text)
|
new_obj.append(text)
|
||||||
elif isinstance(obj_to_decode, dict):
|
elif isinstance(obj_to_decode, dict):
|
||||||
new_obj = {}
|
new_obj = {}
|
||||||
for key, value in obj_to_decode.items():
|
for key, value in obj_to_decode.items():
|
||||||
try:
|
key = safe_decode(key)
|
||||||
new_key = key.decode('utf-8')
|
value = safe_decode(value)
|
||||||
new_value = value.decode('utf-8')
|
new_obj[key] = value
|
||||||
new_obj[new_key] = new_value
|
|
||||||
except AttributeError: # nosec
|
|
||||||
# py3 will raise if it is already a string
|
|
||||||
pass
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
new_obj = obj_to_decode.decode('utf-8')
|
new_obj = obj_to_decode.decode('utf-8')
|
||||||
|
@ -387,6 +380,10 @@ class Lock(object):
|
||||||
else:
|
else:
|
||||||
return self._acquire_pidfile()
|
return self._acquire_pidfile()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
if not os.path.exists(self.lockpath):
|
||||||
|
raise Exception('Lock file (%s) is missing'
|
||||||
|
% self.lockpath)
|
||||||
|
|
||||||
# it is ok to fail to acquire, we just return that we failed
|
# it is ok to fail to acquire, we just return that we failed
|
||||||
LOG.debug('Exception in acquire lock. '
|
LOG.debug('Exception in acquire lock. '
|
||||||
'path: %s pid: %s owner: %s error: %s' %
|
'path: %s pid: %s owner: %s error: %s' %
|
||||||
|
|
Loading…
Reference in New Issue