Skip to content

Commit c9fe334

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "network: Add '--marker', '--limit' to most list commands"
2 parents 6d3dac4 + e15c231 commit c9fe334

46 files changed

Lines changed: 773 additions & 33 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

openstackclient/network/v2/address_group.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from osc_lib import utils
2525

2626
from openstackclient import command
27+
from openstackclient.common import pagination
2728
from openstackclient.i18n import _
2829
from openstackclient.identity import common as identity_common
2930
from openstackclient.network import common
@@ -172,6 +173,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
172173
),
173174
)
174175
identity_common.add_project_domain_option_to_parser(parser)
176+
pagination.add_marker_pagination_option_to_parser(parser)
175177

176178
return parser
177179

@@ -204,6 +206,11 @@ def take_action(
204206
parsed_args.project_domain,
205207
).id
206208
attrs['project_id'] = project_id
209+
if parsed_args.marker is not None:
210+
attrs['marker'] = parsed_args.marker
211+
if parsed_args.limit is not None:
212+
attrs['limit'] = parsed_args.limit
213+
207214
data = client.address_groups(**attrs)
208215

209216
return (

openstackclient/network/v2/address_scope.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from osc_lib import utils
2424

2525
from openstackclient import command
26+
from openstackclient.common import pagination
2627
from openstackclient.i18n import _
2728
from openstackclient.identity import common as identity_common
2829
from openstackclient.network import common
@@ -188,7 +189,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
188189
),
189190
)
190191
identity_common.add_project_domain_option_to_parser(parser)
191-
192+
pagination.add_marker_pagination_option_to_parser(parser)
192193
shared_group = parser.add_mutually_exclusive_group()
193194
shared_group.add_argument(
194195
'--share',
@@ -200,6 +201,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
200201
action='store_true',
201202
help=_("List only address scopes not shared between projects"),
202203
)
204+
203205
return parser
204206

205207
def take_action(
@@ -237,6 +239,10 @@ def take_action(
237239
parsed_args.project_domain,
238240
).id
239241
attrs['project_id'] = project_id
242+
if parsed_args.marker is not None:
243+
attrs['marker'] = parsed_args.marker
244+
if parsed_args.limit is not None:
245+
attrs['limit'] = parsed_args.limit
240246
data = client.address_scopes(**attrs)
241247

242248
return (

openstackclient/network/v2/floating_ip.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from osc_lib.utils import tags as _tag
2626

2727
from openstackclient import command
28+
from openstackclient.common import pagination
2829
from openstackclient.i18n import _
2930
from openstackclient.identity import common as identity_common
3031
from openstackclient.network import common
@@ -311,6 +312,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
311312
default=False,
312313
help=_("List additional fields in output"),
313314
)
315+
pagination.add_marker_pagination_option_to_parser(parser)
314316
return parser
315317

316318
def take_action(
@@ -398,6 +400,10 @@ def take_action(
398400
).id
399401
router_ids.append(router_id)
400402
query['router_id'] = router_ids
403+
if parsed_args.marker is not None:
404+
query['marker'] = parsed_args.marker
405+
if parsed_args.limit is not None:
406+
query['limit'] = parsed_args.limit
401407

402408
_tag.get_tag_filtering_args(parsed_args, query)
403409

openstackclient/network/v2/floating_ip_port_forwarding.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from osc_lib import utils
2424

2525
from openstackclient import command
26+
from openstackclient.common import pagination
2627
from openstackclient.i18n import _
2728
from openstackclient.network import common
2829

@@ -297,7 +298,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
297298
"specified protocol number"
298299
),
299300
)
300-
301+
pagination.add_marker_pagination_option_to_parser(parser)
301302
return parser
302303

303304
def take_action(
@@ -343,6 +344,10 @@ def take_action(
343344
)
344345
if parsed_args.protocol is not None:
345346
query['protocol'] = parsed_args.protocol
347+
if parsed_args.marker is not None:
348+
query['marker'] = parsed_args.marker
349+
if parsed_args.limit is not None:
350+
query['limit'] = parsed_args.limit
346351

347352
obj = client.find_ip(
348353
parsed_args.floating_ip,

openstackclient/network/v2/ip_availability.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from osc_lib import utils
2323

2424
from openstackclient import command
25+
from openstackclient.common import pagination
2526
from openstackclient.i18n import _
2627
from openstackclient.identity import common as identity_common
2728

@@ -65,6 +66,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
6566
),
6667
)
6768
identity_common.add_project_domain_option_to_parser(parser)
69+
pagination.add_marker_pagination_option_to_parser(parser)
6870
return parser
6971

7072
def take_action(
@@ -88,7 +90,6 @@ def take_action(
8890
filters = {}
8991
if parsed_args.ip_version:
9092
filters['ip_version'] = parsed_args.ip_version
91-
9293
if parsed_args.project:
9394
identity_client = self.app.client_manager.identity
9495
project_id = identity_common.find_project(
@@ -97,6 +98,11 @@ def take_action(
9798
parsed_args.project_domain,
9899
).id
99100
filters['project_id'] = project_id
101+
if parsed_args.marker is not None:
102+
filters['marker'] = parsed_args.marker
103+
if parsed_args.limit is not None:
104+
filters['limit'] = parsed_args.limit
105+
100106
data = client.network_ip_availabilities(**filters)
101107
return (
102108
column_headers,

openstackclient/network/v2/l3_conntrack_helper.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from osc_lib import utils
2424

2525
from openstackclient import command
26+
from openstackclient.common import pagination
2627
from openstackclient.i18n import _
2728

2829
LOG = logging.getLogger(__name__)
@@ -179,6 +180,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
179180
'the netfilter conntrack target rule (name or ID)'
180181
),
181182
)
183+
pagination.add_marker_pagination_option_to_parser(parser)
182184

183185
return parser
184186

@@ -200,7 +202,13 @@ def take_action(
200202
'Protocol',
201203
'Port',
202204
)
205+
203206
attrs = _get_attrs(client, parsed_args)
207+
if parsed_args.marker is not None:
208+
attrs['marker'] = parsed_args.marker
209+
if parsed_args.limit is not None:
210+
attrs['limit'] = parsed_args.limit
211+
204212
data = client.conntrack_helpers(attrs.pop('router_id'), **attrs)
205213

206214
return (

openstackclient/network/v2/network.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from osc_lib.utils import tags as _tag
2626

2727
from openstackclient import command
28+
from openstackclient.common import pagination
2829
from openstackclient.i18n import _
2930
from openstackclient.identity import common as identity_common
3031
from openstackclient.network import common
@@ -579,6 +580,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
579580
help=_('List only networks hosted the specified agent (ID only)'),
580581
)
581582
_tag.add_tag_filtering_option_to_parser(parser, _('networks'))
583+
pagination.add_marker_pagination_option_to_parser(parser)
582584
return parser
583585

584586
def take_action(
@@ -690,6 +692,11 @@ def take_action(
690692
args['provider:segmentation_id'] = parsed_args.segmentation_id
691693
args['provider_segmentation_id'] = parsed_args.segmentation_id
692694

695+
if parsed_args.marker is not None:
696+
args['marker'] = parsed_args.marker
697+
if parsed_args.limit is not None:
698+
args['limit'] = parsed_args.limit
699+
693700
_tag.get_tag_filtering_args(parsed_args, args)
694701

695702
return (

openstackclient/network/v2/network_agent.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from osc_lib import utils
2626

2727
from openstackclient import command
28+
from openstackclient.common import pagination
2829
from openstackclient.i18n import _
2930

3031
LOG = logging.getLogger(__name__)
@@ -249,6 +250,7 @@ def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
249250
default=False,
250251
help=_("List additional fields in output"),
251252
)
253+
pagination.add_marker_pagination_option_to_parser(parser)
252254

253255
return parser
254256

@@ -276,6 +278,10 @@ def take_action(
276278
)
277279

278280
filters = {}
281+
if parsed_args.marker is not None:
282+
filters['marker'] = parsed_args.marker
283+
if parsed_args.limit is not None:
284+
filters['limit'] = parsed_args.limit
279285

280286
data: list[_agent.Agent]
281287
if parsed_args.network is not None:

openstackclient/network/v2/network_flavor.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from osc_lib import utils
2424

2525
from openstackclient import command
26+
from openstackclient.common import pagination
2627
from openstackclient.i18n import _
2728
from openstackclient.identity import common as identity_common
2829
from openstackclient.network import common
@@ -193,6 +194,11 @@ def take_action(self, parsed_args: argparse.Namespace) -> None:
193194
class ListNetworkFlavor(command.Lister):
194195
_description = _("List network flavors")
195196

197+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
198+
parser = super().get_parser(prog_name)
199+
pagination.add_marker_pagination_option_to_parser(parser)
200+
return parser
201+
196202
def take_action(
197203
self, parsed_args: argparse.Namespace
198204
) -> tuple[tuple[str, ...], Iterable[tuple[Any, ...]]]:
@@ -207,7 +213,13 @@ def take_action(
207213
'Description',
208214
)
209215

210-
data = client.flavors()
216+
filters = {}
217+
if parsed_args.marker is not None:
218+
filters['marker'] = parsed_args.marker
219+
if parsed_args.limit is not None:
220+
filters['limit'] = parsed_args.limit
221+
222+
data = client.flavors(**filters)
211223
return (
212224
column_headers,
213225
(

openstackclient/network/v2/network_flavor_profile.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from osc_lib import utils
2222

2323
from openstackclient import command
24+
from openstackclient.common import pagination
2425
from openstackclient.i18n import _
2526
from openstackclient.network import common
2627

@@ -162,6 +163,11 @@ def take_action(self, parsed_args: argparse.Namespace) -> None:
162163
class ListNetworkFlavorProfile(command.Lister):
163164
_description = _("List network flavor profile(s)")
164165

166+
def get_parser(self, prog_name: str) -> argparse.ArgumentParser:
167+
parser = super().get_parser(prog_name)
168+
pagination.add_marker_pagination_option_to_parser(parser)
169+
return parser
170+
165171
def take_action(
166172
self, parsed_args: argparse.Namespace
167173
) -> tuple[tuple[str, ...], Iterable[tuple[Any, ...]]]:
@@ -182,7 +188,14 @@ def take_action(
182188
'Description',
183189
)
184190

185-
data = client.service_profiles()
191+
filters = {}
192+
if parsed_args.marker is not None:
193+
filters['marker'] = parsed_args.marker
194+
if parsed_args.limit is not None:
195+
filters['limit'] = parsed_args.limit
196+
197+
data = client.service_profiles(**filters)
198+
186199
return (
187200
column_headers,
188201
(

0 commit comments

Comments
 (0)