) # Only need to blank the config for Windows because osPlatforms such as Linux and # Windows Connection Mgr supports multiple sessions and a new session always come up as a blank config. if osPlatform == 'windows': mainObj.newBlankConfig() else: if api_session_id != None: mainObj.newBlankConfig() # Existing session, clear config mainObj.configLicenseServerDetails([licenseServerIp], licenseModel) portObj = PortMgmt(mainObj) portObj.assignPorts(portList, forceTakePortOwnership) portObj.modifyPortMediaType(portList, portMediaType) protocolObj = Protocol(mainObj) topologyObj1 = protocolObj.createTopologyNgpf(portList=[portList[0]], topologyName='Topo1') deviceGroupObj1 = protocolObj.createDeviceGroupNgpf(topologyObj1, multiplier=100, deviceGroupName='DG1') topologyObj2 = protocolObj.createTopologyNgpf(portList=[portList[1]], topologyName='Topo2') deviceGroupObj2 = protocolObj.createDeviceGroupNgpf(topologyObj2, multiplier=100, deviceGroupName='DG2')
portObj.releasePorts(portList) portObj.clearPortOwnership(portList) else: raise IxNetRestApiException('\nPorts are owned by another user and forceTakePortOwnership is set to False. Exiting test.') portObj.releasePorts(portList) mainObj.configLicenseServerDetails([licenseServerIp], licenseModel) fileMgmtObj = FileMgmt(mainObj) fileMgmtObj.importJsonConfigFile(jsonConfigFile, option='newConfig') # Set configPortName=False because loading a saved config file assumes ports already have configured names. Don't overwrite them. portObj.assignPorts(portList, forceTakePortOwnership, configPortName=False) if modifyPortMediaType: portObj.modifyPortMediaType(portList=portList, mediaType=modifyPortMediaType) portObj.verifyPortState() # Example: How to modify # Mofify the BGP configuration using JSON XPATH. XPATH are obtained from a JSON exported config file. # 1> Export the JSON configuration to a file. # 2> Get the XPATH for what you want to modify the configuraiton. # 3> Import the modified JSON data object to IxNetwork. xpathObj = [{"xpath": "/multivalue[@source = '/topology[1]/deviceGroup[1]/ethernet[1]/ipv4[1]/bgpIpv4Peer[1] flap']/singleValue", "value": "true"}, {"xpath": "/multivalue[@source = '/topology[1]/deviceGroup[1]/ethernet[1]/ipv4[1]/bgpIpv4Peer[1] uptimeInSec']/singleValue", "value": "28"}, {"xpath": "/multivalue[@source = '/topology[1]/deviceGroup[1]/ethernet[1]/ipv4[1]/bgpIpv4Peer[1] downtimeInSec']/singleValue", "value": "68"} ]