当前位置: 首页>>代码示例>>Python>>正文


Python ACIModule.result['filter_string']方法代码示例

本文整理汇总了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)
开发者ID:jedelman8,项目名称:aci-ansible,代码行数:85,代码来源:aci_config_rollback.py


注:本文中的ansible.module_utils.aci.ACIModule.result['filter_string']方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。