Fix a bug about next_index property of cluster
Remove cluster_get_next_index method from db_api since we don't need it anymore. Now we directly use db_api.cluster_get to fetch the next_index value of a cluster. Now cluster's next_index property will only be changed when the following two methods are invoked: 1. db_api.node_create 2. db_api.node_migrate Change-Id: I4361955cff18070200a97bd246ea7e9ddd330141 Closes-Bug: #1447468
This commit is contained in:
@@ -192,23 +192,6 @@ def cluster_get_by_short_id(context, short_id):
|
||||
return query_by_short_id(context, models.Cluster, short_id)
|
||||
|
||||
|
||||
def cluster_get_next_index(context, cluster_id):
|
||||
query = model_query(context, models.Cluster)
|
||||
session = query.session
|
||||
session.begin()
|
||||
cluster = query.get(cluster_id)
|
||||
|
||||
if cluster is None:
|
||||
session.rollback()
|
||||
return None
|
||||
|
||||
index = cluster.next_index
|
||||
cluster.next_index += 1
|
||||
cluster.save(session)
|
||||
session.commit()
|
||||
return index
|
||||
|
||||
|
||||
def cluster_get_all_by_parent(context, parent):
|
||||
results = soft_delete_aware_query(context, models.Cluster).\
|
||||
filter_by(parent=parent).all()
|
||||
|
||||
Reference in New Issue
Block a user