def _delete_number(db_sess, sip_uri, private_id, delete_digest, on_success, on_failure, force_delete): """ Deletes all information associated with a private/public identity pair, optionally deleting the digest associated with the private identity """ def on_upstream_deletion(*args): _log.info("Deletion from Homestead and Homer was OK - returning number to pool") numbers.remove_owner(db_sess, sip_uri) db_sess.commit() on_success(args) # Concurrently, delete data from Homestead and Homer request_group = HTTPCallbackGroup(on_upstream_deletion, on_failure) if force_delete: request_group = HTTPCallbackGroup(on_success, on_failure) _log.info("Returning number to pool before attempting deletion from Homestead and Homer") numbers.remove_owner(db_sess, sip_uri) db_sess.commit() if delete_digest: # Deleting the private ID will delete its associated IRS (and # therefore any subsidiary public IDs and their service profiles) homestead.delete_private_id(private_id, request_group.callback()) else: homestead.delete_public_id(sip_uri, request_group.callback()) xdm.delete_simservs(sip_uri, request_group.callback())
def _delete_number(db_sess, sip_uri, private_id, delete_digest, on_success, on_failure, force_delete): """ Deletes all information associated with a private/public identity pair, optionally deleting the digest associated with the private identity """ def on_upstream_deletion(*args): _log.info( "Deletion from Homestead and Homer was OK - returning number to pool" ) numbers.remove_owner(db_sess, sip_uri) db_sess.commit() on_success(args) # Concurrently, delete data from Homestead and Homer request_group = HTTPCallbackGroup(on_upstream_deletion, on_failure) if force_delete: # pragma: no cover request_group = HTTPCallbackGroup(on_success, on_failure) _log.info( "Returning number to pool before attempting deletion from Homestead and Homer" ) numbers.remove_owner(db_sess, sip_uri) db_sess.commit() if delete_digest: # Deleting the private ID will delete its associated IRS (and # therefore any subsidiary public IDs and their service profiles) homestead.delete_private_id(private_id, request_group.callback()) else: homestead.delete_public_id(sip_uri, request_group.callback()) xdm.delete_simservs(sip_uri, request_group.callback())
def test_delete_simservs(self, settings, AsyncHTTPClient): settings.XDM_URL = "xdm" client = Mock() AsyncHTTPClient.return_value = client callback = Mock() xdm.delete_simservs(SIP_URI, callback) client.fetch.assert_called_once_with(SIMSERVS_URL, callback, method="DELETE", headers={"X-XCAP-Asserted-Identity": SIP_URI})
def _on_get_failure(self, sip_uri, response): # pragma: no cover _log.warn("Failed to fetch private identities from homestead for %s", sip_uri) if hasattr(response, 'code') and response.code == 404: # The number has no records in Homestead, so forget about it locally _log.warn("Returning %s to the pool", sip_uri) db_sess = self.db_session() numbers.remove_owner(db_sess, sip_uri) db_sess.commit() # Also try and remove it from Homer, but do nothing if we fail xdm.delete_simservs(sip_uri, lambda responses: None) self.forward_error(response)
def test_delete_simservs(self, settings, AsyncHTTPClient): settings.XDM_URL = "xdm" client = Mock() AsyncHTTPClient.return_value = client callback = Mock() xdm.delete_simservs(SIP_URI, callback) client.fetch.assert_called_once_with(SIMSERVS_URL, callback, method="DELETE", headers={"X-XCAP-Asserted-Identity": SIP_URI}, allow_ipv6=True)
def _delete_number(db_sess, sip_uri, private_id, delete_digest, on_success, on_failure): """ Deletes all information associated with a private/public identity pair, optionally deleting the digest associated with the private identity """ numbers.remove_owner(db_sess, sip_uri) db_sess.commit() # Concurrently, delete data from Homestead and Homer request_group = HTTPCallbackGroup(on_success, on_failure) if delete_digest: homestead.delete_private_id(private_id, request_group.callback()) homestead.delete_public_id(sip_uri, request_group.callback()) xdm.delete_simservs(sip_uri, request_group.callback())
def delete_line(): """ Remove details about line from ellis, homestead and homer """ print "Deleting %s %s" % (private_id, sip_uri) numbers.remove_owner(db_session, sip_uri) # Attempt to delete info about line from remotes global pending_requests if private_id: stats["Credentials & associations deleted"] += 1 pending_requests += 2 homestead.delete_password(private_id, logging_handler) homestead.delete_associated_public(private_id, sip_uri, logging_handler) stats["Simservs & iFCs deleted"] += 1 pending_requests += 2 homestead.delete_filter_criteria(sip_uri, logging_handler) xdm.delete_simservs(sip_uri, logging_handler)