Adding dry_run flag for salt.control state
Issue: on virtual environments where nested virtualization is not
possible, we cannot get config drive iso files
Solution: generate config dirve isoes by running salt.control
state with dry_run=True
As for comment in the code, I prefer to switch from start=True to
dry_run=False and switch to it.
This is why I added new flag. Product team can switch on the fly
and deprecate start=True usage
Prod-Related: PROD-29586
Change-Id: I2e5485e3e2a4fec06edc874de12fd50fb76d8264
diff --git a/_modules/virtng.py b/_modules/virtng.py
index 2da9d36..933d590 100644
--- a/_modules/virtng.py
+++ b/_modules/virtng.py
@@ -552,6 +552,7 @@
nic='default',
hypervisor=VIRT_DEFAULT_HYPER,
start=True, # pylint: disable=redefined-outer-name
+ dry_run=False,
disk='default',
saltenv='base',
rng=None,
@@ -632,6 +633,8 @@
os.makedirs(img_dir)
if 'image' in args:
+ if dry_run:
+ continue
# Create disk from specified image
sfn = __salt__['cp.cache_file'](args['image'], saltenv)
try:
@@ -814,7 +817,7 @@
xml = xml_doc.toxml()
define_xml_str(xml)
- if start:
+ if start and not dry_run:
create(name)
return True
diff --git a/salt/control/virt.sls b/salt/control/virt.sls
index 08e6158..187462c 100644
--- a/salt/control/virt.sls
+++ b/salt/control/virt.sls
@@ -62,6 +62,7 @@
- mem: {{ size.ram }}
- image: {{ node.image }}
- start: True
+ - dry_run: False
- disk: {{ size.disk_profile }}
- nic: {{ size.net_profile }}
{%- if node.rng is defined %}