cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1138
Views
5
Helpful
3
Replies

CUCM Control Center Services API - getProductInformationList: Unknown fault occured

Hello,

 

I am trying to run the following python program to obtain product information from CUCM.

The python program errors out with the following message -

 

Zeep error: getProductInformationList: Unknown fault occured

 

However while using postman I can retrieve data.

 

Python code below -

 

 

from lxml import etree
import requests
from requests import Session
from requests.auth import HTTPBasicAuth

from zeep import Client, Settings, Plugin
from zeep.transports import Transport
from zeep.exceptions import Fault

import os
import sys

from dotenv import load_dotenv
load_dotenv()

DEBUG = os.getenv( 'DEBUG' ) == 'True'



WSDL_FILE = 'file://C:/Users/serviceability-python-zeep-samples/schema/ControlCenterServices.wsdl'


class MyLoggingPlugin( Plugin ):

    def egress( self, envelope, http_headers, operation, binding_options ):

        if not DEBUG: return

     
        xml = etree.tostring( envelope, pretty_print = True, encoding = 'unicode')

        print( f'\nRequest\n-------\nHeaders:\n{http_headers}\n\nBody:\n{xml}' )

    def ingress( self, envelope, http_headers, operation ):

        if not DEBUG: return

  
        xml = etree.tostring( envelope, pretty_print = True, encoding = 'unicode')

        print( f'\nResponse\n-------\nHeaders:\n{http_headers}\n\nBody:\n{xml}' )


session = Session()


session.verify = False

requests.packages.urllib3.disable_warnings(requests.packages.urllib3.exceptions.InsecureRequestWarning)


username = 'admin'
password = 'password'
host = '1.1.1.1'

session.auth = HTTPBasicAuth( os.getenv( username ), os.getenv( password ) )

transport = Transport( session = session, timeout = 10 )

settings = Settings( strict = False, xml_huge_tree = True )

plugin = [ MyLoggingPlugin() ] if DEBUG else [ ]

client = Client( WSDL_FILE, settings = settings, transport = transport, plugins = plugin )

service = client.create_service(
    '{http://schemas.cisco.com/ast/soap}ControlCenterServicesBinding',
    f'https://{host}:8443/controlcenterservice2/services/ControlCenterServices' 
    )


try:
	resp = service.getProductInformationList(ServiceInfo='')
except Fault as err:
    print( f'Zeep error: getProductInformationList: {err}' )
    sys.exit( 1 )

print( "\ngetProductInformationList response:\n" )


    

 

 

1 Accepted Solution

Accepted Solutions

After spending another hour on this code figured out a syntactical error. 

View solution in original post

3 Replies 3

After spending another hour on this code figured out a syntactical error. 

what was the mistake?

BjoernMartin
Enthusiast
Enthusiast

Hi!

Do you working with environment variable or do you want to use credentials from the code?
Your code want to use username and password from your
environment variable (os.getenv( username ) , os.getenv( password) ) to create a session authentication.


If you want to use environment variable:

    - create in your python code directory a file .env like this

    username = 'admin'
    password = 'password'
    host = '1.1.1.1'
    DEBUG=True


    - change following line in your code

    service = client.create_service(
    '{http://schemas.cisco.com/ast/soap}ControlCenterServicesBinding',
    'https://{}:8443/controlcenterservice2/services/ControlCenterServices'.format(os.getenv('host'))
    )

    CHECK YOUR ENVIRONMENT VARIABLES
    - Existing entries in your ENVIRONMENT VARIABLES are not overwritten (like USERNAME).
       To check this use a simple print(os.environ) or print(os.getenv( 'username' )).

       To be able to overwrite them change yout to to:

        load_dotnev(override=True)

 

 

If you want to use credentials from your python code:

    username = 'admin'
    password = 'password'
    host = '1.1.1.1'

 

    session.auth = HTTPBasicAuth( username, password )

 

 

Here is another helful link (many thanks to dstaudt):
https://github.com/CiscoDevNet/serviceability-python-zeep-samples

 

If you have any questions, please get in touch

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: