Always log error before raise a msg
Change-Id: Iba8c7e63b52acc41964ff099efc7fa181185bad7 Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
parent
7d730c5edf
commit
f2eac2c7e6
|
@ -58,8 +58,9 @@ def _run_command(args, env=None, name=None):
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
env=env).decode('utf-8')
|
env=env).decode('utf-8')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
LOG.error('%s failed: %s', name, e.output)
|
message = '%s failed: %s' % (name, e.output)
|
||||||
raise
|
LOG.error(message)
|
||||||
|
raise RuntimeError(message)
|
||||||
|
|
||||||
|
|
||||||
def _run_live_command(args, env=None, name=None):
|
def _run_live_command(args, env=None, name=None):
|
||||||
|
@ -81,7 +82,9 @@ def _run_live_command(args, env=None, name=None):
|
||||||
if line == '' and process.poll() is not None:
|
if line == '' and process.poll() is not None:
|
||||||
break
|
break
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
raise RuntimeError('%s failed. See log for details.' % name)
|
message = '%s failed. See log for details.' % name
|
||||||
|
LOG.error(message)
|
||||||
|
raise RuntimeError(message)
|
||||||
|
|
||||||
|
|
||||||
def _check_hostname():
|
def _check_hostname():
|
||||||
|
@ -118,8 +121,9 @@ def _check_hostname():
|
||||||
else:
|
else:
|
||||||
short_hostname = detected_static_hostname.split('.')[0]
|
short_hostname = detected_static_hostname.split('.')[0]
|
||||||
if short_hostname == detected_static_hostname:
|
if short_hostname == detected_static_hostname:
|
||||||
raise RuntimeError('Configured hostname is not fully '
|
message = 'Configured hostname is not fully qualified.'
|
||||||
'qualified.')
|
LOG.error(message)
|
||||||
|
raise RuntimeError(message)
|
||||||
sed_cmd = ('sed -i "s/127.0.0.1\(\s*\)/127.0.0.1\\1%s %s /" '
|
sed_cmd = ('sed -i "s/127.0.0.1\(\s*\)/127.0.0.1\\1%s %s /" '
|
||||||
'/etc/hosts' %
|
'/etc/hosts' %
|
||||||
(detected_static_hostname, short_hostname))
|
(detected_static_hostname, short_hostname))
|
||||||
|
@ -193,6 +197,7 @@ def _validate_ips():
|
||||||
except netaddr.core.AddrFormatError:
|
except netaddr.core.AddrFormatError:
|
||||||
msg = '%s "%s" must be a valid IP address' % \
|
msg = '%s "%s" must be a valid IP address' % \
|
||||||
(param_name, value)
|
(param_name, value)
|
||||||
|
LOG.error(msg)
|
||||||
raise FailedValidation(msg)
|
raise FailedValidation(msg)
|
||||||
for ip in CONF.undercloud_nameservers:
|
for ip in CONF.undercloud_nameservers:
|
||||||
is_ip(ip, 'undercloud_nameservers')
|
is_ip(ip, 'undercloud_nameservers')
|
||||||
|
@ -208,19 +213,23 @@ def _validate_value_formats():
|
||||||
try:
|
try:
|
||||||
local_ip = netaddr.IPNetwork(CONF.local_ip)
|
local_ip = netaddr.IPNetwork(CONF.local_ip)
|
||||||
if local_ip.prefixlen == 32:
|
if local_ip.prefixlen == 32:
|
||||||
|
LOG.error('Invalid netmask')
|
||||||
raise netaddr.AddrFormatError('Invalid netmask')
|
raise netaddr.AddrFormatError('Invalid netmask')
|
||||||
# If IPv6 the ctlplane network uses the EUI-64 address format,
|
# If IPv6 the ctlplane network uses the EUI-64 address format,
|
||||||
# which requires the prefix to be /64
|
# which requires the prefix to be /64
|
||||||
if local_ip.version == 6 and local_ip.prefixlen != 64:
|
if local_ip.version == 6 and local_ip.prefixlen != 64:
|
||||||
|
LOG.error('Prefix must be 64 for IPv6')
|
||||||
raise netaddr.AddrFormatError('Prefix must be 64 for IPv6')
|
raise netaddr.AddrFormatError('Prefix must be 64 for IPv6')
|
||||||
except netaddr.core.AddrFormatError as e:
|
except netaddr.core.AddrFormatError as e:
|
||||||
message = ('local_ip "%s" not valid: "%s" '
|
message = ('local_ip "%s" not valid: "%s" '
|
||||||
'Value must be in CIDR format.' %
|
'Value must be in CIDR format.' %
|
||||||
(CONF.local_ip, str(e)))
|
(CONF.local_ip, str(e)))
|
||||||
|
LOG.error(message)
|
||||||
raise FailedValidation(message)
|
raise FailedValidation(message)
|
||||||
hostname = CONF['undercloud_hostname']
|
hostname = CONF['undercloud_hostname']
|
||||||
if hostname is not None and '.' not in hostname:
|
if hostname is not None and '.' not in hostname:
|
||||||
message = 'Hostname "%s" is not fully qualified.' % hostname
|
message = 'Hostname "%s" is not fully qualified.' % hostname
|
||||||
|
LOG.error(message)
|
||||||
raise FailedValidation(message)
|
raise FailedValidation(message)
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,10 +241,12 @@ def _validate_in_cidr(subnet_props, subnet_name):
|
||||||
if netaddr.IPAddress(addr) not in cidr:
|
if netaddr.IPAddress(addr) not in cidr:
|
||||||
message = ('Config option %s "%s" not in defined CIDR "%s"' %
|
message = ('Config option %s "%s" not in defined CIDR "%s"' %
|
||||||
(pretty_name, addr, cidr))
|
(pretty_name, addr, cidr))
|
||||||
|
LOG.error(message)
|
||||||
raise FailedValidation(message)
|
raise FailedValidation(message)
|
||||||
except netaddr.core.AddrFormatError:
|
except netaddr.core.AddrFormatError:
|
||||||
if require_ip:
|
if require_ip:
|
||||||
message = 'Invalid IP address: %s' % addr
|
message = 'Invalid IP address: %s' % addr
|
||||||
|
LOG.error(message)
|
||||||
raise FailedValidation(message)
|
raise FailedValidation(message)
|
||||||
|
|
||||||
if subnet_name == CONF.local_subnet:
|
if subnet_name == CONF.local_subnet:
|
||||||
|
@ -265,6 +276,7 @@ def _validate_dhcp_range(subnet_props):
|
||||||
if start >= end:
|
if start >= end:
|
||||||
message = ('Invalid dhcp range specified, dhcp_start "%s" does '
|
message = ('Invalid dhcp range specified, dhcp_start "%s" does '
|
||||||
'not come before dhcp_end "%s"' % (start, end))
|
'not come before dhcp_end "%s"' % (start, end))
|
||||||
|
LOG.error(message)
|
||||||
raise FailedValidation(message)
|
raise FailedValidation(message)
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,6 +286,7 @@ def _validate_inspection_range(subnet_props):
|
||||||
if start >= end:
|
if start >= end:
|
||||||
message = ('Invalid inspection range specified, inspection_iprange '
|
message = ('Invalid inspection range specified, inspection_iprange '
|
||||||
'"%s" does not come before "%s"' % (start, end))
|
'"%s" does not come before "%s"' % (start, end))
|
||||||
|
LOG.error(message)
|
||||||
raise FailedValidation(message)
|
raise FailedValidation(message)
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,6 +312,7 @@ def _validate_interface_exists():
|
||||||
and CONF.local_interface not in netifaces.interfaces()):
|
and CONF.local_interface not in netifaces.interfaces()):
|
||||||
message = ('Invalid local_interface specified. %s is not available.' %
|
message = ('Invalid local_interface specified. %s is not available.' %
|
||||||
CONF.local_interface)
|
CONF.local_interface)
|
||||||
|
LOG.error(message)
|
||||||
raise FailedValidation(message)
|
raise FailedValidation(message)
|
||||||
|
|
||||||
|
|
||||||
|
@ -344,6 +358,7 @@ def _validate_passwords_file():
|
||||||
message = ('The %s file is missing. This will cause all service '
|
message = ('The %s file is missing. This will cause all service '
|
||||||
'passwords to change and break the existing undercloud. ' %
|
'passwords to change and break the existing undercloud. ' %
|
||||||
PASSWORD_PATH)
|
PASSWORD_PATH)
|
||||||
|
LOG.error(message)
|
||||||
raise FailedValidation(message)
|
raise FailedValidation(message)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue