def _build_config(self, num_ports, num_ints): self.ixn.new_config() self.logger.info( 'Build config with {} ports and {} interfaces per port'.format( num_ports, num_ints)) for port_num in range(1, num_ports + 1): port_name = 'Port {}'.format(port_num) self.logger.info('Create Port "{}"'.format(port_name)) ixn_port = IxnPort(name=port_name, parent=self.ixn.root) for int_num in range(1, num_ints + 1): int_name = '{} int {}'.format(port_name, int_num) self.logger.info('Build Interface "{}"'.format(int_name)) ixn_int = IxnInterface(name=int_name, parent=ixn_port) ixn_int_eth = ixn_int.get_child_static('ethernet') macAddress = '00:11:22:33:{}:{}'.format(port_num, int_num) ixn_int_eth.set_attributes(macAddress=macAddress) ixn_int_ip = IxnObject(parent=ixn_int, objType='ipv4') ip = '1.2.{}.{}'.format(port_num, int_num) ixn_int_ip.set_attributes(ip=ip) self.ixn.commit() ixn_ports = OrderedDict() for ixn_port in self.ixn.root.get_children('vport'): ixn_ports[ixn_port] = ixn_port.get_children('interface') return ixn_ports
def __init__(self, **data): """ Create new FCoE forwarder endpoint object in the API. :param parent: parent port object. """ data['parent'] = IxnObject(parent=data['parent'].get_child_static('protocolStack'), objType='ethernet') data['objType'] = 'fcoeFwdEndpoint' super(self.__class__, self).__init__(**data)
def testBasicConfig(self): """ Test configuration build with basic objects - ports, interfaces, traffic items... """ self.logger.info(IxnTestOffline.testBasicConfig.__doc__) num_ports = 2 num_ints = 2 ixn_ports = self._build_config(num_ports, num_ints) assert (len(ixn_ports) == num_ports) for ixn_port in ixn_ports: assert (len(ixn_ports[ixn_port]) == num_ints) ixn_protocols = list(ixn_ports.keys())[0].get_child_static('protocols') ixn_bgp = ixn_protocols.get_child_static('bgp') ixn_bgp.set_attributes(enabled=True) ixn_ipv4_neighbor = IxnObject(parent=ixn_bgp, objType='neighborRange') ixn_ipv4_neighbor.set_attributes(bgpId='1.1.1.1') ixn_ipv4_neighbor.set_attributes( interfaces=list(ixn_ports.values())[0][0].obj_ref()) ixn_ipv4_neighbor.set_attributes(localIpAddress='0.0.0.0') ixn_ti = IxnL23TrafficItem(name='One interface') ixn_ti.set_attributes(trafficType='ipv4') ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') sources = [ list(ixn_ports)[0].get_objects_by_type('interface')[0].obj_ref() ] destinations = [ list(ixn_ports)[1].get_objects_by_type('interface')[0].obj_ref() ] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) self._save_config()
def testFlowGroups(self): """ Test configuration build with various flow group types. """ self.logger.info(IxnTestOffline.testFlowGroups.__doc__) num_ports = 2 num_ints = 2 ixn_ports = self._build_config(num_ports, num_ints) ixn_ti = IxnL23TrafficItem(name='IPv4 TI with two EPs') ixn_ti.set_attributes(trafficType='ipv4') ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') sources = [ixn_ports.keys()[0].obj_ref()] destinations = [ixn_ports.keys()[1].obj_ref()] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') sources = [ixn_ports.keys()[1].obj_ref()] destinations = [ixn_ports.keys()[0].obj_ref()] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) ixn_ti = IxnL23TrafficItem(name='Raw TI with two EPs') ixn_ti.set_attributes(trafficType='raw') ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') ixn_ti_es.api.commit() sources = [ixn_ports.keys()[0].obj_ref() + '/protocols'] destinations = [ixn_ports.keys()[1].obj_ref() + '/protocols'] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) ixn_ti_es.api.commit() ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') ixn_ti_es.api.commit() sources = [ixn_ports.keys()[1].obj_ref() + '/protocols'] destinations = [ixn_ports.keys()[0].obj_ref() + '/protocols'] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) ixn_ti_es.api.commit() ixn_tis = self.ixn.root.get_child_static('traffic').get_children( 'trafficItem') assert (len(ixn_tis) == 2) ixn_eps = ixn_tis[0].get_children('endpointSet') assert (len(ixn_eps) == 2) ixn_eps = ixn_tis[1].get_children('endpointSet') assert (len(ixn_eps) == 2) self._save_config()
def test_flow_groups(self, api): """ Test configuration build with various flow group types. todo: refactor with NGPF """ if self._is_linux_server(): pytest.skip('server does not support classical protocols') num_ports = 2 num_ints = 2 ixn_ports = self._build_config(num_ports, num_ints) ixn_ti = IxnL23TrafficItem(name='IPv4 TI with two EPs') ixn_ti.set_attributes(trafficType='ipv4') ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') sources = [list(ixn_ports.keys())[0].ref] destinations = [list(ixn_ports.keys())[1].ref] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') sources = [list(ixn_ports.keys())[1].ref] destinations = [list(ixn_ports.keys())[0].ref] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) ixn_ti = IxnL23TrafficItem(name='Raw TI with two EPs') ixn_ti.set_attributes(trafficType='raw') ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') ixn_ti_es.api.commit() sources = [list(ixn_ports.keys())[0].ref + '/protocols'] destinations = [list(ixn_ports.keys())[1].ref + '/protocols'] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) ixn_ti_es.api.commit() ixn_ti_es = IxnObject(parent=ixn_ti, objType='endpointSet') ixn_ti_es.api.commit() sources = [list(ixn_ports.keys())[1].ref + '/protocols'] destinations = [list(ixn_ports.keys())[0].ref + '/protocols'] ixn_ti_es.set_attributes(sources=sources, destinations=destinations) ixn_ti_es.api.commit() ixn_tis = self.ixn.root.get_child_static('traffic').get_children( 'trafficItem') assert (len(ixn_tis) == 2) ixn_eps = ixn_tis[0].get_children('endpointSet') assert (len(ixn_eps) == 2) ixn_eps = ixn_tis[1].get_children('endpointSet') assert (len(ixn_eps) == 2) self._save_config()