def connectIxChassis(self, chassisIp, timeout=30, **kwargs): """ Description Connect to an Ixia chassis. Parameter chassisIp: |: A string or a list of chassis IP addresses. timeout: : Default=30 seconds. The amount of time to wait for the chassis to be in the ready state. kwargs: Any chassis attributes and values. For example, if two chassis' are dasisy chained, include: chainTopology=None, masterChassis='10.10.10.1', sequenceId=1 Syntax /api/v1/sessions/{id}/ixnetwork/availableHardware/chassis """ if isinstance(chassisIp, list) == False: chassisIp = chassisIp.split(' ') chassisObjList = [] url = self.ixnObj.sessionUrl+'/availableHardware/chassis' for chassisIpAddress in chassisIp: data = {'hostname': chassisIpAddress} if kwargs: data.update(kwargs) response = self.ixnObj.post(url, data=data) if type(response.json()) == list: # 8.50 json response is a list. chassisIdObj = response.json()[0]['links'][0]['href'] else: chassisIdObj = response.json()['links'][0]['href'] self.ixnObj.logInfo('\n', timestamp=False) # Chassis states: down, polling, ready for timer in range(1,timeout+1): response = self.ixnObj.get(self.ixnObj.httpHeader + chassisIdObj, silentMode=True) currentStatus = response.json()['state'] self.ixnObj.logInfo('connectIxChassis {0}: Status: {1}. Wait {2}/{3} seconds'.format( chassisIpAddress, currentStatus, timer, timeout), timestamp=False) if currentStatus != 'ready' and timer < timeout: time.sleep(1) if currentStatus != 'ready' and timer == timeout: #raise IxNetRestApiException('connectIxChassis: Connecting to chassis {0} failed'.format(chassisIpAddress)) if currentStatus == 'polling': errorMsg = "Chassis could not be located." else: errorMsg = '' raise IxNetRestApiException('connectIxChassis failed. chassisIP:{0}. It is in the {1} state. {2}'.format(chassisIp, currentStatus, errorMsg)) if currentStatus == 'ready' and timer < timeout: chassisObjList.append(chassisIdObj) break # http://192.168.70.127:11009/api/v1/sessions/1/ixnetwork/availableHardware/chassis/1 return chassisObjList