Support viewing source volumes
This commit is contained in:
parent
698b185fb4
commit
a9b8403812
|
@ -865,6 +865,7 @@ def format_list_template_storage(template_template):
|
||||||
template_id_length = 3
|
template_id_length = 3
|
||||||
template_disk_id_length = 8
|
template_disk_id_length = 8
|
||||||
template_disk_pool_length = 8
|
template_disk_pool_length = 8
|
||||||
|
template_disk_source_length = 14
|
||||||
template_disk_size_length = 10
|
template_disk_size_length = 10
|
||||||
template_disk_filesystem_length = 11
|
template_disk_filesystem_length = 11
|
||||||
template_disk_fsargs_length = 10
|
template_disk_fsargs_length = 10
|
||||||
|
@ -889,6 +890,10 @@ def format_list_template_storage(template_template):
|
||||||
_template_disk_pool_length = len(str(disk['pool'])) + 1
|
_template_disk_pool_length = len(str(disk['pool'])) + 1
|
||||||
if _template_disk_pool_length > template_disk_pool_length:
|
if _template_disk_pool_length > template_disk_pool_length:
|
||||||
template_disk_pool_length = _template_disk_pool_length
|
template_disk_pool_length = _template_disk_pool_length
|
||||||
|
# template_disk_source column
|
||||||
|
_template_disk_source_length = len(str(disk['source_volume'])) + 1
|
||||||
|
if _template_disk_source_length > template_disk_source_length:
|
||||||
|
template_disk_source_length = _template_disk_source_length
|
||||||
# template_disk_size column
|
# template_disk_size column
|
||||||
_template_disk_size_length = len(str(disk['disk_size_gb'])) + 1
|
_template_disk_size_length = len(str(disk['disk_size_gb'])) + 1
|
||||||
if _template_disk_size_length > template_disk_size_length:
|
if _template_disk_size_length > template_disk_size_length:
|
||||||
|
@ -910,6 +915,7 @@ def format_list_template_storage(template_template):
|
||||||
template_list_output_header = '{bold}{template_name: <{template_name_length}} {template_id: <{template_id_length}} \
|
template_list_output_header = '{bold}{template_name: <{template_name_length}} {template_id: <{template_id_length}} \
|
||||||
{template_disk_id: <{template_disk_id_length}} \
|
{template_disk_id: <{template_disk_id_length}} \
|
||||||
{template_disk_pool: <{template_disk_pool_length}} \
|
{template_disk_pool: <{template_disk_pool_length}} \
|
||||||
|
{template_disk_source: <{template_disk_source_length}} \
|
||||||
{template_disk_size: <{template_disk_size_length}} \
|
{template_disk_size: <{template_disk_size_length}} \
|
||||||
{template_disk_filesystem: <{template_disk_filesystem_length}} \
|
{template_disk_filesystem: <{template_disk_filesystem_length}} \
|
||||||
{template_disk_fsargs: <{template_disk_fsargs_length}} \
|
{template_disk_fsargs: <{template_disk_fsargs_length}} \
|
||||||
|
@ -918,6 +924,7 @@ def format_list_template_storage(template_template):
|
||||||
template_id_length=template_id_length,
|
template_id_length=template_id_length,
|
||||||
template_disk_id_length=template_disk_id_length,
|
template_disk_id_length=template_disk_id_length,
|
||||||
template_disk_pool_length=template_disk_pool_length,
|
template_disk_pool_length=template_disk_pool_length,
|
||||||
|
template_disk_source_length=template_disk_source_length,
|
||||||
template_disk_size_length=template_disk_size_length,
|
template_disk_size_length=template_disk_size_length,
|
||||||
template_disk_filesystem_length=template_disk_filesystem_length,
|
template_disk_filesystem_length=template_disk_filesystem_length,
|
||||||
template_disk_fsargs_length=template_disk_fsargs_length,
|
template_disk_fsargs_length=template_disk_fsargs_length,
|
||||||
|
@ -928,6 +935,7 @@ def format_list_template_storage(template_template):
|
||||||
template_id='ID',
|
template_id='ID',
|
||||||
template_disk_id='Disk ID',
|
template_disk_id='Disk ID',
|
||||||
template_disk_pool='Pool',
|
template_disk_pool='Pool',
|
||||||
|
template_disk_source='Source Volume',
|
||||||
template_disk_size='Size [GB]',
|
template_disk_size='Size [GB]',
|
||||||
template_disk_filesystem='Filesystem',
|
template_disk_filesystem='Filesystem',
|
||||||
template_disk_fsargs='Arguments',
|
template_disk_fsargs='Arguments',
|
||||||
|
@ -940,12 +948,6 @@ def format_list_template_storage(template_template):
|
||||||
'{bold}{template_name: <{template_name_length}} {template_id: <{template_id_length}}{end_bold}'.format(
|
'{bold}{template_name: <{template_name_length}} {template_id: <{template_id_length}}{end_bold}'.format(
|
||||||
template_name_length=template_name_length,
|
template_name_length=template_name_length,
|
||||||
template_id_length=template_id_length,
|
template_id_length=template_id_length,
|
||||||
template_disk_id_length=template_disk_id_length,
|
|
||||||
template_disk_pool_length=template_disk_pool_length,
|
|
||||||
template_disk_size_length=template_disk_size_length,
|
|
||||||
template_disk_filesystem_length=template_disk_filesystem_length,
|
|
||||||
template_disk_fsargs_length=template_disk_fsargs_length,
|
|
||||||
template_disk_mountpoint_length=template_disk_mountpoint_length,
|
|
||||||
bold='',
|
bold='',
|
||||||
end_bold='',
|
end_bold='',
|
||||||
template_name=str(template['name']),
|
template_name=str(template['name']),
|
||||||
|
@ -957,6 +959,7 @@ def format_list_template_storage(template_template):
|
||||||
'{bold}{template_name: <{template_name_length}} {template_id: <{template_id_length}} \
|
'{bold}{template_name: <{template_name_length}} {template_id: <{template_id_length}} \
|
||||||
{template_disk_id: <{template_disk_id_length}} \
|
{template_disk_id: <{template_disk_id_length}} \
|
||||||
{template_disk_pool: <{template_disk_pool_length}} \
|
{template_disk_pool: <{template_disk_pool_length}} \
|
||||||
|
{template_disk_source: <{template_disk_source_length}} \
|
||||||
{template_disk_size: <{template_disk_size_length}} \
|
{template_disk_size: <{template_disk_size_length}} \
|
||||||
{template_disk_filesystem: <{template_disk_filesystem_length}} \
|
{template_disk_filesystem: <{template_disk_filesystem_length}} \
|
||||||
{template_disk_fsargs: <{template_disk_fsargs_length}} \
|
{template_disk_fsargs: <{template_disk_fsargs_length}} \
|
||||||
|
@ -965,6 +968,7 @@ def format_list_template_storage(template_template):
|
||||||
template_id_length=template_id_length,
|
template_id_length=template_id_length,
|
||||||
template_disk_id_length=template_disk_id_length,
|
template_disk_id_length=template_disk_id_length,
|
||||||
template_disk_pool_length=template_disk_pool_length,
|
template_disk_pool_length=template_disk_pool_length,
|
||||||
|
template_disk_source_length=template_disk_source_length,
|
||||||
template_disk_size_length=template_disk_size_length,
|
template_disk_size_length=template_disk_size_length,
|
||||||
template_disk_filesystem_length=template_disk_filesystem_length,
|
template_disk_filesystem_length=template_disk_filesystem_length,
|
||||||
template_disk_fsargs_length=template_disk_fsargs_length,
|
template_disk_fsargs_length=template_disk_fsargs_length,
|
||||||
|
@ -975,6 +979,7 @@ def format_list_template_storage(template_template):
|
||||||
template_id='',
|
template_id='',
|
||||||
template_disk_id=str(disk['disk_id']),
|
template_disk_id=str(disk['disk_id']),
|
||||||
template_disk_pool=str(disk['pool']),
|
template_disk_pool=str(disk['pool']),
|
||||||
|
template_disk_source=str(disk['source_volume']),
|
||||||
template_disk_size=str(disk['disk_size_gb']),
|
template_disk_size=str(disk['disk_size_gb']),
|
||||||
template_disk_filesystem=str(disk['filesystem']),
|
template_disk_filesystem=str(disk['filesystem']),
|
||||||
template_disk_fsargs=str(disk['filesystem_args']),
|
template_disk_fsargs=str(disk['filesystem_args']),
|
||||||
|
|
|
@ -2239,8 +2239,13 @@ def provisioner_template_storage_disk():
|
||||||
help='The storage pool for the disk.'
|
help='The storage pool for the disk.'
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
'-s', '--size', 'size',
|
'-i', '--source-volume', 'source_volume',
|
||||||
required=True, type=int,
|
default=None,
|
||||||
|
help='The source volume to clone'
|
||||||
|
)
|
||||||
|
@click.option(
|
||||||
|
'-s', '--size', 'size', type=int,
|
||||||
|
default=None,
|
||||||
help='The size of the disk (in GB).'
|
help='The size of the disk (in GB).'
|
||||||
)
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
|
@ -2258,14 +2263,20 @@ def provisioner_template_storage_disk():
|
||||||
default=None,
|
default=None,
|
||||||
help='The target Linux mountpoint of the disk; requires a filesystem.'
|
help='The target Linux mountpoint of the disk; requires a filesystem.'
|
||||||
)
|
)
|
||||||
def provisioner_template_storage_disk_add(name, disk, pool, size, filesystem, fsargs, mountpoint):
|
def provisioner_template_storage_disk_add(name, disk, pool, source_volume, size, filesystem, fsargs, mountpoint):
|
||||||
"""
|
"""
|
||||||
Add a new DISK to storage template NAME.
|
Add a new DISK to storage template NAME.
|
||||||
|
|
||||||
DISK must be a Linux-style disk identifier such as "sda" or "vdb".
|
DISK must be a Linux-style disk identifier such as "sda" or "vdb".
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if source_volume and (size or filesystem or mountpoint):
|
||||||
|
click.echo('The "--source-volume" option is not compatible with the "--size", "--filesystem", or "--mountpoint" options.')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
params = dict()
|
params = dict()
|
||||||
params['pool'] = pool
|
params['pool'] = pool
|
||||||
|
params['source_volume'] = source_volume
|
||||||
params['disk_size'] = size
|
params['disk_size'] = size
|
||||||
if filesystem:
|
if filesystem:
|
||||||
params['filesystem'] = filesystem
|
params['filesystem'] = filesystem
|
||||||
|
|
Loading…
Reference in New Issue