def getPortObjectId(connection, sessionUrl, communityPortIdTuple): ''' This method is used to get the objectID of a port from a communityList. Args: - connection is the connection object that manages the HTTP data transfers between the client and the REST API - communityPortIdTuple is a tuple composed of (communityID and portName) - communityID is the id of the community list for which captures should be retrieved. - portName is the name of the port for which the objectID will be retrieved ( in the following format:'1.5.1') - sessionUrl is the address of the session on which the test was ran. ''' communityObjectID, portID = communityPortIdTuple communityUrl = sessionUrl + ("/ixload/test/activeTest/communityList/%s/network/portList" % communityObjectID) portList = connection.httpRequest('GET', communityUrl).json() objectID = None for port in portList: if port['id'] == portID: objectID = port["objectID"] break if objectID is None: raise Exception("Could not find port with id '%s' on community with id '%s'" % (portID, communityObjectID)) return objectID