cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
590
Views
0
Helpful
5
Replies

Python script to add profile rule to 3PCC phone.

NetworkCorner
Level 1
Level 1

Hi Team, 

I have a script to add profile rules to the web GUI of a Cisco cp-7841-3pcc Phone which has been converted from Entreprise to MPP. In the last step of the process, we need to add a profile rule for the new provider. As we have a bulk global rollout. I have written a script to do it. The script fails to find the input field in the script and I have no idea why. I spoke with a programmer and he says it's because the Cisco web GUI is a DOM. "Makes no sense to me"  I have attached the script all help is welcome. All help is welcome. Thanks in advance.

 

 

 

#!/usr/bin/python3

import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

# Set up Chrome options
chrome_options = Options()
chrome_options.add_argument("--headless")  # Run Chrome in headless mode

# Add directory containing chromedriver to PATH
chromedriver_directory = "/home/linux_work"
os.environ["PATH"] += os.pathsep + chromedriver_directory

# Initialize Chrome WebDriver
driver = webdriver.Chrome(options=chrome_options)

# Navigate to the Cisco IP phone GUI advanced admin page
driver.get("http://10.160.61.141/admin/advanced")  # URL of Cisco phone

# Wait for the input field with ID "385" to be present
wait = WebDriverWait(driver, 10)
input_element = wait.until(EC.presence_of_element_located((By.ID, "385")))

# Clear the existing value (gds://)
input_element.clear()

# Insert the profile rule
profile_rule_value = "https://cisco.mangos.com/cisco/$MA.cfg"
input_element.send_keys(profile_rule_value)

# Find the input field for the Upgrade Rule and clear the existing value
input_element = driver.find_element(By.ID, "408")
input_element.clear()

# Insert the Upgrade Rule
upgrade_rule_value = "https://cisco.mangos.com/cisco/78xx-11.3.1MSR1-3/sip78xx.11-3-1MSR1-3.loads"
input_element.send_keys(upgrade_rule_value)

# Find the submit button by its ID attribute
submit_button = driver.find_element(By.ID, "submitButton_label")

# Click the submit button
submit_button.click()

# Close the web driver
driver.quit()

 

 

 

 

2 Accepted Solutions

Accepted Solutions

Geovani
Cisco Employee
Cisco Employee

Hi there, 
The only way you'll be able to change the profile rule or upgrade rule via script, is if you use action URL. Something like this: 
http://{ip_address.strip()}/admin/advanced/resync?{file}'
http://{ip_address.strip()}/admin/advanced/upgrade?{file}'

There is only so much you can do using these actions URL. Upgrade, resync (against a profile rule), reboot, factory reset etc.. 
This is assuming that there is no admin password set on the phone. 
OR, you could use DHCP options or CDA/EDOS

View solution in original post

You might be able to.. but its beyond my knowledge at this point. If all you're trying to do is to push a bulk profile rule, why not use action url? you can get the script to read form a list of IP or subnet and push it. 

View solution in original post

5 Replies 5

Geovani
Cisco Employee
Cisco Employee

Hi there, 
The only way you'll be able to change the profile rule or upgrade rule via script, is if you use action URL. Something like this: 
http://{ip_address.strip()}/admin/advanced/resync?{file}'
http://{ip_address.strip()}/admin/advanced/upgrade?{file}'

There is only so much you can do using these actions URL. Upgrade, resync (against a profile rule), reboot, factory reset etc.. 
This is assuming that there is no admin password set on the phone. 
OR, you could use DHCP options or CDA/EDOS

Cant i mimic someone who is trying to do it manually via gui with automation

 

You might be able to.. but its beyond my knowledge at this point. If all you're trying to do is to push a bulk profile rule, why not use action url? you can get the script to read form a list of IP or subnet and push it. 

I was doing it the hardway. your simple solution worked. thanks.

Glad it’s working for you but I really suggest asking your provider about CDA/EDOS so you aren’t required to do this every time a phone is factory reset. They can claim the MAC address so the phone is automatically pointed toward their platform to fetch provisioning/config details. Far more scalable/supportable IMO. Other IP Phone OEMs have equivalent functionality so you shouldn’t get a blank stare if they know what they’re doing.