99# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1010# License for the specific language governing permissions and limitations
1111# under the License.
12- #
13-
1412
1513import argparse
1614from collections .abc import Iterable , Sequence
2523from openstackclient .network .v2 .dynamic_routing import bgp_peer
2624
2725
28- def _get_attrs (
29- client_manager : Any , parsed_args : argparse .Namespace
30- ) -> dict [str , Any ]:
26+ def _get_attrs (parsed_args : argparse .Namespace ) -> dict [str , Any ]:
3127 attrs : dict [str , Any ] = {}
3228 if parsed_args .name is not None :
3329 attrs ['name' ] = str (parsed_args .name )
@@ -43,15 +39,6 @@ def _get_attrs(
4339 attrs ['advertise_floating_ip_host_routes' ] = True
4440 if parsed_args .no_advertise_floating_ip_host_routes :
4541 attrs ['advertise_floating_ip_host_routes' ] = False
46-
47- if 'project' in parsed_args and parsed_args .project is not None :
48- identity_client = client_manager .identity
49- project_id = identity_common .find_project (
50- identity_client ,
51- parsed_args .project ,
52- parsed_args .project_domain ,
53- ).id
54- attrs ['tenant_id' ] = project_id
5542 return attrs
5643
5744
@@ -184,7 +171,17 @@ def take_action(
184171 self , parsed_args : argparse .Namespace
185172 ) -> tuple [Sequence [str ], Iterable [Any ]]:
186173 client = self .app .client_manager .network
187- attrs = _get_attrs (self .app .client_manager , parsed_args )
174+
175+ attrs = _get_attrs (parsed_args )
176+ if parsed_args .project is not None :
177+ identity_client = self .app .client_manager .sdk_connection .identity
178+ project_id = identity_common .find_project_id_sdk (
179+ identity_client ,
180+ parsed_args .project ,
181+ parsed_args .project_domain ,
182+ )
183+ attrs ['project_id' ] = project_id
184+
188185 obj = client .create_bgp_speaker (** attrs )
189186 display_columns , columns = utils .get_osc_show_columns_for_sdk_resource (
190187 obj , {}, ['location' , 'tenant_id' ]
@@ -346,7 +343,7 @@ def take_action(self, parsed_args: argparse.Namespace) -> None:
346343 id = client .find_bgp_speaker (
347344 parsed_args .bgp_speaker , ignore_missing = False
348345 ).id
349- attrs = _get_attrs (self . app . client_manager , parsed_args )
346+ attrs = _get_attrs (parsed_args )
350347 client .update_bgp_speaker (id , ** attrs )
351348
352349
0 commit comments