22
22
from oslo_log import log
23
23
24
24
from neutron .common .ovn import constants as ovn_const
25
+ from neutron .db import db_base_plugin_common
26
+ from neutron .db import ovn_revision_numbers_db as db_rev
25
27
from neutron .objects import ports as port_obj
26
28
from neutron .services .trunk .drivers import base as trunk_base
27
29
@@ -47,20 +49,23 @@ def _set_sub_ports(self, parent_port, subports):
47
49
context = n_context .get_admin_context ()
48
50
db_parent_port = port_obj .Port .get_object (context , id = parent_port )
49
51
parent_port_status = db_parent_port .status
50
- for port in subports :
52
+ for subport in subports :
51
53
with db_api .CONTEXT_WRITER .using (context ), (
52
54
txn (check_error = True )) as ovn_txn :
53
- self ._set_binding_profile (context , port , parent_port ,
54
- parent_port_status , ovn_txn )
55
+ port = self ._set_binding_profile (context , subport , parent_port ,
56
+ parent_port_status , ovn_txn )
57
+ db_rev .bump_revision (context , port , ovn_const .TYPE_PORTS )
55
58
56
59
def _unset_sub_ports (self , subports ):
57
60
txn = self .plugin_driver .nb_ovn .transaction
58
61
context = n_context .get_admin_context ()
59
- for port in subports :
62
+ for subport in subports :
60
63
with db_api .CONTEXT_WRITER .using (context ), (
61
64
txn (check_error = True )) as ovn_txn :
62
- self ._unset_binding_profile (context , port , ovn_txn )
65
+ port = self ._unset_binding_profile (context , subport , ovn_txn )
66
+ db_rev .bump_revision (context , port , ovn_const .TYPE_PORTS )
63
67
68
+ @db_base_plugin_common .convert_result_to_dict
64
69
def _set_binding_profile (self , context , subport , parent_port ,
65
70
parent_port_status , ovn_txn ):
66
71
LOG .debug ("Setting parent %s for subport %s" ,
@@ -71,6 +76,9 @@ def _set_binding_profile(self, context, subport, parent_port,
71
76
"binding_profile: %s" ,
72
77
subport .port_id )
73
78
return
79
+ check_rev_cmd = self .plugin_driver .nb_ovn .check_revision_number (
80
+ db_port .id , db_port , ovn_const .TYPE_PORTS )
81
+ ovn_txn .add (check_rev_cmd )
74
82
try :
75
83
# NOTE(flaviof): We expect binding's host to be set. Otherwise,
76
84
# sub-port will not transition from DOWN to ACTIVE.
@@ -103,7 +111,9 @@ def _set_binding_profile(self, context, subport, parent_port,
103
111
))
104
112
LOG .debug ("Done setting parent %s for subport %s" ,
105
113
parent_port , subport .port_id )
114
+ return db_port
106
115
116
+ @db_base_plugin_common .convert_result_to_dict
107
117
def _unset_binding_profile (self , context , subport , ovn_txn ):
108
118
LOG .debug ("Unsetting parent for subport %s" , subport .port_id )
109
119
db_port = port_obj .Port .get_object (context , id = subport .port_id )
@@ -112,6 +122,9 @@ def _unset_binding_profile(self, context, subport, ovn_txn):
112
122
"binding_profile: %s" ,
113
123
subport .port_id )
114
124
return
125
+ check_rev_cmd = self .plugin_driver .nb_ovn .check_revision_number (
126
+ db_port .id , db_port , ovn_const .TYPE_PORTS )
127
+ ovn_txn .add (check_rev_cmd )
115
128
try :
116
129
db_port .device_owner = ''
117
130
for binding in db_port .bindings :
@@ -140,6 +153,7 @@ def _unset_binding_profile(self, context, subport, ovn_txn):
140
153
external_ids_update = ext_ids ,
141
154
))
142
155
LOG .debug ("Done unsetting parent for subport %s" , subport .port_id )
156
+ return db_port
143
157
144
158
def trunk_created (self , trunk ):
145
159
# Check if parent port is handled by OVN.
0 commit comments