Summary: drop use of str() on exception messages

Description:
- Oracle-Bug: 21810245 - drop use of strings on exception messages.
When messages are in > 128 unicode, str() will throw an exception.
This commit is contained in:
Steve Noyes 2015-09-11 11:11:46 -04:00
parent 987b8fa2c5
commit 1079c0fa4c
3 changed files with 8 additions and 8 deletions

View File

@ -125,14 +125,14 @@ class Host(object):
except Exception as e: except Exception as e:
raise exceptions.CommandError( raise exceptions.CommandError(
'ERROR: Host (%s) setup failed : %s' 'ERROR: Host (%s) setup failed : %s'
% (self.name, str(e))) % (self.name, e))
return True return True
def check(self): def check(self):
kollacli_home = get_kollacli_home() kollacli_home = get_kollacli_home()
command_string = 'sudo -u kolla ansible ' command_string = 'sudo -u kolla ansible '
inventory_string = '-i ' + os.path.join(kollacli_home, inventory_string = '-i ' + os.path.join(kollacli_home,
'tools', 'json_generator.py') 'tools', 'json_generator.py')
ping_string = ' %s %s' % (self.name, '-m ping') ping_string = ' %s %s' % (self.name, '-m ping')
cmd = (command_string + inventory_string + ping_string) cmd = (command_string + inventory_string + ping_string)
@ -140,11 +140,12 @@ class Host(object):
if err_flag: if err_flag:
raise exceptions.CommandError( raise exceptions.CommandError(
'ERROR: Host (%s) check failed : %s' 'ERROR: Host (%s) check failed : %s'
% (self.name, str(output))) % (self.name, output))
else: else:
self.log.info('Host (%s) check succeeded' % self.name) self.log.info('Host (%s) check succeeded' % self.name)
return True return True
class HostGroup(object): class HostGroup(object):
class_version = 1 class_version = 1
@ -292,7 +293,7 @@ class Inventory(object):
shutil.copyfile(tmp_path, inventory_path) shutil.copyfile(tmp_path, inventory_path)
os.remove(tmp_path) os.remove(tmp_path)
except Exception as e: except Exception as e:
raise Exception('ERROR: saving inventory : %s' % str(e)) raise Exception('ERROR: saving inventory : %s' % e)
finally: finally:
try: try:
os.close(tmp_filehandle) os.close(tmp_filehandle)

View File

@ -100,14 +100,14 @@ def _post_setup_checks(net_addr, log):
ssh_client = ssh_connect(net_addr, get_admin_user(), '') ssh_client = ssh_connect(net_addr, get_admin_user(), '')
except Exception as e: except Exception as e:
raise CommandError("ERROR: remote login failed : %s" % str(e)) raise CommandError("ERROR: remote login failed : %s" % e)
try: try:
# a basic test # a basic test
ssh_client.exec_command('ls') ssh_client.exec_command('ls')
except Exception as e: except Exception as e:
raise CommandError("ERROR: remote command 'ls' failed : %s" % str(e)) raise CommandError("ERROR: remote command 'ls' failed : %s" % e)
finally: finally:
_close_ssh_client(ssh_client) _close_ssh_client(ssh_client)

View File

@ -13,9 +13,8 @@
# under the License. # under the License.
import logging import logging
import os import os
import yaml
import pexpect import pexpect
import string import yaml
def get_kolla_home(): def get_kolla_home():