def configMpls(self, ethernetObj, **kwargs): """ Description Create or modify static MPLS. Parameters ethernetObj: : The Ethernet object handle. Example: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id} Syntax POST: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/mpls PATCH: /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/mpls/{id} Example: mplsObj1 = protocolObj.configMpls(ethernetObj1, name = 'mpls-1', destMac = {'start': '00:01:02:00:00:01', 'direction': 'increment', 'step': '00:00:00:00:00:01'}, exp = {'start': 0, 'direction': 'increment', 'step': 1}, ttl = {'start': 16, 'direction': 'increment', 'step': 1}, rxLabelValue = {'start': 288, 'direction': 'increment', 'step': 1}, txLabelValue = {'start': 888, 'direction': 'increment', 'step': 1}) Return /api/v1/sessions/{id}/ixnetwork/topology/{id}/deviceGroup/{id}/ethernet/{id}/mpls/{id} """ # To create a new MPLS if 'mpls' not in ethernetObj: mplsUrl = self.ixnObj.httpHeader+ethernetObj+'/mpls' self.ixnObj.logInfo('Create new MPLS protocol in NGPF') response = self.ixnObj.post(mplsUrl) mplsObj = response.json()['links'][0]['href'] # To modify MPLS if 'mpls' in ethernetObj: mplsObj = ethernetObj self.ixnObj.logInfo('GET ATTRIBUTE MULTIVALUE IDs') mplsResponse = self.ixnObj.get(self.ixnObj.httpHeader+mplsObj) if 'name' in kwargs: self.ixnObj.patch(self.ixnObj.httpHeader+mplsObj, data={'name': kwargs['name']}) # All of these mpls attributes configures multivalue counter. So just loop them to do the same thing. mplsAttributes = ['rxLabelValue', 'txLabelValue', 'destMac', 'cos', 'ttl'] for mplsAttribute in mplsAttributes: if mplsAttribute in kwargs: multiValue = mplsResponse.json()[mplsAttribute] self.ixnObj.logInfo('Configuring MPLS attribute: %s' % mplsAttribute) self.configMultivalue(multiValue, 'counter', data=kwargs[mplsAttribute]) self.configuredProtocols.append(mplsObj) return mplsObj