Ejemplo n.º 1
0
 def test_var_json_data(self):
     argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" --var-json VLAN_MEMBER'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict(
             '{\n    "Vlan1000|Ethernet8": {\n        "tagging_mode": "untagged"\n    },'
             ' \n    "Vlan2000|Ethernet12": {\n        "tagging_mode": "tagged"\n    },'
             ' \n    "Vlan2001|Ethernet12": {\n        "tagging_mode": "tagged"\n    }}'
         ))
 def test_minigraph_t2_chassis_fe_interfaces(self):
     argument = '-m "' + self.sample_graph_t2_chassis_fe + '" -p "' + self.t2_chassis_fe_port_config + '" -v "INTERFACE"'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict("{'Ethernet8': {}, "
                       "('Ethernet8', '172.16.0.9/30'): {}, "
                       "'Ethernet0': {'vnet_name': 'VnetFE'}, "
                       "('Ethernet4', '172.16.0.1/30'): {}, "
                       "('Ethernet0', '192.168.0.2/30'): {}, "
                       "'Ethernet4': {}}"))
    def test_platform_json_specific_ethernet_interfaces(self):

        argument = '-m "' + self.sample_graph_simple + '" -p "' + self.platform_json + '" -S "' + self.hwsku_json  + '" -v "PORT[\'Ethernet8\']"'
        output = self.run_script(argument)
        expected = "{'index': '3', 'lanes': '8', 'description': 'Eth3/1', 'admin_status': 'up', 'mtu': '9100', 'alias': 'Eth3/1', 'pfc_asym': 'off', 'speed': '25000'}"
        self.assertEqual(utils.to_dict(output.strip()), utils.to_dict(expected))

        argument = '-m "' + self.sample_graph_simple + '" -p "' + self.platform_json + '" -S "' + self.hwsku_json  + '" -v "PORT[\'Ethernet112\']"'
        output = self.run_script(argument)
        expected = "{'index': '29', 'lanes': '112', 'description': 'Eth29/1', 'admin_status': 'up', 'mtu': '9100', 'alias': 'Eth29/1', 'pfc_asym': 'off', 'speed': '25000'}"
        self.assertEqual(utils.to_dict(output.strip()), utils.to_dict(expected))
 def test_minigraph_t2_chassis_fe_pc_interfaces(self):
     argument = '-m "' + self.sample_graph_t2_chassis_fe_pc + '" -p "' + self.t2_chassis_fe_port_config + '" -v "PORTCHANNEL_INTERFACE"'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict("{'PortChannel8': {}, "
                       "('PortChannel0', '192.168.0.2/30'): {}, "
                       "('PortChannel4', '172.16.0.1/30'): {}, "
                       "'PortChannel4': {}, "
                       "('PortChannel8', '172.16.0.9/30'): {}, "
                       "'PortChannel0': {'vnet_name': 'VnetFE'}}"))
Ejemplo n.º 5
0
 def test_minigraph_vlans(self):
     argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict(
             "{'Vlan1000': {'alias': 'ab1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '1000', 'members': ['Ethernet8']}, "
             "'Vlan2001': {'alias': 'ab3', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2001', 'members': ['Ethernet12']},"
             "'Vlan2000': {'alias': 'ab2', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2000', 'members': ['Ethernet12']},"
             "'Vlan2020': {'alias': 'kk1', 'dhcp_servers': ['192.0.0.1', '192.0.0.2'], 'vlanid': '2020', 'members': ['Ethernet12']}}"
         ))
Ejemplo n.º 6
0
 def test_minigraph_vlan_members(self):
     argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict(
             "{('Vlan2000', 'Ethernet12'): {'tagging_mode': 'tagged'}, "
             "('Vlan1000', 'Ethernet8'): {'tagging_mode': 'untagged'}, "
             "('Vlan2020', 'Ethernet12'): {'tagging_mode': 'tagged'}, "
             "('Vlan2001', 'Ethernet12'): {'tagging_mode': 'tagged'}}"
         )
     )
Ejemplo n.º 7
0
 def test_minigraph_extra_neighbors(self):
     argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v DEVICE_NEIGHBOR'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict(
             "{'Ethernet124': {'name': 'ARISTA04T1', 'port': 'Ethernet1/1'}, "
             "'Ethernet120': {'name': 'ARISTA03T1', 'port': 'Ethernet1/1'}, "
             "'Ethernet4': {'name': 'Servers0', 'port': 'eth0'}, "
             "'Ethernet116': {'name': 'ARISTA02T1', 'port': 'Ethernet1/1'}, "
             "'Ethernet100': {'name': 'Servers100', 'port': 'eth0'}, "
             "'Ethernet112': {'name': 'ARISTA01T1', 'port': 'Ethernet1/1'}}"
         ))
Ejemplo n.º 8
0
 def test_minigraph_ethernet_interfaces(self):
     argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORT[\'Ethernet8\']"'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict("{'lanes': '37,38,39,40', 'description': 'Interface description', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/8', 'admin_status': 'up', 'speed': '1000'}")
     )
     argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORT[\'Ethernet12\']"'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict("{'lanes': '33,34,35,36', 'fec': 'rs', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/12', 'admin_status': 'up', 'speed': '100000', 'description': 'Interface description'}")
     )
    def test_minigraph_neighbor_metadata(self):
        argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_NEIGHBOR_METADATA"'

        expected_table = {
            'switch-01t1': {
                'lo_addr': '10.1.0.186/32',
                'mgmt_addr': '10.7.0.196/26',
                'hwsku': 'Force10-S6000',
                'type': 'LeafRouter',
                'deployment_id': '2'
            },
            'switch2-t0': {
                'hwsku': 'Force10-S6000',
                'lo_addr': '25.1.1.10',
                'mgmt_addr': '10.7.0.196/26',
                'type': 'ToRRouter'
            },
            'server1': {
                'hwsku': 'server-sku',
                'lo_addr': '10.10.10.1/32',
                'lo_addr_v6': 'fe80::0001/128',
                'mgmt_addr': '10.0.0.1/32',
                'type': 'Server'
            },
            'server2': {
                'hwsku': 'server-sku',
                'lo_addr': '10.10.10.2/32',
                'lo_addr_v6': 'fe80::0002/128',
                'mgmt_addr': '10.0.0.2/32',
                'type': 'Server'
            }
        }
        output = self.run_script(argument)
        self.maxDiff = None
        self.assertEqual(utils.to_dict(output.strip()), expected_table)
Ejemplo n.º 10
0
    def test_minigraph_tunnel_table(self):
        argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "TUNNEL"'
        expected_tunnel = {
            "MuxTunnel0": {
                "tunnel_type": "IPINIP",
                "dst_ip": "10.1.0.32",
                "dscp_mode": "uniform",
                "encap_ecn_mode": "standard",
                "ecn_mode": "copy_from_outer",
                "ttl_mode": "pipe"
            }
        }

        output = self.run_script(argument)
        self.assertEqual(utils.to_dict(output.strip()), expected_tunnel)

        # Validate tunnel config is as before when tunnel_qos_remap = disabled
        sample_graph_disabled_remap = os.path.join(
            self.test_dir, 'simple-sample-graph-case-remap-disabled.xml')
        argument = '-m "' + sample_graph_disabled_remap + '" -p "' + self.port_config + '" -v "TUNNEL"'

        output = self.run_script(argument)
        self.assertEqual(utils.to_dict(output.strip()), expected_tunnel)

        # Validate extra config is generated when tunnel_qos_remap = enabled
        sample_graph_enabled_remap = os.path.join(
            self.test_dir, 'simple-sample-graph-case-remap-enabled.xml')
        argument = '-m "' + sample_graph_enabled_remap + '" -p "' + self.port_config + '" -v "TUNNEL"'
        expected_tunnel = {
            "MuxTunnel0": {
                "tunnel_type": "IPINIP",
                "src_ip": "25.1.1.10",
                "dst_ip": "10.1.0.32",
                "dscp_mode": "uniform",
                "encap_ecn_mode": "standard",
                "ecn_mode": "copy_from_outer",
                "ttl_mode": "pipe",
                "decap_dscp_to_tc_map": "AZURE_TUNNEL",
                "decap_tc_to_pg_map": "AZURE_TUNNEL",
                "encap_tc_to_dscp_map": "AZURE_TUNNEL",
                "encap_tc_to_queue_map": "AZURE_TUNNEL"
            }
        }

        output = self.run_script(argument)
        self.assertEqual(utils.to_dict(output.strip()), expected_tunnel)
Ejemplo n.º 11
0
 def test_minigraph_acl(self):
     argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v ACL_TABLE'
     output = self.run_script(argument, True)
     self.assertEqual(
         utils.to_dict(output.strip().replace("Warning: Ignoring Control Plane ACL NTP_ACL without type\n", '')),
         utils.to_dict(
             "{'NTP_ACL': {'services': ['NTP'], 'type': 'CTRLPLANE', 'policy_desc': 'NTP_ACL', 'stage': 'ingress'}, "
             "'EVERFLOW': {'stage': 'ingress', 'type': 'MIRROR', 'ports': ['PortChannel01', 'PortChannel02', 'PortChannel03', 'PortChannel04', 'Ethernet4', 'Ethernet100'], 'policy_desc': 'EVERFLOW'}, "
             "'EVERFLOW_EGRESS': {'stage': 'egress', 'type': 'MIRROR', 'ports': ['PortChannel01', 'PortChannel02', 'PortChannel03', 'PortChannel04', 'Ethernet4', 'Ethernet100'], 'policy_desc': 'EVERFLOW_EGRESS'}, "
             "'ROUTER_PROTECT': {'services': ['SSH', 'SNMP'], 'type': 'CTRLPLANE', 'policy_desc': 'ROUTER_PROTECT', 'stage': 'ingress'}, "
             "'DATAACLINGRESS': {'stage': 'ingress', 'type': 'L3', 'ports': ['PortChannel01', 'PortChannel02', 'PortChannel03', 'PortChannel04'], 'policy_desc': 'DATAACLINGRESS'}, "
             "'SNMP_ACL': {'services': ['SNMP'], 'type': 'CTRLPLANE', 'policy_desc': 'SNMP_ACL', 'stage': 'ingress'}, "
             "'SSH_ACL': {'services': ['SSH'], 'type': 'CTRLPLANE', 'policy_desc': 'SSH_ACL', 'stage': 'ingress'}, "
             "'DATAACLEGRESS': {'stage': 'egress', 'type': 'L3', 'ports': ['PortChannel01', 'PortChannel02'], 'policy_desc': 'DATAACLEGRESS'}, "
             "'EVERFLOWV6': {'stage': 'ingress', 'type': 'MIRRORV6', 'ports': ['PortChannel01', 'PortChannel02', 'PortChannel03', 'PortChannel04', 'Ethernet4', 'Ethernet100'], 'policy_desc': 'EVERFLOWV6'}}"
         )
     )
 def test_minigraph_vlan_interfaces(self):
     argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "VLAN_INTERFACE"'
     output = self.run_script(argument)
     expected_table = {
         'Vlan1000|192.168.0.1/27': {},
         'Vlan1000': {
             'proxy_arp': 'enabled',
             'grat_arp': 'enabled'
         }
     }
     self.assertEqual(utils.to_dict(output.strip()), expected_table)
 def test_minigraph_vlan_members(self):
     argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN_MEMBER'
     output = self.run_script(argument)
     expected = {
                    'Vlan1000|Ethernet8': {'tagging_mode': 'untagged'},
                    'Vlan2000|Ethernet4': {'tagging_mode': 'untagged'}
                }
     self.assertEqual(
             utils.to_dict(output.strip()),
             expected
     )
Ejemplo n.º 14
0
    def test_minigraph_extra_ethernet_interfaces(self):
        argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORT"'
        output = self.run_script(argument)

        self.assertEqual(
            utils.to_dict(output.strip()),
            utils.to_dict(
                "{'Ethernet8': {'lanes': '37,38,39,40', 'description': 'Interface description', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/8', 'admin_status': 'up', 'speed': '1000'}, "
                "'Ethernet0': {'lanes': '29,30,31,32', 'description': 'fortyGigE0/0', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/0', 'admin_status': 'up', 'speed': '10000'}, "
                "'Ethernet4': {'lanes': '25,26,27,28', 'description': 'fortyGigE0/4', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/4', 'admin_status': 'up', 'speed': '25000'}, "
                "'Ethernet108': {'alias': 'fortyGigE0/108', 'pfc_asym': 'off', 'lanes': '81,82,83,84', 'description': 'fortyGigE0/108', 'mtu': '9100'}, "
                "'Ethernet100': {'alias': 'fortyGigE0/100', 'pfc_asym': 'off', 'lanes': '125,126,127,128', 'description': 'fortyGigE0/100', 'mtu': '9100'}, "
                "'Ethernet104': {'alias': 'fortyGigE0/104', 'pfc_asym': 'off', 'lanes': '85,86,87,88', 'description': 'fortyGigE0/104', 'mtu': '9100'}, "
                "'Ethernet68': {'alias': 'fortyGigE0/68', 'pfc_asym': 'off', 'lanes': '69,70,71,72', 'description': 'fortyGigE0/68', 'mtu': '9100'}, "
                "'Ethernet96': {'alias': 'fortyGigE0/96', 'pfc_asym': 'off', 'lanes': '121,122,123,124', 'description': 'fortyGigE0/96', 'mtu': '9100'}, "
                "'Ethernet124': {'alias': 'fortyGigE0/124', 'pfc_asym': 'off', 'lanes': '101,102,103,104', 'description': 'fortyGigE0/124', 'mtu': '9100'}, "
                "'Ethernet92': {'alias': 'fortyGigE0/92', 'pfc_asym': 'off', 'lanes': '113,114,115,116', 'description': 'fortyGigE0/92', 'mtu': '9100'}, "
                "'Ethernet120': {'alias': 'fortyGigE0/120', 'pfc_asym': 'off', 'lanes': '97,98,99,100', 'description': 'fortyGigE0/120', 'mtu': '9100'}, "
                "'Ethernet52': {'alias': 'fortyGigE0/52', 'pfc_asym': 'off', 'lanes': '53,54,55,56', 'description': 'fortyGigE0/52', 'mtu': '9100'}, "
                "'Ethernet56': {'alias': 'fortyGigE0/56', 'pfc_asym': 'off', 'lanes': '61,62,63,64', 'description': 'fortyGigE0/56', 'mtu': '9100'}, "
                "'Ethernet76': {'alias': 'fortyGigE0/76', 'pfc_asym': 'off', 'lanes': '73,74,75,76', 'description': 'fortyGigE0/76', 'mtu': '9100'}, "
                "'Ethernet72': {'alias': 'fortyGigE0/72', 'pfc_asym': 'off', 'lanes': '77,78,79,80', 'description': 'fortyGigE0/72', 'mtu': '9100'}, "
                "'Ethernet64': {'alias': 'fortyGigE0/64', 'pfc_asym': 'off', 'lanes': '65,66,67,68', 'description': 'fortyGigE0/64', 'mtu': '9100'}, "
                "'Ethernet32': {'alias': 'fortyGigE0/32', 'pfc_asym': 'off', 'lanes': '9,10,11,12', 'description': 'fortyGigE0/32', 'mtu': '9100'}, "
                "'Ethernet16': {'alias': 'fortyGigE0/16', 'pfc_asym': 'off', 'lanes': '41,42,43,44', 'description': 'fortyGigE0/16', 'mtu': '9100'}, "
                "'Ethernet36': {'alias': 'fortyGigE0/36', 'pfc_asym': 'off', 'lanes': '13,14,15,16', 'description': 'fortyGigE0/36', 'mtu': '9100'}, "
                "'Ethernet12': {'lanes': '33,34,35,36', 'fec': 'rs', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/12', 'admin_status': 'up', 'speed': '100000', 'description': 'Interface description'}, "
                "'Ethernet88': {'alias': 'fortyGigE0/88', 'pfc_asym': 'off', 'lanes': '117,118,119,120', 'description': 'fortyGigE0/88', 'mtu': '9100'}, "
                "'Ethernet116': {'alias': 'fortyGigE0/116', 'pfc_asym': 'off', 'lanes': '93,94,95,96', 'description': 'fortyGigE0/116', 'mtu': '9100'}, "
                "'Ethernet80': {'alias': 'fortyGigE0/80', 'pfc_asym': 'off', 'lanes': '105,106,107,108', 'description': 'fortyGigE0/80', 'mtu': '9100'}, "
                "'Ethernet112': {'alias': 'fortyGigE0/112', 'pfc_asym': 'off', 'lanes': '89,90,91,92', 'description': 'fortyGigE0/112', 'mtu': '9100'}, "
                "'Ethernet84': {'alias': 'fortyGigE0/84', 'pfc_asym': 'off', 'lanes': '109,110,111,112', 'description': 'fortyGigE0/84', 'mtu': '9100'}, "
                "'Ethernet48': {'alias': 'fortyGigE0/48', 'pfc_asym': 'off', 'lanes': '49,50,51,52', 'description': 'fortyGigE0/48', 'mtu': '9100'}, "
                "'Ethernet44': {'alias': 'fortyGigE0/44', 'pfc_asym': 'off', 'lanes': '17,18,19,20', 'description': 'fortyGigE0/44', 'mtu': '9100'}, "
                "'Ethernet40': {'alias': 'fortyGigE0/40', 'pfc_asym': 'off', 'lanes': '21,22,23,24', 'description': 'fortyGigE0/40', 'mtu': '9100'}, "
                "'Ethernet28': {'alias': 'fortyGigE0/28', 'pfc_asym': 'off', 'lanes': '1,2,3,4', 'description': 'fortyGigE0/28', 'mtu': '9100'}, "
                "'Ethernet60': {'alias': 'fortyGigE0/60', 'pfc_asym': 'off', 'lanes': '57,58,59,60', 'description': 'fortyGigE0/60', 'mtu': '9100'}, "
                "'Ethernet20': {'alias': 'fortyGigE0/20', 'pfc_asym': 'off', 'lanes': '45,46,47,48', 'description': 'fortyGigE0/20', 'mtu': '9100'}, "
                "'Ethernet24': {'alias': 'fortyGigE0/24', 'pfc_asym': 'off', 'lanes': '5,6,7,8', 'description': 'fortyGigE0/24', 'mtu': '9100'}}"
            )
        )
Ejemplo n.º 15
0
 def test_minigraph_neighbor_metadata(self):
     argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DEVICE_NEIGHBOR_METADATA"'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict("{" \
             "'switch-01t1': {" \
                 "'lo_addr': '10.1.0.186/32'," \
                 "'mgmt_addr': '10.7.0.196/26'," \
                 "'hwsku': 'Force10-S6000'," \
                 "'type': 'LeafRouter'," \
                 "'deployment_id': '2'" \
             "}," \
             "'switch2-t0': {" \
                 "'hwsku': 'Force10-S6000'," \
                 "'lo_addr': '25.1.1.10'," \
                 "'mgmt_addr': '10.7.0.196/26'," \
                 "'type': 'ToRRouter'" \
             "}" \
         "}")
     )
 def test_dhcp_table(self):
     argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "DHCP_RELAY"'
     expected = {
         'Vlan1000': {
             'dhcpv6_servers': ["fc02:2000::1", "fc02:2000::2"]
         },
         'Vlan2000': {
             'dhcpv6_servers': ["fc02:2000::3", "fc02:2000::4"]
         }
     }
     output = self.run_script(argument)
     self.assertEqual(utils.to_dict(output.strip()), expected)
 def test_minigraph_peer_switch(self):
     argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "PEER_SWITCH"'
     expected_table = {
         'switch2-t0': {
             'address_ipv4': "25.1.1.10"
         }
     }
     
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         expected_table
     )
Ejemplo n.º 18
0
    def test_minigraph_tunnel_table(self):
        argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "TUNNEL"'
        expected_tunnel = {
            "MuxTunnel0": {
                "tunnel_type": "IPINIP",
                "dst_ip": "10.1.0.32",
                "dscp_mode": "uniform",
                "encap_ecn_mode": "standard",
                "ecn_mode": "copy_from_outer",
                "ttl_mode": "pipe"
            }
        }

        output = self.run_script(argument)
        self.assertEqual(utils.to_dict(output.strip()), expected_tunnel)
Ejemplo n.º 19
0
    def test_minigraph_mux_cable_table(self):
        argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v "MUX_CABLE"'
        expected_table = {
            'Ethernet4': {
                'state': 'auto',
                'server_ipv4': '10.10.10.1/32',
                'server_ipv6': 'fe80::0001/128'
            },
            'Ethernet8': {
                'state': 'auto',
                'server_ipv4': '10.10.10.2/32',
                'server_ipv6': 'fe80::0002/128'
            }
        }

        output = self.run_script(argument)
        self.assertEqual(utils.to_dict(output.strip()), expected_table)
    def test_minigraph_vlans(self):
        argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v VLAN'
        output = self.run_script(argument)

        expected = {
            'Vlan1000': {
                'alias': 'ab1',
                'dhcp_servers': ['192.0.0.1', '192.0.0.2'],
                'dhcpv6_servers': ['fc02:2000::1', 'fc02:2000::2'],
                'vlanid': '1000',
                'mac': '00:aa:bb:cc:dd:ee',
            },
            'Vlan2000': {
                'alias': 'ab2',
                'dhcp_servers': ['192.0.0.1'],
                'dhcpv6_servers': ['fc02:2000::3', 'fc02:2000::4'],
                'vlanid': '2000'
            }
        }
        self.assertEqual(utils.to_dict(output.strip()), expected)
Ejemplo n.º 21
0
 def test_metadata_ntp(self):
     argument = '-m "' + self.sample_graph_metadata + '" -p "' + self.port_config + '" -v "NTP_SERVER"'
     output = self.run_script(argument)
     self.assertEqual(utils.to_dict(output.strip()),
                      utils.to_dict("{'10.0.10.1': {}, '10.0.10.2': {}}"))
Ejemplo n.º 22
0
    def test_minigraph_port_autonegotiation(self):
        # Test with a port_config.ini file which doesn't have an 'autoneg' column
        argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v "PORT"'
        output = self.run_script(argument)
        self.assertEqual(
            utils.to_dict(output.strip()),
            utils.to_dict(
                "{'Ethernet0': {'alias': 'fortyGigE0/0', 'pfc_asym': 'off', 'lanes': '29,30,31,32', 'description': 'fortyGigE0/0', 'mtu': '9100'}, "
                "'Ethernet4': {'lanes': '25,26,27,28', 'description': 'Servers0:eth0', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/4', 'admin_status': 'up', 'autoneg': '1', 'speed': '100000'}, "
                "'Ethernet8': {'lanes': '37,38,39,40', 'description': 'fortyGigE0/8', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/8', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet12': {'lanes': '33,34,35,36', 'description': 'fortyGigE0/12', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/12', 'admin_status': 'up'}, "
                "'Ethernet16': {'lanes': '41,42,43,44', 'description': 'fortyGigE0/16', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/16', 'admin_status': 'up'}, "
                "'Ethernet20': {'lanes': '45,46,47,48', 'description': 'fortyGigE0/20', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/20', 'admin_status': 'up'}, "
                "'Ethernet24': {'lanes': '5,6,7,8', 'description': 'fortyGigE0/24', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/24', 'admin_status': 'up'}, "
                "'Ethernet28': {'lanes': '1,2,3,4', 'description': 'fortyGigE0/28', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/28', 'admin_status': 'up'}, "
                "'Ethernet32': {'lanes': '9,10,11,12', 'description': 'fortyGigE0/32', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/32', 'admin_status': 'up'}, "
                "'Ethernet36': {'lanes': '13,14,15,16', 'description': 'fortyGigE0/36', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/36', 'admin_status': 'up'}, "
                "'Ethernet40': {'lanes': '21,22,23,24', 'description': 'fortyGigE0/40', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/40', 'admin_status': 'up'}, "
                "'Ethernet44': {'lanes': '17,18,19,20', 'description': 'fortyGigE0/44', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/44', 'admin_status': 'up'}, "
                "'Ethernet48': {'lanes': '49,50,51,52', 'description': 'fortyGigE0/48', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/48', 'admin_status': 'up'}, "
                "'Ethernet52': {'lanes': '53,54,55,56', 'description': 'fortyGigE0/52', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/52', 'admin_status': 'up'}, "
                "'Ethernet56': {'lanes': '61,62,63,64', 'description': 'fortyGigE0/56', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/56', 'admin_status': 'up'}, "
                "'Ethernet60': {'lanes': '57,58,59,60', 'description': 'fortyGigE0/60', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/60', 'admin_status': 'up'}, "
                "'Ethernet64': {'lanes': '65,66,67,68', 'description': 'fortyGigE0/64', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/64', 'admin_status': 'up'}, "
                "'Ethernet68': {'lanes': '69,70,71,72', 'description': 'fortyGigE0/68', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/68', 'admin_status': 'up'}, "
                "'Ethernet72': {'lanes': '77,78,79,80', 'description': 'fortyGigE0/72', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/72', 'admin_status': 'up'}, "
                "'Ethernet76': {'lanes': '73,74,75,76', 'description': 'fortyGigE0/76', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/76', 'admin_status': 'up'}, "
                "'Ethernet80': {'lanes': '105,106,107,108', 'description': 'fortyGigE0/80', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/80', 'admin_status': 'up'}, "
                "'Ethernet84': {'lanes': '109,110,111,112', 'description': 'fortyGigE0/84', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/84', 'admin_status': 'up'}, "
                "'Ethernet88': {'lanes': '117,118,119,120', 'description': 'fortyGigE0/88', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/88', 'admin_status': 'up'}, "
                "'Ethernet92': {'lanes': '113,114,115,116', 'description': 'fortyGigE0/92', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/92', 'admin_status': 'up'}, "
                "'Ethernet96': {'lanes': '121,122,123,124', 'description': 'fortyGigE0/96', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/96', 'admin_status': 'up'}, "
                "'Ethernet100': {'lanes': '125,126,127,128', 'description': 'Servers100:eth0', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/100', 'admin_status': 'up'}, "
                "'Ethernet104': {'alias': 'fortyGigE0/104', 'pfc_asym': 'off', 'lanes': '85,86,87,88', 'description': 'fortyGigE0/104', 'mtu': '9100'}, "
                "'Ethernet108': {'alias': 'fortyGigE0/108', 'pfc_asym': 'off', 'lanes': '81,82,83,84', 'description': 'fortyGigE0/108', 'mtu': '9100'}, "
                "'Ethernet112': {'lanes': '89,90,91,92', 'description': 'ARISTA01T1:Ethernet1/1', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/112', 'admin_status': 'up'}, "
                "'Ethernet116': {'lanes': '93,94,95,96', 'description': 'ARISTA02T1:Ethernet1/1', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/116', 'admin_status': 'up'}, "
                "'Ethernet120': {'lanes': '97,98,99,100', 'description': 'ARISTA03T1:Ethernet1/1', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/120', 'admin_status': 'up'}, "
                "'Ethernet124': {'lanes': '101,102,103,104', 'fec': 'rs', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/124', 'admin_status': 'up', 'speed': '100000', 'description': 'ARISTA04T1:Ethernet1/1'}}"
            ))

        # Test with a port_config.ini file which has an 'autoneg' column
        argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config_autoneg + '" -v "PORT"'
        output = self.run_script(argument)
        self.assertEqual(
            utils.to_dict(output.strip()),
            utils.to_dict(
                "{'Ethernet0': {'lanes': '29,30,31,32', 'description': 'fortyGigE0/0', 'mtu': '9100', 'alias': 'fortyGigE0/0', 'pfc_asym': 'off', 'autoneg': '0'}, "
                "'Ethernet4': {'lanes': '25,26,27,28', 'description': 'Servers0:eth0', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/4', 'admin_status': 'up', 'autoneg': '1', 'speed': '100000'}, "
                "'Ethernet8': {'lanes': '37,38,39,40', 'description': 'fortyGigE0/8', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/8', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet12': {'lanes': '33,34,35,36', 'description': 'fortyGigE0/12', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/12', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet16': {'lanes': '41,42,43,44', 'description': 'fortyGigE0/16', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/16', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet20': {'lanes': '45,46,47,48', 'description': 'fortyGigE0/20', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/20', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet24': {'lanes': '5,6,7,8', 'description': 'fortyGigE0/24', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/24', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet28': {'lanes': '1,2,3,4', 'description': 'fortyGigE0/28', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/28', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet32': {'lanes': '9,10,11,12', 'description': 'fortyGigE0/32', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/32', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet36': {'lanes': '13,14,15,16', 'description': 'fortyGigE0/36', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/36', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet40': {'lanes': '21,22,23,24', 'description': 'fortyGigE0/40', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/40', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet44': {'lanes': '17,18,19,20', 'description': 'fortyGigE0/44', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/44', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet48': {'lanes': '49,50,51,52', 'description': 'fortyGigE0/48', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/48', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet52': {'lanes': '53,54,55,56', 'description': 'fortyGigE0/52', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/52', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet56': {'lanes': '61,62,63,64', 'description': 'fortyGigE0/56', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/56', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet60': {'lanes': '57,58,59,60', 'description': 'fortyGigE0/60', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/60', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet64': {'lanes': '65,66,67,68', 'description': 'fortyGigE0/64', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/64', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet68': {'lanes': '69,70,71,72', 'description': 'fortyGigE0/68', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/68', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet72': {'lanes': '77,78,79,80', 'description': 'fortyGigE0/72', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/72', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet76': {'lanes': '73,74,75,76', 'description': 'fortyGigE0/76', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/76', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet80': {'lanes': '105,106,107,108', 'description': 'fortyGigE0/80', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/80', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet84': {'lanes': '109,110,111,112', 'description': 'fortyGigE0/84', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/84', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet88': {'lanes': '117,118,119,120', 'description': 'fortyGigE0/88', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/88', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet92': {'lanes': '113,114,115,116', 'description': 'fortyGigE0/92', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/92', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet96': {'lanes': '121,122,123,124', 'description': 'fortyGigE0/96', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/96', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet100': {'lanes': '125,126,127,128', 'description': 'Servers100:eth0', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/100', 'admin_status': 'up', 'autoneg': '0'}, "
                "'Ethernet104': {'lanes': '85,86,87,88', 'description': 'fortyGigE0/104', 'mtu': '9100', 'alias': 'fortyGigE0/104', 'pfc_asym': 'off', 'autoneg': '0'}, "
                "'Ethernet108': {'lanes': '81,82,83,84', 'description': 'fortyGigE0/108', 'mtu': '9100', 'alias': 'fortyGigE0/108', 'pfc_asym': 'off', 'autoneg': '0'}, "
                "'Ethernet112': {'lanes': '89,90,91,92', 'description': 'ARISTA01T1:Ethernet1/1', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/112', 'admin_status': 'up', 'autoneg': '1'}, "
                "'Ethernet116': {'lanes': '93,94,95,96', 'description': 'ARISTA02T1:Ethernet1/1', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/116', 'admin_status': 'up', 'autoneg': '1'}, "
                "'Ethernet120': {'lanes': '97,98,99,100', 'description': 'ARISTA03T1:Ethernet1/1', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/120', 'admin_status': 'up', 'autoneg': '1'}, "
                "'Ethernet124': {'lanes': '101,102,103,104', 'fec': 'rs', 'pfc_asym': 'off', 'mtu': '9100', 'alias': 'fortyGigE0/124', 'admin_status': 'up', 'autoneg': '1', 'speed': '100000', 'description': 'ARISTA04T1:Ethernet1/1'}}"
            ))
Ejemplo n.º 23
0
 def test_additional_json_data_level2_key(self):
     argument = '-a \'{"k1":{"k11":"v11","k12":"v12"},"k2":{"k22":"v22"}}\' --var-json k1 -K k11'
     output = self.run_script(argument)
     self.assertEqual(utils.to_dict(output.strip()),
                      utils.to_dict('{\n    "k11": "v11"\n}'))
Ejemplo n.º 24
0
 def test_minigraph_neighbors(self):
     argument = '-m "' + self.sample_graph_t0 + '" -p "' + self.port_config + '" -v "DEVICE_NEIGHBOR[\'Ethernet124\']"'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict("{'name': 'ARISTA04T1', 'port': 'Ethernet1/1'}"))
 def test_minigraph_console_port(self):
     argument = '-m "' + self.sample_graph + '" -p "' + self.port_config + '" -v CONSOLE_PORT'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict("{'1': {'baud_rate': '9600', 'remote_device': 'managed_device', 'flow_control': 1}}"))
 def test_minigraph_console_mgmt_feature(self):
     argument = '-m "' + self.sample_graph + '" -v CONSOLE_SWITCH'
     output = self.run_script(argument)
     self.assertEqual(
         utils.to_dict(output.strip()),
         utils.to_dict("{'console_mgmt': {'enabled': 'no'}}"))
Ejemplo n.º 27
0
    def test_minigraph_sub_port_interfaces(self, check_stderr=True):
        try:
            print('\n    Change device type to %s' % (BACKEND_TOR_ROUTER))
            if check_stderr:
                output = subprocess.check_output(
                    "sed -i \'s/%s/%s/g\' %s" %
                    (TOR_ROUTER, BACKEND_TOR_ROUTER, self.sample_graph_simple),
                    stderr=subprocess.STDOUT,
                    shell=True)
            else:
                output = subprocess.check_output(
                    "sed -i \'s/%s/%s/g\' %s" %
                    (TOR_ROUTER, BACKEND_TOR_ROUTER, self.sample_graph_simple),
                    shell=True)

            self.test_jinja_expression(self.sample_graph_simple,
                                       BACKEND_TOR_ROUTER)

            # INTERFACE table does not exist
            argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "INTERFACE"'
            output = self.run_script(argument)
            self.assertEqual(output.strip(), "")

            # PORTCHANNEL_INTERFACE table does not exist
            argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v "PORTCHANNEL_INTERFACE"'
            output = self.run_script(argument)
            self.assertEqual(output.strip(), "")

            # All the other tables stay unchanged
            self.test_var_json_data()
            self.test_minigraph_vlans()
            self.test_minigraph_vlan_members()
            self.test_minigraph_vlan_interfaces()
            self.test_minigraph_portchannels()
            self.test_minigraph_ethernet_interfaces()
            self.test_minigraph_extra_ethernet_interfaces()
            self.test_minigraph_vnet()
            self.test_minigraph_vxlan()

            # VLAN_SUB_INTERFACE
            argument = '-m "' + self.sample_graph_simple + '" -p "' + self.port_config + '" -v VLAN_SUB_INTERFACE'
            output = self.run_script(argument)
            print(output.strip())
            self.assertEqual(
                utils.to_dict(output.strip()),
                utils.to_dict("{('PortChannel01.10', '10.0.0.56/31'): {}, "
                              "'Ethernet0.10': {'admin_status': 'up'}, "
                              "('Ethernet0.10', '10.0.0.58/31'): {}, "
                              "('PortChannel01.10', 'FC00::71/126'): {}, "
                              "'PortChannel01.10': {'admin_status': 'up'}, "
                              "('Ethernet0.10', 'FC00::75/126'): {}}"))

        finally:
            print('\n    Change device type back to %s' % (TOR_ROUTER))
            if check_stderr:
                output = subprocess.check_output(
                    "sed -i \'s/%s/%s/g\' %s" %
                    (BACKEND_TOR_ROUTER, TOR_ROUTER, self.sample_graph_simple),
                    stderr=subprocess.STDOUT,
                    shell=True)
            else:
                output = subprocess.check_output(
                    "sed -i \'s/%s/%s/g\' %s" %
                    (BACKEND_TOR_ROUTER, TOR_ROUTER, self.sample_graph_simple),
                    shell=True)

            self.test_jinja_expression(self.sample_graph_simple, TOR_ROUTER)