Skip to content

Commit 42bceed

Browse files
committed
Merge branch 'release-v5.8.5'
2 parents b2a02ac + 8ff0d9e commit 42bceed

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

netfoundry/ctl.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,17 @@
1212
import re
1313
import signal
1414
import tempfile
15-
# from getpass import getuser
1615
from json import dumps as json_dumps
1716
from json import load as json_load
1817
from json import loads as json_loads
1918
from os import environ, path # , stat
20-
# from pathlib import Path
2119
from random import choice, sample, shuffle
2220
from re import sub
23-
# from shlex import split as shplit
24-
# from shutil import which
25-
from stat import S_IRUSR, S_IWUSR, S_IXUSR, filemode
2621
from subprocess import CalledProcessError
2722
from sys import exit as sysexit
2823
from sys import stdin, stdout, stderr
2924
from xml.sax.xmlreader import InputSource
3025

31-
# importing this causes the 'config' subcommand to be available
3226
from jwt.exceptions import PyJWTError
3327
from pygments import highlight
3428
from pygments.formatters import Terminal256Formatter
@@ -181,13 +175,14 @@ def login(cli):
181175
cli.echo(json_dumps(summary_object, indent=4))
182176
else: # if eval
183177
token_env = f"""
184-
# $ source <(nfctl --credentials=credentials.json login --eval)
178+
# $ eval "$({cli.prog_name} --credentials=credentials.json login --eval)"
185179
export NETFOUNDRY_API_TOKEN="{organization.token}"
186180
export NETFOUNDRY_API_ACCOUNT="{organization.credentials if hasattr(organization, 'credentials') else ''}"
187181
export NETFOUNDRY_ORGANIZATION="{organization.id}"
188182
{'export NETFOUNDRY_NETWORK="'+network.id+'"' if network else ''}
189183
{'export NETFOUNDRY_NETWORK_GROUP="'+network_group.id+'"' if network_group else ''}
190184
{'export MOPENV="'+organization.environment+'"' if organization.environment else ''}
185+
eval "$(register-python-argcomplete {cli.prog_name})"
191186
"""
192187
if cli.config.general.color:
193188
highlighted = highlight(token_env, bash_lexer, Terminal256Formatter(style=cli.config.general.style))
@@ -550,7 +545,7 @@ def list(cli, spinner: object = None):
550545
cli.log.warn("try 'get' command to get by id")
551546
if cli.args.output == "text":
552547
if not stdout.isatty():
553-
cli.log.warning("use --output=yaml or json for scripting nfctl")
548+
cli.log.warning(f"use --output=yaml or json for scripting {cli.prog_name}")
554549
else: # output is YAML or JSON
555550
# don't emit INFO messages to stdout because they will break deserialization
556551
cli.log.setLevel(logging.WARN)
@@ -751,11 +746,12 @@ def delete(cli):
751746
sysexit(1)
752747

753748

749+
@cli.argument("-p", "--prefix", default=f"{cli.prog_name}-demo", help="choose a network name prefix to identify all of your demos")
754750
@cli.argument("-j", "--jwt", action="store_boolean", default=True, help="save the one-time enroll token for each demo identity in the current directory")
755751
@cli.argument("-s", "--size", default="small", help=argparse.SUPPRESS) # troubleshoot scale-up instance size factor
756752
@cli.argument("-v", "--product-version", default="default", help="network product version: 'default', 'latest', or any active semver")
757-
@cli.argument("--provider", default="AWS", required=False, help="cloud provider to host edge routers", choices=DC_PROVIDERS)
758-
@cli.argument("--regions", dest="regions", default=["us-west-1"], nargs="+", help="cloud location codes in which to host edge routers")
753+
@cli.argument("--provider", default="AWS", help="cloud provider for hosted edge routers", choices=DC_PROVIDERS)
754+
@cli.argument("--regions", dest="regions", default=["us-west-1"], nargs="+", help="provider regions for hosted edge routers")
759755
@cli.subcommand('create a functioning demo network')
760756
def demo(cli):
761757
"""Create a demo network or add demo resources to existing network."""
@@ -769,7 +765,7 @@ def demo(cli):
769765
friendly_words_filename = path.join(resources_dir, "friendly-words/generated/words.json")
770766
with open(friendly_words_filename, 'r') as friendly_words_path:
771767
friendly_words = json_load(friendly_words_path)
772-
network_name = f"nfctl-demo-{choice(friendly_words['predicates'])}-{choice(friendly_words['objects'])}"
768+
network_name = f"{cli.config.demo.prefix}-{choice(friendly_words['predicates'])}-{choice(friendly_words['objects'])}"
773769
demo_confirmed = False
774770
if cli.config.general.yes:
775771
demo_confirmed = True

netfoundry/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1920,7 +1920,7 @@ def rotate_edge_router_registration(self, id: str):
19201920

19211921
get_edge_router_registration = rotate_edge_router_registration
19221922

1923-
def delete_resource(self, type: str, id: str = None, wait: int = 0, progress: bool = False):
1923+
def delete_resource(self, type: str, id: str = None, wait: int = 0, sleep: int = 10, progress: bool = False):
19241924
"""Delete a resource.
19251925
19261926
:param type: required entity type to delete i.e. network, endpoint, service, edge-router

netfoundry/utility.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,10 @@ class ResourceType(ResourceTypeParent):
495495
create_responses: list = field(default_factory=list) # expected HTTP response codes for create operation
496496
no_update_props: list = field(default_factory=list) # expected HTTP response codes for create operation
497497
create_template: dict = field(default_factory=lambda: {
498-
'hint': "No template was found for this resource type. Replace the contents of this buffer with the request body as YAML or JSON to create a resource. networkId will be added automatically."
498+
'hint': "No template was found for this resource type. "
499+
" Replace the contents of this buffer with the "
500+
" request body as YAML or JSON to create a resource."
501+
" networkId will be added automatically."
499502
}) # object to load when creating from scratch in nfctl
500503
abbreviation: str = field(default='default')
501504
status_symbols: dict = field(default_factory=lambda: RESOURCE_STATUS_SYMBOLS) # dictionary with three predictable keys: complete, progress, error, each a tuple associating status symbols with a state

0 commit comments

Comments
 (0)