@@ -14,21 +14,27 @@ def self.which(cmd)
14
14
nil
15
15
end
16
16
17
- def self . ssh ( verbose , host_os , token , url )
17
+ def self . command_string ( verbose , service , host_os , use_token )
18
18
ssh_path = which ( 'ssh' )
19
19
raise 'Could not determine path to ssh' unless ssh_path
20
20
21
21
os_types = { }
22
22
os_types [ host_os ] = 1
23
23
24
- response = Pooler . retrieve ( verbose , os_types , token , url )
25
- raise "Could not get vm from vmpooler :\n #{ response } " unless response [ 'ok' ]
24
+ response = service . retrieve ( verbose , os_types , use_token )
25
+ raise "Could not get vm from #{ service . type } :\n #{ response } " unless response [ 'ok' ]
26
26
27
27
user = /win/ . match? ( host_os ) ? 'Administrator' : 'root'
28
28
29
- hostname = "#{ response [ host_os ] [ 'hostname' ] } .#{ response [ 'domain' ] } "
30
- cmd = "#{ ssh_path } #{ user } @#{ hostname } "
29
+ hostname = response [ host_os ] [ 'hostname' ]
30
+ hostname = response [ host_os ] [ 'hostname' ] [ 0 ] if response [ host_os ] [ 'hostname' ] . is_a? ( Array )
31
+ hostname = "#{ hostname } .#{ response [ 'domain' ] } " unless hostname . end_with? ( 'puppetlabs.net' )
31
32
33
+ "#{ ssh_path } #{ user } @#{ hostname } "
34
+ end
35
+
36
+ def self . ssh ( verbose , service , host_os , use_token )
37
+ cmd = command_string ( verbose , service , host_os , use_token )
32
38
# TODO: Should this respect more ssh settings? Can it be configured
33
39
# by users ssh config and does this respect those settings?
34
40
Kernel . exec ( cmd )
0 commit comments