Example #1
0
    def getconfig_crossconnects(self, **kwargs):
        
        """create the oxc b/w given ingress and egress ports and create the xml for
        cross-connects tag for get-config operation, get the xml output from this, then parsed this xml
        , from parsed xml get the ingress and egress port list, then compare this ports
        with given ports.Fially save the output in final.csv file
        Arguments:
        file_name             : any file name
        ingressPort list      : valid ingress port list
        egressPort list       : valid egress port list
        """
        
        self.create_box('getconfig_crossconnects')
        s = time.time()
        LOG.info('-----[ create oxc conection ]-----\n')
        self.edit_config_create_oxc_without_opr(kwargs['ingress_ports'], kwargs['egress_ports'])
        
        LOG.info('-----[ create xml for get-config operation ]-----\n')
	
    	crossconnects = Element('opsw:cross-connects', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",

    	                                                    'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})

    	xmlstr = tostring(crossconnects)
        xmlout = self.getconfig_rpc_request(xmlstr, kwargs['file_name'])
        result = self.compare_list(xmlout)
        e = time.time()
        d = int(round((e - s)* 1000))
        csvOutput('cross-connects', 'getconfig_crossconnects', d, result)
Example #2
0
 def getconfig_egress(self, **kwargs):   
     
     """create the oxc b/w given ingress and egress ports and create the xml for
     egress port tag for get-config operation, get the xml output from this, then parsed this xml
     , from parsed xml get the ingress and egress port list, then compare this ports
     with given ports.Finally save the output in final.csv file
     Arguments:
     file_name             : any file name
     ingressPort list      : valid ingress port list
     egressPort list       : valid egress port list
     """
 
     self.create_box('test_getconfig_egress')
     s = time.time()
     
     LOG.info('-----[ create xml for get-config operation ]-----\n')
 	crossconnects = Element('opsw:cross-connects', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",
 	                                                'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})
 	pairs = SubElement(crossconnects, 'opsw:pairs')
 	egress = SubElement(pairs, 'opsw:egress')
 	xmlstr = tostring(crossconnects)
     xmlout = self.getconfig_rpc_request(xmlstr, kwargs['file_name'])
     result = self.compare_list(xmlout)
     e = time.time()
     d = int(round((e - s)* 1000))
     csvOutput('cross-connects', 'getconfig_egress_port', d, result)
     nose.tools.assert_equals('PASS', result)
def get(tcName, xmlstr, outFileName):
    ### get the given switch product information ####
    global swMgr

    try:
        logger.info('Quering for running configuration data from switch using get\n\n')
        logger.info('-------[[[Get  - pass xml query to switch]]]-------\n\n')
        prettyXmlstr = prettify(xmlstr)
        logger.info('xml str is : \n\n%s\n\n' %prettyXmlstr)
        print '\n\n'

        s = time.time()
        xmlData = swMgr.get(filter=('subtree',xmlstr)).data_xml
        print '\n\n'
        prettyXml = prettify(xmlData)
        logger.info('-------[[[Get - Output from the switch]]]-------\n\n%s\n' % prettyXml)

        e = time.time()
        t = int(round((e - s)* 1000))
        writeToFile(outFileName,prettyXml);
        csvOutput('productInformation', tcName, t, 'PASS')

    except Exception as err:
        print '\n\n'
        logger.error('\t\t-------[[[ Error from the Switch ]]]-------\n\n%s\n\n', err)
        csvOutput('productInformation', tcName, 0, 'FAIL')
    def get_software_version(self, **kwargs):
        """create xml to get software version info then parse get manufacturer switch output xml
        , compare it with existing values.Finally save the output in final.csv file
        Arguments:
        file_name                 : any file name
        software_version          : software_version value
        """

        self.create_box('test_get_software_version')
        s = time.time()

        global existing_product_info

        existing_product_info = kwargs['software_version'].split()

        LOG.info('-----[ create xml for get operation ]-----\n')
        product_info = Element(
            'opsw:product-information', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                         'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})
        software_version = SubElement(product_info, 'opsw:software-version')

        xmlstr = tostring(product_info)
        xmlout = self.get_rpc_request(xmlstr, kwargs['file_name'])
        result = self.compare_list(xmlout)
        e = time.time()
        d = int(round((e - s) * 1000))
        csvOutput('product-information', 'get_software_version', d, result)
        nose.tools.assert_equals('PASS', result)
Example #5
0
def getConfig(tcName, xmlstr, fileName):
    ### getConfig - configuration for required operation ###

    global swMgr
    global cnt

    try:
        logger.info("Quering for running configuration data from switch using getConfig\n\n")
        logger.info("Get  - pass XML str to the switch...\n\n")
        prettyXml = prettify(xmlstr)
        logger.info("xml str is : \n\n%s\n\n" % prettyXml)

        s = time.time()
        xmlData = swMgr.get_config(source="running", filter=("subtree", xmlstr)).data_xml
        print "\n\n"
        prettyXml = prettify(xmlData)
        logger.info("Get - Output from the switch\n\n%s\n" % prettyXml)

        e = time.time()
        t = int(round((e - s) * 1000))
        # t = (e - s)* 1000
        writeToFile(fileName, prettyXml)
        csvOutput("Ports", tcName, t, "PASS")

    except Exception as err:
        print "\n\n"
        logger.error("\t\t-----[ Error from the Switch ]-----\n\n%s\n\n", err)
        csvOutput("Ports", tcName, 0, "FAIL")
Example #6
0
def getConfig(tcName, xmlstr, fileName):
    ### getConfig - configuration for required operation ###

    global swMgr
    global cnt

    try:
       logger.info('Quering for running configuration data from switch using getConfig\n\n')
       logger.info('Get  - pass XML str to the switch...\n\n')
       prettyXml = prettify(xmlstr)
       logger.info('xml str is : \n\n%s\n\n' % prettyXml)

       s = time.time()
       xmlData = swMgr.get_config(source='running', filter=('subtree',xmlstr)).data_xml
       print '\n\n'
       prettyXml = prettify(xmlData)
       logger.info('Get - Output from the switch\n\n%s\n' % prettyXml)

       e = time.time()
       t = int(round((e - s)* 1000))
       #t = (e - s)* 1000
       writeToFile(fileName,prettyXml);
       csvOutput('Ports', tcName, t, 'PASS')

    except Exception as err:
       print '\n\n'
       logger.error('\t\t-----[ Error from the Switch ]-----\n\n%s\n\n', err)
       csvOutput('Ports', tcName, 0, 'FAIL')
Example #7
0
def getConfig(tcName, xmlstr, fileName):
    global swMgr
    global cnt

    c = len(tcName)+7
    p = '       +' + (c * '-') + '+       '
    q = '| ' + str(cnt) +' -  '+ str(tcName) + ' |'

    try:
        logger.info('\n\n%s\n       %s\n%s\n\n' % (p, q, p))
        logger.info('Quering for running configuration data from switch using get_config\n\n')
        logger.info('Get Config - Response from the switch...\n\n')

        s = time.time()
        xmlData = swMgr.get_config(source='running',  filter=('subtree',xmlstr)).data_xml
        print '\n\n'


        prettyXml = prettify(xmlData)
        logger.info('Get Config - Output from the switch\n\n%s\n' % prettyXml)

        e = time.time()
        t = int(round((e - s)* 1000))
        writeToFile(fileName, prettyXml);
        csvOutput(cnt, tcName, t, 'PASS')

		
    except Exception as err:
        print '\n\n'
        logger.error('\t\t-----[ Error from the Switch ]-----\n\n%s\n\n', err)
        csvOutput(cnt, tcName, 0, 'FAIL')
    
    cnt = cnt+1
    def editconfig_create_user_with_password_and_group(self, **kwargs):
        """ create xml for creating user using editconfig operation,
        then get this using getconfig operation, finally parsed the output of getconfig
        operation , compare parsed output with given input
        """

        global gvn_names
        global gvn_passwords
        global gvn_groups
        global xmlstr

        gvn_names = kwargs['names'].split(',')
        gvn_passwords = kwargs['passwords'].split(',')
        gvn_groups = kwargs['groups'].split(',')

        l = len(gvn_names)

        s = time.time()
        self.create_box('test_editconfig_create_user_with_password_and_group')
        xmlstr = self.create_xml_for_user_with_password_and_group()
        result = self.edit_config_opr()

        if result == 'PASS':
            LOG.info(
                '-----[ create xml for get-config operation with names ]-----\n\n')
            system_config = Element(
                'opsw:system-config', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                       'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})
            for tag1 in range(0, l):
                user = SubElement(system_config, 'opsw:user')
                names = SubElement(user, 'opsw:name')
                names_val = gvn_names[tag1]
                names.text = str(names_val)

            xmlstr = tostring(system_config)
            xmlout, result = self.getconfig_rpc_request(
                xmlstr, kwargs['file_name'])
            result1, result2 = self.get_parsed_values(xmlout)

            if str(gvn_names) == str(result1) and str(gvn_groups) == str(result2):
                LOG.info('gvn_names : %s' % gvn_names)
                # LOG.info('gvn_passwords : %s' % gvn_passwords)
                LOG.info('gvn_groups : %s\n\n' % gvn_groups)
                LOG.info('compare names, passwords, groups : PASS\n')
                result = 'PASS'
            else:
                LOG.error('comparision failed : FAIL\n')
                result = 'FAIL'

            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput(
                'system-config',
                'editconfig_create_user_with_password_and_group',
                d,
                result)
        else:
            LOG.info('getting error from switch : FAIL\n\n')

        nose.tools.assert_equals('PASS', result)
Example #9
0
def get(tcName, xmlstr, fileName):
    global swMgr
    global cnt

    c = len(tcName) + 7
    l = len(str(cnt))
    if l == 2:
        c = c + 1
        p = '       +' + (c * '-') + '+       '
        q = '| ' + str(cnt) + ' -  ' + str(tcName) + ' |'
    else:
        p = '       +' + (c * '-') + '+       '
        q = '| ' + str(cnt) + ' -  ' + str(tcName) + ' |'

    try:
        logger.info('\n\n%s\n       %s\n%s\n\n' % (p, q, p))
        logger.info('created xmlstr : \n%s\n\n' % xmlstr)

        s = time.time()
        xmlData = swMgr.get(filter=('subtree', xmlstr)).data_xml
        print '\n\n'
        prettyXml = prettify(xmlData)
        logger.info('response from the switch : \n%s\n\n' % prettyXml)

        e = time.time()
        t = int(round((e - s) * 1000))
        writeToFile(fileName, prettyXml)
        csvOutput('crossconnects', tcName, t, 'PASS')

    except Exception as err:
        print '\n\n'
        logger.error('\t\t-----[ Error from the Switch ]-----\n\n%s\n\n', err)
        csvOutput('crossconnects', tcName, 0, 'FAIL')

    cnt = cnt + 1
Example #10
0
    def editconfig_replace_operation(self, **kwargs):
        
        """create the xml using replace operation, then get the configuration using
        get-config operation, parsed the output and then compare the both ports list
        Arguments:
        ingress_ports		: valid ingress ports
        egress ports		: valid egress ports
        """
    	global xmlstr
    	
        self.create_box('test_editconfig_replace_operation')
    	self.split_port_list(kwargs['ingress_ports'], kwargs['egress_ports'])
        s = time.time()
    	xmlstr = self.create_xml('replace')
    	result = self.edit_config_opr()
        if result == 'PASS':
            LOG.info('-----[ create xml for get-config operation ]-----\n')
    	    crossconnects = Element('opsw:cross-connects', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",
                                                            'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})

    	    xmlstr = tostring(crossconnects)
            xmlout = self.getconfig_rpc_request(xmlstr, kwargs['file_name'])
            result = self.compare_list(xmlout)
            e = time.time()
            d = int(round((e - s)* 1000))
            csvOutput('cross-connects', 'editconfig_replace_operation', d, result)
        else:
            LOG.info('getting error from switch : FAIL')

        nose.tools.assert_equals('PASS', result)
Example #11
0
    def get_egress_ports(self, **kwargs):
        
        """create the oxc b/w given ingress and egress ports and create the xml for
        many egress ports for get operation, get the xml output from this, then parsed this xml
        , from parsed xml get the ingress and egress port list, then compare this ports
        with given ports.Fially save the output in final.csv file
        Arguments:
        file_name             : any file name
        ingressPort list      : valid ingress port list
        egressPort list       : valid egress port list
        """
    	
        global ex_egress_ports 
    	global req_egress_ports
    	
        self.create_box('get_egress_ports')
        s = time.time()
        LOG.info('-----[ create oxc conection ]-----\n')
        self.edit_config_create_oxc_without_opr(kwargs['ingress_ports'], kwargs['egress_ports'])
        
        LOG.info('-----[ create xml for get operation ]-----\n')
    	crossconnects = Element('opsw:cross-connects', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",
    	                                                    'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})

    	egrSymbol = re.split(r'[\d]', portList)
    	
    	if str(egrSymbol[1]) == ',' or str(egrSymbol[1]) == '':
    	    req_egress_ports = portList.split(',')
    	
    	if str(ingSymbol[2]) == '-' or str(ingSymbol[1]) == '-':
    	    req_egress_ports = []
    	    req_egress_ports1 = portList.split('-')
    	    for i in range(int(req_egress_ports1[0]), int(egrPLst1[1])+1):
    	        req_egress_ports.append(i)
    	    LOG.info('egress port list: %s' % req_egress_ports)
    	else:
    	    LOG.error('Give for example comma or hypen seperated values ...\n\n')
    	    
    	l = len(req_egress_ports)
    	for i in range(0, l):
    	    a = req_egress_ports[i]
    	    if a in ex_egress_ports:
    	       pairs = SubElement(crossconnects, 'opsw:pairs')
    	       egress = SubElement(pairs, 'opsw:egress')
    	       egress.text = str(a)
    	    else:
    	       pairs = SubElement(crossconnects, 'opsw:pairs')
    	       egress = SubElement(pairs, 'opsw:egress')
    	       egress.text = str(a)

    	xmlstr = tostring(crossconnects)
        xmlout = self.get_rpc_request(xmlstr, kwargs['file_name'])
        result = self.compare_list(xmlout)
        e = time.time()
        d = int(round((e - s)* 1000))
        csvOutput('cross-connects', 'get_egress_ports', d, result)
Example #12
0
def editConfig(tcName, xmlstr):
    ### editConfig - configuration for required operation ###

    global swMgr
    global cnt
    global prtIdLst

    try:
        logger.info("Quering for running configuration data from switch using editConfig\n\n")
        logger.info("edit  - the XML str & passs it to the switch...\n\n")
        prettyXml = prettify(xmlstr)
        logger.info("xml str is : \n\n%s\n\n" % prettyXml)

        s = time.time()
        xmlData = swMgr.edit_config(target="running", config=xmlstr)

        prettyXml = prettify(str(xmlData))
        logger.info("EditConfig - Output from the switch\n\n%s\n" % prettyXml)

        ports = Element(
            "opsw:ports",
            {
                "xmlns:plts": "http://www.polatis.com/yang/polatis-switch",
                "xmlns:opsw": "http://www.polatis.com/yang/optical-switch",
            },
        )
        try:
            l = len(prtIdLst)
            for i in range(0, l):
                a = prtIdLst[i]
                port = SubElement(ports, "opsw:port")
                port_id = SubElement(port, "opsw:port-id")
                port_id.text = str(a)
                port_label = SubElement(port, "opsw:port-label")
        except Exception as err:
            logger.error("\t\t-----[ Error from the Switch ]-----\n\n%s\n\n" % err)

        # logger.info('-----[ Compare the Edit Config and Get Config Ports ]-----\n\n')
        # xmlstr = tostring(ports)
        # xmlData = swMgr.get_config(source='running',  filter=('subtree',xmlstr)).data_xml
        # print "\n\n"

        # prettyXml = prettify(xmlData)
        # logger.info('Get  config -  Response from the switch\n\n%s \n\n' % prettyXml)

        # result = cmpIngEgrPortLst(xmlData)

        e = time.time()
        t = int(round((e - s) * 1000))
        csvOutput("Ports", tcName, t, "PASS")

    except Exception as err:
        print "\n\n"
        logger.error("\t\t-----[ Error from the Switch ]-----\n\n%s\n\n", err)
        csvOutput("Ports", tcName, 0, "FAIL")
Example #13
0
    def editconfig_negative_case_with_invalid_ingress_port(self, **kwargs):
        """create the xml with invalid ingress port, then get the configuration using
        get-config operation, parsed the output and then compare the both ports list
        Arguments:
        ingress_ports		: valid ingress ports
        egress ports		: valid egress ports
        """
        global xmlstr
        global req_ingress_ports
        global req_egress_ports

        self.create_box(
            'test_editconfig_negative_case_with_invalid_ingress_port')
        # self.split_port_list(kwargs['ingress_ports'], kwargs['egress_ports'])
        req_ingress_ports = kwargs['ingress_ports'].split()
        req_egress_ports = kwargs['egress_ports']

        s = time.time()
        LOG.info(
            '-----[ create xml for edit-config invalid ingress port operation ]-----\n')
        xmlstr = self.create_xml('create')
        result = self.edit_config_opr()
        if result == 'PASS':
            LOG.info('-----[ create xml for get-config operation ]-----\n')
            crossconnects = Element(
                'opsw:cross-connects', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                        'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})

            xmlstr = tostring(crossconnects)
            LOG.info('xmlstr : \n%s' % xmlstr)
            xmlout = self.getconfig_rpc_request(xmlstr, kwargs['file_name'])
            result = self.compare_list(xmlout)
            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput(
                'cross-connects',
                'editconfig_negative_case_with_ingress_port',
                d,
                result)
        else:
            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput(
                'cross-connects',
                'editconfig_negative_case_with_invalid_ingress_port',
                d,
                'PASS')
            LOG.info(
                'getting error from switch using invalid ingress port : PASS\n\n')

        # e = time.time()
        # d = int(round((e - s)* 1000))
        # csvOutput('cross-connects',
        # 'editconfig_negative_case_invalid_oxc_connection', d, result)
        nose.tools.assert_equals('FAIL', result)
Example #14
0
    def editconfig_create_startup_mode_with_mode_volatile(self, **kwargs):
        """ create xml for creating startup mode wit mode preserve using editconfig operation,
        then get this using getconfig operation, finally parsed the output of getconfig
        operation , compare parsed output with given input
        """

        global gvn_mode
        global xmlstr

        gvn_mode = kwargs['mode_volatile']
        # print gvn_mode

        l = len(gvn_mode)

        s = time.time()
        self.create_box(
            'test_editconfig_create_startup_mode_with_mode_volatile')
        xmlstr = self.create_xml_for_startup_mode_with_given_mode()
        result = self.edit_config_opr()

        if result == 'PASS':
            LOG.info('-----[ create xml for get-config operation ]-----\n\n')
            system_config = Element(
                'opsw:system-config', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                       'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})
            startup_mode = SubElement(system_config, 'plts:startup-mode')

            xmlstr = tostring(system_config)
            xmlout, result = self.getconfig_rpc_request(
                xmlstr, kwargs['file_name'])
            result = self.get_parsed_values_startup_mode(xmlout)

            gvn_mode = kwargs['mode_volatile'].split()

            if str(gvn_mode) == str(result):
                LOG.info('gvn_mode : %s\n\n' % gvn_mode)
                LOG.info('compare mode : PASS\n')
                result = 'PASS'
            else:
                LOG.error('comparision failed : FAIL\n')
                result = 'FAIL'

            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput(
                'system-config',
                'editconfig_create_startup_mode_with_mode_volatile',
                d,
                result)
        else:
            LOG.info('getting error from switch : FAIL\n\n')

        nose.tools.assert_equals('PASS', result)
Example #15
0
    def get_edit_config(self, **kwargs):
        
        """create the oxc b/w given ingress and egress ports and create the xml for
        get the edit-config oxc connection tag for get operation, get the xml output from this, then parsed this xml
        , from parsed xml get the ingress and egress port list, then compare this ports
        with given ports.Fially save the output in final.csv file
        Arguments:
        file_name             : any file name
        ingressPort list      : valid ingress port list
        egressPort list       : valid egress port list
        """
    	
        global ex_ingress_ports
    	global req_ingress_ports
    	global ex_egress_ports 
    	global req_egress_ports
    	
        self.create_box('get_editconfig')
        s = time.time()
        LOG.info('-----[ create oxc conection ]-----\n')
        self.edit_config_create_oxc_without_opr(kwargs['ingress_ports'], kwargs['egress_ports'])
        
        LOG.info('-----[ create xml for get operation ]-----\n')
    	crossconnects = Element('opsw:cross-connects', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",
                                                        'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})
    	try:
    	    l = len(req_egress_ports)
    	    for i in range(0, l):
    	        a = req_ingress_ports[i]
    	        b = req_egress_ports[i]
    	        if a in ex_ingress_ports and b in ex_egress_ports:
    	           pairs = SubElement(crossconnects, 'opsw:pairs')
    	           ingress = SubElement(pairs, 'opsw:ingress')
    	           ingress.text = str(a)
    	           egress = SubElement(pairs, 'opsw:egress')
    	           egress.text = str(b)
    	        else:
    	           pairs = SubElement(crossconnects, 'opsw:pairs')
    	           ingress = SubElement(pairs, 'opsw:ingress')
    	           ingress.text = str(a)
    	           egress = SubElement(pairs, 'opsw:egress')
    	           egress.text = str(b)
    	except Exception as err:
    	    LOG.error('\t\t-----[ Error from the Switch ]-----\n\n%s\n\n', err)


    	xmlstr = tostring(crossconnects)
        xmlout = self.get_rpc_request(xmlstr, kwargs['file_name'])
        result = self.compare_list(xmlout)
        e = time.time()
        d = int(round((e - s)* 1000))
        csvOutput('cross-connects', 'get_editconfig', d, result)
Example #16
0
def editConfig(tcName, xmlstr):
    ### editConfig - configuration for required operation ###

    global swMgr
    global cnt
    global prtIdLst

    try:
       logger.info('Quering for running configuration data from switch using editConfig\n\n')
       logger.info('edit  - the XML str & passs it to the switch...\n\n')
       prettyXml = prettify(xmlstr)
       logger.info('xml str is : \n\n%s\n\n' % prettyXml)

       s = time.time()
       xmlData = swMgr.edit_config(target='running', config=xmlstr)

       prettyXml = prettify(str(xmlData))
       logger.info('EditConfig - Output from the switch\n\n%s\n' % prettyXml)

       ports = Element('opsw:ports', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",
                                      'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})
       try:
          l = len(prtIdLst)
          for i in range(0, l):
              port = SubElement(ports, 'opsw:port')
              port_id = SubElement(port, 'opsw:port-id')
              port_id.text = str(a)
              port_label = SubElement(port, 'opsw:port-label')
       except Exception as err:
          logger.error('\t\t-----[ Error from the Switch ]-----\n\n%s\n\n' % err)


       logger.info('-----[ Compare the Edit Config and Get Config Ports ]-----\n\n')
       xmlstr = tostring(ports)
       xmlData = swMgr.get_config(source='running',  filter=('subtree',xmlstr)).data_xml
       print "\n\n"
     
       prettyXml = prettify(xmlData)
       logger.info('Get  config -  Response from the switch\n\n%s \n\n' % prettyXml)
       
       result = cmpIngEgrPortLst(xmlData)
       
       e = time.time()
       t = int(round((e - s)* 1000))
       csvOutput('Ports', tcName, t, result)

    except Exception as err:
       print '\n\n'
       logger.error('\t\t-----[ Error from the Switch ]-----\n\n%s\n\n', err)
       csvOutput('Ports', tcName, 0, result)
Example #17
0
    def editconfig_create_user_with_group_and_invalid_password(self, **kwargs):
        """ create xml for creating user using editconfig operation,
        then get this using getconfig operation, finally parsed the output of getconfig
        operation , compare parsed output with given input
        """

        global gvn_names
        global gvn_passwords
        global gvn_groups
        global xmlstr

        gvn_names = kwargs['names'].split(',')
        gvn_passwords = kwargs['passwords'].split(',')
        gvn_groups = kwargs['groups'].split(',')

        l = len(gvn_names)

        s = time.time()
        self.create_box(
            'test_editconfig_create_user_with_group_and_invalid_password')
        xmlstr = self.create_xml_for_user_with_password_and_group()
        result = self.edit_config_opr()
        LOG.info('gvn_name : %s' % gvn_names)
        LOG.info('gvn_password : %s\n\n' % gvn_passwords)
        LOG.info('gvn_group : %s\n\n' % gvn_groups)
        if result == 'PASS':
            e = time.time()
            d = int(round((e - s) * 1000))
            LOG.info('Invalid case is passed : FAIL\n\n')
            csvOutput(
                'system-config',
                'editconfig_create_user_with_group_and_invalid_password',
                d,
                result)
        else:
            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput(
                'system-config',
                'editconfig_create_user_with_group_and_invalid_password',
                d,
                result)
            LOG.info('getting error from switch : PASS\n\n')

        nose.tools.assert_equals('FAIL', result)
Example #18
0
    def get_ingress_ports(self, **kwargs):
        """create the oxc b/w given ingress and egress ports and create the xml for
        many ingress ports for get operation, get the xml output from this, then parsed this xml
        , from parsed xml get the ingress and egress port list, then compare this ports
        with given ports.Finally save the output in final.csv file
        Arguments:
        file_name             : any file name
        ingressPort list      : valid ingress port list
        egressPort list       : valid egress port list
        """

        global ex_ingress_ports
        global req_ingress_ports

        self.create_box('test_get_ingress_ports')
        s = time.time()

        LOG.info('-----[ create xml for get operation ]-----\n')

        crossconnects = Element(
            'opsw:cross-connects', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                    'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})

        req_ingress_ports = kwargs['ingress_ports']

        l = len(req_ingress_ports)
        for i in range(0, l):
            a = req_ingress_ports[i]
            if a in ex_ingress_ports:
                pairs = SubElement(crossconnects, 'opsw:pairs')
                ingress = SubElement(pairs, 'opsw:ingress')
                ingress.text = str(a)
            else:
                pairs = SubElement(crossconnects, 'opsw:pairs')
                ingress = SubElement(pairs, 'opsw:ingress')
                ingress.text = str(a)

        xmlstr = tostring(crossconnects)
        LOG.info('xmlstr : \n%s' % xmlstr)
        xmlout = self.get_rpc_request(xmlstr, kwargs['file_name'])
        result = self.compare_list(xmlout)
        e = time.time()
        d = int(round((e - s) * 1000))
        csvOutput('cross-connects', 'get_ingress_ports', d, result)
        nose.tools.assert_equals('PASS', result)
Example #19
0
    def editconfig_create_invalid_startup_mode_with_mode_volatile(
            self, **kwargs):
        """ create xml for creating startup mode wit mode preserve using editconfig operation,
        then get this using getconfig operation, finally parsed the output of getconfig
        operation , compare parsed output with given input
        """

        global gvn_mode
        global xmlstr

        gvn_mode = kwargs['mode_volatile']
        # print gvn_mode

        l = len(gvn_mode)

        s = time.time()
        self.create_box(
            'test_editconfig_create_invalid_startup_mode_with_mode_volatile')
        xmlstr = self.create_xml_for_startup_mode_with_given_mode()
        result = self.edit_config_opr()
        gvn_mode = kwargs['mode_volatile'].split()
        LOG.info('gvn_mode : %s\n\n' % gvn_mode)
        if result == 'PASS':
            e = time.time()
            d = int(round((e - s) * 1000))
            LOG.info('Invalid case is passed : FAIL\n\n')
            csvOutput(
                'system-config',
                'editconfig_create_invalid_startup_mode_with_mode_volatile',
                d,
                result)
        else:
            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput(
                'system-config',
                'editconfig_create_invalid_startup_mode_with_mode_volatile',
                d,
                result)
            LOG.info('getting error from switch : PASS\n\n')

        nose.tools.assert_equals('FAIL', result)
Example #20
0
    def editconfig_create_operation(self, **kwargs):
    	global xmlstr
    	
        self.create_box('get_editconfig_create_operation')
    	self.split_port_list(kwargs['ingress_ports'], kwargs['egress_ports'])
        s = time.time()
        LOG.info('create xml using CREATE operation')
    	xmlstr = self.create_xml('create')
    	self.edit_config_opr()
        LOG.info('-----[ create xml using get-config operation ]-----')
    	crossconnects = Element('opsw:cross-connects', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",

    	                                                    'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})

    	xmlstr = tostring(crossconnects)
        xmlout = self.getconfig_rpc_request(xmlstr, kwargs['file_name'])
        result = self.compare_list(xmlout)
        e = time.time()
        d = int(round((e - s)* 1000))
        csvOutput('cross-connects', 'getconfig_crossconnects', d, result)
Example #21
0
    def get_interface_status(self, **kwargs):
        """ create xml for get interface status, then parsed this,
        compare parsed values with given values
        """

        gvn_interface_status = kwargs['interface_status'].split(',')
        # print "gvn_interface_status : %s" % gvn_interface_status

        self.create_box('test_get_interface_status')
        s = time.time()

        LOG.info('-----[ create xml for get operation ]-----\n')
        system_config = Element(
            'opsw:system-config', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                   'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})
        interface_status = SubElement(system_config, 'opsw:interface-status')

        xmlstr = tostring(system_config)
        LOG.info('xmlstr : \n%s\n\n' % xmlstr)
        xmlout, result = self.get_rpc_request(xmlstr, kwargs['file_name'])
        if result == 'PASS':
            result = self.get_parsed_values_for_intr_status(
                xmlout, 'interface-status')

            if str(gvn_interface_status) == str(result):
                # LOG.info("validate system config info\n\n")
                LOG.info(
                    'gvn_interface_status : %s\n\n' %
                    gvn_interface_status)
                LOG.info('compare interface_status : PASS\n')
                result = 'PASS'
            else:
                LOG.error('comparision failed : FAIL\n')
                result = 'FAIL'
        else:
            LOG.info('getting error from switch : FAIL\n\n')
            result = self.compare_list(xmlout)
            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput('system_config', 'get_interface_status', d, result)
        nose.tools.assert_equals('PASS', result)
    def get_egress_ports_type_info(self, **kwargs):
        """create xml to get egress ports type info then parse get manufacturer switch output xml
        , compare it with existing values.Finally save the output in final.csv file
        Arguments:
        file_name             : any file name
        manufacturer          : manufacturer value
        """

        self.create_box('test_get_egress_ports_type_info')
        s = time.time()

        global existing_product_info

        egress_port_ids = kwargs['egress_port_ids']
        port_types = ['EGRESS_PORT', 'EGRESS_PORT', 'EGRESS_PORT']

        LOG.info('-----[ create xml for get operation ]-----\n')
        product_info = Element(
            'opsw:product-information', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                         'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})
        # ports = SubElement(product_info, 'opsw:ports')
        for id in range(0, len(egress_port_ids)):
            ports = SubElement(product_info, 'opsw:ports')
            port_id = SubElement(ports, 'opsw:port-id')
            port_id.text = str(egress_port_ids[id])
            port_type = SubElement(ports, 'opsw:port-type')

        existing_product_info = egress_port_ids + port_types

        xmlstr = tostring(product_info)
        xmlout = self.get_rpc_request(xmlstr, kwargs['file_name'])
        result = self.compare_list(xmlout)
        e = time.time()
        d = int(round((e - s) * 1000))
        csvOutput(
            'product-information',
            'get_egress_ports_type_info',
            d,
            result)
        nose.tools.assert_equals('PASS', result)
Example #23
0
    def get_current_datetime(self, **kwargs):
        """ create xml for creating startup mode with mode volatile using editconfig operation,
        then get this using get operation, finally parsed the output of get
        operation , compare parsed output with given input
        """

        global gvn_mode
        global xmlstr

        s = time.time()
        self.create_box('test_get_current_datetime')

        result = 'PASS'

        if result == 'PASS':
            LOG.info('-----[ create xml for get operation ]-----\n\n')
            system_config = Element(
                'opsw:system-config', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                       'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})
            current_datetime = SubElement(
                system_config,
                'opsw:current-datetime')

            xmlstr = tostring(system_config)
            LOG.info('xmlstr : \n%s\n\n' % xmlstr)
            xmlout, result = self.get_rpc_request(xmlstr, kwargs['file_name'])
            result = self.get_parsed_values_get_curent_datetime(xmlout)

            LOG.info("current time value : %s" % result)

            result = 'PASS'
            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput('system-config', 'get_current_datetime', d, result)
        else:
            LOG.info('getting error from switch : FAIL\n\n')

        nose.tools.assert_equals('PASS', result)
Example #24
0
def editConfig(tcName):
    global swMgr
    global xmlstr
    global cnt
    global ingPorts
    global ingPLst
    global egrPorts 
    global egrPLst
    s = time.time()
    
    
    c = len(tcName)+7
    p = '       +' + (c * '-') + '+       '
    q = '| ' + str(cnt) +' -  '+ str(tcName) + ' |'

    try:
       logger.info('\n\n%s\n       %s\n%s\n\n' % (p, q, p))

       logger.info('Existing ingress port list: %s' % ingPorts)
       logger.info('Existing egress port list : %s\n\n' %  egrPorts)

       logger.info('ingress port list: %s' % ingPLst)
       logger.info('egress port list : %s\n\n' % egrPLst)
       
       logger.info("Issuing edit config to switch for cross-connect configuration\n")


       xmldata = swMgr.edit_config(target='running', config=xmlstr)
       print "\n\n"

    
       logger.info('Edit config - Response from the switch\n\n%s\n\n' % xmldata)

       crossconnects = Element('opsw:cross-connects', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",
                                                        'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})
       try:
          l = len(egrPLst)
          for i in range(0, l):
              a = ingPLst[i]
              b = egrPLst[i]
              if a in ingPorts and b in egrPorts:
                 pairs = SubElement(crossconnects, 'opsw:pairs')
                 ingress = SubElement(pairs, 'opsw:ingress')
                 ingress.text = str(a)
                 egress = SubElement(pairs, 'opsw:egress')
                 egress.text = str(b)
              else:
                 pairs = SubElement(crossconnects, 'opsw:pairs')
                 ingress = SubElement(pairs, 'opsw:ingress')
                 ingress.text = str(a)
                 egress = SubElement(pairs, 'opsw:egress')
                 egress.text = str(b)
       except Exception as err:
          logger.error('\t\t-----[ Error from the Switch ]-----\n\n%s\n\n' % err)


       logger.info('-----[ Compare the Edit Config and Get Config Ports ]-----\n\n')
       xmlstr = tostring(crossconnects)
       xmlData = swMgr.get_config(source='running',  filter=('subtree',xmlstr)).data_xml
       print "\n\n"
     
       prettyXml = prettify(xmlData)
       logger.info('Get  config -  Response from the switch\n\n%s \n\n' % prettyXml)
       
       result = cmpIngEgrPortLst(xmlData)

       e = time.time()
       t = int(round((e - s)* 1000))
       csvOutput('oxC', tcName, t, result)

    except Exception as err:
       print "\n\n"
       logger.error('\t\t-----[ Error from the Switch ]-----\n\n%s\n\n' %  err)
       e = time.time()
       t = int(round((e - s)* 1000))

       csvOutput('oxC', tcName, t, 'FAIL')

    cnt = cnt+1
Example #25
0
    def editconfig_delete_all_users(self, **kwargs):
        """ create xml for delete all users except admin
        using edit-config and get this modification using get-config
        then parsed this xml and compare parsed users with given users
        Arguments:
            xmlData   : xmlstr
        """
        gvn_user = ['admin']
        global xmlstr

        self.create_box('test_delete_all_users')
        s = time.time()

        LOG.info('-----[ create xml for get operation ]-----\n')
        system_config = Element(
            'opsw:system-config', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                   'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})
        user = SubElement(system_config, 'opsw:user')

        xmlstr = tostring(system_config)
        LOG.info('xmlstr : \n%s\n\n' % xmlstr)

        xmlout, result = self.get_rpc_request(xmlstr, kwargs['file_name'])

        config = Element(
            'config',
            {'xmlns:ns': "urn:ietf:params:xml:ns:netconf:base:1.0"})
        system_config = SubElement(
            config,
            'system-config',
            {'xmlns': "http://www.polatis.com/yang/optical-switch"})

        if result == 'PASS':
            result1, result2 = self.get_parsed_values(xmlout)

            l = len(result1)
            for user_ind in range(0, l):
                name_val = result1[user_ind]
                # user = SubElement(system_config, 'user',
                # {'ns:operation':'delete'})
                if name_val == 'admin':
                    continue
                else:
                    user = SubElement(
                        system_config,
                        'user',
                        {'ns:operation': 'delete'})
                    name = SubElement(user, 'name')
                    name.text = str(name_val)

            xmlstr = tostring(config)
            self.edit_config_opr()
            system_config = Element(
                'opsw:system-config', {'xmlns:plts': "http://www.polatis.com/yang/polatis-switch",
                                       'xmlns:opsw': "http://www.polatis.com/yang/optical-switch"})
            user = SubElement(system_config, 'opsw:user')

            xmlstr = tostring(system_config)
            xmlout, result = self.get_rpc_request(xmlstr, kwargs['file_name'])
            result1, result2 = self.get_parsed_values(xmlout)
            if str(gvn_user) == str(result1):
                LOG.info('gvn_user : %s\n\n' % gvn_user)
                LOG.info('compare user : PASS\n')
                result = 'PASS'
            else:
                LOG.error('comparision failed : FAIL\n')
                result = 'FAIL'

        else:
            LOG.info('getting error from switch : FAIL\n\n')
            result = self.compare_list(xmlout)
            e = time.time()
            d = int(round((e - s) * 1000))
            csvOutput('system_config', 'get_interface', d, result)
        nose.tools.assert_equals('PASS', result)
    def set_and_get_boot_datetime(self, **kwargs):

        """create xml to get restart datetime info then parse get switch output xml 
        , compare it with existing values.Finally save the output in final.csv file
        Arguments:
        file_name             : any file name
        """

     
        global sw_mgr
        global host
        global curr_time
 
        self.create_box('test_set_and_get_boot_datetime')
        username = get_config_arg("login_credentials", "cli_username")
        password = get_config_arg("login_credentials", "cli_password")
        s = time.time()
   
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        
        ssh.connect(host, username=username, password=password)
        
        stdin, stdout, stderr = ssh.exec_command("date -u +'%Y-%m-%dT%H:%M:%S.%s%z'")
        sys_restart = ssh.exec_command("reboot")
           
        t = stdout.readlines()      


        now = datetime.datetime.now()
        curr_time = now.isoformat()
        

        LOG.info('-----[ create xml for set operation ]-----\n')

        xmlstr = """<system-restart xmlns="http://www.polatis.com/yang/optical-switch">"""


        LOG.info('%s\n\n' % xmlstr)
        try:
            xmlout = sw_mgr.rpc(xmlstr)
        except:
            time.sleep(180)
            print '\n\n'
            self.connect_switch()
            #LOG.info('-----[ output from switch ]-----\n\n%s\n\n' % xmlout)
            LOG.info('-----[ create xml for get operation ]-----\n')
            sys_config = Element('opsw:system-config', {'xmlns:plts':"http://www.polatis.com/yang/polatis-switch",
                                        'xmlns:opsw':"http://www.polatis.com/yang/optical-switch"})
            boot_time = SubElement(sys_config, 'opsw:boot-datetime')

            xmlstr = tostring(sys_config)

            xmlout = self.get_rpc_request(xmlstr)
            prettyXml = self.prettify(xmlout)
            self.write_to_file(kwargs['file_name'], prettyXml);

            curr_time = str(t).split('\'') 
            match = re.search(r'(\d+-\d+-\d+T\d+:\d+)', curr_time[1])
            curr_time = match.group(1)

            result = self.compare_list(xmlout)
            e = time.time()
            d = int(round((e - s)* 1000))
            csvOutput('set-current-datetime', 'set_and_get_boot_datetime', d, result)
        nose.tools.assert_equals('PASS', result)