self.info("Restarting bind9")
self.chdir('${PREFIX}')
- self.set_nameserver(self.getvar('INTERFACE_IP'))
-
self.run_cmd("mkdir -p var/named/data")
self.run_cmd("chown -R ${BIND_USER} var/named")
def port_wait(self, hostname, port, retries=200, delay=3, wait_for_fail=False):
'''wait for a host to come up on the network'''
- self.retry_cmd("nc -v -z -w 1 %s %u" % (hostname, port), ['succeeded'],
- retries=retries, delay=delay, wait_for_fail=wait_for_fail)
+
+ while retries > 0:
+ child = self.pexpect_spawn("nc -v -z -w 1 %s %u" % (hostname, port), crlf=False, timeout=1)
+ i = child.expect(['succeeded', 'failed', pexpect.EOF, pexpect.TIMEOUT])
+ if wait_for_fail:
+ if i > 0:
+ return
+ else:
+ if i == 0:
+ return
+
+ time.sleep(delay)
+ retries -= 1
+ self.info("retrying (retries=%u delay=%u)" % (retries, delay))
+
+ raise RuntimeError("gave up waiting for %s:%d" % (hostname, port))
def run_net_time(self, child):
'''run net time on windows'''
child.expect('\d+.\d+.\d+.\d+')
self.setvar('WIN_SUBNET_MASK', child.after)
child.expect('Default Gateway')
- child.expect('\d+.\d+.\d+.\d+')
- self.setvar('WIN_DEFAULT_GATEWAY', child.after)
- child.expect("C:")
+ i = child.expect(['\d+.\d+.\d+.\d+', "C:"])
+ if i == 0:
+ self.setvar('WIN_DEFAULT_GATEWAY', child.after)
+ child.expect("C:")
def get_is_dc(self, child):
'''check if a windows machine is a domain controller'''
def disable_firewall(self, child):
'''remove the annoying firewall'''
child.sendline('netsh advfirewall set allprofiles state off')
- i = child.expect(["Ok", "The following command was not found: advfirewall set allprofiles state off", "The requested operation requires elevation"])
+ i = child.expect(["Ok", "The following command was not found: advfirewall set allprofiles state off", "The requested operation requires elevation", "Access is denied"])
child.expect("C:")
if i == 1:
child.sendline('netsh firewall set opmode mode = DISABLE profile = ALL')
- i = child.expect(["Ok", "The following command was not found"])
+ i = child.expect(["Ok", "The following command was not found", "Access is denied"])
if i != 0:
self.info("Firewall disable failed - ignoring")
child.expect("C:")
'''open a telnet connection to a windows server, return the pexpect child'''
set_route = False
set_dns = False
+ set_telnetclients = True
if self.getvar('WIN_IP'):
ip = self.getvar('WIN_IP')
else:
child.expect("password:")
child.sendline(password)
i = child.expect(["C:",
+ "TelnetClients",
"Denying new connections due to the limit on number of connections",
"No more connections are allowed to telnet server",
"Unable to connect to remote host",
"No route to host",
"Connection refused",
pexpect.EOF])
+ if i == 1:
+ if set_telnetclients:
+ self.run_cmd('bin/net rpc group addmem TelnetClients "authenticated users" -S $WIN_IP -U$WIN_USER%$WIN_PASS')
+ child.close()
+ retries -= 1
+ set_telnetclients = False
+ self.info("retrying (retries=%u delay=%u)" % (retries, delay))
+ continue
+ else:
+ raise RuntimeError("Failed to connect with telnet due to missing TelnetClients membership")
+
if i != 0:
child.close()
time.sleep(delay)
child.sendline("shutdown -r -t 0")
self.port_wait("${WIN_IP}", 139, wait_for_fail=True)
self.port_wait("${WIN_IP}", 139)
- self.retry_cmd("host -t SRV _ldap._tcp.${WIN_REALM} ${WIN_IP}", ['has SRV record'] )
+ self.retry_cmd("host -t SRV _ldap._tcp.${WIN_REALM} ${WIN_IP}", ['has SRV record'], retries=60, delay=5 )
def start_winvm(self, vm):
self.setwinvars(vm)
self.info('Testing smbclient')
self.chdir('${PREFIX}')
- self.cmd_contains("bin/smbclient --version", ["${SAMBA_VERSION}"])
- self.retry_cmd('bin/smbclient -L ${WIN_HOSTNAME} -U%s%%%s %s' % (username, password, args), ["IPC"])
+ smbclient = self.getvar("smbclient")
+ self.cmd_contains("%s --version" % (smbclient), ["${SAMBA_VERSION}"])
+ self.retry_cmd('%s -L ${WIN_HOSTNAME} -U%s%%%s %s' % (smbclient, username, password, args), ["IPC"], retries=60, delay=5)
def test_net_use(self, vm, realm, domain, username, password):
self.setwinvars(vm)
self.parser.add_option("--prefix", type='string', default=None, help='override install prefix')
self.parser.add_option("--sourcetree", type='string', default=None, help='override sourcetree location')
self.parser.add_option("--nocleanup", action='store_true', default=False, help='disable cleanup code')
+ self.parser.add_option("--use-ntvfs", action='store_true', default=False, help='use NTVFS for the fileserver')
self.opts, self.args = self.parser.parse_args()
self.info('cleaning')
self.chdir('${SOURCETREE}/' + subdir)
self.run_cmd('make clean')
+
+ if self.opts.use_ntvfs:
+ self.setvar('USE_NTVFS', "--use-ntvfs")
+ else:
+ self.setvar('USE_NTVFS', "")