def delete_ipv4(ipv4_id): """Delete Ipv4.""" try: ipv4_obj = get_ipv4_by_id(ipv4_id) ipv4_obj.delete_v4() except ObjectDoesNotExistException, e: raise ObjectDoesNotExistException(e.detail)
def update_ipv4(ipv4, user): """Updates a Ipv4.""" try: ipv4_obj = get_ipv4_by_id(ipv4.get('id')) ipv4_obj.update_v4(ipv4) except ObjectDoesNotExistException, e: raise ObjectDoesNotExistException(e.detail)
def delete_ipv4(self, ip_id, user_id): msg = {'object_type': 'ipv4', 'action': 'deallocate', 'object_id': ip_id} self.update_state(state='PROGRESS', meta=msg) ip_obj = facade_v3.get_ipv4_by_id(ip_id) try: facade_v4.delete_ipv4(ip_id) except Exception, exception: msg['message'] = 'IPv4 {} was not deallocated.'.format(ip_obj) msg['reason'] = str(exception) raise Exception(msg)
def update_ipv4(self, ip_dict, user_id): msg = { 'object_type': 'ipv4', 'action': 'update', 'object_id': ip_dict.get('id') } self.update_state(state='PROGRESS', meta=msg) ip_obj = facade_v3.get_ipv4_by_id(ip_dict.get('id')) user = Usuario.objects.get(id=user_id) try: facade_v4.update_ipv4(ip_dict, user) except Exception, exception: msg['message'] = 'IPv4 {} was not updated.'.format(ip_obj) msg['reason'] = str(exception) raise Exception(msg)
def delete_ipv4(self, ip_id, user_id): msg = { 'object_type': 'ipv4', 'action': 'deallocate', 'object_id': ip_id } self.update_state( state='PROGRESS', meta=msg ) ip_obj = facade.get_ipv4_by_id(ip_id) try: facade.delete_ipv4(ip_id) except Exception, exception: msg['message'] = 'IPv4 {} was not deallocated.'.format(ip_obj) msg['reason'] = str(exception) raise Exception(msg)
def update_ipv4(self, ip_dict, user_id): msg = { 'object_type': 'ipv4', 'action': 'update', 'object_id': ip_dict.get('id') } self.update_state( state='PROGRESS', meta=msg ) ip_obj = facade.get_ipv4_by_id(ip_dict.get('id')) user = Usuario.objects.get(id=user_id) try: facade.update_ipv4(ip_dict, user) except Exception, exception: msg['message'] = 'IPv4 {} was not updated.'.format(ip_obj) msg['reason'] = str(exception) raise Exception(msg)