Skip to main content

VIOS Migration Flow

In this document, we will explain the process of migrating Virtual I/O Servers (VIOS) using the nim_migvios_tuple function. The process involves checking the previous status of the VIOS, verifying the time limit, executing the migration command, and finalizing the migration.

The flow starts by checking the previous status of the VIOS. If no previous status is found or if the previous status is not 'SUCCESS', the migration is skipped. Next, it checks if the time limit has been reached, and if so, the migration is skipped. Then, the migration command is executed, and the status is updated based on the return code. Finally, the operation progress is checked, and the status is updated accordingly.

Flow drill down


Handling the Migration Status

First, we check the previous status of the VIOS. If no previous status is found, the migration is skipped, and a message is logged. If the previous status is not 'SUCCESS', the migration is also skipped, and the status is updated accordingly.

        if module.params['vios_status'] is not None:
if vios_key not in module.params['vios_status']:
msg = f'{vios_key} vioses skipped (no previous status found)'
module.log('[WARNING] ' + msg)
results['meta'][vios_key]['messages'].append(msg)
results['status'][vios_key] = 'SKIPPED-NO-PREV-STATUS'
continue

if 'SUCCESS' not in module.params['vios_status'][vios_key]:
vios_status = module.params['vios_status'][vios_key]
msg = f'{vios_key} VIOSes skipped (vios_status: {vios_status})'
module.log(msg)
results['meta'][vios_key]['messages'].append(msg)
results['status'][vios_key] = module.params['vios_status'][vios_key]
continue


Checking for Time Limit

Next, we check if the stop_event is set, indicating that the time limit has been reached. If so, the migration is skipped, and a message is logged.

        # check if we are asked to stop (time_limit might be reached)
if stop_event and stop_event.isSet():
time_limit = time.strftime('%m/%d/%Y %H:%M', module.params['time_limit'])
msg = f'Time limit {time_limit} reached, no further operation'
module.log('[WARNING] ' + msg)
results['meta'][vios_key]['messages'].append(msg)
results['status'][vios_key] = "SKIPPED-TIMEOUT"
return


Executing the Migration Command

Then, we call the nim_migvios function to execute the migration command. The status is updated based on the return code of the command.

        rc = nim_migvios(module, vios_key, vios)
if rc == 0:
if vios == vios1:
results['status'][vios_key] = 'SUCCESS-UPGR1-INIT'
else:
results['status'][vios_key] = 'SUCCESS-UPGR2-INIT'
else:
if vios == vios1:
results['status'][vios_key] = 'FAILURE-UPGR1-INIT'
else:
results['status'][vios_key] = 'FAILURE-UPGR2-INIT'
return


Finalizing the Migration

Finally, we check the operation progress and wait for completion. The status is updated based on the return code of the nim_wait_migvios function.

        # check the operation progress, wait the completion and set the status
rc = nim_wait_migvios(module, vios_key, vios)
if rc == 0:
if vios == vios1:
module.status[vios_key] = 'SUCCESS-UPGR1'
else:
module.status[vios_key] = 'SUCCESS-UPGR2'
elif rc == -1:
if vios == vios1:
module.status[vios_key] = 'FAILURE-UPGR1-WAIT'
else:
module.status[vios_key] = 'FAILURE-UPGR2-WAIT'
# will not migrate the next vios
return
else:
if vios == vios1:
module.status[vios_key] = 'FAILURE-UPGR1'
else:
module.status[vios_key] = 'FAILURE-UPGR2'
# will not migrate the next vios
return


Building the Migration Command

The nim_migvios function builds the migration command using various parameters such as ios_mksysb, ios_backup, spot, and others. These parameters are used to customize the migration command based on the user's requirements.

    cmd = ['nim', '-Fo', 'migvios']

cmd += ['-a', f'ios_mksysb={mksysb_name}']
cmd += ['-a', f'ios_backup={backup_name}']

if module.params['group']:
params_group = module.params['group']
cmd += ['-a', f'group={params_group}']

if module.params['spot_name'] or module.params['spot_prefix'] or module.params['spot_postfix']:
if not module.params['spot_name'] and module.params['spot_postfix'] is None:
module.params['spot_postfix'] = '_spot'
spot_name = build_name(vios, module.params['spot_name'], module.params['spot_prefix'], module.params['spot_postfix'])
cmd += ['-a', f'spot={spot_name}']

lpp_source = module.params['lpp_source']
bosinst_data = module.params['bosinst_data']
resolv_conf = module.params['resolv_conf']
image_data = module.params['image_data']
log = module.params['log']
file_resource = module.params['file_resource']


Running the Migration Command

The migration command is executed using the module.run_command method. If the command fails, an error message is logged, and the status is updated. If the command succeeds, the status is updated to indicate a successful migration.

    cmd = ' '.join(cmd)
rc, stdout, stderr = module.run_command(cmd)

if rc != 0:
msg = f'Failed to migrate {vios} VIOS, migvios returned {rc}'
module.log(msg)
module.log(f'cmd \'{cmd}\' failed, stdout: {stdout}, stderr:{stderr}')
results['meta'][vios_key]['messages'].append(msg)
results['meta'][vios_key][vios]['cmd'] = cmd
results['meta'][vios_key][vios]['stdout'] = stdout
results['meta'][vios_key][vios]['stderr'] = stderr
else:
# update the nim
if 'backup' in module.nim_node['vios'][vios]:
module.nim_node['vios'][vios]['backup']['name'] = backup_name
else:
module.nim_node['vios'][vios]['backup'] = {}
module.nim_node['vios'][vios]['backup']['name'] = backup_name
msg = f'VIOS {vios} migration successfully initiated'
module.log(msg)
results['meta'][vios_key]['messages'].append(msg)

Where is this flow used?

This flow is used multiple times in the codebase as represented in the following diagram:

 

This is an auto-generated document by Swimm 🌊 and has not yet been verified by a human