DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

information about the phone. It uses the AXLAPI.wsdl
file downloaded with the AXL Toolkit.


Example 10-24 Full Client Code to Update and Get
Back Device Details


Click here to view code image


""" Update and Retrieve Client Details """
from zeep import Client
from zeep.cache import SqliteCache
from zeep.transports import Transport
from requests import Session
from requests.auth import HTTPBasicAuth
import urllib3
from urllib3.exceptions import
InsecureRequestWarning
urllib3.disable_warnings(InsecureRequestWarning)

USERNAME = 'administrator'
PASSWORD = 'ciscopsdt'
IP_ADDRESS = "10.10.20.1"
WSDL = 'schema//12.0//AXLAPI.wsdl'
BINDING_NAME = "
{http://www.cisco.com/AXLAPIService/}AXLAPIBinding"
ADDRESS =
"https://{ip}:8443/axl/".format(ip=IP_ADDRESS)
def update_phone_by_name(client, name,
description):
""" Update Phone by Name """
return client.updatePhone(**{'name': name,
'description': description})
def get_phone_by_name(client, name):
""" Get Phone by Name """
return client.getPhone(name=name)
def main():
""" Main """
session = Session()
session.verify = False
session.auth = HTTPBasicAuth(USERNAME,
PASSWORD)
transport = Transport(cache=SqliteCache(),
session=session, timeout=60)
client = Client(wsdl=WSDL,
transport=transport)
axl = client.create_service(BINDING_NAME,
Free download pdf