Add dest image/map path sections

This commit is contained in:
2Shirt 2018-07-18 23:19:42 -06:00
parent 646e1a3764
commit e640caee74
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C

View file

@ -261,6 +261,7 @@ def menu_clone(source_path, dest_path):
# Show selection details # Show selection details
show_selection_details(source, dest) show_selection_details(source, dest)
set_dest_image_paths(source, dest)
# Confirm # Confirm
if not ask('Proceed with clone?'): if not ask('Proceed with clone?'):
@ -326,6 +327,7 @@ def menu_image(source_path, dest_path):
# Select child device(s) # Select child device(s)
source['Children'] = menu_select_children(source) source['Children'] = menu_select_children(source)
set_dest_image_paths(source, dest)
# Main menu # Main menu
build_outer_panes(source, dest) build_outer_panes(source, dest)
@ -444,13 +446,14 @@ def menu_select_children(source):
'Base Name': '{:<14}(Whole device)'.format(source['Dev Path']), 'Base Name': '{:<14}(Whole device)'.format(source['Dev Path']),
'Path': source['Dev Path'], 'Path': source['Dev Path'],
'Selected': True}] 'Selected': True}]
for child in source['Details'].get('children', []): for c_details in source['Details'].get('children', []):
dev_options.append({ dev_options.append({
'Base Name': '{:<14}({:>6} {})'.format( 'Base Name': '{:<14}({:>6} {})'.format(
child['name'], c_details['name'],
child['size'], c_details['size'],
child['fstype'] if child['fstype'] else 'Unknown'), c_details['fstype'] if c_details['fstype'] else 'Unknown'),
'Path': child['name'], 'Details': c_details,
'Path': c_details['name'],
'Selected': False}) 'Selected': False})
actions = [ actions = [
{'Name': 'Proceed', 'Letter': 'P'}, {'Name': 'Proceed', 'Letter': 'P'},
@ -493,6 +496,7 @@ def menu_select_children(source):
# Check selection # Check selection
selected_children = [{ selected_children = [{
'Details': d['Details'],
'Dev Path': d['Path'], 'Dev Path': d['Path'],
'Pass 1': {'Status': 'Pending', 'Done': False}, 'Pass 1': {'Status': 'Pending', 'Done': False},
'Pass 2': {'Status': 'Pending', 'Done': False}, 'Pass 2': {'Status': 'Pending', 'Done': False},
@ -887,6 +891,38 @@ def select_device(description='device', provided_path=None,
return dev return dev
def set_dest_image_paths(source, dest):
"""Set destination image path for source and any child devices."""
if source['Type'] == 'Clone':
base = '{pwd}/Clone_{Date-Time}'.format(
pwd = os.path.realpath(global_vars['Env']['PWD']),
**global_vars)
else:
base = '{Path}/{size}_{model}'.format(
size = source['Details']['size'],
model = source['Details'].get('model', 'Unknown'),
**dest)
source['Dest Paths'] = {
'Image': '{}.dd'.format(base),
'Map': '{}.map'.format(base)}
# Child devices
for child in source['Children']:
p_label = ''
if child['Details']['label']:
p_label = '_{}'.format(child['Details']['label'])
base = '{Path}/{size}_{model}_{p_num}_{p_size}{p_label}'.format(
size = source['Details']['size'],
model = source['Details'].get('model', 'Unknown'),
p_num = child['Details']['name'].replace(
child['Details']['pkname'], ''),
p_size = child['Details']['size'],
p_label = p_label,
**dest)
child['Dest Paths'] = {
'Image': '{}.dd'.format(base),
'Map': '{}.map'.format(base)}
def setup_loopback_device(source_path): def setup_loopback_device(source_path):
"""Setup a loopback device for source_path, returns dev_path as str.""" """Setup a loopback device for source_path, returns dev_path as str."""
cmd = ( cmd = (