CLI: add --verbose and --extra-args

The --extra-args argument allows passing arbitrary arguments to DIB.

Change-Id: I26be362263c08ea5cfe3bd265372ff5ab406d85c
This commit is contained in:
Dmitry Tantsur 2019-10-23 16:10:04 +02:00
parent f6bf7b97d5
commit 07d27a573e
3 changed files with 12 additions and 2 deletions

View File

@ -12,6 +12,7 @@
import argparse import argparse
import os import os
import shlex
import subprocess import subprocess
import sys import sys
@ -50,6 +51,10 @@ def main():
parser.add_argument("-b", "--branch", parser.add_argument("-b", "--branch",
help="If set, override the branch that is used for " help="If set, override the branch that is used for "
"ironic-python-agent and requirements") "ironic-python-agent and requirements")
parser.add_argument("-v", "--verbose", action='store_true',
help="Enable verbose logging in diskimage-builder")
parser.add_argument("--extra-args",
help="Extra arguments to pass to diskimage-builder")
# TODO(dtantsur): handle distribution == tinyipa # TODO(dtantsur): handle distribution == tinyipa
os.environ['ELEMENTS_PATH'] = find_elements_path() os.environ['ELEMENTS_PATH'] = find_elements_path()
if not os.environ.get('DIB_INSTALLTYPE_pip_and_virtualenv'): if not os.environ.get('DIB_INSTALLTYPE_pip_and_virtualenv'):
@ -63,10 +68,13 @@ def main():
if args.branch: if args.branch:
os.environ['DIB_REPOREF_ironic_python_agent'] = args.branch os.environ['DIB_REPOREF_ironic_python_agent'] = args.branch
os.environ['DIB_REPOREF_requirements'] = args.branch os.environ['DIB_REPOREF_requirements'] = args.branch
extra_args = shlex.split(args.extra_args) if args.extra_args else []
if args.verbose:
extra_args.append("-x")
try: try:
subprocess.check_call(['disk-image-create', '-o', args.output, subprocess.check_call(['disk-image-create', '-o', args.output,
'ironic-python-agent-ramdisk', 'ironic-python-agent-ramdisk',
args.distribution] + args.element) args.distribution] + args.element + extra_args)
except (EnvironmentError, subprocess.CalledProcessError) as exc: except (EnvironmentError, subprocess.CalledProcessError) as exc:
sys.exit(str(exc)) sys.exit(str(exc))
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@ -5,3 +5,4 @@ ipa_source_path: '{{ ansible_user_dir }}/src/opendev.org/openstack/ironic-python
requirements_path: '{{ ansible_user_dir }}/src/opendev.org/openstack/requirements' requirements_path: '{{ ansible_user_dir }}/src/opendev.org/openstack/requirements'
ipa_raw_dir: '{{ ansible_user_dir }}/src/opendev.org/openstack/ironic-python-agent/UPLOAD_RAW' ipa_raw_dir: '{{ ansible_user_dir }}/src/opendev.org/openstack/ironic-python-agent/UPLOAD_RAW'
ipa_tar_dir: '{{ ansible_user_dir }}/src/opendev.org/openstack/ironic-python-agent/UPLOAD_TAR' ipa_tar_dir: '{{ ansible_user_dir }}/src/opendev.org/openstack/ironic-python-agent/UPLOAD_TAR'
dib_extra_args:

View File

@ -4,8 +4,9 @@
- name: Build a DIB image - name: Build a DIB image
command: | command: |
ironic-python-agent-builder -o {{ image_name }} -b HEAD ironic-python-agent-builder -o {{ image_name }} -b HEAD -v
{{ "-r {}".format(image_release) if image_release else '' }} {{ "-r {}".format(image_release) if image_release else '' }}
{{ "--extra-args '{}'".format(dib_extra_args) if dib_extra_args else '' }}
{{ image_distro }} {{ image_distro }}
environment: environment:
# Increase from the default value of 30 # Increase from the default value of 30