Add test=True suport in cinderv3.py
PROD-34615
Change-Id: I49df5964582642860d9911f1ffaa5abaac31bb78
diff --git a/_states/cinderv3.py b/_states/cinderv3.py
index 511ec5f..c35c32d 100644
--- a/_states/cinderv3.py
+++ b/_states/cinderv3.py
@@ -13,7 +13,11 @@
def _cinder_call(fname, *args, **kwargs):
- return __salt__['cinderv3.{}'.format(fname)](*args, **kwargs)
+ if __opts__.get('test') and not (fname.find('_list') > 0 or fname.find('_get_') > 0):
+ return {'changes': 'cinderv3 state {} with options {} {} will be executed'.format(fname, args, kwargs),
+ 'result': None}
+ else:
+ return __salt__['cinderv3.{}'.format(fname)](*args, **kwargs)
def _resource_present(resource, name, cloud_name, **kwargs):
@@ -168,6 +172,13 @@
'result': True,
'comment': 'Volume type "{0}" was updated'.format(name)
}
+ elif signal_create["result"] is None:
+ ret = {
+ 'name': name,
+ 'changes': keys,
+ 'result': None,
+ 'comment': 'Volume type "{0}" will be updated'.format(name)
+ }
else:
ret = {
'name': name,
@@ -178,6 +189,12 @@
return ret
+def _check_test_mode():
+ if __opts__.get('test'):
+ return None
+ else:
+ return True
+
def _succeeded(op, name, resource, changes=None):
msg_map = {
'create': '{0} {1} created',
@@ -189,7 +206,7 @@
}
changes_dict = {
'name': name,
- 'result': True,
+ 'result': _check_test_mode,
'comment': msg_map[op].format(resource, name),
'changes': changes or {},
}