29
29
30
30
# NOTE(ralonsoh): this was migrated from networking-ovn to neutron and should
31
31
# be refactored to be integrated in a OVO.
32
+ @db_api .retry_if_session_inactive ()
32
33
def add_node (context , group_name , node_uuid = None ):
33
34
if node_uuid is None :
34
35
node_uuid = uuidutils .generate_uuid ()
@@ -41,6 +42,7 @@ def add_node(context, group_name, node_uuid=None):
41
42
return node_uuid
42
43
43
44
45
+ @db_api .retry_if_session_inactive ()
44
46
def remove_nodes_from_host (context , group_name ):
45
47
with db_api .CONTEXT_WRITER .using (context ):
46
48
context .session .query (ovn_models .OVNHashRing ).filter (
@@ -50,13 +52,15 @@ def remove_nodes_from_host(context, group_name):
50
52
CONF .host , group_name )
51
53
52
54
55
+ @db_api .retry_if_session_inactive ()
53
56
def remove_node_by_uuid (context , node_uuid ):
54
57
with db_api .CONTEXT_WRITER .using (context ):
55
58
context .session .query (ovn_models .OVNHashRing ).filter (
56
59
ovn_models .OVNHashRing .node_uuid == node_uuid ).delete ()
57
60
LOG .info ('Node "%s" removed from the Hash Ring' , node_uuid )
58
61
59
62
63
+ @db_api .retry_if_session_inactive ()
60
64
def _touch (context , updated_at = None , ** filter_args ):
61
65
if updated_at is None :
62
66
updated_at = timeutils .utcnow ()
@@ -90,19 +94,22 @@ def _get_nodes_query(context, interval, group_name, offline=False,
90
94
return query
91
95
92
96
97
+ @db_api .retry_if_session_inactive ()
93
98
@db_api .CONTEXT_READER
94
99
def get_active_nodes (context , interval , group_name , from_host = False ):
95
100
query = _get_nodes_query (context , interval , group_name ,
96
101
from_host = from_host )
97
102
return query .all ()
98
103
99
104
105
+ @db_api .retry_if_session_inactive ()
100
106
@db_api .CONTEXT_READER
101
107
def count_offline_nodes (context , interval , group_name ):
102
108
query = _get_nodes_query (context , interval , group_name , offline = True )
103
109
return query .count ()
104
110
105
111
112
+ @db_api .retry_if_session_inactive ()
106
113
@db_api .CONTEXT_READER
107
114
def count_nodes_from_host (context , group_name ):
108
115
query = context .session .query (ovn_models .OVNHashRing ).filter (
0 commit comments