def verifyPortState(self, timeout=70): """ Description Verify port states for all the vports connected to physical ports. Parameter timeout: : The timeout value to declare as failed. Default=70 seconds. """ response = self.ixnObj.get(self.ixnObj.sessionUrl+'/vport') vportList = [metaDatas["links"][0]['href'] for metaDatas in response.json()] for eachVport in vportList: for counter in range(1,timeout+1): stateResponse = self.ixnObj.get(self.ixnObj.httpHeader+eachVport+'?includes=state,connectionStatus', silentMode=True) assignedToResponse = self.ixnObj.get(self.ixnObj.httpHeader+eachVport+'?includes=assignedTo', silentMode=True) if 'Port Released' in stateResponse.json()['connectionStatus']: raise IxNetRestApiException(stateResponse.json()['connectionStatus']) if stateResponse.json()['state'] == 'unassigned': self.ixnObj.logWarning('\nThe vport {0} is not assigned to a physical port. Skipping this vport verification.'.format(eachVport)) break self.ixnObj.logInfo('Port: %s' % assignedToResponse.json()['assignedTo']) self.ixnObj.logInfo('\tVerifyPortState: %s\n\tWaiting %s/%s seconds' % (stateResponse.json()['state'], counter, timeout), timestamp=False) if counter < timeout and stateResponse.json()['state'] in ['down', 'busy']: time.sleep(1) continue if counter < timeout and stateResponse.json()['state'] in ['up', 'connectedLinkUp']: break if counter == timeout and stateResponse.json()['state'] == 'down': # Failed raise IxNetRestApiException('Port failed to come up')