protected override void Run() { base.Run(); var session = Connection.Session; var url = session.Url; Uri uri = new Uri(url); var appFolder = Path.Combine(m_applianceDirectory, m_applianceFileName); var appFile = string.Format("{0}.ovf", m_applianceFileName); if (!Directory.Exists(appFolder)) { Directory.CreateDirectory(appFolder); } PercentComplete = 5; Description = Messages.EXPORTING_VMS; EnvelopeType env; try { m_transportAction = new XenOvfTransport.Export(uri, session) { UpdateHandler = UpdateHandler, ShouldVerifyDisks = m_shouldVerify, Cancel = Cancelling //in case the Cancel button has already been pressed }; m_transportAction.SetTvmNetwork(m_networkUuid, m_isTvmIpStatic, m_tvmIpAddress, m_tvmSubnetMask, m_tvmGateway); env = (m_transportAction as XenOvfTransport.Export).Process(appFolder, m_applianceFileName, (from VM vm in m_vmsToExport select vm.uuid).ToArray()); PercentComplete = 60; } catch (OperationCanceledException) { throw new CancelledException(); } foreach (var eula in m_eulas) { if (Cancelling) { throw new CancelledException(); } Description = Messages.ADDING_EULAS; OVF.AddEula(env, eula); } if (Cancelling) { throw new CancelledException(); } var ovfPath = Path.Combine(appFolder, appFile); Description = String.Format(Messages.CREATING_FILE, appFile); OVF.SaveAs(env, ovfPath); PercentComplete = 70; if (Cancelling) { throw new CancelledException(); } if (m_signAppliance) { Description = Messages.SIGNING_APPLIANCE; OVF.Sign(m_certificate, appFolder, appFile); } else if (m_createManifest) { Description = Messages.CREATING_MANIFEST; OVF.Manifest(appFolder, appFile); } PercentComplete = 90; if (Cancelling) { throw new CancelledException(); } if (m_createOVA) { Description = String.Format(Messages.CREATING_FILE, String.Format("{0}.ova", m_applianceFileName)); OVF.ConvertOVFtoOVA(appFolder, appFile, m_compressOVFfiles); } else if (m_compressOVFfiles) { Description = Messages.COMPRESSING_FILES; m_compressor = new OvfCompressor { CancelCompression = Cancelling }; //in case the Cancel button has already been pressed} try { m_compressor.CompressOvfFiles(ovfPath, "GZip"); } catch (OperationCanceledException) { throw new CancelledException(); } } PercentComplete = 100; Description = Messages.COMPLETED; }