Example #1
0
 def test_search_intf1(self):
     self.iIntf1 = switch.Interface('eth1/1', 'BLT01 VC1X1')
     self.iIntf2 = switch.Interface('eth1/2', 'BLT01 VC2X1')
     self.iIntf3 = switch.Interface('eth1/52', 'VPC-PEER')
     self.iIntf4 = switch.Interface('eth1/53', 'VPC-PEER')
     self.iSwitch.intf = [
         self.iIntf1, self.iIntf2, self.iIntf3, self.iIntf4
     ]
     assert self.iSwitch.search_intf('BLT') == [self.iIntf1, self.iIntf2]
Example #2
0
 def test_set_switch_intf(self):
     self.iIntf1 = switch.Interface('eth1/1', 'BLT01 VC1X1')
     self.iIntf2 = switch.Interface('eth1/2', 'BLT01 VC2X1')
     self.iIntf3 = switch.Interface('eth1/52', 'VPC-PEER')
     self.iIntf4 = switch.Interface('eth1/53', 'VPC-PEER')
     self.iSwitch.intf = [
         self.iIntf1, self.iIntf2, self.iIntf3, self.iIntf4
     ]
     # self.iSwitch.intf = list_intf
     assert self.iSwitch.intf == [
         self.iIntf1, self.iIntf2, self.iIntf3, self.iIntf4
     ]
Example #3
0
    def get_intf_api(self):
        my_headers = {'content_type': 'application/json-rpc'}
        my_payload = [{
            "jsonrpc": 2.0,
            "method": "cli",
            "params": {
                "cmd": "show interface description",
                "version": 1
            },
            "id": 1
        }]
        result = self.execute_api_command(my_headers, my_payload)

        list_intf = result['TABLE_interface']['ROW_interface']
        liste_retour = []
        for intf in list_intf:
            if 'desc' not in intf:
                intf['desc'] = 'vide'
            print('\nintf = \n')
            pprint(intf)
            tmp = switch.Interface(name=intf['interface'], desc=intf['desc'])
            liste_retour.append(tmp)
        print('\nliste_retour = \n')
        pprint(liste_retour)
        return liste_retour
Example #4
0
    def test_get_intf_api_when_desc_is_null(self):
        json_resp = {"id": 1, "jsonrpc": '2.0', "result": {"body": {"TABLE_interface": {"ROW_interface": [{
                                                                                           "interface": 'Ethernet1/1',
                                                                                           "speed": '10G',
                                                                                           "type": 'eth'}]}}}}
        self.mock_post.return_value = Mock(ok=True)
        self.mock_post.return_value.status_code = 200
        rep = json.dumps(json_resp, separators=(',', ':'))
        self.mock_post.return_value.json = json.loads(rep)

        iNxos = nexus.Nxos('SPINE1', 'user', 'pwd', 80)

        resp = iNxos.get_intf_api()
        print('\nresp = ')
        pprint(resp)

        intf1 = switch.Interface('Ethernet1/1','vide')
        liste_retour = [intf1]

        assert len(resp) == len(liste_retour)
        assert resp[0] == liste_retour[0]
Example #5
0
 def setup_method(self):
     self.iIntf1 = switch.Interface('eth1/1', 'BLT01 VC1X1')
     self.iIntf2 = switch.Interface('eth1/2', 'BLT01 VC2X1')
     self.iIntf3 = switch.Interface('eth1/52', 'VPC-PEER')
     self.iIntf4 = switch.Interface('eth1/53', 'VPC-PEER')