cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2618
Views
10
Helpful
5
Replies

addPhone via Python 3.6 & Zeep

Evgeny Udaltsov
Level 1
Level 1

Hi Team!

Could you help me, i have tried to create a new phone om my CUCM 11.5. via Python. There is my function:

resp = service.addPhone(phone={"name": 000100020003,
                                     "description": "AXL Test Phone",
                                     "product": "Cisco 8845",
                                     "class": "Phone",
                                     "protocol": "SIP",
                                     "protocolSide": "User",
                                     "callingSearchSpaceName": "CSS_MSK_FullAccess",
                                     "devicePoolName": "DP_MSK",
                                     "lines": {"line": {"index": 1,
                                                        "label": "AXL Test Phone",
                                                        "display": "AXL Test Phone",
                                                        "dirn": {"pattern": 94952374,
                                                                 "routePartitionName": "Pt_Internal"}}},
                                     "commonDeviceConfigName": "None",
                                     "commonPhoneConfigName": "Standard Common Phone Profile",
                                     "locationName": "Hub_None",
                                     "useTrustedRelayPoint": "Default",
                                     "phoneTemplateName": "Standard 8845 SIP",
                                     "primaryPhoneName": "None",
                                     "softkeyTemplateName": "Standard User PickUp",
                                     "securityProfileName": "Cisco 8845 - Standard SIP Non-Secure Profile",
                                     "builtInBridgeStatus": "Default",
                                     "packetCaptureMode" : "None",
                                     "certificateOperation": "No Pending Operation",
                                     "deviceMobilityMode": "Default"})

I know that, the Line should be created before the the Phone, I have already done it with "rest = service.add Line(...)". However when i try to add a new phone, i get a message  
"<axlmessage>Item not valid: The specified None was not found</axlmessage>"

There is my request:

<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
  <soap-env:Body>
    <ns0:addPhone xmlns:ns0="http://www.cisco.com/AXL/API/11.5">
      <phone>
        <name>000100020003</name>
        <description>AXL Test Phone</description>
        <product>Cisco 8845</product>
        <class>Phone</class>
        <protocol>SIP</protocol>
        <protocolSide>User</protocolSide>
        <callingSearchSpaceName>CSS_MSK_FullAccess</callingSearchSpaceName>
        <devicePoolName>DP_MSK</devicePoolName>
        <commonDeviceConfigName>None</commonDeviceConfigName>
        <commonPhoneConfigName>Standard Common Phone Profile</commonPhoneConfigName>
        <locationName>Hub_None</locationName>
        <useTrustedRelayPoint>Default</useTrustedRelayPoint>
        <securityProfileName>Cisco 8845 - Standard SIP Non-Secure Profile</securityProfileName>
        <lines>
          <line>
            <index>1</index>
            <label>AXL Test Phone</label>
            <display>AXL Test Phone</display>
            <dirn>
              <pattern>94952374</pattern>
              <routePartitionName>Pt_Internal</routePartitionName>
            </dirn>
          </line>
        </lines>
        <phoneTemplateName>Standard 8845 SIP</phoneTemplateName>
        <primaryPhoneName>None</primaryPhoneName>
        <softkeyTemplateName>Standard User PickUp</softkeyTemplateName>
        <builtInBridgeStatus>Default</builtInBridgeStatus>
        <packetCaptureMode>None</packetCaptureMode>
        <certificateOperation>No Pending Operation</certificateOperation>
        <deviceMobilityMode>Default</deviceMobilityMode>
      </phone>
    </ns0:addPhone>
  </soap-env:Body>
</soap-env:Envelope>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  <soapenv:Body>
    <soapenv:Fault>
      <faultcode>soapenv:Server</faultcode>
      <faultstring>Item not valid: The specified None was not found</faultstring>
      <detail>
        <axlError>
          <axlcode>5007</axlcode>
          <axlmessage>Item not valid: The specified None was not found</axlmessage>
          <request>addPhone</request>
        </axlError>
      </detail>
    </soapenv:Fault>
  </soapenv:Body>
</soapenv:Envelope>

Process finished with exit code 0

5 Replies 5

theflyingwombat
Level 1
Level 1
Here is an example of what mine looks like, maybe it will help you.  I would say you should triple check your variable names are correct. We store phone numbers in e164 format in CUCM '\+1xxxyyyzzzz'


phone_name = sep_plus_mac product = 'Cisco 8851' common_phone_config = '8851 Standard Common Phone Profile' phone_template = '8851 2 Line 3 BLF/SPD SIP' description = line_description device_CSS = 'dCSS-OKC' device_pool = 'DP-OKC' device_config = 'CDC Default' phone_config = '8851 Standard Common Phone Profile' subscribe_CSS = 'CSS-Internal' security_profile = 'Cisco 8851 - Standard SIP Non-Secure Profile' sip_profile = 'Standard SIP Profile' subscribe_CSS = 'CSS-SubscribeDefault' hookswitch_control = '<ehookEnable>1</ehookEnable>' mobility = 'true' phone_data = {'name': phone_name, 'product': product, 'class': 'Phone', 'protocol': 'SIP', 'protocolSide': 'User', 'devicePoolName': device_pool, 'commonPhoneConfigName': common_phone_config, 'locationName': 'Hub_None', 'useTrustedRelayPoint': 'Default', 'phoneTemplateName': phone_template, 'primaryPhoneName': None, 'builtInBridgeStatus': 'Default', 'packetCaptureMode': 'None', 'certificateOperation': 'No Pending Operation', 'deviceMobilityMode': 'Default', 'subscribeCallingSearchSpaceName': subscribe_CSS, 'securityProfileName': security_profile, 'sipProfileName': sip_profile, 'ownerUserName': user_input, 'description': description, 'vendorConfig': ET.fromstring(hookswitch_control), 'callingSearchSpaceName': device_CSS, 'commonDeviceConfigName': 'CDC Default', 'enableExtensionMobility': 'false', 'networkHoldMohAudioSourceId': '0', 'userHoldMohAudioSourceId': '0', 'lines': {'line': {'index': '1', 'dirn': e164_phone_number, # /+number 'display': user_fullname, 'displayAscii': user_fullname, 'e164Mask': e164_no_slash, # +number 'label': description}}}

theflyingwombat Thank You! I have discovered a tiny mistake in my script, i forgot the SEP prefix:
Here is the working function:

def cucm_server_add_new_phone(mac_address):
    try:
        resp = service.addPhone(phone={"name": "SEP" + mac_address,
                                     "description": "AXL Test Phone",
                                     "product": "Cisco 8845",
                                     "class": "Phone",
                                     "protocol": "SIP",
                                     "protocolSide": "User",
                                     "callingSearchSpaceName": "CSS_XXXX",
                                     "devicePoolName": "DP_MSK",
                                     "lines": {"line": {"index": 1,
                                                        "label": "AXL Test Phone",
                                                        "display": "AXL Test Phone",
                                                        "dirn": {"pattern": XXXX,
                                                                 "routePartitionName": "Pt_XXXX"}}},
                                     "commonPhoneConfigName": "Standard Common Phone Profile",
                                     "locationName": "Hub_None",
                                     "useTrustedRelayPoint": "Default",
                                     "phoneTemplateName": "Standard 8845 SIP",
                                     "primaryPhoneName": None,
                                     "softkeyTemplateName": "Standard User PickUp",
                                     "securityProfileName": "Cisco 8845 - Standard SIP Non-Secure Profile",
                                     "builtInBridgeStatus": "Default",
                                     "packetCaptureMode" : "None",
                                     "certificateOperation": "No Pending Operation",
                                     "deviceMobilityMode": "Default"})
        print("CUCM @ Add A New Phone Function @ -> Success", resp)
    except Fault:
        print("CUCM @ Add A New Phone Function @ -> Failed")
        show_history()

hi

do you use zeep?

i m trying to addphone using zeep but struggle with  'vendorConfig'

what's the ET.fromstring(hookswitch_control)?

thanks

The vendor config isn't needed to add a phone using zeep.  I just used it so we could set "headset hookswitch control" to ON by default.

 

# import this module
import lxml.etree as ET

# vendor config is done differently than the rest of the phone build and uses XML
'vendorConfig': ET.fromstring('<ehookEnable>1</ehookEnable>'),

collinks2
Level 5
Level 5

@Evgeny Udaltsov ,i know this is an old post.I want to achieve something similar.I want to use python to add cisco jabber to cucm.I have a template for cisco jabber. So i will be adding only the device name ,extension no, owner id, Display Name. Users already exist in the cucm. can you provide with the script to connect to cucm via axl and add a new phone using the phone template

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: