Remove Python 2.6 format style
In Python 2.6 it was required to use {0}, {1}...{n} when using the string format function. In Python 2.7 and Python 3 it it not required. Change {N} to {} in code. This brings the code in style alignment with other projects like ironic and ironic-lib. Change-Id: I81c4bb67b0974f73905f14b589b3dd0a7131650d Depends-On: I8f0e5405f3e2d6e35418c73f610ac6b779dd75e5
This commit is contained in:
parent
bf3c4fb38c
commit
20d960ff98
@ -117,7 +117,7 @@ class IronicPythonAgentHeartbeater(threading.Thread):
|
||||
self.min_jitter_multiplier,
|
||||
self.max_jitter_multiplier)
|
||||
interval = self.agent.heartbeat_timeout * interval_multiplier
|
||||
log_msg = 'sleeping before next heartbeat, interval: {0}'
|
||||
log_msg = 'sleeping before next heartbeat, interval: {}'
|
||||
LOG.info(log_msg.format(interval))
|
||||
finally:
|
||||
os.close(self.reader)
|
||||
|
@ -87,7 +87,7 @@ class InvalidCommandParamsError(InvalidContentError):
|
||||
|
||||
class RequestedObjectNotFoundError(NotFound):
|
||||
def __init__(self, type_descr, obj_id):
|
||||
details = '{0} with id {1} not found.'.format(type_descr, obj_id)
|
||||
details = '{} with id {} not found.'.format(type_descr, obj_id)
|
||||
super(RequestedObjectNotFoundError, self).__init__(details)
|
||||
|
||||
|
||||
@ -142,7 +142,7 @@ class ImageDownloadError(RESTError):
|
||||
message = 'Error downloading image'
|
||||
|
||||
def __init__(self, image_id, msg):
|
||||
details = 'Download of image id {0} failed: {1}'.format(image_id, msg)
|
||||
details = 'Download of image id {} failed: {}'.format(image_id, msg)
|
||||
super(ImageDownloadError, self).__init__(details)
|
||||
|
||||
|
||||
@ -150,9 +150,9 @@ class ImageChecksumError(RESTError):
|
||||
"""Error raised when an image fails to verify against its checksum."""
|
||||
|
||||
message = 'Error verifying image checksum'
|
||||
details_str = ('Image failed to verify against checksum. location: {0}; '
|
||||
'image ID: {1}; image checksum: {2}; verification '
|
||||
'checksum: {3}')
|
||||
details_str = ('Image failed to verify against checksum. location: {}; '
|
||||
'image ID: {}; image checksum: {}; verification '
|
||||
'checksum: {}')
|
||||
|
||||
def __init__(self, image_id, image_location, checksum,
|
||||
calculated_checksum):
|
||||
@ -167,8 +167,8 @@ class ImageWriteError(RESTError):
|
||||
message = 'Error writing image to device'
|
||||
|
||||
def __init__(self, device, exit_code, stdout, stderr):
|
||||
details = ('Writing image to device {0} failed with exit code '
|
||||
'{1}. stdout: {2}. stderr: {3}')
|
||||
details = ('Writing image to device {} failed with exit code '
|
||||
'{}. stdout: {}. stderr: {}')
|
||||
details = details.format(device, exit_code, stdout, stderr)
|
||||
super(ImageWriteError, self).__init__(details)
|
||||
|
||||
@ -179,7 +179,7 @@ class ConfigDriveTooLargeError(RESTError):
|
||||
message = 'Configdrive is too large for intended partition'
|
||||
|
||||
def __init__(self, filename, filesize):
|
||||
details = ('Configdrive at {0} has size {1}, which is larger than '
|
||||
details = ('Configdrive at {} has size {}, which is larger than '
|
||||
'the intended partition.').format(filename, filesize)
|
||||
super(ConfigDriveTooLargeError, self).__init__(details)
|
||||
|
||||
@ -190,8 +190,8 @@ class ConfigDriveWriteError(RESTError):
|
||||
message = 'Error writing configdrive to device'
|
||||
|
||||
def __init__(self, device, exit_code, stdout, stderr):
|
||||
details = ('Writing configdrive to device {0} failed with exit code '
|
||||
'{1}. stdout: {2}. stderr: {3}.')
|
||||
details = ('Writing configdrive to device {} failed with exit code '
|
||||
'{}. stdout: {}. stderr: {}.')
|
||||
details = details.format(device, exit_code, stdout, stderr)
|
||||
super(ConfigDriveWriteError, self).__init__(details)
|
||||
|
||||
@ -202,8 +202,8 @@ class SystemRebootError(RESTError):
|
||||
message = 'Error rebooting system'
|
||||
|
||||
def __init__(self, exit_code, stdout, stderr):
|
||||
details = ('Reboot script failed with exit code {0}. stdout: '
|
||||
'{1}. stderr: {2}.')
|
||||
details = ('Reboot script failed with exit code {}. stdout: '
|
||||
'{}. stderr: {}.')
|
||||
details = details.format(exit_code, stdout, stderr)
|
||||
super(SystemRebootError, self).__init__(details)
|
||||
|
||||
@ -263,7 +263,7 @@ class HardwareManagerMethodNotFound(RESTError):
|
||||
message = 'No HardwareManager found to handle method'
|
||||
|
||||
def __init__(self, method):
|
||||
details = 'Could not find method: {0}'.format(method)
|
||||
details = 'Could not find method: {}'.format(method)
|
||||
super(HardwareManagerMethodNotFound, self).__init__(details)
|
||||
|
||||
|
||||
@ -291,7 +291,7 @@ class CleanVersionMismatch(RESTError):
|
||||
|
||||
def __init__(self, agent_version, node_version):
|
||||
self.status_code = 409
|
||||
details = ('Agent clean version: {0}, node clean version: {1}'
|
||||
details = ('Agent clean version: {}, node clean version: {}'
|
||||
.format(agent_version, node_version))
|
||||
super(CleanVersionMismatch, self).__init__(details)
|
||||
|
||||
@ -311,7 +311,7 @@ class ISCSIError(RESTError):
|
||||
message = 'Error starting iSCSI target'
|
||||
|
||||
def __init__(self, error_msg):
|
||||
details = 'Error starting iSCSI target: {0}'.format(error_msg)
|
||||
details = 'Error starting iSCSI target: {}'.format(error_msg)
|
||||
super(ISCSIError, self).__init__(details)
|
||||
|
||||
|
||||
@ -319,7 +319,7 @@ class ISCSICommandError(ISCSIError):
|
||||
"""Error executing TGT command."""
|
||||
|
||||
def __init__(self, error_msg, exit_code, stdout, stderr):
|
||||
details = ('{0}. Failed with exit code {1}. stdout: {2}. stderr: {3}')
|
||||
details = ('{}. Failed with exit code {}. stdout: {}. stderr: {}')
|
||||
details = details.format(error_msg, exit_code, stdout, stderr)
|
||||
super(ISCSICommandError, self).__init__(details)
|
||||
|
||||
|
@ -119,7 +119,7 @@ class AsyncCommandResult(BaseCommandResult):
|
||||
self.execute_method = execute_method
|
||||
self.command_state_lock = threading.Lock()
|
||||
|
||||
thread_name = 'agent-command-{0}'.format(self.id)
|
||||
thread_name = 'agent-command-{}'.format(self.id)
|
||||
self.execution_thread = threading.Thread(target=self.run,
|
||||
name=thread_name)
|
||||
|
||||
@ -200,14 +200,14 @@ class BaseAgentExtension(object):
|
||||
cmd = self.command_map.get(command_name)
|
||||
if cmd is None:
|
||||
raise errors.InvalidCommandError(
|
||||
'Unknown command: {0}'.format(command_name))
|
||||
'Unknown command: {}'.format(command_name))
|
||||
return cmd(**kwargs)
|
||||
|
||||
def check_cmd_presence(self, ext_obj, ext, cmd):
|
||||
if not (hasattr(ext_obj, 'execute') and hasattr(ext_obj, 'command_map')
|
||||
and cmd in ext_obj.command_map):
|
||||
raise errors.InvalidCommandParamsError(
|
||||
"Extension {0} doesn't provide {1} method".format(ext, cmd))
|
||||
"Extension {} doesn't provide {} method".format(ext, cmd))
|
||||
|
||||
|
||||
class ExecuteCommandMixin(object):
|
||||
|
@ -94,14 +94,14 @@ def _start_lio(iqn, portal_port, device):
|
||||
rtslib_fb.LUN(tpg, storage_object=storage, lun=1)
|
||||
tpg.enable = 1
|
||||
except rtslib_fb.utils.RTSLibError as exc:
|
||||
msg = 'Failed to create a target: {0}'.format(exc)
|
||||
msg = 'Failed to create a target: {}'.format(exc)
|
||||
raise errors.ISCSIError(msg)
|
||||
|
||||
try:
|
||||
# bind to the default port on all interfaces
|
||||
rtslib_fb.NetworkPortal(tpg, '0.0.0.0', portal_port)
|
||||
except rtslib_fb.utils.RTSLibError as exc:
|
||||
msg = 'Failed to publish a target: {0}'.format(exc)
|
||||
msg = 'Failed to publish a target: {}'.format(exc)
|
||||
raise errors.ISCSIError(msg)
|
||||
|
||||
|
||||
|
@ -48,7 +48,7 @@ def _image_location(image_info):
|
||||
:param image_info: Image information dictionary.
|
||||
:returns: The full, absolute path to the image as a string.
|
||||
"""
|
||||
return '/tmp/{0}'.format(image_info['id'])
|
||||
return '/tmp/{}'.format(image_info['id'])
|
||||
|
||||
|
||||
def _path_to_script(script):
|
||||
@ -83,8 +83,8 @@ def _write_partition_image(image, image_info, device):
|
||||
root_mb = image_info['root_mb']
|
||||
if image_mb > int(root_mb):
|
||||
msg = ('Root partition is too small for requested image. Image '
|
||||
'virtual size: {0} MB, Root size: {1} MB').format(image_mb,
|
||||
root_mb)
|
||||
'virtual size: {} MB, Root size: {} MB').format(image_mb,
|
||||
root_mb)
|
||||
raise errors.InvalidCommandParamsError(msg)
|
||||
try:
|
||||
return disk_utils.work_on_disk(device, root_mb,
|
||||
@ -115,7 +115,7 @@ def _write_whole_disk_image(image, image_info, device):
|
||||
"""
|
||||
script = _path_to_script('shell/write_image.sh')
|
||||
command = ['/bin/bash', script, image, device]
|
||||
LOG.info('Writing image with command: {0}'.format(' '.join(command)))
|
||||
LOG.info('Writing image with command: {}'.format(' '.join(command)))
|
||||
try:
|
||||
stdout, stderr = utils.execute(*command, check_exit_code=[0])
|
||||
except processutils.ProcessExecutionError as e:
|
||||
@ -139,7 +139,7 @@ def _write_image(image_info, device):
|
||||
else:
|
||||
_write_whole_disk_image(image, image_info, device)
|
||||
totaltime = time.time() - starttime
|
||||
LOG.info('Image {0} written to device {1} in {2} seconds'.format(
|
||||
LOG.info('Image {} written to device {} in {} seconds'.format(
|
||||
image, device, totaltime))
|
||||
return uuids
|
||||
|
||||
@ -173,7 +173,7 @@ def _write_configdrive_to_file(configdrive, filename):
|
||||
:param configdrive: Contents of the configdrive file.
|
||||
:param filename: The filename of where to write the configdrive.
|
||||
"""
|
||||
LOG.debug('Writing configdrive to {0}'.format(filename))
|
||||
LOG.debug('Writing configdrive to {}'.format(filename))
|
||||
# configdrive data is base64'd, decode it first
|
||||
data = six.StringIO(base64.b64decode(configdrive))
|
||||
gunzipped = gzip.GzipFile('configdrive', 'rb', 9, data)
|
||||
@ -208,7 +208,7 @@ def _write_configdrive_to_partition(configdrive, device):
|
||||
starttime = time.time()
|
||||
script = _path_to_script('shell/copy_configdrive_to_disk.sh')
|
||||
command = ['/bin/bash', script, filename, device]
|
||||
LOG.info('copying configdrive to disk with command {0}'.format(
|
||||
LOG.info('copying configdrive to disk with command {}'.format(
|
||||
' '.join(command)))
|
||||
|
||||
try:
|
||||
@ -220,7 +220,7 @@ def _write_configdrive_to_partition(configdrive, device):
|
||||
e.stderr)
|
||||
|
||||
totaltime = time.time() - starttime
|
||||
LOG.info('configdrive copied from {0} to {1} in {2} seconds'.format(
|
||||
LOG.info('configdrive copied from {} to {} in {} seconds'.format(
|
||||
filename,
|
||||
device,
|
||||
totaltime))
|
||||
@ -236,12 +236,12 @@ def _message_format(msg, image_info, device, partition_uuids):
|
||||
partition_uuids.get('efi system partition uuid'))
|
||||
if (image_info.get('deploy_boot_mode') == 'uefi' and
|
||||
image_info.get('boot_option') == 'local'):
|
||||
result_msg = msg + 'root_uuid={2} efi_system_partition_uuid={3}'
|
||||
result_msg = msg + 'root_uuid={} efi_system_partition_uuid={}'
|
||||
message = result_msg.format(image_info['id'], device,
|
||||
root_uuid,
|
||||
efi_system_partition_uuid)
|
||||
else:
|
||||
result_msg = msg + 'root_uuid={2}'
|
||||
result_msg = msg + 'root_uuid={}'
|
||||
message = result_msg.format(image_info['id'], device, root_uuid)
|
||||
else:
|
||||
message = result_msg.format(image_info['id'], device)
|
||||
@ -280,12 +280,12 @@ class ImageDownload(object):
|
||||
details = []
|
||||
for url in image_info['urls']:
|
||||
try:
|
||||
LOG.info("Attempting to download image from {0}".format(url))
|
||||
LOG.info("Attempting to download image from {}".format(url))
|
||||
self._request = self._download_file(image_info, url)
|
||||
except errors.ImageDownloadError as e:
|
||||
failtime = time.time() - self._time
|
||||
log_msg = ('URL: {0}; time: {1} '
|
||||
'seconds. Error: {2}').format(
|
||||
log_msg = ('URL: {}; time: {} '
|
||||
'seconds. Error: {}').format(
|
||||
url, failtime, e.details)
|
||||
LOG.warning('Image download failed. %s', log_msg)
|
||||
details += log_msg
|
||||
@ -313,8 +313,8 @@ class ImageDownload(object):
|
||||
proxies = image_info.get('proxies', {})
|
||||
resp = requests.get(url, stream=True, proxies=proxies)
|
||||
if resp.status_code != 200:
|
||||
msg = ('Received status code {0} from {1}, expected 200. Response '
|
||||
'body: {2}').format(resp.status_code, url, resp.text)
|
||||
msg = ('Received status code {} from {}, expected 200. Response '
|
||||
'body: {}').format(resp.status_code, url, resp.text)
|
||||
raise errors.ImageDownloadError(image_info['id'], msg)
|
||||
return resp
|
||||
|
||||
@ -352,8 +352,8 @@ def _verify_image(image_info, image_location, checksum):
|
||||
:raises: ImageChecksumError if the checksum of the local image does not
|
||||
match the checksum as reported by glance in image_info.
|
||||
"""
|
||||
LOG.debug('Verifying image at {0} against MD5 checksum '
|
||||
'{1}'.format(image_location, checksum))
|
||||
LOG.debug('Verifying image at {} against MD5 checksum '
|
||||
'{}'.format(image_location, checksum))
|
||||
if checksum != image_info['checksum']:
|
||||
LOG.error(errors.ImageChecksumError.details_str.format(
|
||||
image_location, image_info['id'],
|
||||
@ -379,13 +379,13 @@ def _download_image(image_info):
|
||||
for chunk in image_download:
|
||||
f.write(chunk)
|
||||
except Exception as e:
|
||||
msg = 'Unable to write image to {0}. Error: {1}'.format(
|
||||
msg = 'Unable to write image to {}. Error: {}'.format(
|
||||
image_location, str(e))
|
||||
raise errors.ImageDownloadError(image_info['id'], msg)
|
||||
|
||||
totaltime = time.time() - starttime
|
||||
LOG.info("Image downloaded from {0} in {1} seconds".format(image_location,
|
||||
totaltime))
|
||||
LOG.info("Image downloaded from {} in {} seconds".format(image_location,
|
||||
totaltime))
|
||||
_verify_image(image_info, image_location, image_download.md5sum())
|
||||
|
||||
|
||||
@ -405,7 +405,7 @@ def _validate_image_info(ext, image_info=None, **kwargs):
|
||||
|
||||
for field in ['id', 'urls', 'checksum']:
|
||||
if field not in image_info:
|
||||
msg = 'Image is missing \'{0}\' field.'.format(field)
|
||||
msg = 'Image is missing \'{}\' field.'.format(field)
|
||||
raise errors.InvalidCommandParamsError(msg)
|
||||
|
||||
if type(image_info['urls']) != list or not image_info['urls']:
|
||||
@ -465,12 +465,12 @@ class StandbyExtension(base.BaseAgentExtension):
|
||||
for chunk in image_download:
|
||||
f.write(chunk)
|
||||
except Exception as e:
|
||||
msg = 'Unable to write image to device {0}. Error: {1}'.format(
|
||||
msg = 'Unable to write image to device {}. Error: {}'.format(
|
||||
device, str(e))
|
||||
raise errors.ImageDownloadError(image_info['id'], msg)
|
||||
|
||||
totaltime = time.time() - starttime
|
||||
LOG.info("Image streamed onto device {0} in {1} "
|
||||
LOG.info("Image streamed onto device {} in {} "
|
||||
"seconds".format(device, totaltime))
|
||||
# Verify if the checksum of the streamed image is correct
|
||||
_verify_image(image_info, device, image_download.md5sum())
|
||||
@ -492,13 +492,13 @@ class StandbyExtension(base.BaseAgentExtension):
|
||||
LOG.debug('Caching image %s', image_info['id'])
|
||||
device = hardware.dispatch_to_managers('get_os_install_device')
|
||||
|
||||
msg = 'image ({0}) already present on device {1} '
|
||||
msg = 'image ({}) already present on device {} '
|
||||
|
||||
if self.cached_image_id != image_info['id'] or force:
|
||||
LOG.debug('Already had %s cached, overwriting',
|
||||
self.cached_image_id)
|
||||
self._cache_and_write_image(image_info, device)
|
||||
msg = 'image ({0}) cached to device {1} '
|
||||
msg = 'image ({}) cached to device {} '
|
||||
|
||||
result_msg = _message_format(msg, image_info, device,
|
||||
self.partition_uuids)
|
||||
@ -553,7 +553,7 @@ class StandbyExtension(base.BaseAgentExtension):
|
||||
if configdrive is not None:
|
||||
_write_configdrive_to_partition(configdrive, device)
|
||||
|
||||
msg = 'image ({0}) written to device {1} '
|
||||
msg = 'image ({}) written to device {} '
|
||||
result_msg = _message_format(msg, image_info, device,
|
||||
self.partition_uuids)
|
||||
LOG.info(result_msg)
|
||||
|
@ -57,7 +57,7 @@ def _get_device_info(dev, devclass, field):
|
||||
return f.read().strip()
|
||||
except IOError:
|
||||
LOG.warning(
|
||||
"Can't find field {0} for device {1} in device class {2}".format(
|
||||
"Can't find field {} for device {} in device class {}".format(
|
||||
field, dev, devclass))
|
||||
|
||||
|
||||
@ -498,8 +498,8 @@ class GenericHardwareManager(HardwareManager):
|
||||
return self.lldp_data.get(interface_name)
|
||||
|
||||
def _get_interface_info(self, interface_name):
|
||||
addr_path = '{0}/class/net/{1}/address'.format(self.sys_path,
|
||||
interface_name)
|
||||
addr_path = '{}/class/net/{}/address'.format(self.sys_path,
|
||||
interface_name)
|
||||
with open(addr_path) as addr_file:
|
||||
mac_addr = addr_file.read().strip()
|
||||
|
||||
@ -520,8 +520,8 @@ class GenericHardwareManager(HardwareManager):
|
||||
return None
|
||||
|
||||
def _interface_has_carrier(self, interface_name):
|
||||
path = '{0}/class/net/{1}/carrier'.format(self.sys_path,
|
||||
interface_name)
|
||||
path = '{}/class/net/{}/carrier'.format(self.sys_path,
|
||||
interface_name)
|
||||
try:
|
||||
with open(path, 'rt') as fp:
|
||||
return fp.read().strip() == '1'
|
||||
@ -531,12 +531,12 @@ class GenericHardwareManager(HardwareManager):
|
||||
return False
|
||||
|
||||
def _is_device(self, interface_name):
|
||||
device_path = '{0}/class/net/{1}/device'.format(self.sys_path,
|
||||
interface_name)
|
||||
device_path = '{}/class/net/{}/device'.format(self.sys_path,
|
||||
interface_name)
|
||||
return os.path.exists(device_path)
|
||||
|
||||
def list_network_interfaces(self):
|
||||
iface_names = os.listdir('{0}/class/net'.format(self.sys_path))
|
||||
iface_names = os.listdir('{}/class/net'.format(self.sys_path))
|
||||
iface_names = [name for name in iface_names if self._is_device(name)]
|
||||
|
||||
if CONF.collect_lldp:
|
||||
@ -749,7 +749,7 @@ class GenericHardwareManager(HardwareManager):
|
||||
if self._shred_block_device(node, block_device):
|
||||
return
|
||||
|
||||
msg = ('Unable to erase block device {0}: device is unsupported.'
|
||||
msg = ('Unable to erase block device {}: device is unsupported.'
|
||||
).format(block_device.name)
|
||||
LOG.error(msg)
|
||||
raise errors.IncompatibleHardwareMethodError(msg)
|
||||
@ -869,12 +869,12 @@ class GenericHardwareManager(HardwareManager):
|
||||
|
||||
if 'enabled' in security_lines:
|
||||
raise errors.BlockDeviceEraseError(
|
||||
('Block device {0} already has a security password set'
|
||||
('Block device {} already has a security password set'
|
||||
).format(block_device.name))
|
||||
|
||||
if 'not frozen' not in security_lines:
|
||||
raise errors.BlockDeviceEraseError(
|
||||
('Block device {0} is frozen and cannot be erased'
|
||||
('Block device {} is frozen and cannot be erased'
|
||||
).format(block_device.name))
|
||||
|
||||
try:
|
||||
@ -905,7 +905,7 @@ class GenericHardwareManager(HardwareManager):
|
||||
security_lines = self._get_ata_security_lines(block_device)
|
||||
if 'not enabled' not in security_lines:
|
||||
raise errors.BlockDeviceEraseError(
|
||||
('An unknown error occurred erasing block device {0}'
|
||||
('An unknown error occurred erasing block device {}'
|
||||
).format(block_device.name))
|
||||
|
||||
return True
|
||||
@ -982,7 +982,7 @@ def _get_managers():
|
||||
for extension in extensions:
|
||||
if extension.obj.evaluate_hardware_support() > 0:
|
||||
preferred_managers.append(extension.obj)
|
||||
LOG.info('Hardware manager found: {0}'.format(
|
||||
LOG.info('Hardware manager found: {}'.format(
|
||||
extension.entry_point_target))
|
||||
|
||||
if not preferred_managers:
|
||||
@ -1019,7 +1019,7 @@ def dispatch_to_all_managers(method, *args, **kwargs):
|
||||
try:
|
||||
response = getattr(manager, method)(*args, **kwargs)
|
||||
except errors.IncompatibleHardwareMethodError:
|
||||
LOG.debug('HardwareManager {0} does not support {1}'
|
||||
LOG.debug('HardwareManager {} does not support {}'
|
||||
.format(manager, method))
|
||||
continue
|
||||
except Exception as e:
|
||||
@ -1029,7 +1029,7 @@ def dispatch_to_all_managers(method, *args, **kwargs):
|
||||
raise
|
||||
responses[manager.__class__.__name__] = response
|
||||
else:
|
||||
LOG.debug('HardwareManager {0} does not have method {1}'
|
||||
LOG.debug('HardwareManager {} does not have method {}'
|
||||
.format(manager, method))
|
||||
|
||||
if responses == {}:
|
||||
@ -1061,7 +1061,7 @@ def dispatch_to_managers(method, *args, **kwargs):
|
||||
try:
|
||||
return getattr(manager, method)(*args, **kwargs)
|
||||
except(errors.IncompatibleHardwareMethodError):
|
||||
LOG.debug('HardwareManager {0} does not support {1}'
|
||||
LOG.debug('HardwareManager {} does not support {}'
|
||||
.format(manager, method))
|
||||
except Exception as e:
|
||||
LOG.exception('Unexpected error dispatching %(method)s to '
|
||||
@ -1069,7 +1069,7 @@ def dispatch_to_managers(method, *args, **kwargs):
|
||||
{'method': method, 'manager': manager, 'e': e})
|
||||
raise
|
||||
else:
|
||||
LOG.debug('HardwareManager {0} does not have method {1}'
|
||||
LOG.debug('HardwareManager {} does not have method {}'
|
||||
.format(manager, method))
|
||||
|
||||
raise errors.HardwareManagerMethodNotFound(method)
|
||||
|
@ -93,7 +93,7 @@ class APIClient(object):
|
||||
data = json.loads(response.content)
|
||||
raise errors.HeartbeatConflictError(data.get('faultstring'))
|
||||
elif response.status_code != requests.codes.ACCEPTED:
|
||||
msg = 'Invalid status code: {0}'.format(response.status_code)
|
||||
msg = 'Invalid status code: {}'.format(response.status_code)
|
||||
raise errors.HeartbeatError(msg)
|
||||
|
||||
def lookup_node(self, hardware_info, timeout, starting_interval,
|
||||
@ -190,5 +190,5 @@ class APIClient(object):
|
||||
raise loopingcall.LoopingCallDone(retvalue=content)
|
||||
|
||||
def _get_agent_url(self, advertise_address):
|
||||
return 'http://{0}:{1}'.format(advertise_address[0],
|
||||
advertise_address[1])
|
||||
return 'http://{}:{}'.format(advertise_address[0],
|
||||
advertise_address[1])
|
||||
|
@ -470,8 +470,8 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
self.agent_extension.cached_image_id)
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('cache_image: image ({0}) cached to device '
|
||||
'{1} ').format(image_info['id'], 'manager')
|
||||
cmd_result = ('cache_image: image ({}) cached to device '
|
||||
'{} ').format(image_info['id'], 'manager')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
@mock.patch('ironic_python_agent.hardware.dispatch_to_managers',
|
||||
@ -495,9 +495,9 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
self.agent_extension.cached_image_id)
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('cache_image: image ({0}) cached to device {1} '
|
||||
'root_uuid={2}').format(image_info['id'], 'manager',
|
||||
'root_uuid')
|
||||
cmd_result = ('cache_image: image ({}) cached to device {} '
|
||||
'root_uuid={}').format(image_info['id'], 'manager',
|
||||
'root_uuid')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
@mock.patch('ironic_python_agent.hardware.dispatch_to_managers',
|
||||
@ -524,8 +524,8 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
self.agent_extension.cached_image_id)
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('cache_image: image ({0}) cached to device '
|
||||
'{1} ').format(image_info['id'], 'manager')
|
||||
cmd_result = ('cache_image: image ({}) cached to device '
|
||||
'{} ').format(image_info['id'], 'manager')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
@mock.patch('ironic_python_agent.hardware.dispatch_to_managers',
|
||||
@ -550,8 +550,8 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
self.agent_extension.cached_image_id)
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('cache_image: image ({0}) already present on device '
|
||||
'{1} ').format(image_info['id'], 'manager')
|
||||
cmd_result = ('cache_image: image ({}) already present on device '
|
||||
'{} ').format(image_info['id'], 'manager')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
@mock.patch(('ironic_python_agent.extensions.standby.'
|
||||
@ -592,8 +592,8 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('prepare_image: image ({0}) written to device '
|
||||
'{1} ').format(image_info['id'], 'manager')
|
||||
cmd_result = ('prepare_image: image ({}) written to device '
|
||||
'{} ').format(image_info['id'], 'manager')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
download_mock.reset_mock()
|
||||
@ -613,8 +613,8 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('prepare_image: image ({0}) written to device '
|
||||
'{1} ').format(image_info['id'], 'manager')
|
||||
cmd_result = ('prepare_image: image ({}) written to device '
|
||||
'{} ').format(image_info['id'], 'manager')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
@mock.patch(('ironic_python_agent.extensions.standby.'
|
||||
@ -654,8 +654,8 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('prepare_image: image ({0}) written to device {1} '
|
||||
'root_uuid={2}').format(
|
||||
cmd_result = ('prepare_image: image ({}) written to device {} '
|
||||
'root_uuid={}').format(
|
||||
image_info['id'], 'manager', 'root_uuid')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
@ -675,8 +675,8 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('prepare_image: image ({0}) written to device {1} '
|
||||
'root_uuid={2}').format(
|
||||
cmd_result = ('prepare_image: image ({}) written to device {} '
|
||||
'root_uuid={}').format(
|
||||
image_info['id'], 'manager', 'root_uuid')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
@ -713,8 +713,8 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
self.assertEqual(0, configdrive_copy_mock.call_count)
|
||||
self.assertEqual('SUCCEEDED', async_result.command_status)
|
||||
self.assertIn('result', async_result.command_result)
|
||||
cmd_result = ('prepare_image: image ({0}) written to device '
|
||||
'{1} ').format(image_info['id'], 'manager')
|
||||
cmd_result = ('prepare_image: image ({}) written to device '
|
||||
'{} ').format(image_info['id'], 'manager')
|
||||
self.assertEqual(cmd_result, async_result.command_result['result'])
|
||||
|
||||
@mock.patch(('ironic_python_agent.extensions.standby.'
|
||||
@ -882,7 +882,7 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
|
||||
def test__message_format_whole_disk(self):
|
||||
image_info = _build_fake_image_info()
|
||||
msg = 'image ({0}) already present on device {1}'
|
||||
msg = 'image ({}) already present on device {}'
|
||||
device = '/dev/fake'
|
||||
partition_uuids = {}
|
||||
result_msg = standby._message_format(msg, image_info,
|
||||
@ -893,7 +893,7 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
|
||||
def test__message_format_partition_bios(self):
|
||||
image_info = _build_fake_partition_image_info()
|
||||
msg = ('image ({0}) already present on device {1} ')
|
||||
msg = ('image ({}) already present on device {} ')
|
||||
device = '/dev/fake'
|
||||
partition_uuids = {'root uuid': 'root_uuid',
|
||||
'efi system partition uuid': None}
|
||||
@ -907,7 +907,7 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
image_info = _build_fake_partition_image_info()
|
||||
image_info['deploy_boot_mode'] = 'uefi'
|
||||
image_info['boot_option'] = 'netboot'
|
||||
msg = ('image ({0}) already present on device {1} ')
|
||||
msg = ('image ({}) already present on device {} ')
|
||||
device = '/dev/fake'
|
||||
partition_uuids = {'root uuid': 'root_uuid',
|
||||
'efi system partition uuid': None}
|
||||
@ -921,7 +921,7 @@ class TestStandbyExtension(test_base.BaseTestCase):
|
||||
image_info = _build_fake_partition_image_info()
|
||||
image_info['deploy_boot_mode'] = 'uefi'
|
||||
image_info['boot_option'] = 'local'
|
||||
msg = ('image ({0}) already present on device {1} ')
|
||||
msg = ('image ({}) already present on device {} ')
|
||||
device = '/dev/fake'
|
||||
partition_uuids = {'root uuid': 'root_uuid',
|
||||
'efi system partition uuid': 'efi_id'}
|
||||
|
Loading…
Reference in New Issue
Block a user