File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ def host_shortname(hostname):
51
51
else :
52
52
return hostname .split ('.' , 1 )[0 ]
53
53
54
- def canonicalize_hostname (hostname , user : Optional [str ] = 'ubuntu' ):
54
+ # sentinel value to indicate the default user value is to be used.
55
+ # None and the empty string are reserved for specifying no user value
56
+ # to be backwards compatible with older code.
57
+ _default_user = '.'
58
+
59
+ def canonicalize_hostname (hostname , user : Optional [str ] = _default_user ):
60
+ user = get_test_user () if user == _default_user else user
55
61
hostname_expr = hostname_expr_templ .format (
56
62
lab_domain = config .lab_domain .replace ('.' , r'\.' ))
57
63
match = re .match (hostname_expr , hostname )
Original file line number Diff line number Diff line change @@ -93,21 +93,22 @@ def tweak_ssh_config(ctx, config):
93
93
"""
94
94
Turn off StrictHostKeyChecking
95
95
"""
96
+ user = misc .get_test_user ()
96
97
run .wait (
97
98
ctx .cluster .run (
98
99
args = [
99
100
'echo' ,
100
101
'StrictHostKeyChecking no\n ' ,
101
102
run .Raw ('>' ),
102
- run .Raw ('/home/ubuntu /.ssh/config' ),
103
+ run .Raw (f '/home/{ user } /.ssh/config' ),
103
104
run .Raw ('&&' ),
104
105
'echo' ,
105
106
'UserKnownHostsFile ' ,
106
107
run .Raw ('/dev/null' ),
107
108
run .Raw ('>>' ),
108
- run .Raw ('/home/ubuntu /.ssh/config' ),
109
+ run .Raw (f '/home/{ user } /.ssh/config' ),
109
110
run .Raw ('&&' ),
110
- run .Raw ('chmod 600 /home/ubuntu /.ssh/config' ),
111
+ run .Raw (f 'chmod 600 /home/{ user } /.ssh/config' ),
111
112
],
112
113
wait = False ,
113
114
)
@@ -119,7 +120,7 @@ def tweak_ssh_config(ctx, config):
119
120
finally :
120
121
run .wait (
121
122
ctx .cluster .run (
122
- args = ['rm' ,run .Raw ('/home/ubuntu /.ssh/config' )],
123
+ args = ['rm' ,run .Raw (f '/home/{ user } /.ssh/config' )],
123
124
wait = False
124
125
),
125
126
)
You can’t perform that action at this time.
0 commit comments