Skip to content

Commit 28db6db

Browse files
committed
Fix ssh generation if env USER is missing
1 parent 3757f69 commit 28db6db

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = ibm-ray-config
3-
version = 1.0.0b28
3+
version = 1.0.0b30
44
author = Omer J Cohen
55
author_email = [email protected]
66
description = Interactive tool generating ray configuration for IBM platforms

src/ibm_ray_config/modules/gen2/ssh_key.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@
1010
validate_exists, validate_not_empty, free_dialog)
1111

1212
from ibm_cloud_sdk_core import ApiException
13-
DEFAULT_KEY_NAME = f'ray-{os.environ.get("USERNAME")}-{str(uuid4())[:5]}'
13+
DEFAULT_KEY_NAME = f'ray-{os.environ.get("USER")}-{str(uuid4())[:5]}'
1414

1515
def generate_keypair():
1616
"""Returns newly generated public ssh-key's contents and private key's path"""
17+
global DEFAULT_KEY_NAME
18+
# if no USER env exists, replace the None received by os.environ.get("USER")
19+
# with a valid string name for a key on ibm vpc platform
20+
if "None" in DEFAULT_KEY_NAME:
21+
DEFAULT_KEY_NAME= DEFAULT_KEY_NAME.replace("None", "autogen")
22+
1723
filename = f"{os.sep}tmp{os.sep}{DEFAULT_KEY_NAME}"
1824

1925
os.system(f'ssh-keygen -b 2048 -t rsa -f {filename} -q -N ""')

0 commit comments

Comments
 (0)