def set_mask(self, name=None, netmask=None, folder='Common'): if name: folder = str(folder).replace('/', '') request_url = self.bigip.icr_url + '/net/self/' request_url += '~' + folder + '~' + name request_url += '?$select=address' response = self.bigip.icr_session.get( request_url, timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: return_obj = json.loads(response.text) try: address = self._strip_mask(return_obj['address']) net = netaddr.IPNetwork( strip_domain_address(address) + '/' + netmask) payload = dict() payload['address'] = address + '/' + str(net.prefixlen) request_url = self.bigip.icr_url + '/net/self/' request_url += '~' + folder + '~' + name response = self.bigip.icr_session.put( request_url, data=json.dumps(payload), timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: return True else: Log.error('self', response.text) raise exceptions.SelfIPUpdateException(response.text) except Exception as e: Log.error('self', 'set_mask exception:' + e.message) else: Log.error('self', response.text) raise exceptions.SelfIPQueryException(response.text) return False
def set_port_lockdown_allow_none(self, name=None, folder='Common'): if name: folder = str(folder).replace('/', '') request_url = self.bigip.icr_url + '/net/self/' request_url += '~' + folder + '~' + name payload = dict() payload['allowService'] = 'none' response = self.bigip.icr_session.put( request_url, data=json.dumps(payload), timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: return True else: Log.error('self', response.text) raise exceptions.SelfIPUpdateException(response.text) return False
def set_description(self, name=None, description=None, folder='Common'): """ Set selfip description """ if name and description: folder = str(folder).replace('/', '') request_url = self.bigip.icr_url + '/net/self/' request_url += '~' + folder + '~' + name payload = dict() payload['description'] = description response = self.bigip.icr_session.put( request_url, data=json.dumps(payload), timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: return True else: Log.error('self', response.text) raise exceptions.SelfIPUpdateException(response.text) return False
def set_traffic_group(self, name=None, traffic_group=None, folder='Common'): if name and traffic_group: folder = str(folder).replace('/', '') request_url = self.bigip.icr_url + '/net/self/' request_url += '~' + folder + '~' + name payload = dict() payload['trafficGroup'] = traffic_group response = self.bigip.icr_session.put( request_url, data=json.dumps(payload), timeout=const.CONNECTION_TIMEOUT) if response.status_code < 400: return True else: Log.error('self', response.text) raise exceptions.SelfIPUpdateException(response.text) return False