Beispiel #1
0
def get_interfaces(host: dict) -> str:
    response = restconf_helpers.RestconfRequestHelper().get(
        url=
        f'https://{host["connection_address"]}/restconf/data/Cisco-IOS-XE-native:native/interface/',
        username=host['username'],
        password=host['password'])
    return response
Beispiel #2
0
def put_configuration(host: dict, config: str) -> str:
    response = restconf_helpers.RestconfRequestHelper().put(
        url=
        f'https://{host["connection_address"]}/restconf/data/Cisco-IOS-XE-native:native/',
        username=host['username'],
        password=host['password'],
        config=config)
    return response
def patch_configuration(host: dict, retries = 0) -> int:
    rendering_data = rendering.RenderJinjaTemplate().rendering(host)
    rendered_xml_data = rendering.XmlParser().parseXml(rendering_data)

    response_code = restconf_helpers.RestconfRequestHelper().patch(
        url=f'https://{host["connection_address"]}/restconf/data/Cisco-IOS-XE-native:native/',
        username=host['username'],
        password=host['password'],
        data=rendered_xml_data)
    if(ERROR_CODE_409 == response_code and retries <= MAX_RETRIES):
        patch_configuration(host, retries+1)
    elif(retries > MAX_RETRIES):
        logger.error('409 Conflict status-line. The error-tag value object already exists is returned if used for other methods or resource types.\n 409 Client Error: Conflict')
    return response_code