Skip to content

Commit 5a53f2c

Browse files
committed
network: Replace new use of keystoneclient
Change Id9014aef47af42ac813cacaaccc61346a0282897 removed all use of keystoneclient from openstackclient.network, but these users slipped in in the interim. Replace them. Change-Id: I8c23b789facdde7cbbcd7631a28156463fc12f8d Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
1 parent bad01d3 commit 5a53f2c

3 files changed

Lines changed: 26 additions & 32 deletions

File tree

openstackclient/network/v2/dynamic_routing/bgp_dragent.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
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-
#
1312

1413
import argparse
1514
from collections.abc import Iterable, Sequence

openstackclient/network/v2/dynamic_routing/bgp_peer.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
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-
#
1312

1413
import argparse
1514
from collections.abc import Iterable, Sequence
@@ -29,9 +28,7 @@
2928
MAX_AS_NUM = 4294967295
3029

3130

32-
def _get_attrs(
33-
client_manager: Any, parsed_args: argparse.Namespace
34-
) -> dict[str, Any]:
31+
def _get_attrs(parsed_args: argparse.Namespace) -> dict[str, Any]:
3532
attrs = {}
3633

3734
# Validate password
@@ -58,15 +55,6 @@ def _get_attrs(
5855
attrs['peer_ip'] = parsed_args.peer_ip
5956
if 'password' in parsed_args:
6057
attrs['password'] = parsed_args.password
61-
62-
if 'project' in parsed_args and parsed_args.project is not None:
63-
identity_client = client_manager.identity
64-
project_id = identity_common.find_project(
65-
identity_client,
66-
parsed_args.project,
67-
parsed_args.project_domain,
68-
).id
69-
attrs['tenant_id'] = project_id
7058
return attrs
7159

7260

@@ -120,7 +108,17 @@ def take_action(
120108
self, parsed_args: argparse.Namespace
121109
) -> tuple[Sequence[str], Iterable[Any]]:
122110
client = self.app.client_manager.network
123-
attrs = _get_attrs(self.app.client_manager, parsed_args)
111+
112+
attrs = _get_attrs(parsed_args)
113+
if parsed_args.project is not None:
114+
identity_client = self.app.client_manager.sdk_connection.identity
115+
project_id = identity_common.find_project_id_sdk(
116+
identity_client,
117+
parsed_args.project,
118+
parsed_args.project_domain,
119+
)
120+
attrs['project_id'] = project_id
121+
124122
obj = client.create_bgp_peer(**attrs)
125123
display_columns, columns = utils.get_osc_show_columns_for_sdk_resource(
126124
obj, {}, ['location', 'tenant_id']
@@ -193,7 +191,7 @@ def take_action(self, parsed_args: argparse.Namespace) -> None:
193191
id = client.find_bgp_peer(
194192
parsed_args.bgp_peer, ignore_missing=False
195193
).id
196-
attrs = _get_attrs(self.app.client_manager, parsed_args)
194+
attrs = _get_attrs(parsed_args)
197195
client.update_bgp_peer(id, **attrs)
198196

199197

openstackclient/network/v2/dynamic_routing/bgp_speaker.py

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
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

1513
import argparse
1614
from collections.abc import Iterable, Sequence
@@ -25,9 +23,7 @@
2523
from 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

Comments
 (0)