Skip to content

Commit b2a02ac

Browse files
committed
Merge branch 'release-v5.8.4'
2 parents c44098e + dfbbf99 commit b2a02ac

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

netfoundry/ctl.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def get(cli, echo: bool = True, embed='all', spinner: object = None):
532532

533533
@cli.argument('query', arg_only=True, action=StoreDictKeyPair, nargs='?', help="query params as k=v,k=v comma-separated pairs")
534534
@cli.argument('-k', '--keys', arg_only=True, action=StoreListKeys, help="list of keys as a,b,c to print only selected keys (columns)")
535-
@cli.argument('-m', '--mine', arg_only=True, action='store_true', help="filter roles by caller identity")
535+
@cli.argument('-m', '--my-roles', arg_only=True, action='store_true', help="filter roles by caller identity")
536536
@cli.argument('-a', '--as', dest='accept', arg_only=True, choices=['create'], help="request the as=create alternative form of the resources")
537537
@cli.argument('resource_type', arg_only=True, help='type of resource', metavar="RESOURCE_TYPE", choices=[choice for group in [[type, RESOURCES[type].abbreviation] for type in RESOURCES.keys()] for choice in group])
538538
@cli.subcommand(description='find resources as lists')
@@ -570,9 +570,9 @@ def list(cli, spinner: object = None):
570570
elif cli.args.resource_type in ["identities", "user-identities", "api-account-identities"]:
571571
matches = organization.find_identities(type=cli.args.resource_type, **cli.args.query)
572572
elif cli.args.resource_type == "roles":
573-
if cli.args.mine:
573+
if cli.args.my_roles:
574574
if cli.args.query.get('identityId'):
575-
cli.log.warning("got --mine, ignoring param 'identityId'")
575+
cli.log.warning("got --my-roles, ignoring param 'identityId'")
576576
cli.args.query['identityId'] = organization.caller['id']
577577
matches = organization.find_roles(**cli.args.query)
578578
else:
@@ -751,6 +751,7 @@ def delete(cli):
751751
sysexit(1)
752752

753753

754+
@cli.argument("-j", "--jwt", action="store_boolean", default=True, help="save the one-time enroll token for each demo identity in the current directory")
754755
@cli.argument("-s", "--size", default="small", help=argparse.SUPPRESS) # troubleshoot scale-up instance size factor
755756
@cli.argument("-v", "--product-version", default="default", help="network product version: 'default', 'latest', or any active semver")
756757
@cli.argument("--provider", default="AWS", required=False, help="cloud provider to host edge routers", choices=DC_PROVIDERS)
@@ -802,11 +803,13 @@ def demo(cli):
802803
else:
803804
cli.log.debug(f"creating network named '{network_name}'")
804805
spinner.text = f"Creating network '{network_name}'"
806+
# FIXME: don't use wait > 0 until process-executions beta is launched, until then poll for status
807+
cli.config.general['wait'] = 0
805808
network_created = network_group.create_network(
806809
name=network_name,
807810
size=cli.config.demo.size,
808811
version=cli.config.demo.product_version,
809-
wait=0) # don't use wait > 0 until process-executions beta is launched, until then poll for status
812+
wait=cli.config.general.wait)
810813
network, network_group = use_network(
811814
organization=organization,
812815
group=cli.config.general.network_group,
@@ -901,17 +904,22 @@ def demo(cli):
901904
endpoints[exit] = {
902905
"attributes": ["#demo_exits"]
903906
}
904-
for end in endpoints.keys():
907+
for end, spec in endpoints.items():
905908
spinner.text = f"Finding endpoint '{end}'"
906909
with spinner:
907910
if not network.endpoint_exists(name=end):
908911
# create an endpoint for the dialing device that will access services
909912
spinner.text = f"Creating endpoint '{end}'"
910-
endpoints[end]['properties'] = network.create_endpoint(name=end, attributes=endpoints[end]['attributes'])
913+
endpoints[end]['properties'] = network.create_endpoint(name=end, attributes=spec['attributes'])
911914
spinner.succeed(sub('Creating', 'Created', spinner.text))
912915
else:
913-
endpoints[end]['properties'] = network.endpoints(name=end)[0]
916+
spec['properties'] = network.endpoints(name=end)[0]
914917
spinner.succeed(sub('Finding', 'Found', spinner.text))
918+
if cli.args.jwt and spec['properties'].get('jwt'): # save if --jwt, token is absent if already enrolled
919+
jwt = spec['properties']['jwt']
920+
with open(end+'.jwt', 'wt') as tf:
921+
tf.write(jwt)
922+
cli.log.info(f"Saved enrollment token in {tf.name}")
915923

916924
services = {
917925
"Fireworks Service": {

netfoundry/utility.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ def get_generic_resource(url: str, headers: dict, proxies: dict = dict(), verify
254254

255255
resource_type = get_resource_type_by_url(url)
256256
logging.debug(f"detected resource type {resource_type.name}")
257-
if resource_type.name in HOSTABLE_NET_RESOURCES.keys():
257+
# always embed the host record if getting the base resource (not leaf operations like /session or /rotatekey)
258+
if resource_type.name in HOSTABLE_NET_RESOURCES.keys() and url.endswith(resource_type.name):
258259
params['embed'] = "host"
259260
elif resource_type.name in ["process-executions"]:
260261
params['beta'] = str()

0 commit comments

Comments
 (0)