本文整理汇总了C#中Instance.InstallUninstall方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.InstallUninstall方法的具体用法?C# Instance.InstallUninstall怎么用?C# Instance.InstallUninstall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instance
的用法示例。
在下文中一共展示了Instance.InstallUninstall方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallUninstall
public bool InstallUninstall(
InstallerConfig installerConfig,
DriverTaskInstanceOptions options)
{
try
{
_results.Clear();
_vmPowerDriver.PowerOnDependencies();
_vmPowerDriver.ThrowOnFailure();
_vmPowerDriver.ConnectToHost();
CopyMethod copyMethod = _vmConfig.CopyMethod;
if (copyMethod == CopyMethod.undefined) copyMethod = installerConfig.CopyMethod;
_vmPowerDriver.MapVirtualMachine(copyMethod);
if (!_snapshotRestored)
{
_vmPowerDriver.PrepareSnapshot();
_snapshotRestored = true;
}
_vmPowerDriver.LoginToGuest();
CopyInstaller(installerConfig);
Instance installInstance = new Instance(
_logpath, _simulationOnly, _config, _vmPowerDriver.Vm, _vmPowerDriver.VmConfig, installerConfig, _vmPowerDriver.SnapshotConfig);
Instance.InstanceOptions instanceOptions = new Instance.InstanceOptions();
instanceOptions.Install = options.Install;
instanceOptions.Uninstall = options.Uninstall;
Result remoteInstallResult = installInstance.InstallUninstall(instanceOptions);
foreach (VirtualMachinePowerResult powerResult in _vmPowerDriver.PowerResults)
{
remoteInstallResult.Add(powerResult);
}
_results.Add(remoteInstallResult);
if (remoteInstallResult.RebootRequired)
{
if (installerConfig.RebootIfRequired)
{
ConsoleOutput.WriteLine("Shutting down '{0}:{1}'", _vmPowerDriver.VmConfig.Name,
_vmPowerDriver.SnapshotConfig.Name);
_vmPowerDriver.ShutdownGuest();
ConsoleOutput.WriteLine("Powering on '{0}:{1}'", _vmPowerDriver.VmConfig.Name,
_vmPowerDriver.SnapshotConfig.Name);
_vmPowerDriver.PowerOn();
}
else if (options.PowerOff)
{
_vmPowerDriver.PowerOff();
}
else
{
ConsoleOutput.WriteLine("Skipping reboot of '{0}:{1}'", _vmPowerDriver.VmConfig.Name,
_vmPowerDriver.SnapshotConfig.Name);
}
}
else if (options.PowerOff)
{
_vmPowerDriver.PowerOff();
}
return remoteInstallResult.Success;
}
catch (Exception ex)
{
ConsoleOutput.WriteLine(ex);
Result result = new Result(installerConfig.Name, installerConfig.SvnRevision);
result.LastError = ex.Message;
result.SuccessfulInstall = result.SuccessfulUnInstall = InstallResult.False;
_results.Add(result);
return false;
}
finally
{
_vmPowerDriver.CloseVirtualMachine();
_vmPowerDriver.DisconnectFromHost();
_vmPowerDriver.PowerOffDependencies();
}
}