def invoke(self, command, *args, **kwargs): """ Pass-through for ixnetwork.py functions (ixnetwork.py? or something else?) """ lib = 'ngpf' if re.search(r'^IxNet::', command): lib = 'ixnet' command = command.replace('IxNet::', '', 1) # Initialize IxNet if not set up already if not self._ixiaixnet: from IxNetwork import IxNet # pylint: disable=import-error self._ixiaixnet = IxNet() self._connect_ixnet() if 'port_handle' in kwargs.keys(): port_handle = kwargs['port_handle'] if isinstance(port_handle, six.string_types): port_handle = port_handle.split(' ') if port_handle[0] in self.intf_to_port_map.keys(): new_port_handle = list() for intf in port_handle: new_port_handle.append(self.port_to_handle_map[self.intf_to_port_map[intf]]) kwargs['port_handle'] = ' '.join(new_port_handle) # User contributed module if command in self.user_functions: self.log(level="info", message="Invoking Juniper IXIA function " + command + " with parameters " + str(kwargs)) result = self.user_functions[command](self, **kwargs) self.log(level="info", message="Invocation of Juniper IXIA function " + command + " completed with result: " + str(result)) return result # ngpf method elif lib == 'ngpf': self.log(level="info", message="Invoking IXIA ngpf method " + command + " with parameters " + str(kwargs)) ixia_method = getattr(self._ixiangpf, command) result = ixia_method(**kwargs) if result['status'] == '0': raise TobyIxiaException("Invocation of IXIA method " + command + " failed with result: " + str(result), host_obj=self) else: self.log(level="debug", message="Invocation of IXIA method " + command + " succeeded with result: " + str(result)) return result # ixnet method elif lib == 'ixnet': ixnet_args = kwargs.get('ixnet_args', None) if not ixnet_args and len(args) > 0: # args came in via python *args instead of via kwargs(ixnet_args) ixnet_args = args self.log("INFO", message="Invoking IXIA ixnet API '" +command + "' with parameters " + str(ixnet_args)) ixia_method = getattr(self._ixiaixnet, command) if ixnet_args: result = ixia_method(*ixnet_args) else: result = ixia_method() self.log("INFO", message="Invocation of IXIA API '" + command + "' completed with result: " + str(result)) return result
def __init__(self, **ixiad): self.connected = True self.stats = OrderedDict() self.rowstats = OrderedDict() self.user_stats = OrderedDict() self.flow_stats = OrderedDict() self.user_flow_stats = OrderedDict() self.traffic_items = list() self.traffic_names = list() self.name = ixiad.get('name', 'ixnet') self.server = ixiad.get('server') self.chassis = ixiad.get('chassis') self.tclport = ixiad.get('port') self.pattern = ixiad.get('pattern', None) self.ixtis = None # log_columns defines those columns to be printed in log file # they must be sub-list of stats_long_names self.log_columns = [ 'Tx Frames', 'Rx Frames', 'Frames Delta', 'Loss %', 'Packet Loss Duration (ms)', 'Tx Frame Rate', 'Store-Forward Avg Latency (ns)' ] # stats_long_names defines those columns interested by tester # they must be sub-list of real Ixia view columnCaptions self.stats_long_names = [ 'Tx Frames', 'Rx Frames', 'Frames Delta', 'Loss %', 'Packet Loss Duration (ms)', 'Tx Frame Rate', 'Rx Frame Rate', 'Store-Forward Avg Latency (ns)', 'Store-Forward Min Latency (ns)', 'Store-Forward Min Latency (ns)' ] # stats_short_names defines short-names that correspond to # stats_long_names (one by one) self.stats_short_names = [ 'tx', 'rx', 'delta', 'loss%', 'loss_ms', 'tx_rate', 'rx_rate', 'avg_latency' 'min_latency' 'max_latency' ] # run parent constructot IxNet.__init__(self) # set stats_root self.stats_root = self._root + 'statistics/view:"Traffic Item Statistics"' self.stats_user = self._root + 'statistics/view:"User Defined Statistics"' # try connect and set traffic try: self.connect(self.server, '-port', self.tclport, '-version', '8.01') mylog.info('Ixia %s:%s connected' % (self.server, self.tclport)) if self.pattern: self.set_traffic(pattern=self.pattern, commit=True) except: mylog.exception('Ixia connection error!') self.connected = False
def _ixnetwork_session_handler(self, context): try: self.ixnetwork_session.getVersion() except (AttributeError, Exception) as e: if e.__class__ != AttributeError: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] _ixnetwork_session_handler %s:%s" % (self.resource_name, e.__class__.__name__, e.message)) utility_server_name, utility_server_resource = self.utility_server.popitem() api_address = utility_server_resource.FullAddress api_port = context.resource.attributes['API Port'] api_version = context.resource.attributes['API Version'] try: self.ixnetwork_session = IxNet() self.ixnetwork_session.connect(api_address, '-port', api_port, '-version', api_version) self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Connected to API v%s at %s:%s" % (self.resource_name, api_version, api_address, api_port)) except Exception as e: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Failed to connect to API client v%s at %s:%s, %s:%s" % (self.resource_name, api_version, api_address, api_port, e.__class__.__name__, e.message)) raise return
################################################################################ if 'py' not in dir(): class TestFailedError(Exception): pass class Py: pass py = Py() py.ports = [('10.205.15.62', 3, 5), ('10.205.15.62', 3, 6)] py.ixTclServer = '10.205.15.224' py.ixTclPort = 8009 ################################################################################ # Import the IxNet library ################################################################################ from IxNetwork import IxNet import time ixNet = IxNet() ################################################################################ # Connect to IxNet client ################################################################################ ixNet.connect(py.ixTclServer, '-port', py.ixTclPort, '-version', '7.40') ################################################################################ # Cleaning up IxNetwork ################################################################################ print ("Cleaning up IxNetwork...") ixNet.execute('newConfig') ################################################################################ # Adding ports to configuration
pass class Py: pass py = Py() py.ports = [('10.205.15.62', 3, 5), ('10.205.15.62', 3, 6)] py.ixTclServer = '10.205.15.224' py.ixTclPort = 8009 ################################################################################ # Import the IxNet library ################################################################################ from IxNetwork import IxNet import time ixNet = IxNet() ################################################################################ # Connect to IxNet client ################################################################################ ixNet.connect(py.ixTclServer, '-port', py.ixTclPort, '-version', '7.40') ################################################################################ # Cleaning up IxNetwork ################################################################################ print "Cleaning up IxNetwork..." ixNet.execute('newConfig') ################################################################################ # Adding ports to configuration
port1 = ['2', '3'] # where values are: {<card> <port>} port2 = ['2', '4'] # where values are: {<card> <port>} PFCriteria_Higher = ['Initiator Tx Rate (Mbps)', '40'] # statistic from Application Traffic item Statistics view that has to be higher than given value PFCriteria_Lower = ['Flows Failed', '40'] # statistic from Application Traffic item Statistics view that has to be lower than given value #--------------------------------------------------------- # Connecting to TCL Server and loading required packages #--------------------------------------------------------- from IxNetwork import IxNet ixNet = IxNet() import time print("Connecting to TCL Server...") ixNet.connect('127.0.0.1', '-version', applicationVersion, '-port', '8449') ixNet.execute('newConfig') root = ixNet.getRoot() availableHW = ixNet.getRoot() + 'availableHardware' #------------------------------------ # Adding chassis #------------------------------------ print("Adding chassis to the configuration") chassis1 = ixNet.add(availableHW, 'chassis') chassis1ID = ixNet.remapIds(chassis1)[0]
# # ################################################################################ # import Python packages import time import os from IxNetwork import IxNet # create an instance of the IxNet class ixNet = IxNet() # create absolute path for the config and load it print("Connecting to server: localhost") ixNet.connect('localhost', '-port', 8009, '-version', '7.40') print("Cleaning up IxNetwork...") ixNet.execute('newConfig') # all objects are under root root = ixNet.getRoot()
pass class Py: pass py = Py() py.ports = [('10.205.15.62', 3, 5), ('10.205.15.62', 3, 6)] py.ixTclServer = '10.205.15.224' py.ixTclPort = 8009 ################################################################################ # Import the IxNet library ################################################################################ from IxNetwork import IxNet import time ixNet = IxNet() ################################################################################ # Connect to IxNet client ################################################################################ ixNet.connect(py.ixTclServer, '-port', py.ixTclPort, '-version', '7.40') ################################################################################ # Cleaning up IxNetwork ################################################################################ print "Cleaning up IxNetwork..." ixNet.execute('newConfig') ################################################################################
class Py: pass py = Py() py.ports = [('10.205.15.62', 3, 5), ('10.205.15.62', 3, 6)] py.ixTclServer = '10.205.15.224' py.ixTclPort = 8009 ################################################################################ # Import the IxNet library ################################################################################ from IxNetwork import IxNet import time ixNet = IxNet() ################################################################################ # Connect to IxNet client ################################################################################ ixNet.connect(py.ixTclServer, '-port', py.ixTclPort, '-version', '7.40') ################################################################################ # Cleaning up IxNetwork ################################################################################ print "Cleaning up IxNetwork..." ixNet.execute('newConfig') ################################################################################ # Adding ports to configuration
# Description: # # Script will create following: # # 1. Adding ports to configuration # # 2. Create VxLanV6 with IPv4 hosts # # 3. Enable unicast info # # 4. Start all protocols # # 5. Check stats and learned info # # 6. Stop all protocols # # # ################################################################################ import time import os from IxNetwork import IxNet ixNet = IxNet() print("Connecting to the server") ixNet.connect('10.39.65.1', '-setAttribute', 'strict', '-port', 9863, '-version', '9.00') print("Cleaning up IxNetwork...") ixNet.execute('newConfig') root = ixNet.getRoot() print("\nAdd virtual ports to configuration...") vports = ixNet.getList(ixNet.getRoot(), 'vport') print('Add chassis in IxNetwork...') chassis = '10.39.64.117'
# The sample was tested on an FlexAP10G16S module. # # Software: # # IxOS 6.80 EA # # IxNetwork 7.40 EA # # # ################################################################################ # END HARNESS VARS ************************************************************ import time import os from IxNetwork import IxNet ixNet = IxNet() print ("Connecting to the server") ixNet.connect('ixro-smqa-r-22', '-setAttribute', 'strict', '-port', 8009, '-version', '7.40') print ("Cleaning up IxNetwork...") ixNet.execute('newConfig') # all objects are under root root = ixNet.getRoot() print ("\nAdd virtual ports to configuration...") vports = [] vports.append(ixNet.add(root, 'vport')) vports.append(ixNet.add(root, 'vport')) ixNet.commit()
# Description: # # The script creates and configures 2 DHCP stacks. # # Set/Get multivalue parameters. # # Start/Stop protocols. # # Module: # # The sample was tested on an FlexAP10G16S module. # # # ################################################################################ # import Python packages import time import os from IxNetwork import IxNet # create an instance of the IxNet class ixNet = IxNet() # create absolute path for the config and load it print("Connecting to server: localhost") ixNet.connect('localhost', '-port', 8009, '-version', '7.30') print("Cleaning up IxNetwork...") ixNet.execute('newConfig') # all objects are under root root = ixNet.getRoot() print("\nAdd virtual ports to configuration...") vports = [] vports.append(ixNet.add(root, 'vport')) vports.append(ixNet.add(root, 'vport'))
class IxiaIxNetworkDriver(ResourceDriverInterface): def cleanup(self): """ Destroy the driver session, this function is called everytime a driver instance is destroyed This is a good place to close any open sessions, finish writing to log files """ return def __init__(self): """ ctor must be without arguments, it is created with reflection at run time """ self.cs_session = None self.ixnetwork_session = None self.logger = None self.cards_in_chassis = 0 self.chassis_card = {} self.reservation_description = None self.reservation_id = None self.resource_name = None return def initialize(self, context): """ Initialize the driver session, this function is called everytime a new instance of the driver is created This is a good place to load and cache the driver configuration, initiate sessions etc. :param InitCommandContext context: the context the command runs on """ self.logger = get_qs_logger() return def add_card(self, context, card_address, num_ports): if card_address in self.chassis_card.values(): existing_card = self.chassis_card.keys()[self.chassis_card.values().index(card_address)] self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Card %02d(%s) already exists in the chassis" % (self.resource_name, existing_card, self.chassis_card[existing_card])) else: self._cs_session_handler(context) self._refresh_reservation_details(context) self._ixnetwork_session_handler(context) root_path = self.ixnetwork_session.getRoot() available_hardware_path = root_path + '/availableHardware' virtual_chassis_path = available_hardware_path + '/virtualChassis' self.cards_in_chassis += 1 virtual_chassis = self.ixnetwork_session.getList(available_hardware_path, 'virtualChassis')[0] try: card = self.ixnetwork_session.add(virtual_chassis, 'ixVmCard') self.ixnetwork_session.setMultiAttribute(card, '-managementIp', card_address, '-cardId', self.cards_in_chassis, '-keepAliveTimeout', '300') self.ixnetwork_session.commit() self.chassis_card[self.cards_in_chassis] = card_address self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Added Card %02d(%s)" % (self.resource_name, self.cards_in_chassis, self.chassis_card[self.cards_in_chassis])) except Exception as e: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Failed to add Card %02d(%s) to chassis, %s:%s" % (self.resource_name, self.cards_in_chassis, card_address, e.__class__.__name__, e.message)) self.cards_in_chassis -= 1 raise current_port = None try: virtual_card = self.ixnetwork_session.getList(virtual_chassis_path, 'ixVmCard')[ self.cards_in_chassis - 1] for current_port in range(1, num_ports + 1): port_root = self.ixnetwork_session.add(virtual_card, 'ixVmPort') self.ixnetwork_session.setMultiAttribute(port_root, '-portId', current_port, '-interface', 'eth1', '-promiscMode', 'true') self.ixnetwork_session.commit() self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Added Port %02d to Card %02d" % (self.resource_name, current_port, self.cards_in_chassis)) except Exception as e: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Failed to add Port %02d to Card %02d, %s:%s" % (self.resource_name, current_port, self.cards_in_chassis, e.__class__.__name__, e.message)) raise return def add_chassis(self, context, chassis_address): self._cs_session_handler(context) self._refresh_reservation_details(context) self._ixnetwork_session_handler(context) root_path = self.ixnetwork_session.getRoot() available_hardware_path = root_path + '/availableHardware' chassis = self.ixnetwork_session.add(available_hardware_path, 'chassis') self.ixnetwork_session.setAttribute(chassis, '-hostname', chassis_address) self.ixnetwork_session.setAttribute(chassis, '-masterChassis', '') self.ixnetwork_session.commit() try: self.ixnetwork_session.execute('connectToChassis', chassis_address) self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Connected to chassis(%s)" % (self.resource_name, chassis_address)) except Exception as e: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Failed to connect to chassis(%s), %s:%s" % (self.resource_name, chassis_address, e.__class__.__name__, e.message)) raise return def configure_via_sandbox(self, context): self._cs_session_handler(context) self._refresh_reservation_details(context) self._ixnetwork_session_handler(context) chassis = self.resource['Ixia Virtual Application']['Ixia IxVM Chassis'] if len(chassis) != 1: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "%s chassis found, current implementation only supports one" % len(chassis)) return license_server = self.resource['Ixia Application']['Ixia License Server'] if len(license_server) != 1: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "%s license servers found, current implementation only supports one" % len(license_server)) return card = OrderedDict(sorted(self.resource['Ixia Virtual Application']['Ixia IxVM Card'].items())) if len(card) == 0: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "No cards found, at least one is required") return chassis_name, chassis_resource = chassis.popitem() self.add_chassis(context, chassis_resource.FullAddress) license_server_name, license_server_resource = license_server.popitem() self.set_license_server(context, license_server_resource.FullAddress) for card_name, card_resource in card.iteritems(): self.add_card(context, card_resource.FullAddress, 1) return def set_license_server(self, context, license_server_address): self._cs_session_handler(context) self._refresh_reservation_details(context) self._ixnetwork_session_handler(context) root_path = self.ixnetwork_session.getRoot() available_hardware_path = root_path + '/availableHardware' virtual_chassis = self.ixnetwork_session.getList(available_hardware_path, 'virtualChassis')[0] self.ixnetwork_session.setAttribute(virtual_chassis, '-licenseServer', license_server_address) self.ixnetwork_session.commit() self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Set license server to %s" % (self.resource_name, license_server_address)) return def teardown(self, context): self._cs_session_handler(context) self._refresh_reservation_details(context) self._ixnetwork_session_handler(context) self.ixnetwork_session.disconnect() return def _ixnetwork_session_handler(self, context): try: self.ixnetwork_session.getVersion() except (AttributeError, Exception) as e: if e.__class__ != AttributeError: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] _ixnetwork_session_handler %s:%s" % (self.resource_name, e.__class__.__name__, e.message)) utility_server_name, utility_server_resource = self.utility_server.popitem() api_address = utility_server_resource.FullAddress api_port = context.resource.attributes['API Port'] api_version = context.resource.attributes['API Version'] try: self.ixnetwork_session = IxNet() self.ixnetwork_session.connect(api_address, '-port', api_port, '-version', api_version) self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Connected to API v%s at %s:%s" % (self.resource_name, api_version, api_address, api_port)) except Exception as e: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "[%s] Failed to connect to API client v%s at %s:%s, %s:%s" % (self.resource_name, api_version, api_address, api_port, e.__class__.__name__, e.message)) raise return def _refresh_reservation_details(self, context): self.reservation_id = context.reservation.reservation_id self.reservation_description = self.cs_session.GetReservationDetails(self.reservation_id).ReservationDescription self.resource = self._covert_reservation_resources() self.utility_server = {} if 'Ixia Virtual Application' in self.resource: self.utility_server.update(self.resource['Ixia Virtual Application'].get('Ixia IxVM Utility Server', {})) if 'Ixia Application' in self.resource: self.utility_server.update(self.resource['Ixia Application'].get('Ixia Utility Server', {})) if len(self.utility_server) != 1: self.cs_session.WriteMessageToReservationOutput(self.reservation_id, "%s utility servers found, current implementation requires one" % len(self.utility_server)) return return def _covert_reservation_resources(self): dictionary = {} for resource in self.reservation_description.Resources: if resource.ResourceFamilyName not in dictionary: dictionary[resource.ResourceFamilyName] = {} if resource.ResourceModelName not in dictionary[resource.ResourceFamilyName]: dictionary[resource.ResourceFamilyName][resource.ResourceModelName] = {} dictionary[resource.ResourceFamilyName][resource.ResourceModelName][resource.Name] = resource return dictionary def _cs_session_handler(self, context): self.resource_name = context.resource.name for attempt in range(3): try: self.cs_session = CloudShellAPISession(host=context.connectivity.server_address, token_id=context.connectivity.admin_auth_token, domain=context.reservation.domain) except: continue else: break else: raise return
# # # Description: # # Script will create following: # # 1. Create PPPoX Client # # 2. Setting DSL type in DSL line Attribute. # # 3. Setting CUSTOM TLV in DSL Line Attribute.. # # 4. Setting 01 Access-Loop-Circuit-ID # # 5. Setting PON-Access-Line-Attributes # # # ################################################################################ import time import os from IxNetwork import IxNet ixNet = IxNet() print("Connecting to the server") ixNet.connect('10.39.64.169', '-setAttribute', 'strict', '-port', 8876, '-version', '9.00') print("Cleaning up IxNetwork...") ixNet.execute('newConfig') root = ixNet.getRoot() print("\nAdd virtual ports to configuration...") vports = [] vports.append(ixNet.add(root, 'vport')) vports.append(ixNet.add(root, 'vport')) ixNet.commit()
# Also demonstrates how to set a multivalue. # # Module: # # The sample was tested on an FlexAP10G16S module. # # Software: # # IxOS 6.80 EA # # IxNetwork 7.40 EA # # # ################################################################################ # import Python packages import time import os from IxNetwork import IxNet # create an instance of the IxNet class ixNet = IxNet() # create absolute path for the config and load it print("Connecting to server: localhost") ixNet.connect('localhost', '-port', 8009, '-version', '7.40') print("Cleaning up IxNetwork...") ixNet.execute('newConfig') # all objects are under root root = ixNet.getRoot() print("\nAdd virtual ports to configuration...") vports = [] vports.append(ixNet.add(root, 'vport')) vports.append(ixNet.add(root, 'vport'))
# The sample was tested on an FlexAP10G16S module. # # Software: # # IxOS 6.70 EA # # IxNetwork 7.30 EA # # # ################################################################################ # import Python packages import time import os from IxNetwork import IxNet # create an instance of the IxNet class ixNet = IxNet() # create absolute path for the config and load it print ("Connecting to server: localhost") ixNet.connect('localhost', '-port', 8009, '-version', '7.30') print ("Cleaning up IxNetwork...") ixNet.execute('newConfig') # all objects are under root root = ixNet.getRoot() print ("\nAdd virtual ports to configuration...") vports = [] vports.append(ixNet.add(root, 'vport')) vports.append(ixNet.add(root, 'vport'))
class Ixia(TrafficGen): """ IXIA emulation class """ def __init__(self, system_data=None, chassis=None, appserver=None, license_server=None, ixia_lib_path=None): """ IXIA abstraction layer for HLTAPI -- Workflow 1 -- :param system_data *MANDATORY* Dictionary of IXIA information Example: system_data = system: primary: appserver: wf-appserver2.englab.juniper.net controllers: unknown: domain: englab.juniper.net hostname: wf-ixchassis2 mgt-intf-name: mgt0 mgt-ip: 10.9.1.107 osname: IxOS license_server: sv8-pod1-ixlic1.englab.juniper.net make: ixia model: xgs12 name: wf-ixchassis2 osname: IxOS -- Workflow 2 -- :param chassis *MANDATORY* Name of chassis :param appserver *MANDATORY* Name of tcl server :param license_server *MANDATORY* Name of chassis :return: ixia object """ self.virtual = False self.port_list = None self.session_info = None self.handle_to_port_map = None self.port_to_handle_map = None self.intf_to_port_map = None self.major_minor_version = None self.physical_port_type = 'fiber' self.user_functions = dict() self.connect_args = dict() self.cleanup_session_args = None self.port_order = None self.interfaces = None self.port = 8009 self.connect_to_current_session = False self.connect_to_current_session_args = dict() # args just for connecting to current session atexit.register(self.cleanup) self.min_version = None self.username, self.password = credentials.get_credentials(os='Ixia') self.port_type = dict() # Ixia API handles self._ixiangpf = None self._ixiaixnet = None if ixia_lib_path: self.lib_path = ixia_lib_path else: environment = yaml.safe_load(open(os.path.join(os.path.dirname(credentials.__file__), "environment.yaml"))) self.lib_path = environment['ixia-lib-path'] if system_data: sys_pri = system_data['system']['primary'] controller_key = list(sys_pri['controllers'].keys())[0] self.chassis = sys_pri['controllers'][controller_key]['mgt-ip'] # Instantiate host object for logging host_args = dict() if 'name' in sys_pri: host_args['host'] = sys_pri['name'] else: raise TobyIxiaException("Missing 'name' from 'primary' system stanza") if 'osname' in sys_pri['controllers'][controller_key]: host_args['os'] = sys_pri['controllers'][controller_key]['osname'] else: raise TobyIxiaException("Missing 'osname' from controller " + controller_key + " stanza") super(Ixia, self).__init__(**host_args) # connect user fv- knob information and materialize kwargs for Ixia connect() call if 'appserver' in sys_pri: self.connect_args['ixnetwork_tcl_server'] = sys_pri['appserver'] if 'appserver-port' in sys_pri: self.connect_args['ixnetwork_tcl_server'] = sys_pri['appserver'] + ':' + str(sys_pri['appserver-port']) self.port = sys_pri['appserver-port'] if 'appserver-username' in sys_pri: self.connect_args['user_name'] = sys_pri['appserver-username'] if 'appserver-password' in sys_pri: self.connect_args['user_password'] = sys_pri['appserver-password'] if 'return-detailed-handles' in sys_pri: if sys_pri['return-detailed-handles'] == 'disable': self.connect_args['return_detailed_handles'] = 0 if 'config-file' in sys_pri: self.connect_args['config_file'] = sys_pri['config-file'] else: self.connect_args['reset'] = 1 if sys_pri['model'].lower().startswith('ixvm') or sys_pri['model'].lower().startswith('vixia'): self.virtual = True self.model = sys_pri['model'].lower() self.log(level='INFO', message="IXIA Type= Virtual") if 'license_server' in sys_pri: self.connect_args['ixnetwork_license_servers'] = sys_pri['license_server'] if 'license_type' in sys_pri: if sys_pri['license_type'].startswith('tier'): self.connect_args['ixnetwork_license_type'] = 'mixed_' + sys_pri['license_type'] else: self.connect_args['ixnetwork_license_type'] = sys_pri['license_type'] else: self.log(level='INFO', message="IXIA Type= Physical") if 'connect-args' in sys_pri and type(sys_pri['connect-args']) is dict: self.connect_args.update(sys_pri['connect-args']) if 'cleanup-session-args' in sys_pri and type(sys_pri['cleanup-session-args']) is dict: self.cleanup_session_args = sys_pri['cleanup-session-args'] if 'port-order' in sys_pri: self.port_order = sys_pri['port-order'] if 'connect-to-current-session' in sys_pri and sys_pri['connect-to-current-session'] == 'enable': self.connect_to_current_session = True self.connect_to_current_session_args['ixnetwork_tcl_server'] = self.connect_args['ixnetwork_tcl_server'] # adding only connect-args for current session (no other arguments so can preserve session) if 'connect-args' in sys_pri and type(sys_pri['connect-args']) is dict: self.connect_to_current_session_args.update(sys_pri['connect-args']) if 'min-version' in sys_pri and type(sys_pri['min-version']) is str: self.min_version = sys_pri['min-version'] self.log(level='info', message="Ixia Minimum Chassis Version is set to: "+ sys_pri['min-version']) # Ensure mandatory connect() args are satisfied if 'ixnetwork_tcl_server' not in self.connect_args: raise TobyIxiaException("Missing appserver information (ixnetwork_tcl_server). This may be provided via 'fv-ixia-appserver'" "knob, or via 'fv-ixia-connect-args'.", host_obj=self) if sys_pri['model'].lower().startswith('ixvm') or sys_pri['model'].lower().startswith('vixia'): if 'ixnetwork_license_servers' not in self.connect_args: raise TobyIxiaException("Missing VM licensing information (ixnetwork_license_servers)." + \ "This may be provided via 'fv-ixia-license-server' knob, or via 'fv-ixia-connect-args'.", host_obj=self) if 'ixnetwork_license_type' not in self.connect_args: self.connect_args['ixnetwork_license_type'] = 'mixed_tier1' elif chassis and appserver: self.chassis = chassis self.appserver = appserver if license_server: self.license_server = license_server else: raise TobyIxiaException("Missing either system_data (Workflow 1) or chassis/appserver" "/license_server (Workflow 2) parameters", host_obj=self) self.intf_status = None self.log(level='info', message="CHASSIS= " + self.chassis) self.log(level='info', message="APPSERVER= " + self.connect_args['ixnetwork_tcl_server']) self.wait = 1 self.telnet_handle = None self.version = self._get_version() if self.min_version: if(float(self.version) < float(self.min_version)): raise TobyIxiaChassisConnectException("Ixia Minimum Chassis Version Check Failed", host_obj=self) if self.virtual: result = self._configure_promiscuous() if not result: self.log(level='WARN', message="Unable to set Promiscuous mode on IXIA virtual chassis") else: self.log(level='info', message="Successfully set Promiscuous mode on IXIA virtual chassis") if self.chassis_type is not None: if self.model.startswith('vixia') and re.search('Virtual Load Module', self.chassis_type, re.I): self.log(level='WARN', message="Virtual ixia chassis type is not correct as virtual modeli defined in params") self.ixia_lib_version = self._get_lib_version() self._set_envs() # Import core modules for native IXIA APIs # disable import-error because dynamic ENV changes based on IXIA version make it possible to import ok from ixiatcl import IxiaTcl # pylint: disable=import-error from ixiahlt import IxiaHlt # pylint: disable=import-error from ixiangpf import IxiaNgpf # pylint: disable=import-error # from ixiaerror import IxiaError # pylint: disable=import-error self.ixiatcl = IxiaTcl() self.ixiahlt = IxiaHlt(self.ixiatcl) self._ixiangpf = IxiaNgpf(self.ixiahlt) # Import extended ixia modules with functions # from jnpr/toby/trafficgen/ixia current_dir = os.path.dirname(os.path.abspath( inspect.getfile(inspect.currentframe()))) user_module_dir = re.sub(r"jnpr\/toby.*", "jnpr/toby/trafficgen/ixia", current_dir) sys.path.append(user_module_dir) file_list = list(filter(lambda x: os.path.isfile(os.path.join(user_module_dir, x)), os.listdir(user_module_dir))) for file_name in file_list: if file_name.endswith('.py') and not file_name.startswith('__'): module = re.sub(r"\.py$", "", file_name) obj = __import__(module) function_list = [o for o in inspect.getmembers(obj) if inspect.isfunction(o[1])] for function_tuple in function_list: function_name, function = function_tuple if function_name in self.user_functions: raise TobyIxiaException("Duplicate functions in user contributed modules", host_obj=self) self.user_functions[function_name] = function def _configure_promiscuous(self): """ To enable promiscuous mode for Ixia Virtual Test Appliance """ try: cmd = 'set promiscuous-mode all enable' if (self.version): match = re.match(r'(\d+.\d+).*', self.version) if match and float(match.group(1)) >= 8.50: cmd = 'set promiscuous-mode all all enable' pexp = pexpect.spawn('ssh -l StrictHostKeyChecking=no %s@%s' % (self.username, self.chassis)) pexp.expect('password:'******'#') pexp.sendline(cmd) pexp.expect('#') output = pexp.before pexp.sendline('exit') if re.search(r'Promiscuous mode was successfully set|promiscuous mode.*enabled', output.decode('utf-8'), re.IGNORECASE): return True else: return False except Exception: self.log(level="ERROR", message="Unable to connect to IXIA virtual Chassis") def _get_version(self): """ Get Chassis OS Version of IXIA TC : :return: ixia chassisversion """ version = None chassis_type = None try: # Trying to get the ixia version with out login to the box using SSH retvalue = os.popen( 'ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no ' + self.username + '@' + self.chassis + ' 2>&1 | grep "Welcome to Ixia\\|IxOS Version\\|Connection refused"').readlines() if retvalue and len(retvalue) > 0: search_obj = re.search(r'Version:\s+(\d+\.\d+\.\d+\.\d+)', retvalue[1]) if search_obj: version = re.sub(r'Version:\s+', '', search_obj.group(0)) chassis_type = self._find_chassis_type(retvalue[0]) elif re.search(r'Connection refused', retvalue[0], re.IGNORECASE): self.log(level="INFO", message="Could not initiate ssh connection to box") raise Exception("Could not initiate ssh connection to box %s" % self.chassis) if version is None: #Trying to get the ixia version by login to the box using SSH ssh_cl = paramiko.client.SSHClient() ssh_cl.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh_cl.connect(hostname=self.chassis, username=self.username, password=self.password, allow_agent=False, look_for_keys=False) channel = None data = '' try: channel = ssh_cl.invoke_shell(width=160) time.sleep(2) except: transport = ssh_cl.get_transport() channel = transport.open_session() if channel.recv_ready(): data = channel.in_buffer.empty() try: data = data.decode('utf-8') except UnicodeDecodeError: data = data.decode('iso-8859-1') ver_re = re.compile(r'IxOS Version.*:\s+(\d+\.\d+\.\d+\.\d+)', re.IGNORECASE) ver_old_re = re.compile(r'enter chassis', re.IGNORECASE) version = "" banner_out = "" command_response = '' if ver_re.search(str(data)): banner_out = str(data) ver_search = ver_re.search(banner_out) if ver_search: version = ver_search.group(1) chassis_type = self._find_chassis_type(banner_out) else: self.log(level="INFO", message="Connect response does not have version info: %s" % banner_out) try: channel.exec_command('show chassis installed-versions') except: transport = ssh_cl.get_transport() channel = transport.open_session() channel.exec_command('show chassis installed-versions') time.sleep(2) if channel.recv_ready(): command_response = channel.recv(1024) version = re.search(r'Chassis:\s+\*?((\d+\.){3}\d+)', command_response.decode('utf-8'), re.IGNORECASE).group(1) chassis_type = self._find_chassis_type(banner_out) elif ver_old_re.search(str(data)): channel.send('enter chassis\n') channel.send('show ixos active-version\n') time.sleep(2) if channel.recv_ready(): command_response = channel.recv(5102) match = re.search(r'IxOS active version:.*?(\d+\.\d+\.\d+\.\d+)', command_response.decode('utf-8'), re.IGNORECASE) if match: version = match.group(1) chassis_type = self._find_chassis_type(command_response) else: self.log(level="INFO", message="Connect response does not have version info: %s" % banner_out) try: channel.exec_command('show ixos active-version') except: transport = ssh_cl.get_transport() channel = transport.open_session() channel.exec_command('show ixos active-version') time.sleep(2) if channel.recv_ready(): command_response = channel.recv(1024) match = re.search(r'IxOS active version:\s+IxOS\s+(\d+\.\d+\.\d+\.\d+)', command_response.decode('utf-8'), re.IGNORECASE) if match: version = match.group(1) chassis_type = self._find_chassis_type(command_response) ssh_cl.exec_command('exit') if version is not None: self.log(level="INFO", message="Ixos version: %s \n" % version) else: self.log(level="INFO", message="Could not get the ixia verion using ssh connection") raise Exception("Could not get the ixia verion using ssh connection to box %s" % self.chassis) except Exception as ex: self.log(level="INFO", message="Toby was not able to find version using ssh due to: %s" % ex.__str__()) #Trying to get the ixia version with out login to the box using Telnet self.log(level="INFO", message="Trying telnet for chassis %s" % self.chassis) try: telnet_handle = telnetlib.Telnet(self.chassis) banner_out = telnet_handle.read_until(b"Ixia>") time.sleep(10) cmd = "package require IxTclHal;version cget -ixTclHALVersion\n" cmd = cmd.encode('ascii') telnet_handle.write(cmd) match_results = telnet_handle.expect([br"\d+\.\d+\.\d+\.\d+"]) version = match_results[1].group(0).decode('ascii') self.log(level="INFO", message="Ixos version: %s \n" % version) chassis_type = self._find_chassis_type(banner_out) telnet_handle.close() except Exception as ex: self.log(level="ERROR", message="Toby was not able to find version info using telnet connection due to: %s" % ex.__str__()) #self.log(level="ERROR", message="Could not get the version info using telnet connection") if not version: if not check_device_reachabiliy(self, self.chassis): raise TobyIxiaChassisConnectException("IXIA chassis is not pingable") else: raise TobyIxiaException("Unable to detect IXIA version", host_obj=self) self.log(level='info', message='CHASSIS VERSION: ' + version) self.major_minor_version = re.search(r'^\d+\.\d+', version).group(0) if not self.major_minor_version: raise TobyIxiaException("Unable to derive major and minor version from " + version, host_obj=self) if float(self.major_minor_version) < 8.20: raise TobyIxiaException("Unsupported version " + self.major_minor_version + ". Minimum version supported: 8.20", host_obj=self) self.chassis_type = chassis_type return version def _find_chassis_type(self, response): """ Find Chassis type based :return: ixia chassis type """ chassis_type = None search_obj = re.search(r'Welcome to Ixia (Virtual Chassis|Virtual Test Appliance|Virtual Load Module)', str(response), re.I) if search_obj: chassis_type = search_obj.group(1) self.log(level='info', message='Virtual chassis type: %s' % chassis_type) return chassis_type def _set_envs(self): """ Set ENVs required for IXIA TC """ if self.version is None: self._get_version() ixia_lib_path_prefix = self.lib_path + '/' + self.ixia_lib_version + '/lib' os.environ['TCLLIBPATH'] = ixia_lib_path_prefix sys.path.append(ixia_lib_path_prefix + '/hltapi/library/common/ixiangpf/python') sys.path.append(ixia_lib_path_prefix + '/PythonApi') self.log(level="info", message="ADDED_TO_PATH= " + os.environ['TCLLIBPATH']) self.log(level="info", message="ADDED_TO_PYTHONPATH= " + ixia_lib_path_prefix + '/hltapi/library/common/ixiangpf/python') self.log(level="info", message="ADDED_TO_PYTHONPATH= " + ixia_lib_path_prefix + '/PythonApi') def _get_lib_version(self): """ Needed to determine which IXIA library folder to use. """ ixia_lib_ver = None try: best_match = None ixia_lib_vers = list(filter(lambda x: os.path.isdir(os.path.join( self.lib_path, x)), os.listdir(self.lib_path))) for possible_lib_ver in ixia_lib_vers: if re.search(r'\d+\.\d+\.\d+\.\d+', possible_lib_ver): if possible_lib_ver == self.version: ixia_lib_ver = possible_lib_ver break elif re.search(r'^' + self.major_minor_version, possible_lib_ver): best_match = possible_lib_ver if best_match and not ixia_lib_ver: ixia_lib_ver = best_match except: raise TobyIxiaException( "Unable to find appropriate IXIA lib version in " + self.lib_path + " for Ixia version " + self.version, host_obj=self) if not ixia_lib_ver: raise TobyIxiaException("Unable to find appropriate IXIA lib version in " + self.lib_path + " for Ixia version " + self.version, host_obj=self) self.log(level="INFO", message="IXIA LIB AVAILABLE = " + str(ixia_lib_ver)) return ixia_lib_ver def add_interfaces(self, interfaces): """ Get interfaces{} block from yaml to use fv- knobs therein """ self.interfaces = interfaces def add_intf_to_port_map(self, intf_to_port_map): """ Add attribute to ixia object which contains params intf to port mappings """ self.intf_to_port_map = intf_to_port_map def _initialize_ports(self): # next, initialize the port via interface_config fiber_port_handles = [] copper_port_handles = [] ge_port_handles = [] xe_port_handles = [] for intf in self.interfaces: if 'physical-port-type' in self.interfaces[intf] and self.interfaces[intf]['physical-port-type'] == 'copper': copper_port_handles.insert(0, self.get_port_handle(intf)) else: # fiber fiber_port_handles.insert(0, self.get_port_handle(intf)) if self.port_type: if re.search(r'^Novus', self.port_type[self.interfaces[intf]['name']], re.IGNORECASE): if 'type' in self.interfaces[intf] and 'ge' in self.interfaces[intf]['type']: ge_port_handles.insert(0, self.get_port_handle(intf)) elif 'type' in self.interfaces[intf] and 'xe' in self.interfaces[intf]['type']: xe_port_handles.insert(0, self.get_port_handle(intf)) if len(copper_port_handles): self.log("Invoking interface_config for copper ports: " + str(copper_port_handles)) result = self._ixiangpf.interface_config(port_handle=copper_port_handles, phy_mode='copper') self.log('INFO', "Invokation of interface_config result: " + str(result)) if len(fiber_port_handles): self.log("Invoking interface_config for fiber ports: " + str(fiber_port_handles)) result = self._ixiangpf.interface_config(port_handle=fiber_port_handles, phy_mode='fiber') self.log('INFO', "Invokation of interface_config result: " + str(result)) if len(ge_port_handles): self.log("Invoking interface_config for nova card GE ports: " + str(ge_port_handles)) result = self._ixiangpf.interface_config(port_handle=ge_port_handles, autonegotiation='1', speed='ether1000') self.log('INFO', "Invokation of interface_config result: " + str(result)) if len(xe_port_handles): self.log("Invoking interface_config for nova card XE ports: " + str(xe_port_handles)) result = self._ixiangpf.interface_config(port_handle=xe_port_handles, autonegotiation='0', speed='ether10Gig') self.log('INFO', "Invokation of interface_config result: " + str(result)) def invoke(self, command, *args, **kwargs): """ Pass-through for ixnetwork.py functions (ixnetwork.py? or something else?) """ lib = 'ngpf' if re.search(r'^IxNet::', command): lib = 'ixnet' command = command.replace('IxNet::', '', 1) # Initialize IxNet if not set up already if not self._ixiaixnet: from IxNetwork import IxNet # pylint: disable=import-error self._ixiaixnet = IxNet() self._connect_ixnet() if 'port_handle' in kwargs.keys(): port_handle = kwargs['port_handle'] if isinstance(port_handle, six.string_types): port_handle = port_handle.split(' ') if port_handle[0] in self.intf_to_port_map.keys(): new_port_handle = list() for intf in port_handle: new_port_handle.append(self.port_to_handle_map[self.intf_to_port_map[intf]]) kwargs['port_handle'] = ' '.join(new_port_handle) # User contributed module if command in self.user_functions: self.log(level="info", message="Invoking Juniper IXIA function " + command + " with parameters " + str(kwargs)) result = self.user_functions[command](self, **kwargs) self.log(level="info", message="Invocation of Juniper IXIA function " + command + " completed with result: " + str(result)) return result # ngpf method elif lib == 'ngpf': self.log(level="info", message="Invoking IXIA ngpf method " + command + " with parameters " + str(kwargs)) ixia_method = getattr(self._ixiangpf, command) result = ixia_method(**kwargs) if result['status'] == '0': raise TobyIxiaException("Invocation of IXIA method " + command + " failed with result: " + str(result), host_obj=self) else: self.log(level="debug", message="Invocation of IXIA method " + command + " succeeded with result: " + str(result)) return result # ixnet method elif lib == 'ixnet': ixnet_args = kwargs.get('ixnet_args', None) if not ixnet_args and len(args) > 0: # args came in via python *args instead of via kwargs(ixnet_args) ixnet_args = args self.log("INFO", message="Invoking IXIA ixnet API '" +command + "' with parameters " + str(ixnet_args)) ixia_method = getattr(self._ixiaixnet, command) if ixnet_args: result = ixia_method(*ixnet_args) else: result = ixia_method() self.log("INFO", message="Invocation of IXIA API '" + command + "' completed with result: " + str(result)) return result def _connect_ixnet(self): tcp_port = self.session_info['connection']['port'] client_version = self.session_info['connection']['client_version'] self.log('INFO', "Invoking ixnet connect() on tcp port " + tcp_port + " with client version " + client_version) connect_status = self._ixiaixnet.connect(self.connect_args['ixnetwork_tcl_server'], '-port', tcp_port, '-version', client_version) self.log('INFO', "Ixnet connect status: " + str(connect_status)) def connect(self, port_list=None): """ Connect to IXIA chassis :param port_list (*REQUIRED): port list , ex: '1/9 1/10 1/11' :return: ixia connection object """ if not port_list and not self.connect_to_current_session: raise TobyIxiaException("Missing port_list parameter", host_obj=self) connect_status = None #reorder port list if required - useful when config_file is being loaded and ports need to pair up exactly if self.port_order: duplicate_port_check = {} new_port_list = [] interfaces = self.port_order.split(':') for intf in interfaces: if intf in duplicate_port_check: raise TobyIxiaException("duplicate port " + intf + " found in port_list [fv-ixia-port-list]", host_obj=self) if intf in self.intf_to_port_map: new_port_list.append(self.intf_to_port_map[intf]) duplicate_port_check[intf] = 1 else: raise TobyIxiaException("IXIA Port " + intf + " specified in ordered port list does not exist", host_obj=self) if len(port_list) != len(new_port_list): raise TobyIxiaException("IXIA port ordered list [fv-ixia-port-list] does not match number of interfaces present", host_obj=self) port_list = new_port_list if self.connect_to_current_session: self.log(level="INFO", message="Connecting to existing IXIA session via ngpf(HLTAPI) with the following arguments: " + str(self.connect_to_current_session_args)) connect_status = self._ixiangpf.connect(**self.connect_to_current_session_args) else: ports = " ".join(port_list) self.connect_args['port_list'] = ports self.connect_args['device'] = self.chassis self.log(level="INFO", message="Connecting to IXIA via ngpf(HLTAPI) with parameters " + str(self.connect_args)) connect_status = self._ixiangpf.connect(**self.connect_args) self.log(level="INFO", message="IXIA Connection status: " + str(connect_status)) if connect_status['status'] != '1': error_message = "Not able to connect to IXIA, " if not check_appserver_reachabiliy(self, self.connect_args['ixnetwork_tcl_server'], self.port): error_message += "Failed to connect to appserver %s using port %s" % (self.connect_args['ixnetwork_tcl_server'], self.port) else : if 'log' in connect_status: error_message = error_message + " : " + connect_status['log'] raise TobyIxiaAppserverConnectException(error_message, host_obj=self) self.session_info = connect_status try: root = self._invokeIxNet('getRoot') vports = self._invokeIxNet('getList', root, 'vport') for tr in vports: l1config = self._invokeIxNet('getList', tr, 'l1Config') port_detail = self._invokeIxNet('getAttribute', tr, '-connectionStatus') match1 = port_detail.split(";") interface_name = match1[1].lstrip("0").strip() + "/" + match1[2].split()[0].lstrip("0").strip() card_type = self._invokeIxNet('getAttribute', l1config[0], '-currentType') if interface_name and card_type: self.port_type[interface_name] = card_type except: self.log(level="INFO", message="Unable to get card type of IXIA virtual Chassis ports") if port_list: if self.connect_to_current_session: result = self._ixiangpf.session_info(mode='get_session_keys', session_keys_include_filter='connect.vport_list') port_handle_list = result['vport_list'].split(' ') else: port_handle_list = connect_status['vport_list'].split(' ') self.port_list = port_list self.port_to_handle_map = dict(zip(port_list, port_handle_list)) self.handle_to_port_map = dict(zip(port_handle_list, port_list)) if not self.connect_to_current_session: self._initialize_ports() def get_port_handle(self, intf): """ Use IXIA object information to get port handle keys """ intf = intf.lower() if intf in self.intf_to_port_map.keys(): port = self.intf_to_port_map[intf] if port in self.port_to_handle_map.keys(): return self.port_to_handle_map[port] else: raise TobyIxiaException("No such params interface " + intf, host_obj=self) def cleanup(self): """ Destructor to clean up session """ print("Cleaning up Ixia port handles via cleanup_session() IXIA call") if self.handle_to_port_map: if self.cleanup_session_args: if 'port_handle' not in self.cleanup_session_args: self.cleanup_session_args['port_handle'] = self.handle_to_port_map.keys() print("Clean up session args : "+str(self.cleanup_session_args)) result = self._ixiangpf.cleanup_session(**self.cleanup_session_args) else: result = self._ixiangpf.cleanup_session() if result['status'] == '0': print("Ixia cleanup failed. Ixia API response: " + str(result)) else: print("Ixia cleanup successful") def _invokeIxNet(self, command, *args): """ To Execute Low Level APIs on the Existing Session. """ self.log(level="info", message="Invoking IXIA ixNet method " + command + " with parameters " + str(args)) ixnet = self._ixiangpf.ixnet ixia_method = getattr(ixnet, command) try: result = ixia_method(*args) self.log(level="info", message="Invocation of IXIA method " + command + " succeeded with result: " + str(result)) return result except Exception as e: raise TobyException("Invocation of IXIA method " + command + " failed with result: " + str(e), host_obj=self)
# with VxLAN and a chained Device Group with the DHCPv6 Client stack # # and a corresponding topology containing one Device Group with VxLAN and a # # chained Device Group with DHCPv6 Server stack. # # Also demonstrates how to set a multivalue. # # Module: # # The sample was tested on an FlexAP10G16S module. # # # ################################################################################ # import Python packages import time import os from IxNetwork import IxNet # create an instance of the IxNet class ixNet = IxNet() # create absolute path for the config and load it print("Connecting to server: localhost") ixNet.connect('localhost', '-port', 8009, '-version', '7.30') print("Cleaning up IxNetwork...") ixNet.execute('newConfig') # all objects are under root root = ixNet.getRoot() print("\nAdd virtual ports to configuration...") vports = [] vports.append(ixNet.add(root, 'vport')) vports.append(ixNet.add(root, 'vport'))
# 9. Send LTE tear down control traffic from HAAP to HG # # 10. Stop and start Bonded GRE LTE after tear down # # 11. Send Tear Down from Home Gateway to HAAP with error code 11 # # 12. Check Stats # # 13. Stop Protocols # # 14.Disable Tlv # # Module: # # The sample was tested on a 10GE LSM module. # # # # ############################################################################## import time import os from IxNetwork import IxNet ixNet = IxNet() ##################################################################################### # Procedure : traffitem_enable_regenerate # Purpose : Enable the Traffic Item based on name and Regenerate traffic for that # Parameters: ixNet, tItemName # ixNet - ixNetwork Instance # tItemName - Expected traffic Item Name which needs to be enabled and regenerated # Return : flag # error: -1 # ################################################################################### def traffitem_enable_regenerate(ixNet, tItemName): root = ixNet.getRoot() traffic = ixNet.getList(root, 'traffic')[0] trafficItems = ixNet.getList(traffic, 'trafficItem')
pass class Py: pass py = Py() py.ports = [('10.205.15.62', 3, 5), ('10.205.15.62', 3, 6)] py.ixTclServer = '10.205.15.224' py.ixTclPort = 8009 ################################################################################ # Import the IxNet library ################################################################################ from IxNetwork import IxNet import time ixNet = IxNet() ################################################################################ # Connect to IxNet client ################################################################################ ixNet.connect(py.ixTclServer, '-port', py.ixTclPort, '-version', '7.40') ################################################################################ # Cleaning up IxNetwork ################################################################################ print("Cleaning up IxNetwork...") ixNet.execute('newConfig') ################################################################################ # Adding ports to configuration
pass class Py: pass py = Py() py.ports = [('10.205.15.62', 3, 5), ('10.205.15.62', 3, 6)] py.ixTclServer = '10.205.15.224' py.ixTclPort = 8009 ################################################################################ # Import the IxNet library ################################################################################ from IxNetwork import IxNet import time ixNet = IxNet() ################################################################################ # Connect to IxNet client ################################################################################ ixNet.connect(py.ixTclServer, '-port', py.ixTclPort, '-version', '7.40') ################################################################################ # Cleaning up IxNetwork ################################################################################ print("Cleaning up IxNetwork...") ixNet.execute('newConfig') ################################################################################