本文整理汇总了Python中ansible.module_utils.aci.ACIModule.result['filter_string']方法的典型用法代码示例。如果您正苦于以下问题:Python ACIModule.result['filter_string']方法的具体用法?Python ACIModule.result['filter_string']怎么用?Python ACIModule.result['filter_string']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ansible.module_utils.aci.ACIModule
的用法示例。
在下文中一共展示了ACIModule.result['filter_string']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from ansible.module_utils.aci import ACIModule [as 别名]
# 或者: from ansible.module_utils.aci.ACIModule import result['filter_string'] [as 别名]
def main():
argument_spec = aci_argument_spec
argument_spec.update(
compare_export_policy=dict(type='str'),
compare_snapshot=dict(type='str'),
description=dict(type='str', aliases=['descr']),
export_policy=dict(type='str'),
fail_on_decrypt=dict(type='bool'),
import_mode=dict(type='str', choices=['atomic', 'best-effort']),
import_policy=dict(type='str'),
import_type=dict(type='str', choices=['merge', 'replace']),
snapshot=dict(type='str', required=True),
state=dict(type='str', default='rollback', choices=['preview', 'rollback']),
)
module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=False,
required_if=[
['state', 'preview', ['compare_export_policy', 'compare_snapshot']],
['state', 'rollback', ['import_policy']],
],
)
description = module.params['description']
export_policy = module.params['export_policy']
fail_on_decrypt = module.params['fail_on_decrypt']
if fail_on_decrypt is True:
fail_on_decrypt = 'yes'
elif fail_on_decrypt is False:
fail_on_decrypt = 'no'
import_mode = module.params['import_mode']
import_policy = module.params['import_policy']
import_type = module.params['import_type']
snapshot = module.params['snapshot']
state = module.params['state']
aci = ACIModule(module)
if state == 'rollback':
if snapshot.startswith('run-'):
snapshot = snapshot.replace('run-', '', 1)
if not snapshot.endswith('.tar.gz'):
snapshot += '.tar.gz'
filename = 'ce2_{}-{}'.format(export_policy, snapshot)
aci.construct_url(root_class="import_policy")
aci.get_existing()
# Filter out module parameters with null values
aci.payload(
aci_class='configImportP',
class_config=dict(
adminSt='triggered',
descr=description,
failOnDecryptErrors=fail_on_decrypt,
fileName=filename,
importMode=import_mode,
importType=import_type,
name=import_policy,
snapshot='yes',
),
)
# Generate config diff which will be used as POST request body
aci.get_diff(aci_class='configImportP')
# Submit changes if module not in check_mode and the proposed is different than existing
aci.post_config()
elif state == 'preview':
aci.result['url'] = '%(protocol)s://%(hostname)s/mqapi2/snapshots.diff.xml' % module.params
aci.result['filter_string'] = (
'?s1dn=uni/backupst/snapshots-[uni/fabric/configexp-%(export_policy)s]/snapshot-%(snapshot)s&'
's2dn=uni/backupst/snapshots-[uni/fabric/configexp-%(compare_export_policy)s]/snapshot-%(compare_snapshot)s'
) % module.params
# Generate rollback comparison
get_preview(aci)
module.exit_json(**aci.result)