Пример #1
0
 def button_testaxl_callback():
     info = connectAXL()
     location = info.get('location')
     username = info.get('username')
     password = info.get('password')
     wsdl = info.get('wsdl')
     t = HttpAuthenticated(username=username, password=password)
     t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)
     ssl_def_context = ssl.create_default_context()
     ssl_def_context.check_hostname = False
     ssl_def_context.verify_mode = ssl.CERT_NONE
     ssl_def_context.set_ciphers('HIGH:!DH:!aNULL')
     t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
     t.urlopener = urllib.request.build_opener(t.handler, t1)
     try:
         client = Client(wsdl,
                         location=location,
                         plugins=[ImportDoctor(imp)],
                         transport=t)
         resp = client.service.getCCMVersion()
         version = resp['return'].componentVersion.version
         logger.info('Successfully tested to Call Manager : ' + version)
     except Exception as e:
         logger.error('Failed to connect to ' + location)
         logger.critical(e)
Пример #2
0
 def axlSQL():
     #get AXL information from GUI
     info = connectAXL()
     location = info.get('location')
     username = info.get('username')
     password = info.get('password')
     wsdl = info.get('wsdl')
     t = HttpAuthenticated(username=username, password=password)
     t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)
     ssl_def_context = ssl.create_default_context()
     ssl_def_context.check_hostname = False
     ssl_def_context.verify_mode = ssl.CERT_NONE
     ssl_def_context.set_ciphers('HIGH:!DH:!aNULL')
     t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
     t.urlopener = urllib.request.build_opener(t.handler, t1)
     try:
         client = Client(wsdl,
                         location=location,
                         plugins=[ImportDoctor(imp)],
                         transport=t)
         try:
             result = client.service.executeSQLQuery(
                 "select ProcessNode.name as ProcessNode, ProcessConfig.paramname,ProcessConfig.paramvalue as ProcessConfig from processconfig,processnode where ProcessConfig.fkprocessnode = ProcessNode.pkid"
             )
             car.clearTable()
             for node in result['return']['row']:
                 car.LoadTable(str(node['processnode']),
                               str(node['paramname']),
                               str(node['processconfig']), '')
         except Exception as e:
             logger.critical(e)
     except Exception as e:
         logger.critical(e)
Пример #3
0
 def axlinsertSQL(server, name, newval):
     #get AXL information from GUI
     info = connectAXL()
     location = info.get('location')
     username = info.get('username')
     password = info.get('password')
     wsdl = info.get('wsdl')
     t = HttpAuthenticated(username=username, password=password)
     t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)
     ssl_def_context = ssl.create_default_context()
     ssl_def_context.check_hostname = False
     ssl_def_context.verify_mode = ssl.CERT_NONE
     ssl_def_context.set_ciphers('HIGH:!DH:!aNULL')
     t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
     t.urlopener = urllib.request.build_opener(t.handler, t1)
     try:
         client = Client(wsdl,
                         location=location,
                         plugins=[ImportDoctor(imp)],
                         transport=t)
         try:
             sqlStr = "insert into processconfig(paramvalue,paramname,tkservice,tkparam,fkprocessnode) values ('" + newval + "','" + name + "','0','2',(select ProcessNode.pkid from Processnode where ProcessNode.name='" + server + "'))"
             result = client.service.executeSQLUpdate(sqlStr)
             logger.info("Successfully inserted " + name + " to '" +
                         newval + "' on " + server)
         except Exception as e:
             logger.critical(e)
     except Exception as e:
         logger.critical(e)
Пример #4
0
    def __init__(self, username, password, wsdl, cucm, cucm_version=10):
        """
        :param username: axl username
        :param password: axl password
        :param wsdl: wsdl file location
        :param cucm: UCM IP address
        :param cucm_version: UCM version
        """
        self.username = username
        self.password = password
        self.wsdl = wsdl
        self.cucm = cucm
        self.cucm_version = cucm_version

        tns = 'http://schemas.cisco.com/ast/soap/'
        imp = Import('http://schemas.xmlsoap.org/soap/encoding/',
                     'http://schemas.xmlsoap.org/soap/encoding/')
        imp.filter.add(tns)

        t = HttpAuthenticated(username=self.username, password=self.password)
        t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)

        ssl_def_context = ssl.create_default_context()
        ssl_def_context.check_hostname = False
        ssl_def_context.verify_mode = ssl.CERT_NONE

        t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
        t.urlopener = urllib.request.build_opener(t.handler, t1)

        self.client = Client(self.wsdl,
                             location='https://{0}:8443/axl/'.format(cucm),
                             faults=False,
                             plugins=[ImportDoctor(imp)],
                             transport=t)
Пример #5
0
    def __init__(self, username, password, cucm, cucm_version):
        """
        :param username: ris username
        :param password: ris password
        :param cucm: UCM IP address
        :param cucm_version: UCM version

        example usage:
        >>> from ris import RIS
        >>> ucm = RIS('ris_user', 'ris_pass', '192.168.200.10', '11.5')
        """
        self.username = username
        self.password = password
        self.wsdl = 'https://'+cucm+':8443//realtimeservice2/services/RISService70?wsdl'
        self.cucm = cucm
        self.cucm_version = cucm_version


        tns = 'http://schemas.cisco.com/ast/soap/'
        imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/')
        imp.filter.add(tns)

        t = HttpAuthenticated(username=self.username, password=self.password)
        t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)
        
        ssl_def_context = ssl.create_default_context()
        ssl_def_context.check_hostname = False
        ssl_def_context.verify_mode = ssl.CERT_NONE

        t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
        t.urlopener = urllib.request.build_opener(t.handler, t1)

        self.client = Client(self.wsdl, location='https://{0}:8443/realtimeservice2/services/RISService70'.format(cucm), faults=False,
                             plugins=[ImportDoctor(imp)],
                             transport=t)
Пример #6
0
    def __init__(
            self,
            host=cfg.cucm_host,
            username=cfg.cucm_user,
            password=cfg.cucm_pass,
            timeout=30):

        self.host = host
        self.username = username
        self.password = password
        self.timeout = timeout
        wsdl = 'https://' + host + \
            ':8443/logcollectionservice2/services/LogCollectionPortTypeService?wsdl'
        location = 'https://' + host + \
            ':8443/logcollectionservice2/services/LogCollectionPortTypeService'

        t = HttpAuthenticated(username=self.username,
                              password=self.password, timeout=timeout)
        t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)

        ssl_def_context = ssl.create_default_context()
        ssl_def_context.check_hostname = False
        ssl_def_context.verify_mode = ssl.CERT_NONE

        t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
        t.urlopener = urllib.request.build_opener(t.handler, t1)

        self.client = Client(
            wsdl,
            location=location,
            username=username,
            password=password,
            cache=None,
            transport=t
        )
Пример #7
0
    def __init__(self, con_opts):
        wsdl_url = 'file://%s/PeakflowSP.wsdl' % os.path.dirname(__file__)
        soap_url = 'https://%s/soap/sp' % con_opts.host

        # SOAP shit
        t = HttpAuthenticated(username=con_opts.username, password=con_opts.password)
        t.handler = urllib2.HTTPDigestAuthHandler(t.pm)
        t.urlopener = urllib2.build_opener(t.handler)
        self.client = Client(url = wsdl_url, location = soap_url, transport = t)

        self._timeout = 10
Пример #8
0
    def __init__(self, con_opts):
        wsdl_url = 'file://%s/PeakflowSP.wsdl' % os.path.dirname(__file__)
        soap_url = 'https://%s/soap/sp' % con_opts.host

        # SOAP shit
        t = HttpAuthenticated(username=con_opts.username,
                              password=con_opts.password)
        t.handler = urllib2.HTTPDigestAuthHandler(t.pm)
        t.urlopener = urllib2.build_opener(t.handler)
        self.client = Client(url=wsdl_url, location=soap_url, transport=t)

        self._timeout = 10
Пример #9
0
def get_service():
    global url
    global username
    global password

    wsdl_url = 'file://%s/PeakflowSP.wsdl' % os.getcwd()

    t = HttpAuthenticated(username=username, password=password)
    t.handler = urllib2.HTTPDigestAuthHandler(t.pm)
    t.urlopener = urllib2.build_opener(t.handler)

    client = Client(url=wsdl_url, location=url, transport=t)
    return client
def get_device_ip(phone_name):

    #Disable HTTPS certificate validation check - not recommended for production
    if hasattr(ssl, '_create_unverified_context'):
        ssl._create_default_https_context = ssl._create_unverified_context

    url = 'https://' + user_env.CUCM_LOCATION + ':8443/realtimeservice/services/RisPort?wsdl'
    print(url)

    tns = 'http://schemas.cisco.com/ast/soap/'
    imp = Import('http://schemas.xmlsoap.org/soap/encoding/',
                 'http://schemas.xmlsoap.org/soap/encoding/')
    imp.filter.add(tns)

    t = HttpAuthenticated(username=user_env.CUCM_USER,
                          password=user_env.CUCM_PASSWORD)
    t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)

    context = ssl.SSLContext()

    t1 = urllib.request.HTTPSHandler(context=context)
    t.urlopener = urllib.request.build_opener(t.handler, t1)

    c = Client(url, plugins=[ImportDoctor(imp)], transport=t)

    result = c.service.SelectCmDevice('', {
        'SelectBy': 'Name',
        'Status': 'Any',
        'Class': 'Phone'
    })

    total_phones = result['SelectCmDeviceResult']['TotalDevicesFound']
    list_phones = result['SelectCmDeviceResult']["CmNodes"]
    print('number of devices found', total_phones)

    for node in result['SelectCmDeviceResult']['CmNodes']:
        for device in node['CmDevices']:
            if device["IpAddress"] is None:
                print("IP address not assigned for", device["Name"])
                print("----------------")
                continue
            else:
                print("Name ", device["Name"], "IP Address: ",
                      device["IpAddress"])
                print("----------------")
                continue
Пример #11
0
    def __init__(
        self,
        host=cfg.cucm_host,
        username=cfg.cucm_user,
        password=cfg.cucm_pass,
        cucm_version=cfg.cucm_version,
        timeout=10,
        wsdl="file://" +
            os.path.abspath(
                "axl_wsdl/{0}/AXLAPI.wsdl".format(cfg.cucm_version)),
    ):

        self.username = username
        self.password = password
        self.wsdl = wsdl
        self.host = host
        self.timeout = timeout

        t = HttpAuthenticated(username=self.username,
                              password=self.password, timeout=timeout)
        t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)

        ses = urllib.request.HTTPCookieProcessor()

        ssl_def_context = ssl.create_default_context()
        ssl_def_context.check_hostname = False
        ssl_def_context.verify_mode = ssl.CERT_NONE

        t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
        t.urlopener = urllib.request.build_opener(t.handler, t1, ses)

        tns = 'http://schemas.cisco.com/ast/soap/'
        imp = Import('http://schemas.xmlsoap.org/soap/encoding/',
                     'http://schemas.xmlsoap.org/soap/encoding/')
        imp.filter.add(tns)

        self.client = Client(
            self.wsdl,
            location='https://{0}:8443/axl/'.format(host),
            faults=False,
            plugins=[ImportDoctor(imp)],
            transport=t
        )

        self.service = self.client.service
Пример #12
0
    def __init__(
            self,
            host=cfg.cucm_host,
            username=cfg.cucm_user,
            password=cfg.cucm_pass,
            timeout=30):

        self.host = host
        self.username = username
        self.password = password
        wsdl = 'https://' + host + \
            ':8443/controlcenterservice2/services/ControlCenterServices?wsdl'
        location = 'https://' + host + \
            ':8443/controlcenterservice2/services/ControlCenterServices'
        TNS = 'http://schemas.cisco.com/ast/soap'
        IMP = Import('http://schemas.xmlsoap.org/soap/encoding/')
        IMP.filter.add(TNS)

        t = HttpAuthenticated(username=self.username,
                              password=self.password, timeout=timeout)
        t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)

        ssl_def_context = ssl.create_default_context()
        ssl_def_context.check_hostname = False
        ssl_def_context.verify_mode = ssl.CERT_NONE

        t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
        t.urlopener = urllib.request.build_opener(t.handler, t1)

        class SetPrefix(MessagePlugin):

            def marshalled(self,
                           context):
                context.envelope[1][0][0].setPrefix('soap')

        self.client = Client(
            wsdl,
            location=location,
            username=username,
            password=password,
            cache=None,
            timeout=timeout,
            plugins=[ImportDoctor(IMP), SetPrefix()],
            transport=t
        )
Пример #13
0
    def __init__(self, username, password, wsdl, cucm, cucm_version):
        """
        :param username: axl username
        :param password: axl password
        :param wsdl: wsdl file location
        :param cucm: UCM IP address
        :param cucm_version: UCM version

        example usage:
        >>> from axl.foley import AXL
        >>> wsdl = 'file:///path/to/wsdl/axlsqltoolkit/schema/10.5/AXLAPI.wsdl'
        >>> ucm = AXL('axl_user', 'axl_pass' wsdl, '192.168.200.10')
        """
        self.username = username
        self.password = password
        self.wsdl = wsdl
        self.cucm = cucm
        self.cucm_version = cucm_version

        tns = 'http://schemas.cisco.com/ast/soap/'
        imp = Import('http://schemas.xmlsoap.org/soap/encoding/',
                     'http://schemas.xmlsoap.org/soap/encoding/')
        imp.filter.add(tns)

        t = HttpAuthenticated(username=self.username, password=self.password)
        t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)

        ssl_def_context = ssl.create_default_context()
        ssl_def_context.check_hostname = False
        ssl_def_context.verify_mode = ssl.CERT_NONE
        if float(cucm_version) <= 8.5:
            ssl_def_context.set_ciphers('HIGH:!DH:!aNULL')

        t1 = urllib.request.HTTPSHandler(context=ssl_def_context)
        t.urlopener = urllib.request.build_opener(t.handler, t1)

        self.client = Client(self.wsdl,
                             location='https://{0}:8443/axl/'.format(cucm),
                             faults=False,
                             plugins=[ImportDoctor(imp)],
                             transport=t)
def risport_request():
    phone_list = []

    #Disable HTTPS certificate validation check - not recommended for production
    if hasattr(ssl, '_create_unverified_context'):
        ssl._create_default_https_context = ssl._create_unverified_context

    url = 'https://' + user_env.CUCM_LOCATION + ':8443/realtimeservice/services/RisPort?wsdl'

    tns = 'http://schemas.cisco.com/ast/soap/'
    imp = Import('http://schemas.xmlsoap.org/soap/encoding/',
                 'http://schemas.xmlsoap.org/soap/encoding/')
    imp.filter.add(tns)

    t = HttpAuthenticated(username=user_env.CUCM_USER,
                          password=user_env.CUCM_PASSWORD)
    t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)

    context = ssl.SSLContext()

    t1 = urllib.request.HTTPSHandler(context=context)
    t.urlopener = urllib.request.build_opener(t.handler, t1)

    c = Client(url, plugins=[ImportDoctor(imp)], transport=t)

    result = c.service.SelectCmDevice('', {
        'SelectBy': 'Name',
        'Status': 'Any',
        'Class': 'Phone'
    })

    total_phones = result['SelectCmDeviceResult']['TotalDevicesFound']

    list_phones = result['SelectCmDeviceResult']["CmNodes"]

    for node in result['SelectCmDeviceResult']['CmNodes']:
        for device in node['CmDevices']:
            phone_list.append(device)

    return phone_list
Пример #15
0
tns = 'http://schemas.cisco.com/ast/soap/'
imp = Import('http://schemas.xmlsoap.org/soap/encoding/',
             'http://schemas.xmlsoap.org/soap/encoding/')
imp.filter.add(tns)

t = HttpAuthenticated(username=user, password=pwd)
t.handler = urllib.request.HTTPBasicAuthHandler(t.pm)

context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_REQUIRED
context.load_verify_locations(cafile="mycertfile.pem")

t1 = urllib.request.HTTPSHandler(context=context)
t.urlopener = urllib.request.build_opener(t.handler, t1)

c = Client(url, plugins=[ImportDoctor(imp)], transport=t)

result = c.service.SelectCmDevice('', {
    'SelectBy': 'Name',
    'Status': 'Any',
    'Class': 'Any'
})

print('type result: ', type(result))
print(result)

print('number of devices found',
      result['SelectCmDeviceResult']['TotalDevicesFound'])