Пример #1
0
def get_ucm(user, password, host, version):
    ucm = axl(username=user,
              password=password,
              cucm=host,
              cucm_version=version)

    return ucm
Пример #2
0
def main(argv):
    # Establish a console and UCM object
    console = Console()
    ucm = axl(username=CUCM_USER,
              password=CUCM_PASS,
              cucm=CUCM_HOST,
              cucm_version=CUCM_VER)

    # Get matching translation patterns from UCM
    find_mask = argv[1]
    patterns = ucm.get_translations()
    replace_patterns = [
        pattern for pattern in patterns
        if pattern['calledPartyTransformationMask'] in find_mask
    ]
    console.print(patterns_table(replace_patterns))

    # Stop execution if a replace_mask was not provided
    if (len(argv) < 3):
        exit()
    replace_with = argv[2]

    # Confirm before making change
    print(
        f"The calledPartyTransformationMask of the patterns shown above will be replaced with '{replace_with}'."
    )
    if not confirm_continue():
        print("No changes made.")
        exit()

    # Replace the calledPartyTransformationMask for each pattern, get an updated copy of each pattern to confirm
    replaced_patterns = []
    for pattern in replace_patterns:
        update_mask = ucm.update_translation(
            uuid=pattern['uuid'], calledPartyTransformationMask=replace_with)

        if isinstance(update_mask, Fault):
            raise Exception(update_mask)
        replaced_patterns.append(
            ucm.get_translation(
                uuid=update_mask['return'])['return']['transPattern'])

    console.print(
        f'Updated all calledPartyTransformationMask to {replace_with}')
    console.print(patterns_table(replaced_patterns))
Пример #3
0
import json
import zeep.helpers
import pandas as pd
from pprintjson import pprintjson
#from py_dotenv import read_dotenv

#dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
#read_dotenv(dotenv_path)

cucm = '10.22.192.11'
cucm_username = '******'
cucm_password = '******'
cucm_version = '12.0'

ucm = axl(username=cucm_username,
          password=cucm_password,
          cucm=cucm,
          cucm_version=cucm_version)

cucm_response = ucm.sql_query('select * from enduser')['row']
#JSON Fixup for response
#cucm_response.replace("'", '"')
#cucm_response.replace("None","'None'")
cucm_in_dict = zeep.helpers.serialize_object(cucm_response)
col = []
for x in cucm_in_dict[0]:
    col.append(x.tag)
df = pd.DataFrame(columns=col)

row = []
for obj in cucm_in_dict[1:]:
    row = {}
Пример #4
0
from ciscoaxl import axl
from lxml import etree
cucm = '10.129.225.201'
username = '******'
password = '******'
version = '11.5'
ucm = axl(username=username,
          password=password,
          cucm=cucm,
          cucm_version=version)

# query = {"product": "Cisco Unified Client Services Framework"}
# phones = ucm.get_phones(query=query)
# for phone in phones:
#     print(phone.name)

css = ucm.update_calling_search_space(name="WOB-HQ-CSS",
                                      addMembers=[{
                                          "member": {
                                              "routePartitionName":
                                              "DUBLIN_PT",
                                              "index": "0"
                                          },
                                          "member": {
                                              "routePartitionName": "IPMA-PT",
                                              "index": "1"
                                          }
                                      }])
Пример #5
0
TODO - Enter Webex Teams token:
'''
token = '<your teams token here>'
teams = WebexTeamsAPI(access_token=token)
'''
Cisco CUCM service endpoints: AXL, RIS, CTI, Log Collection
'''
cucm = 'yo-dhzgwgcrwj.dynamic-m.com'
wsdl = 'https://s3-us-west-2.amazonaws.com/devnet2019/schema/12.5/AXLAPI.wsdl'
version = '12.5'
nat = True

axluser, axlpassword = ('administrator', 'D3vn3t2019')
axl = axl(username=axluser,
          password=axlpassword,
          wsdl=wsdl,
          cucm=cucm,
          cucm_version=version)

risuser, rispassword = ('administrator', 'D3vn3t2019')
ris = ris(username=risuser,
          password=rispassword,
          cucm=cucm,
          cucm_version=version)

ctiuser, ctipassword = ('ctiuser', 'D3vn3t2019')

sftpserver, sftpuser, sftppassword = ('yo-dhzgwgcrwj.dynamic-m.com',
                                      'sftpuser', 'devnet')
log = logcollection(username=axluser,
                    password=axlpassword,
Пример #6
0
def main():
    date_time = datetime.now().strftime("%m-%d-%Y_%H.%M.%S")

    # initialize the CLI parser
    parser = GooeyParser(
        description="Cisco Unified Communications Manager Tool")
    cucm_group = parser.add_argument_group(title="cucm connection")
    file_group = parser.add_argument_group(title="output file")
    email_group = parser.add_argument_group(
        title="optional email parameters",
        description="send the output to an email address",
    )

    cucm_group.add_argument(
        "--address",
        "-a",
        action="store",
        dest="cucm_address",
        help="specify cucm address",
        default="ucm1.presidio.cloud",
        required=True,
    )

    cucm_group.add_argument(
        "--version",
        "-v",
        action="store",
        dest="cucm_version",
        choices=["8.5", "10.0", "10.5", "11.0", "11.5", "12.0", "12.5"],
        help="specify cucm AXL version",
        required=False,
        default="11.0",
    )

    cucm_group.add_argument(
        "--username",
        "-u",
        action="store",
        dest="cucm_username",
        help="specify ucm account username with AXL permissions",
        required=True,
        default="Administrator",
    )

    cucm_group.add_argument(
        "--password",
        "-p",
        action="store",
        dest="cucm_password",
        help="specify ucm account password",
        required=True,
        default="Dev@1998",
        widget="PasswordField",
    )

    file_group.add_argument(
        "--out",
        "-o",
        action="store",
        dest="filename",
        help='filename of export file (.csv format) - default="export.csv"',
        required=False,
        default="export.csv",
    )

    file_group.add_argument(
        "--timestamp",
        "-t",
        action="store_true",
        dest="timestamp",
        help="append filename with timestamp",
    )

    cucm_group.add_argument(
        "--export",
        "-e",
        action="store",
        dest="cucm_export",
        choices=[
            "users", "phones", "translations", "sip-trunks",
            "registered-phones"
        ],
        help="specify what you want to export",
        required=False,
        default="users",
    )

    email_group.add_argument(
        "--smtpserver",
        "-s",
        action="store",
        dest="smtpserver",
        required=False,
        help="smtp server name or ip address",
    )

    email_group.add_argument(
        "--mailto",
        "-m",
        action="store",
        dest="mailto",
        required=False,
        help="send output to mail recipient",
    )

    # update variables from cli arguments
    cli_args = parser.parse_args()
    filename = cli_args.filename
    # print(cli_args)

    # store the UCM details
    cucm_address = cli_args.cucm_address
    cucm_username = cli_args.cucm_username
    cucm_password = cli_args.cucm_password
    cucm_version = cli_args.cucm_version

    # initialize Cisco AXL connection
    ucm_axl = axl(
        username=cucm_username,
        password=cucm_password,
        cucm=cucm_address,
        cucm_version=cucm_version,
    )
    # TODO: Add RIS connection as separate credentials
    # ucm_ris = ris(
    #     username=cucm_username,
    #     password=cucm_password,
    #     cucm=cucm_address,
    #     cucm_version=cucm_version,
    # )

    if cli_args.cucm_export == "users":
        output = cucm.export_users(ucm_axl)
        if len(output) > 0:
            saved_file = write_csv(filename=filename,
                                   cli_args=cli_args,
                                   content=output)
        else:
            print(f"status: no {cli_args.cucm_export} found...")
        print(f"status: elapsed time -- {datetime.now() - start_time}\n")
    elif cli_args.cucm_export == "phones":
        output = cucm.export_phones(ucm_axl)
        if len(output) > 0:
            saved_file = write_csv(filename=filename,
                                   cli_args=cli_args,
                                   content=output)
        else:
            print(f"status: no {cli_args.cucm_export} found...")
        print(f"status: elapsed time -- {datetime.now() - start_time}\n")
    elif cli_args.cucm_export == "translations":
        output = cucm.export_translations(ucm_axl)
        if len(output) > 0:
            saved_file = write_csv(filename=filename,
                                   cli_args=cli_args,
                                   content=output)
        else:
            print(f"status: no {cli_args.cucm_export} found...")
        print(f"status: elapsed time -- {datetime.now() - start_time}\n")
    elif cli_args.cucm_export == "sip-trunks":
        output = cucm.export_siptrunks(ucm_axl)
        if len(output) > 0:
            saved_file = write_csv(filename=filename,
                                   cli_args=cli_args,
                                   content=output)
        else:
            print(f"status: no {cli_args.cucm_export} found...")
        print(f"status: elapsed time -- {datetime.now() - start_time}\n")
    else:
        print(f"exporting {cli_args.cucm_export} is not yet supported")
        return

    # send email if selected
    if cli_args.mailto and cli_args.smtpserver:
        response = send_email(
            smtp_server=cli_args.smtpserver,
            send_to_email=cli_args.mailto,
            fileToSend=saved_file,
        )
        print(
            f"status: mail sent to {cli_args.mailto} via {cli_args.smtpserver} at {date_time} - {saved_file}"
        )
    elif cli_args.mailto and not cli_args.smtpserver:
        print(f"status: mail unable to send.  no smtp server was defined")
    elif cli_args.smtpserver and not cli_args.mailto:
        print(f"status: mail unable to send.  no mailto address was defined")
            return self.client.updateRoutePattern(**args)
        except Fault as e:
            return e


if __name__ == '__main__':
    # change to user, password, cucm, and ver of choosing.
    print('\n')
    print('WELCOME TO THE ROUTE LIST FLIPPER APPLICATION', '\n')
    userid = input('Enter your CUCM username: '******'Enter Pub IP address: ')
    version = input('Enter CUCM version (11.5 or 12.5): ')
    print('Please wait...')
    while True:
        client = axl(userid, pwd, cucm, version)
        # add as many RPs to the list below as needed.  example: patterns = ['800%', '877%', '888%', '855%']
        patterns = [
            '800%', '833%', '844%', '855%', '866%', '877%', '888%', '81339%'
        ]
        # get a list of UUIDs for patterns
        rps = client.get_route_pattern(patterns=patterns)
        for rp in rps:
            print(
                f"{rp.pattern} - {rp.routePartitionName._value_1} - {rp.uuid}")
        # once UUID is identified, you can use func to change RL as desired, UUIDs don't change so this can be hard coded
        # if same RP will be flipped/changed to different RLs.
        uuid = input(
            'Please Enter the uuid of the RP you would like to update: ')
        print('\nPlease select from the available Route Lists: ')
        rls = client.get_route_lists()
Пример #8
0
""" Using CiscoAXL SDK to retrieve phone info """
from ciscoaxl import axl

URL = "10.1.50.1"
USER = "******"
PASSWORD = "******"
VERSION = "12.0"

# initiate an object from the axl Class
myUCM = axl(username=USER, password=PASSWORD, cucm=URL, cucm_version=VERSION)
print(myUCM)

# use method get_phones
for phone in myUCM.get_phones():
    print(phone.name)  # attribute "name"

# use method get_users
for user in myUCM.get_users():
    print(user.firstName)  # attribute "firstName"