scpExample1 = exampleVm.scpPutCommand(fromHostPath=exampleFile1, toGuestPath="~/example1.txt") print "returncode=" + str(scpExample1.returncode) print "output=" + scpExample1.output scpExample2 = exampleVm.scpGetCommand(fromGuestPath="/etc/hosts", toHostPath=exampleFile1) print "returncode=" + str(scpExample2.returncode) print "output=" + scpExample2.output with open(exampleFile1, "r") as inputFile: exampleFile1Content = inputFile.read() print "content=\n" + exampleFile1Content finally: shutil.rmtree(exampleDir) # a good way to shut down the virtual machine exampleVm.shutdownCommand() VMwareHypervisor.local.sleepUntilNotRunning(exampleVm.vmxFilePath, ticker=True) # a possible modification pointed out # start up again so it is running for use #VMwareHypervisor.local.start(exampleVm.vmxFilePath, gui=True, extraSleepSeconds=0) #exampleVm.sleepUntilSshIsAvailable(ticker=True) # a possible modification pointed out # start up for showing successful login into GUI #VMwareHypervisor.local.start(exampleVm.vmxFilePath, gui=True, extraSleepSeconds=0) #exampleSshParameters = exampleVm.sshParameters(user=exampleVm.regularUser) #LinuxSshCommand.sleepUntilIsGuiAvailable(exampleSshParameters, ticker=True) # a possible modification pointed out # just a demo
scpExample1 = exampleVm.scpPutCommand(fromHostPath=exampleFile1, toGuestPath="~/example1.txt") print "returncode=" + str(scpExample1.returncode) print "output=" + scpExample1.output scpExample2 = exampleVm.scpGetCommand(fromGuestPath="/etc/hosts", toHostPath=exampleFile1) print "returncode=" + str(scpExample2.returncode) print "output=" + scpExample2.output with open(exampleFile1, "r") as inputFile: exampleFile1Content = inputFile.read() print "content=\n" + exampleFile1Content finally: shutil.rmtree(exampleDir) # a good way to shut down the virtual machine, # wait longer because apparently Ubuntu (with GUI) the first time does something important that must be # allowed to finish before shutdown, lest the machine could be in an unusable state exampleVm.shutdownCommand(extraSleepSeconds=60) VMwareHypervisor.local.sleepUntilNotRunning(exampleVm.vmxFilePath, ticker=True) # a possible modification pointed out # start up again so it is running for use #VMwareHypervisor.local.start(exampleVm.vmxFilePath, gui=True, extraSleepSeconds=0) #exampleVm.sleepUntilSshIsAvailable(ticker=True) # a possible modification pointed out # start up for showing successful login into GUI #VMwareHypervisor.local.start(exampleVm.vmxFilePath, gui=True, extraSleepSeconds=0) #regularUserSshParameters = exampleVm.sshParameters(user=exampleVm.regularUser) #LinuxSshCommand.sleepUntilIsGuiAvailable(regularUserSshParameters, ticker=True) # a possible modification pointed out # just a demo
with open(exampleFile1, "w") as outputFile: outputFile.write("this is an example\n" * 1000000) scpExample1 = exampleVm.scpPutCommand(fromHostPath=exampleFile1, toGuestPath="~/example1.txt") print "returncode=" + str(scpExample1.returncode) print "output=" + scpExample1.output scpExample2 = exampleVm.scpGetCommand(fromGuestPath="/etc/hosts", toHostPath=exampleFile1) print "returncode=" + str(scpExample2.returncode) print "output=" + scpExample2.output with open(exampleFile1, "r") as inputFile: exampleFile1Content = inputFile.read() print "content=\n" + exampleFile1Content finally: shutil.rmtree(exampleDir) # a good way to shut down the virtual machine exampleVm.shutdownCommand() VMwareHypervisor.local.sleepUntilNotRunning(exampleVm.vmxFilePath, ticker=True) # a possible modification pointed out # start up again so it is running for use #VMwareHypervisor.local.start(exampleVm.vmxFilePath, gui=True, extraSleepSeconds=0) #exampleVm.sleepUntilSshIsAvailable(ticker=True) # a possible modification pointed out # start up for showing successful login into GUI #VMwareHypervisor.local.start(exampleVm.vmxFilePath, gui=True, extraSleepSeconds=0) #exampleSshParameters = exampleVm.sshParameters(user=exampleVm.regularUser) #LinuxSshCommand.sleepUntilIsGuiAvailable(exampleSshParameters, ticker=True) # a possible modification pointed out # just a demo