@require_admin_context
def cluster_destroy(context, id):
 query = _cluster_query(context, id=id)
 query = query.filter((models.Cluster.num_hosts == 0))
 result = query.update(models.Cluster.delete_values(), synchronize_session=False)
 if (not result):
  cluster_get(context, id=id)
  raise exception.ClusterHasHosts(id=id)

@ require_admin_context def cluster_destroy ( context , id ) : query = _cluster_query ( context , id = id ) query = query . filter ( ( models . Cluster . num_hosts == 0 ) ) result = query . update ( models . Cluster . delete_values ( ) , synchronize_session = False ) if ( not result ) : cluster_get ( context , id = id ) raise exception . ClusterHasHosts ( id = id )
destroy the cluster or raise if it does not exist or has hosts .