Beispiel #1
0
 def get_all_models(self, args):
     self.args = args
     self.elan_elan_instances = elan.elan_instances(Model.CONFIG, args)
     self.elan_elan_interfaces = elan.elan_interfaces(Model.CONFIG, args)
     self.id_manager_id_pools = id_manager.id_pools(Model.CONFIG, args)
     self.ietf_interfaces_interfaces = ietf_interfaces.interfaces(
         Model.CONFIG, args)
     self.ietf_interfaces_interfaces_state = ietf_interfaces.interfaces_state(
         Model.OPERATIONAL, args)
     self.interface_service_bindings_service_bindings = \
         interface_service_bindings.service_bindings(Model.CONFIG, args)
     self.itm_state_tunnels_state = itm_state.tunnels_state(
         Model.OPERATIONAL, args)
     self.l3vpn_vpn_interfaces = l3vpn.vpn_instance_to_vpn_id(
         Model.CONFIG, args)
     self.mip_mac = mip.mac(Model.CONFIG, args)
     self.network_topology_network_topology_config = network_topology.network_topology(
         Model.CONFIG, args)
     self.network_topology_network_topology_operational = network_topology.network_topology(
         Model.CONFIG, args)
     self.neutron_neutron = neutron.neutron(Model.CONFIG, args)
     self.odl_fib_fib_entries = odl_fib.fib_entries(Model.CONFIG, args)
     self.odl_interface_meta_if_index_interface_map = \
         odl_interface_meta.if_indexes_interface_map(Model.OPERATIONAL, args)
     self.odl_inventory_nodes_config = opendaylight_inventory.nodes(
         Model.CONFIG, args)
     self.odl_inventory_nodes_operational = opendaylight_inventory.nodes(
         Model.OPERATIONAL, args)
     self.odl_l3vpn_vpn_instance_to_vpn_id = odl_l3vpn.vpn_instance_to_vpn_id(
         Model.CONFIG, args)
Beispiel #2
0
def analyze_interface(args):
    ietf_interfaces_interfaces = ietf_interfaces.interfaces(Model.CONFIG, args)
    ifaces = ietf_interfaces_interfaces.get_clist_by_key()

    ietf_interfaces_interfaces_state = ietf_interfaces.interfaces_state(
        Model.OPERATIONAL, args)
    ifstates = ietf_interfaces_interfaces_state.get_clist_by_key()

    if not args.ifname:
        print_keys(ifaces, ifstates)
        exit(1)

    ifname = args.ifname
    iface, ifstate, port, tunnel, tunState = by_ifname(args, ifname, ifstates,
                                                       ifaces)
    print "InterfaceConfig: \n{}".format(utils.format_json(args, iface))
    print "InterfaceState: \n{}".format(utils.format_json(args, ifstate))
    if port:
        print "NeutronPort: \n{}".format(utils.format_json(args, port))
        # analyze_neutron_port(port, iface, ifstate)
        return
    if tunnel:
        print "Tunnel: \n{}".format(utils.format_json(args, tunnel))
    if tunState:
        print "TunState: \n{}".format(utils.format_json(args, tunState))
Beispiel #3
0
    def get_models(self, args, models):
        self.args = args

        if "elan_elan_instances" in models:
            self.elan_elan_instances = elan.elan_instances(Model.CONFIG, args)
        if "elan_elan_interfaces" in models:
            self.elan_elan_interfaces = elan.elan_interfaces(
                Model.CONFIG, args)
        if "id_manager_id_pools" in models:
            self.id_manager_id_pools = id_manager.id_pools(Model.CONFIG, args)
        if "ietf_interfaces_interfaces" in models:
            self.ietf_interfaces_interfaces = ietf_interfaces.interfaces(
                Model.CONFIG, args)
        if "ietf_interfaces_interfaces_state" in models:
            self.ietf_interfaces_interfaces_state = ietf_interfaces.interfaces_state(
                Model.OPERATIONAL, args)
        if "interface_service_bindings_service_bindings" in models:
            self.interface_service_bindings_service_bindings = \
                interface_service_bindings.service_bindings(Model.CONFIG, args)
        if "itm_state_dpn_endpoints" in models:
            self.itm_state_dpn_endpoints = itm_state.dpn_endpoints(
                Model.CONFIG, args)
        if "itm_state_tunnels_state" in models:
            self.itm_state_tunnels_state = itm_state.tunnels_state(
                Model.OPERATIONAL, args)
        if "l3vpn_vpn_interfaces" in models:
            self.l3vpn_vpn_interfaces = l3vpn.vpn_interfaces(
                Model.CONFIG, args)
        if "mip_mac" in models:
            self.mip_mac = mip.mac(Model.CONFIG, args)
        if "network_topology_network_topology" in models:
            self.neutron_neutron = neutron.neutron(Model.CONFIG, args)
        if "network_topology_network_topology" in models:
            self.network_topology_network_topology = network_topology.network_topology(
                Model.CONFIG, args)
        if "network_topology_network_topology_operational" in models:
            self.network_topology_network_topology_operational = \
                network_topology.network_topology(Model.OPERATIONAL, args)
        if "neutron_neutron" in models:
            self.neutron_neutron = neutron.neutron(Model.CONFIG, args)
        if "odl_fib_fib_entries" in models:
            self.odl_fib_fib_entries = odl_fib.fib_entries(Model.CONFIG, args)
        if "odl_interface_meta_if_index_interface_map" in models:
            self.odl_interface_meta_if_index_interface_map = \
                odl_interface_meta.if_indexes_interface_map(Model.OPERATIONAL, args)
        if "odl_inventory_nodes" in models:
            self.odl_inventory_nodes = opendaylight_inventory.nodes(
                Model.CONFIG, args)
        if "odl_inventory_nodes_operational" in models:
            self.odl_inventory_nodes_operational = opendaylight_inventory.nodes(
                Model.OPERATIONAL, args)
        if "odl_l3vpn_vpn_instance_to_vpn_id" in models:
            self.odl_l3vpn_vpn_instance_to_vpn_id = odl_l3vpn.vpn_instance_to_vpn_id(
                Model.CONFIG, args)
Beispiel #4
0
    def get_models(self, args, models):
        self.args = args

        if "elan_elan_instances" in models:
            self.elan_elan_instances = elan.elan_instances(Model.CONFIG, args)
        if "elan_elan_interfaces" in models:
            self.elan_elan_interfaces = elan.elan_interfaces(Model.CONFIG, args)
        if "id_manager_id_pools" in models:
            self.id_manager_id_pools = id_manager.id_pools(Model.CONFIG, args)
        if "ietf_interfaces_interfaces" in models:
            self.ietf_interfaces_interfaces = ietf_interfaces.interfaces(Model.CONFIG, args)
        if "ietf_interfaces_interfaces_state" in models:
            self.ietf_interfaces_interfaces_state = ietf_interfaces.interfaces_state(Model.OPERATIONAL, args)
        if "interface_service_bindings_service_bindings" in models:
            self.interface_service_bindings_service_bindings = \
                interface_service_bindings.service_bindings(Model.CONFIG, args)
        if "itm_state_dpn_endpoints" in models:
            self.itm_state_dpn_endpoints = itm_state.dpn_endpoints(Model.CONFIG, args)
        if "itm_state_tunnels_state" in models:
            self.itm_state_tunnels_state = itm_state.tunnels_state(Model.OPERATIONAL, args)
        if "l3vpn_vpn_interfaces" in models:
            self.l3vpn_vpn_interfaces = l3vpn.vpn_interfaces(Model.CONFIG, args)
        if "mip_mac" in models:
            self.mip_mac = mip.mac(Model.CONFIG, args)
        if "network_topology_network_topology" in models:
            self.neutron_neutron = neutron.neutron(Model.CONFIG, args)
        if "network_topology_network_topology" in models:
            self.network_topology_network_topology = network_topology.network_topology(Model.CONFIG, args)
        if "network_topology_network_topology_operational" in models:
            self.network_topology_network_topology_operational = \
                network_topology.network_topology(Model.OPERATIONAL, args)
        if "neutron_neutron" in models:
            self.neutron_neutron = neutron.neutron(Model.CONFIG, args)
        if "odl_fib_fib_entries" in models:
            self.odl_fib_fib_entries = odl_fib.fib_entries(Model.CONFIG, args)
        if "odl_interface_meta_if_index_interface_map" in models:
            self.odl_interface_meta_if_index_interface_map = \
                odl_interface_meta.if_indexes_interface_map(Model.OPERATIONAL, args)
        if "odl_inventory_nodes" in models:
            self.odl_inventory_nodes = opendaylight_inventory.nodes(Model.CONFIG, args)
        if "odl_inventory_nodes_operational" in models:
            self.odl_inventory_nodes_operational = opendaylight_inventory.nodes(Model.OPERATIONAL, args)
        if "odl_l3vpn_vpn_instance_to_vpn_id" in models:
            self.odl_l3vpn_vpn_instance_to_vpn_id = odl_l3vpn.vpn_instance_to_vpn_id(Model.CONFIG, args)
Beispiel #5
0
 def setUp(self):
     logg.Logger(logging.INFO, logging.INFO)
     args = tests.Args(path=tests.get_resources_path())
     self.interfaces = interfaces(Model.CONFIG, args)
     self.interfaces_state = interfaces_state(Model.OPERATIONAL, args)
Beispiel #6
0
def analyze_trunks(args):
    ietf_interfaces_interfaces = ietf_interfaces.interfaces(Model.CONFIG, args)
    # ietf_interfaces_interfaces_state = ietf_interfaces.interfaces_state(Model.OPERATIONAL, args)
    l3vpn_vpn_interfaces = l3vpn.vpn_instance_to_vpn_id(Model.CONFIG, args)
    neutron_neutron = neutron.neutron(Model.CONFIG, args)

    nports = neutron_neutron.get_ports_by_key()
    ntrunks = neutron_neutron.get_trunks_by_key()
    vpninterfaces = l3vpn_vpn_interfaces.get_clist_by_key()
    ifaces = ietf_interfaces_interfaces.get_clist_by_key()
    # ifstates = ietf_interfaces_interfaces_state.get_clist_by_key()
    subport_dict = {}
    for v in ntrunks.itervalues():
        nport = nports.get(v.get('port-id'))
        s_subports = []
        for subport in v.get('sub-ports'):
            sport_id = subport.get('port-id')
            snport = nports.get(sport_id)
            svpniface = vpninterfaces.get(sport_id)
            siface = ifaces.get(sport_id)
            # sifstate = ifstates.get(sport_id)
            subport['SubNeutronPort'] = 'Correct' if snport else 'Wrong'
            subport['SubVpnInterface'] = 'Correct' if svpniface else 'Wrong'
            subport['ofport'] = Model.get_ofport_from_ncid()
            if siface:
                vlan_mode = siface.get('odl-interface:l2vlan-mode')
                parent_iface_id = siface.get('odl-interface:parent-interface')
                if vlan_mode != 'trunk-member':
                    subport['SubIface'] = 'WrongMode'
                elif parent_iface_id != v.get('port-id'):
                    subport['SubIface'] = 'WrongParent'
                elif siface.get('odl-interface:vlan-id') != subport.get(
                        'segmentation-id'):
                    subport['SubIface'] = 'WrongVlanId'
                else:
                    subport['SubIface'] = 'Correct'
            else:
                subport['SubIface'] = 'Wrong'
                # s_subport = 'SegId:{}, PortId:{}, SubNeutronPort:{}, SubIface:{}, SubVpnIface:{}'.format(
                #     subport.get('segmentation-id'), subport.get('port-id'),
                #     subport.get('SubNeutronPort'),
                #     subport.get('SubIface'),
                #     subport.get('SubVpnInterface'))
            s_subports.append(subport)
            subport_dict[subport['port-id']] = subport
            s_trunk = 'TrunkName:{}, TrunkId:{}, PortId:{}, NeutronPort:{}, SubPorts:{}'.format(
                v.get('name'), v.get('uuid'), v.get('port-id'),
                'Correct' if nport else 'Wrong',
                utils.format_json(args, s_subports))
            print s_trunk
            print '\n------------------------------------'
            print 'Analyzing Flow status for SubPorts'
            print '------------------------------------'
            for flow in utils.sort(flows.get_all_flows(['ifm'], ['vlanid']),
                                   'ifname'):
                subport = subport_dict.get(flow.get('ifname')) or None
                vlanid = subport.get('segmentation-id') if subport else None
                ofport = subport.get('ofport') if subport else None
                flow_status = 'Okay'
                if flow.get('ofport') and flow.get('ofport') != ofport:
                    flow_status = 'OfPort mismatch for SubPort:{} and Flow:{}'.format(
                        subport, flow.get('flow'))
                if flow.get('vlanid') and flow.get('vlanid') != vlanid:
                    flow_status = 'VlanId mismatch for SubPort:{} and Flow:{}'.format(
                        subport, flow.get('flow'))
                if subport:
                    print 'SubPort:{},Table:{},FlowStatus:{}'.format(
                        subport.get('port-id'), flow.get('table'), flow_status)