File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ def host_shortname(hostname):
5151 else :
5252 return hostname .split ('.' , 1 )[0 ]
5353
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
5561 hostname_expr = hostname_expr_templ .format (
5662 lab_domain = config .lab_domain .replace ('.' , r'\.' ))
5763 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):
9393 """
9494 Turn off StrictHostKeyChecking
9595 """
96+ user = misc .get_test_user ()
9697 run .wait (
9798 ctx .cluster .run (
9899 args = [
99100 'echo' ,
100101 'StrictHostKeyChecking no\n ' ,
101102 run .Raw ('>' ),
102- run .Raw ('/home/ubuntu /.ssh/config' ),
103+ run .Raw (f '/home/{ user } /.ssh/config' ),
103104 run .Raw ('&&' ),
104105 'echo' ,
105106 'UserKnownHostsFile ' ,
106107 run .Raw ('/dev/null' ),
107108 run .Raw ('>>' ),
108- run .Raw ('/home/ubuntu /.ssh/config' ),
109+ run .Raw (f '/home/{ user } /.ssh/config' ),
109110 run .Raw ('&&' ),
110- run .Raw ('chmod 600 /home/ubuntu /.ssh/config' ),
111+ run .Raw (f 'chmod 600 /home/{ user } /.ssh/config' ),
111112 ],
112113 wait = False ,
113114 )
@@ -119,7 +120,7 @@ def tweak_ssh_config(ctx, config):
119120 finally :
120121 run .wait (
121122 ctx .cluster .run (
122- args = ['rm' ,run .Raw ('/home/ubuntu /.ssh/config' )],
123+ args = ['rm' ,run .Raw (f '/home/{ user } /.ssh/config' )],
123124 wait = False
124125 ),
125126 )
You can’t perform that action at this time.
0 commit comments