コード例 #1
0
def map_config_to_obj(module):
    output = run_commands(module, ["show banner %s" % module.params["banner"]])
    obj = {"banner": module.params["banner"], "state": "absent"}
    if output:
        if is_local_eapi(module):
            # On EAPI we need to extract the banner text from dict key
            # 'loginBanner'
            if module.params["banner"] == "login":
                banner_response_key = "loginBanner"
            else:
                banner_response_key = "motd"
            if (isinstance(output[0], dict)
                    and banner_response_key in output[0].keys()):
                obj["text"] = output[0]
        else:
            obj["text"] = output[0]
        obj["state"] = "present"
    return obj
コード例 #2
0
def map_config_to_obj(module):
    output = run_commands(module, ['show banner %s' % module.params['banner']])
    obj = {'banner': module.params['banner'], 'state': 'absent'}
    if output:
        if is_local_eapi(module):
            # On EAPI we need to extract the banner text from dict key
            # 'loginBanner'
            if module.params['banner'] == 'login':
                banner_response_key = 'loginBanner'
            else:
                banner_response_key = 'motd'
            if isinstance(output[0],
                          dict) and banner_response_key in output[0].keys():
                obj['text'] = output[0]
        else:
            obj['text'] = output[0]
        obj['state'] = 'present'
    return obj