Skip to content

Commit e6c5e33

Browse files
committed
Merge branch 'release-v5.8.17'
2 parents 3efc7d0 + 6952b9d commit e6c5e33

File tree

3 files changed

+92
-24
lines changed

3 files changed

+92
-24
lines changed

netfoundry/ctl.py

+65-17
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,39 @@ def login(cli):
163163
table = tabulate(tabular_data=summary_table, headers=['Domain', 'Summary'], tablefmt=table_borders)
164164
if cli.config.general.color:
165165
highlighted = highlight(table, text_lexer, Terminal256Formatter(style=cli.config.general.style))
166-
cli.echo(highlighted)
166+
try:
167+
cli.echo(highlighted)
168+
except ValueError:
169+
print(highlighted)
167170
else:
168-
cli.echo(table)
171+
try:
172+
cli.echo(table)
173+
except ValueError:
174+
print(table)
169175
elif cli.args.output == "yaml":
170176
if cli.config.general.color:
171177
highlighted = highlight(yaml_dumps(summary_object, indent=4), yaml_lexer, Terminal256Formatter(style=cli.config.general.style))
172-
cli.echo(highlighted)
178+
try:
179+
cli.echo(highlighted)
180+
except ValueError:
181+
print(highlighted)
173182
else:
174-
cli.echo(yaml_dumps(summary_object, indent=4))
183+
try:
184+
cli.echo(yaml_dumps(summary_object, indent=4))
185+
except ValueError:
186+
print(yaml_dumps(summary_object, indent=4))
175187
elif cli.args.output == "json":
176188
if cli.config.general.color:
177189
highlighted = highlight(json_dumps(summary_object, indent=4), json_lexer, Terminal256Formatter(style=cli.config.general.style))
178-
cli.echo(highlighted)
190+
try:
191+
cli.echo(highlighted)
192+
except ValueError:
193+
print(highlighted)
179194
else:
180-
cli.echo(json_dumps(summary_object, indent=4))
195+
try:
196+
cli.echo(json_dumps(summary_object, indent=4))
197+
except ValueError:
198+
print(json_dumps(summary_object, indent=4))
181199
else: # if eval
182200
nonf = """
183201
# helper function logs out from NetFoundry
@@ -212,9 +230,15 @@ def login(cli):
212230
"""
213231
if cli.config.general.color:
214232
highlighted = highlight(token_env, bash_lexer, Terminal256Formatter(style=cli.config.general.style))
215-
cli.echo(highlighted)
233+
try:
234+
cli.echo(highlighted)
235+
except ValueError:
236+
print(highlighted)
216237
else:
217-
cli.echo(token_env)
238+
try:
239+
cli.echo(token_env)
240+
except ValueError:
241+
print(token_env)
218242

219243

220244
@cli.subcommand('logout your identity for the current current profile')
@@ -541,15 +565,27 @@ def get(cli, echo: bool = True, spinner: object = None):
541565
if cli.args.output in ["yaml", "text"]:
542566
if cli.config.general.color:
543567
highlighted = highlight(yaml_dumps(filtered_match, indent=4), yaml_lexer, Terminal256Formatter(style=cli.config.general.style))
544-
cli.echo(highlighted)
568+
try:
569+
cli.echo(highlighted)
570+
except ValueError:
571+
print(highlighted)
545572
else:
546-
cli.echo(yaml_dumps(filtered_match, indent=4))
573+
try:
574+
cli.echo(yaml_dumps(filtered_match, indent=4))
575+
except ValueError:
576+
print(yaml_dumps(filtered_match, indent=4))
547577
elif cli.args.output == "json":
548578
if cli.config.general.color:
549579
highlighted = highlight(json_dumps(filtered_match, indent=4), json_lexer, Terminal256Formatter(style=cli.config.general.style))
550-
cli.echo(highlighted)
580+
try:
581+
cli.echo(highlighted)
582+
except ValueError:
583+
print(highlighted)
551584
else:
552-
cli.echo(json_dumps(filtered_match, indent=4))
585+
try:
586+
cli.echo(json_dumps(filtered_match, indent=4))
587+
except ValueError:
588+
print(json_dumps(filtered_match, indent=4))
553589
elif len(matches) == 0:
554590
cli.log.warn(f"found no {cli.args.resource_type} by '{', '.join(query_keys)}'")
555591
sysexit(1)
@@ -651,7 +687,7 @@ def list(cli, spinner: object = None):
651687
'edgeRouterAttributes', 'serviceAttributes', 'endpointAttributes',
652688
'status', 'zitiId', 'provider', 'locationCode', 'ipAddress', 'networkVersion',
653689
'active', 'default', 'region', 'size', 'attributes', 'email', 'productVersion',
654-
'state']
690+
'state', 'address', 'binding']
655691
valid_keys = set(matches[0].keys()) & set(default_columns)
656692

657693
if valid_keys:
@@ -688,15 +724,27 @@ def list(cli, spinner: object = None):
688724
elif cli.args.output == "yaml":
689725
if cli.config.general.color:
690726
highlighted = highlight(yaml_dumps(filtered_matches, indent=4), yaml_lexer, Terminal256Formatter(style=cli.config.general.style))
691-
cli.echo(highlighted)
727+
try:
728+
cli.echo(highlighted)
729+
except ValueError:
730+
print(highlighted)
692731
else:
693-
cli.echo(yaml_dumps(filtered_matches, indent=4))
732+
try:
733+
cli.echo(yaml_dumps(filtered_matches, indent=4))
734+
except ValueError:
735+
print(yaml_dumps(filtered_matches, indent=4))
694736
elif cli.args.output == "json":
695737
if cli.config.general.color:
696738
highlighted = highlight(json_dumps(filtered_matches, indent=4), json_lexer, Terminal256Formatter(style=cli.config.general.style))
697-
cli.echo(highlighted)
739+
try:
740+
cli.echo(highlighted)
741+
except ValueError:
742+
print(highlighted)
698743
else:
699-
cli.echo(json_dumps(filtered_matches, indent=4))
744+
try:
745+
cli.echo(json_dumps(filtered_matches, indent=4))
746+
except ValueError:
747+
print(json_dumps(filtered_matches, indent=4))
700748

701749

702750
@cli.argument('query', arg_only=True, action=StoreDictKeyPair, nargs='?', help="query params as k=v,k=v comma-separated pairs")

netfoundry/organization.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,9 @@ def get_network(self, network_id: str, embed: object = None, accept: str = None)
592592
else:
593593
requested_types.extend(embed.split(','))
594594
if 'all' in requested_types:
595-
requested_types.extend(EMBED_NET_RESOURCES.keys())
596-
valid_types = [plural(type) for type in requested_types if EMBED_NET_RESOURCES.get(plural(type))]
595+
valid_types = ['all']
596+
else:
597+
valid_types = [plural(type) for type in requested_types if EMBED_NET_RESOURCES.get(plural(type))]
597598
params['embed'] = ','.join(valid_types)
598599
self.logger.debug(f"requesting embed of: '{valid_types}'")
599600

netfoundry/utility.py

+24-5
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,8 @@ def find_generic_resources(url: str, headers: dict, embedded: str = None, proxie
330330
# normalize output with a default sort param
331331
if not params.get('sort'):
332332
params["sort"] = "name,asc"
333-
# workaround sort param bug in MOP-18018
334-
if resource_type.name in ['identities', 'user-identities', 'api-account-identities']:
335-
del params['sort']
336-
elif resource_type.name == 'hosts': # workaround sort param bug in MOP-17863
333+
# workaround sort param bugs in MOP-18018, MOP-17863, MOP-18178
334+
if resource_type.name in ['identities', 'user-identities', 'api-account-identities', 'hosts', 'terminators']:
337335
del params['sort']
338336

339337
# only get one page of the requested size, else default page size and all pages
@@ -706,7 +704,28 @@ def __post_init__(self):
706704
mutable=True,
707705
embeddable=True,
708706
create_responses=["ACCEPTED"],
709-
)
707+
),
708+
'config-types': ResourceType(
709+
name='config-types',
710+
domain='network',
711+
mutable=True,
712+
embeddable=True,
713+
create_responses=["ACCEPTED"],
714+
),
715+
'configs': ResourceType(
716+
name='configs',
717+
domain='network',
718+
mutable=True,
719+
embeddable=True,
720+
create_responses=["ACCEPTED"],
721+
),
722+
'terminators': ResourceType(
723+
name='terminators',
724+
domain='network',
725+
mutable=True,
726+
embeddable=True,
727+
create_responses=["ACCEPTED"],
728+
),
710729
}
711730

712731
# TODO: [MOP-13441] associate locations with a short list of major geographic regions / continents

0 commit comments

Comments
 (0)