def delete(self, urns, client_cert, credentials, best_effort): """ Deletes the requested resources, identified each by an URN. When best_effort is enabled, deletion will be attempted on every resource. @param urns list of URNs with the identifiers of the resources to be treated @param client_cert client certificate (X509) @param credentials client credential(s), provided by the ClearingHouse and generated after the certificates @param best_effort flag to describe the behaviour upon a failure * best_effort = True : as much operations as possible are performed upon an error condition * best_effort = False : the set of operations will be stopped if an error occurs @return ro_slivers structure containing information of slivers (URN, expiration date, etc) """ ro_slivers = [] logger.info("best_effort=%s" % (best_effort,)) route = db_sync_manager.get_slice_routing_keys(urns) logger.debug("Route=%s" % (route,)) for r, v in route.iteritems(): peer = db_sync_manager.get_configured_peer_by_routing_key(r) logger.debug("peer=%s" % (peer,)) if peer.get("type") in self._allowed_peers.values(): slivers = CommonUtils.manage_delete( peer, v, credentials, best_effort) logger.debug("slivers=%s" % (slivers,)) ro_slivers.extend(slivers) db_urns = [] for s in ro_slivers: s["geni_expires"] = dates.rfc3339_to_datetime(s["geni_expires"]) db_urns.append(s.get("geni_sliver_urn")) logger.debug("RO-Slivers(%d)=%s, DB-URNs(%d)=%s" % (len(ro_slivers), ro_slivers, len(db_urns), db_urns)) # update MS to stop slice-monitoring collection slice_urn = db_sync_manager.get_slice_urn(urns) if slice_urn: try: # MS needs to be sent the whole slice data in order to # delete it slice_monitor = SliceMonitoring() slice_monitor.delete_slice_topology(slice_urn) except Exception as e: logger.warning("Delegate could not send slice monitoring" + " information upon Delete. Details: %s", (e,)) db_sync_manager.delete_slice_sdn(slice_urn) db_sync_manager.delete_slice_urns(db_urns) self.__schedule_tnres_update( tn_resource_refresh, 1, "oneshot_tn_resource_refresh") return ro_slivers
def delete(self, urns, client_cert, credentials, best_effort): """ Deletes the requested resources, identified each by an URN. When best_effort is enabled, deletion will be attempted on every resource. @param urns list of URNs with the identifiers of the resources to be treated @param client_cert client certificate (X509) @param credentials client credential(s), provided by the ClearingHouse and generated after the certificates @param best_effort flag to describe the behaviour upon a failure * best_effort = True : as much operations as possible are performed upon an error condition * best_effort = False : the set of operations will be stopped if an error occurs @return ro_slivers structure containing information of slivers (URN, expiration date, etc) """ ro_slivers = [] logger.info("best_effort=%s" % (best_effort, )) route = db_sync_manager.get_slice_routing_keys(urns) logger.debug("Route=%s" % (route, )) for r, v in route.iteritems(): peer = db_sync_manager.get_configured_peer_by_routing_key(r) logger.debug("peer=%s" % (peer, )) if peer.get("type") in self._allowed_peers.values(): slivers = CommonUtils.manage_delete(peer, v, credentials, best_effort) logger.debug("slivers=%s" % (slivers, )) ro_slivers.extend(slivers) db_urns = [] for s in ro_slivers: s["geni_expires"] = dates.rfc3339_to_datetime(s["geni_expires"]) db_urns.append(s.get("geni_sliver_urn")) logger.debug("RO-Slivers(%d)=%s, DB-URNs(%d)=%s" % (len(ro_slivers), ro_slivers, len(db_urns), db_urns)) # update MS to stop slice-monitoring collection slice_urn = db_sync_manager.get_slice_urn(urns) if slice_urn: try: # MS needs to be sent the whole slice data in order to # delete it slice_monitor = SliceMonitoring() slice_monitor.delete_slice_topology(slice_urn) except Exception as e: logger.warning( "Delegate could not send slice monitoring" + " information upon Delete. Details: %s", (e, )) db_sync_manager.delete_slice_sdn(slice_urn) db_sync_manager.delete_slice_urns(db_urns) return ro_slivers
def slice_expiration(urns): logger.info("slice expiration timeout: %s" % (urns, )) ro_slivers = [] route = db_sync_manager.get_slice_routing_keys(urns) logger.debug("Route=%s" % (route, )) for r, v in route.iteritems(): peer = db_sync_manager.get_configured_peer_by_routing_key(r) logger.debug("peer=%s" % (peer, )) adaptor = AdaptorFactory.create_from_db(peer) geni_v3_creds = AdaptorFactory.geni_v3_credentials() of_slivers = adaptor.delete(urns, geni_v3_creds, False) logger.debug("of_s=%s" % (of_slivers, )) ro_slivers.extend(of_slivers) db_urns = [s.get("geni_sliver_urn") for s in ro_slivers] logger.debug("RO-Slivers=%s, DB-URNs=%s" % (ro_slivers, db_urns)) db_sync_manager.delete_slice_urns(db_urns)