Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure to updates Lines on a Phone #38

Open
multcode opened this issue Jul 13, 2022 · 0 comments
Open

Failure to updates Lines on a Phone #38

multcode opened this issue Jul 13, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@multcode
Copy link

CUCM version 11.51.15900-18

Have a script that queries information about a phone and its lines, and then attempts to update a Line on that Phone. I feel pretty certain I have the syntax of the update correct, but I am getting the error "TypeError: Choice elements only work with keyword arguments"

Here is the code where I am trying to update the line:

phone_change=ucm.update_phone(
        name=device_name,
        lines=[
            ('70359', 'Internal', 'John Doe', 'John Doe', 'John Doe 70359', '50398XXXXX')
        ]
)

Here is the resulting error:

Traceback (most recent call last):
File "/usr/local/bin/uc_dev_phone_update_mask.py", line 70, in
('70359', 'Internal', 'Rick Atlansky', 'Rick Atlansky', 'Rick Atlansky 70359', '0294127777')
File "/usr/local/lib/python3.6/dist-packages/ciscoaxl/axl.py", line 2084, in update_phone
return self.client.updatePhone(**args)
File "/usr/local/lib/python3.6/dist-packages/zeep/proxy.py", line 45, in call
kwargs,
File "/usr/local/lib/python3.6/dist-packages/zeep/wsdl/bindings/soap.py", line 119, in send
operation, args, kwargs, client=client, options=options
File "/usr/local/lib/python3.6/dist-packages/zeep/wsdl/bindings/soap.py", line 68, in _create
serialized = operation_obj.create(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/wsdl/definitions.py", line 215, in create
return self.input.serialize(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/wsdl/messages/soap.py", line 68, in serialize
body_value = self.body(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/element.py", line 57, in call
instance = self.type(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/types/complex.py", line 49, in call
return self._value_class(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/valueobjects.py", line 95, in init
items = _process_signature(self._xsd_type, args, kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/valueobjects.py", line 209, in _process_signature
values = element.parse_kwargs(kwargs, None, available_kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 205, in parse_kwargs
sub_result = element.parse_kwargs(kwargs, elm_name, available_kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 457, in parse_kwargs
subresult = choice.parse_kwargs(kwargs, name, temp_kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/element.py", line 134, in parse_kwargs
return self.type.parse_kwargs(kwargs, name or self.attr_name, available_kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/types/complex.py", line 309, in parse_kwargs
value = self._create_object(value, name)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/types/complex.py", line 325, in _create_object
return [self._create_object(val, name) for val in value]
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/types/complex.py", line 325, in
return [self._create_object(val, name) for val in value]
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/types/complex.py", line 335, in _create_object
return self(value)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/types/complex.py", line 49, in call
return self._value_class(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/valueobjects.py", line 95, in init
items = _process_signature(self._xsd_type, args, kwargs)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/valueobjects.py", line 185, in _process_signature
values, args, index = element.parse_args(args, index)
File "/usr/local/lib/python3.6/dist-packages/zeep/xsd/elements/indicators.py", line 321, in parse_args
raise TypeError("Choice elements only work with keyword arguments")
TypeError: Choice elements only work with keyword arguments

Here is the entire script:

#!/usr/bin/python3
'''
Usage: uc_dev_phone_update_line.py [phone name]
'''


import sys
from ciscoaxl import axl

cucm_fqdn = 'REDACTED'
cucm_username = 'ucmaxl'
cucm_password = "REDACTED"
version = '11.5'
ucm = axl(username=cucm_username,password=cucm_password,cucm=cucm_fqdn,cucm_version=version)

device_name = sys.argv[1]

phone = ucm.get_phone(name=device_name)
line_line = '\nLine : Caller ID Number : Caller ID Name\n'
line_dict = {}
response = {}
response_text = ""

try:
    response['Description'] = str(phone.description)
except:
    print("Problem getting phone.")
    quit()

response['CSS'] = str(phone.callingSearchSpaceName._value_1)
response['DevicePool'] = str(phone.devicePoolName._value_1)
response['Common Device Config'] = str(phone.commonDeviceConfigName._value_1)
response['SIP Profile'] = str(phone.sipProfileName._value_1)
response['Phone Template'] = str(phone.phoneTemplateName._value_1)
response['Owner'] = str(phone.ownerUserName._value_1)
response['Presence Group'] = str(phone.presenceGroupName._value_1)
response['Cert Operation'] = str(phone.certificateOperation)
response['Do Not Disturb active'] = str(phone.dndStatus)
for line in phone.lines.line:
    dn=line['dirn']['pattern']
    callerid=line['display']
    calleridno=line['e164Mask']
    line_dict[dn] = callerid
    line_dict[dn] = calleridno
    line_line = str(line_line) + str(dn) + " : " + str(calleridno) +  " : " + str(callerid) + '\n'
    dn=''
    callerid=''
    calleridno=''
response['Lines'] = line_line

'''
Create a nicely formatted output from the dict we've built
'''

for dict_item_name, dict_item_value in response.items():
    response_text = response_text +  dict_item_name + ": " + dict_item_value + "\n"

print(response_text)

print("-------")

phone_change=ucm.update_phone(
        name=device_name,
        lines=[
            ('70359', 'Internal', 'John Doe', 'John Doe', 'John Doe 70359', '50398XXXXX')
        ]
)

print(phone_change)
@rlad78 rlad78 self-assigned this Jul 13, 2022
@rlad78 rlad78 added the bug Something isn't working label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants