1 import logging
, time
, os
2 from autotest_lib
.client
.common_lib
import error
3 from autotest_lib
.client
.virt
import virt_utils
, virt_test_utils
, rss_client
6 def run_whql_client_install(test
, params
, env
):
8 WHQL DTM client installation:
9 1) Log into the guest (the client machine) and into a DTM server machine
10 2) Stop the DTM client service (wttsvc) on the client machine
11 3) Delete the client machine from the server's data store
12 4) Rename the client machine (give it a randomly generated name)
13 5) Move the client machine into the server's workgroup
14 6) Reboot the client machine
15 7) Install the DTM client software
16 8) Setup auto logon for the user created by the installation
17 (normally DTMLLUAdminUser)
20 @param test: kvm test object
21 @param params: Dictionary with the test parameters
22 @param env: Dictionary with test environment.
24 vm
= env
.get_vm(params
["main_vm"])
26 session
= vm
.wait_for_login(timeout
=int(params
.get("login_timeout", 360)))
29 server_address
= params
.get("server_address")
30 server_shell_port
= int(params
.get("server_shell_port"))
31 server_file_transfer_port
= int(params
.get("server_file_transfer_port"))
32 server_studio_path
= params
.get("server_studio_path", "%programfiles%\\ "
33 "Microsoft Driver Test Manager\\Studio")
34 server_username
= params
.get("server_username")
35 server_password
= params
.get("server_password")
36 client_username
= params
.get("client_username")
37 client_password
= params
.get("client_password")
38 dsso_delete_machine_binary
= params
.get("dsso_delete_machine_binary",
39 "deps/whql_delete_machine_15.exe")
40 dsso_delete_machine_binary
= virt_utils
.get_path(test
.bindir
,
41 dsso_delete_machine_binary
)
42 install_timeout
= float(params
.get("install_timeout", 600))
43 install_cmd
= params
.get("install_cmd")
44 wtt_services
= params
.get("wtt_services")
46 # Stop WTT service(s) on client
47 for svc
in wtt_services
.split():
48 virt_test_utils
.stop_windows_service(session
, svc
)
50 # Copy dsso_delete_machine_binary to server
51 rss_client
.upload(server_address
, server_file_transfer_port
,
52 dsso_delete_machine_binary
, server_studio_path
,
55 # Open a shell session with server
56 server_session
= virt_utils
.remote_login("nc", server_address
,
57 server_shell_port
, "", "",
58 session
.prompt
, session
.linesep
)
59 server_session
.set_status_test_command(session
.status_test_command
)
61 # Get server and client information
62 cmd
= "echo %computername%"
63 server_name
= server_session
.cmd_output(cmd
).strip()
64 client_name
= session
.cmd_output(cmd
).strip()
65 cmd
= "wmic computersystem get domain"
66 server_workgroup
= server_session
.cmd_output(cmd
).strip()
67 server_workgroup
= server_workgroup
.splitlines()[-1]
68 regkey
= r
"HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters"
69 cmd
= "reg query %s /v Domain" % regkey
70 o
= server_session
.cmd_output(cmd
).strip().splitlines()[-1]
72 server_dns_suffix
= o
.split(None, 2)[2]
74 server_dns_suffix
= ""
76 # Delete the client machine from the server's data store (if it's there)
77 server_session
.cmd("cd %s" % server_studio_path
)
78 cmd
= "%s %s %s" % (os
.path
.basename(dsso_delete_machine_binary
),
79 server_name
, client_name
)
80 server_session
.cmd(cmd
, print_func
=logging
.info
)
81 server_session
.close()
83 # Rename the client machine
84 client_name
= "autotest_%s" % virt_utils
.generate_random_string(4)
85 logging
.info("Renaming client machine to '%s'", client_name
)
86 cmd
= ('wmic computersystem where name="%%computername%%" rename name="%s"'
88 session
.cmd(cmd
, timeout
=600)
90 # Join the server's workgroup
91 logging
.info("Joining workgroup '%s'", server_workgroup
)
92 cmd
= ('wmic computersystem where name="%%computername%%" call '
93 'joindomainorworkgroup name="%s"' % server_workgroup
)
94 session
.cmd(cmd
, timeout
=600)
96 # Set the client machine's DNS suffix
97 logging
.info("Setting DNS suffix to '%s'", server_dns_suffix
)
98 cmd
= 'reg add %s /v Domain /d "%s" /f' % (regkey
, server_dns_suffix
)
99 session
.cmd(cmd
, timeout
=300)
102 session
= vm
.reboot(session
)
104 # Access shared resources on the server machine
105 logging
.info("Attempting to access remote share on server")
106 cmd
= r
"net use \\%s /user:%s %s" % (server_name
, server_username
,
108 end_time
= time
.time() + 120
109 while time
.time() < end_time
:
117 raise error
.TestError("Could not access server share from client "
121 logging
.info("Installing DTM client (timeout=%ds)", install_timeout
)
122 install_cmd
= r
"cmd /c \\%s\%s" % (server_name
, install_cmd
.lstrip("\\"))
123 session
.cmd(install_cmd
, timeout
=install_timeout
)
126 logging
.info("Setting up auto logon for user '%s'", client_username
)
128 '"HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\winlogon" '
129 '/v "%s" /d "%s" /t REG_SZ /f')
130 session
.cmd(cmd
% ("AutoAdminLogon", "1"))
131 session
.cmd(cmd
% ("DefaultUserName", client_username
))
132 session
.cmd(cmd
% ("DefaultPassword", client_password
))
134 # Reboot one more time
135 session
= vm
.reboot(session
)