public async Task StartDebugger(Server server, StartTask task) { // start debugger IntPtr pInfo = GetDebugInfo($"{host}:{client.DebuggerPort}", Path.GetFileName(targetExe), outputDir); var sp = new ServiceProvider((IServiceProvider)dte); try { var dbg = (IVsDebugger)sp.GetService(typeof(SVsShellDebugger)); int hr = dbg.LaunchDebugTargets(1, pInfo); Marshal.ThrowExceptionForHR(hr); } catch (Exception ex) { logger.Error(ex); string msg; var sh = (IVsUIShell)sp.GetService(typeof(SVsUIShell)); sh.GetErrorInfo(out msg); if (!string.IsNullOrWhiteSpace(msg)) { logger.Error(msg); } throw; } finally { if (pInfo != IntPtr.Zero) { Marshal.FreeCoTaskMem(pInfo); } } }
public CreatePoolP2(BatchTreeViewItem sender, object obj) { pool = null; workitem = null; starttask = null; if (obj is Pool) { this.pool = obj as Pool; } else if (obj is WorkItem) { this.workitem = obj as WorkItem; } else if (obj == null) { // We are going to do some weird things and return a starttask this.starttask = new StartTask(); } else { System.Windows.MessageBox.Show("CreatePoolP2.xaml.cs: Improper object passed in"); } this.Sender = sender; InitializeComponent(); Loaded += OnLoaded; MainWindow.Resize(MainGrid); }
protected CloudPool CreatePool() { CloudPool currentPool = this.FindPoolIfExists(); if (currentPool == null) { // gotta create a new pool CloudServiceConfiguration passConfiguration = new CloudServiceConfiguration(OSFamily); currentPool = this.client.PoolOperations.CreatePool( this.PoolId, VMSize, passConfiguration, targetDedicatedComputeNodes: 1); var password = TestUtilities.GenerateRandomPassword(); currentPool.UserAccounts = new List <UserAccount>() { new UserAccount(AdminUserAccountName, password, ElevationLevel.Admin), new UserAccount(NonAdminUserAccountName, password, ElevationLevel.NonAdmin), }; StartTask st = new StartTask("cmd /c hostname"); // used for tests of StartTask(info) st.EnvironmentSettings = new List <EnvironmentSetting> { new EnvironmentSetting("key", "value") }; currentPool.StartTask = st; currentPool.Commit(); } return(WaitForPoolAllocation(this.client, this.PoolId)); }
/// <summary> /// Creates a pool with a start task which installs ImageMagick onto each VM. /// </summary> private static void CreatePool() { using (IPoolManager pm = config.Client.OpenPoolManager()) { Console.WriteLine("Creating pool: {0}", config.PoolName); //Create a pool -- note that OSFamily 3 is Windows Server 2012. You can learn more about os families and versions at: //http://msdn.microsoft.com/en-us/library/azure/ee924680.aspx ICloudPool pool = pm.CreatePool(config.PoolName, targetDedicated: 3, vmSize: "small", osFamily: "3"); //Create a start task for the pool (which installs ImageMagick). The start task is run on each //VM when they first join the pool. In this case it is used as a setup step to place the ImageMagick exe onto the VM. IStartTask startTask = new StartTask(); startTask.RunElevated = true; startTask.CommandLine = ImageMagickCmdLine; //Set up the resource files for the start task (requires the image magick exe) List <IResourceFile> resFiles = new List <IResourceFile>(); ResourceFile file = new ResourceFile(config.ImageMagickExeSAS, "ImageMagick.exe"); resFiles.Add(file); startTask.ResourceFiles = resFiles; startTask.WaitForSuccess = true; pool.StartTask = startTask; pool.Commit(); //Commit the pool -- this actually creates it on the Batch service. } }
protected CloudPool CreatePool() { CloudPool currentPool = this.FindPoolIfExists(); if (currentPool == null) { // gotta create a new pool CloudServiceConfiguration passConfiguration = new CloudServiceConfiguration(OSFamily); currentPool = this.client.PoolOperations.CreatePool( this.PoolId, VMSize, passConfiguration, targetDedicatedComputeNodes: 1); StartTask st = new StartTask("cmd /c hostname"); // used for tests of StartTask(info) st.EnvironmentSettings = new List <EnvironmentSetting> { new EnvironmentSetting("key", "value") }; currentPool.StartTask = st; currentPool.Commit(); } return(WaitForPoolAllocation(this.client, this.PoolId)); }
private void AppendRenderManagerStartTask( RenderingEnvironment environment, StartTask startTask, bool isWindows) { var startTaskScriptUrl = isWindows ? GetWindowsStartTaskUrl(environment) : GetLinuxStartTaskUrl(environment); if (!string.IsNullOrWhiteSpace(startTaskScriptUrl)) { var uri = new Uri(startTaskScriptUrl); var filename = uri.AbsolutePath.Split('/').Last(); var installScriptResourceFile = new ResourceFile(httpUrl: startTaskScriptUrl, filePath: filename); startTask.ResourceFiles.Add(installScriptResourceFile); if (isWindows) { startTask.CommandLine += $".\\{installScriptResourceFile.FilePath} "; } else { startTask.CommandLine += $"./{installScriptResourceFile.FilePath} "; } } }
public static Task timerForGame(int waitPrRunSeconds, int secondsBeforeEnd, StartTask messageOnCountdown, EndTask timeRunOutTask) { Task task = new Task(() => { CancellationToken token = tokenSource.Token; for (int i = secondsBeforeEnd; i <= secondsBeforeEnd && i > -1 && !token.IsCancellationRequested; i--) { if (i < secondsBeforeEnd && i > 0) { Task.Delay(waitPrRunSeconds * 1000).Wait(); if (!token.IsCancellationRequested) { messageOnCountdown(); Console.WriteLine(i + "\n"); } } else if (i <= 0) { Task.Delay(waitPrRunSeconds * 1000).Wait(); timeRunOutTask(); } } }); task.Start(); return(task); }
public void Handle(StartTask message) { if (Data.InProgress) { ReplyToOriginator <TaskAlreadyStarted>(m => { m.TaskId = message.TaskId; m.StartedBy = Data.HandledBy.Value; }); } else if (Data.Completed) { ReplyToOriginator <TaskAlreadyCompleted>(m => { m.TaskId = message.TaskId; m.CompletedBy = Data.CompletedBy.Value; }); } else { Data.Start(message.UserId); RequestUtcTimeout <TaskTimeout>(TimeSpan.FromMinutes(30)); messageBus.Publish <TaskWasStarted>(m => { m.TaskId = message.TaskId; m.StartedBy = message.UserId; }); } }
/// <summary> /// Creates a test pool for use in Scenario tests. /// </summary> public static void CreateTestPool(BatchController controller, BatchAccountContext context, string poolId, int targetDedicated, CertificateReference certReference = null, StartTask startTask = null) { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); PSCertificateReference[] certReferences = null; if (certReference != null) { certReferences = new PSCertificateReference[] { new PSCertificateReference(certReference) }; } PSStartTask psStartTask = null; if (startTask != null) { psStartTask = new PSStartTask(startTask); } PSCloudServiceConfiguration paasConfiguration = new PSCloudServiceConfiguration("4", "*"); NewPoolParameters parameters = new NewPoolParameters(context, poolId) { VirtualMachineSize = "small", CloudServiceConfiguration = paasConfiguration, TargetDedicated = targetDedicated, CertificateReferences = certReferences, StartTask = psStartTask, InterComputeNodeCommunicationEnabled = true }; client.CreatePool(parameters); }
/// <summary> /// Returns a start task to be executed by the batch pool vm as soon as it's spun up /// </summary> /// <returns> /// A start task /// </returns> /// <param name="name">Blob name</param> /// <param name="uname">Task user identity name</params> public static StartTask GetStartTask(string name, string uname) { string containerName = Environment.GetEnvironmentVariable(AzureEnvConstants.AZURE_STORAGE_APP_DIRECTORY); IStorageEngine engine = AzureStorageEngine.GetInstance(); // ResourceFile resource = engine.GetResourceFile(containerName,name,filePath); ResourceFile resource = engine.GetResourceFile(containerName, name, ""); List <ResourceFile> apps = new List <ResourceFile>() { resource }; StartTask task = null; if (name.Equals(IApplicationTypes.K8S_SINGLE_NODE)) { task = new StartTask(); task.CommandLine = $"/bin/sh -c ./{name}"; task.MaxTaskRetryCount = 2; // set 2 retries task.ResourceFiles = apps; task.UserIdentity = new UserIdentity(uname); task.WaitForSuccess = true; } else { throw new BatchOperationException($"Application Type: {name}, not supported. Aborting..."); } return(task); }
/// <summary> /// Creates a pool with a start task which installs ImageMagick onto each VM. /// </summary> private static void CreatePool() { using (IPoolManager pm = config.Client.OpenPoolManager()) { Console.WriteLine("Creating pool: {0}", config.PoolName); //Create a pool -- note that OSFamily 3 is Windows Server 2012. You can learn more about os families and versions at: //http://msdn.microsoft.com/en-us/library/azure/ee924680.aspx ICloudPool pool = pm.CreatePool(config.PoolName, targetDedicated: 3, vmSize: "small", osFamily: "3"); //Create a start task for the pool (which installs ImageMagick). The start task is run on each //VM when they first join the pool. In this case it is used as a setup step to place the ImageMagick exe onto the VM. IStartTask startTask = new StartTask(); startTask.RunElevated = true; startTask.CommandLine = ImageMagickCmdLine; //Set up the resource files for the start task (requires the image magick exe) List<IResourceFile> resFiles = new List<IResourceFile>(); ResourceFile file = new ResourceFile(config.ImageMagickExeSAS, "ImageMagick.exe"); resFiles.Add(file); startTask.ResourceFiles = resFiles; startTask.WaitForSuccess = true; pool.StartTask = startTask; pool.Commit(); //Commit the pool -- this actually creates it on the Batch service. } }
public static StartTask GetStartTask(IList <ResourceFile> resourceFiles) { var startTask = new StartTask("/bin/bash starttask.sh"); startTask.WaitForSuccess = true; startTask.UserIdentity = new UserIdentity(new AutoUserSpecification(elevationLevel: ElevationLevel.Admin)); startTask.ResourceFiles = resourceFiles; return(startTask); }
public async Task <StartTask> GetDeadlineStartTask( string poolName, IEnumerable <string> additionalPools, IEnumerable <string> additionalGroups, RenderingEnvironment environment, InstallationPackage deadlinePackage, InstallationPackage gpuPackage, IEnumerable <InstallationPackage> generalPackages, bool isWindows, bool useGroups) { await Task.CompletedTask; if (environment == null || environment.RenderManagerConfig == null || environment.RenderManager != RenderManagerType.Deadline) { throw new Exception("Wrong environment for Deadline."); } var resourceFiles = new List <ResourceFile>(); var startTask = new StartTask( "", resourceFiles, GetEnvironmentSettings(environment, isWindows), new UserIdentity( autoUser: new AutoUserSpecification(AutoUserScope.Pool, ElevationLevel.Admin)), 3, // retries true); // waitForSuccess AppendGpu(startTask, gpuPackage); AppendGeneralPackages(startTask, generalPackages); AppendDeadlineSetupToStartTask( environment, poolName, additionalPools, additionalGroups, startTask, environment.RenderManagerConfig.Deadline, deadlinePackage, isWindows, useGroups); // Wrap all the start task command if (isWindows) { startTask.CommandLine = $"powershell.exe -ExecutionPolicy RemoteSigned -NoProfile \"$ErrorActionPreference='Stop'; {startTask.CommandLine}\""; } else { startTask.CommandLine = $"/bin/bash -c 'set -e; set -o pipefail; {startTask.CommandLine}'"; } return(startTask); }
// Create the Compute Pool of the Batch Account public static async Task CreateBatchPoolIfNotExist(BatchClient batchClient, VirtualMachineConfiguration vmConfiguration, string vnetSubnetId) { Console.WriteLine("Creating pool [{0}]...", PoolId); try { CloudPool pool = batchClient.PoolOperations.CreatePool( poolId: PoolId, targetDedicatedComputeNodes: PoolNodeCount, virtualMachineSize: PoolVMSize, virtualMachineConfiguration: vmConfiguration); // Specify the application and version to install on the compute nodes pool.ApplicationPackageReferences = new List <ApplicationPackageReference> { new ApplicationPackageReference { ApplicationId = AppPackageName, Version = AppPackageVersion } }; // Initial the first data disk for each VM in the pool StartTask startTask = new StartTask("cmd /c Powershell -command \"Get-Disk | Where partitionstyle -eq 'raw' | sort number | Select-Object -first 1 |" + " Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -UseMaximumSize -DriveLetter F |" + " Format-Volume -FileSystem NTFS -NewFileSystemLabel data1 -Confirm:$false -Force\""); startTask.MaxTaskRetryCount = 1; startTask.UserIdentity = new UserIdentity(new AutoUserSpecification(AutoUserScope.Pool, ElevationLevel.Admin)); startTask.WaitForSuccess = true; pool.StartTask = startTask; // Create the Pool within the vnet subnet if it's specified. if (vnetSubnetId != null) { pool.NetworkConfiguration = new NetworkConfiguration(); pool.NetworkConfiguration.SubnetId = vnetSubnetId; } await pool.CommitAsync(); await pool.RefreshAsync(); } catch (BatchException be) { // Accept the specific error code PoolExists as that is expected if the pool already exists if (be.RequestInformation?.BatchError?.Code == BatchErrorCodeStrings.PoolExists) { Console.WriteLine("The pool {0} already existed when we tried to create it", PoolId); } else { throw; // Any other exception is unexpected } } }
private async Task AppendQubeSetupToStartTask( RenderingEnvironment environment, string poolName, IEnumerable <string> additionalGroups, StartTask startTask, QubeConfig qubeConfig, InstallationPackage qubePackage, bool isWindows) { var commandLine = startTask.CommandLine; var resourceFiles = new List <ResourceFile>(startTask.ResourceFiles); var startTaskScriptUrl = isWindows ? GetWindowsStartTaskUrl(environment) : GetLinuxStartTaskUrl(environment); var uri = new Uri(startTaskScriptUrl); var filename = uri.AbsolutePath.Split('/').Last(); var installScriptResourceFile = new ResourceFile(httpUrl: startTaskScriptUrl, filePath: filename); resourceFiles.Add(installScriptResourceFile); var workerGroups = $"azure,{poolName}"; if (additionalGroups != null && additionalGroups.Any()) { workerGroups += $",{string.Join(',', additionalGroups)}"; } commandLine += $".\\{installScriptResourceFile.FilePath} " + $"-qubeSupervisorIp {qubeConfig.SupervisorIp} " + $"-workerHostGroups '{workerGroups}'"; if (qubePackage != null && !string.IsNullOrEmpty(qubePackage.Container)) { resourceFiles.AddRange(await GetResourceFilesFromContainer(qubePackage.Container)); // Add qb.conf if one isn't already specified by the package if (!resourceFiles.Any(rf => rf.FilePath.Contains("qb.conf"))) { var qbConfResourceFile = new ResourceFile(httpUrl: _configuration["Qube:QbConf"], filePath: "qb.conf"); resourceFiles.Add(qbConfResourceFile); } } else { // No package, lets just configure commandLine += " -skipInstall "; } commandLine += ";"; startTask.CommandLine = commandLine; startTask.ResourceFiles = resourceFiles; }
/// <summary> /// Shows a dialog with a question which task should be started. /// Referring to the answer the corresponding module is started. /// </summary> /// <returns><strong>True</strong> if selection was done, otherwise /// user clicked cancel and return <strong>false</strong>.</returns> private bool ShowTaskChooseDialog() { var objWhatToDo = new StartTask(); if (objWhatToDo.ShowDialog() == DialogResult.OK) { switch (objWhatToDo.Task) { case Tasks.Replay: this.CreateReplayView(); break; case Tasks.Scanpaths: this.CreateScanpathsView(); break; case Tasks.Statistics: this.CreateStatisticsView(); break; case Tasks.AOIs: this.CreateAOIView(); break; case Tasks.AttentionMaps: this.CreateAttentionMapView(); break; case Tasks.Fixations: this.CreateFixationsView(); break; case Tasks.Import: if (this.CreateDatabaseView()) { ImportRawData.Start(this); } break; case Tasks.Design: this.CreateStimuliDesignView(); break; case Tasks.Record: this.CreateRecordingView(); break; } return(true); } return(false); }
public string GetToken(string site, string siteKey) { HttpRequest request = new HttpRequest(); StartTask task = new StartTask(); task.clientKey = ""; task.softId = 19; task.task = new Task(); task.task.websiteURL = site; task.task.websiteKey = siteKey; return(null); }
private void AppendOpenCueParamsToStartTask( PoolConfigurationModel poolConfiguration, RenderingEnvironment environment, StartTask startTask, OpenCueConfig openCueConfig, InstallationPackage openCuePackage, bool isWindows) { var commandLine = startTask.CommandLine; var resourceFiles = new List <ResourceFile>(startTask.ResourceFiles); if (environment.KeyVaultServicePrincipal != null) { commandLine += GetParameterSet(isWindows, "tenantId", environment.KeyVaultServicePrincipal.TenantId.ToString()); commandLine += GetParameterSet(isWindows, "applicationId", environment.KeyVaultServicePrincipal.ApplicationId.ToString()); commandLine += GetParameterSet(isWindows, "keyVaultCertificateThumbprint", environment.KeyVaultServicePrincipal.Thumbprint); commandLine += GetParameterSet(isWindows, "keyVaultName", environment.KeyVault.Name); } if (!string.IsNullOrWhiteSpace(openCueConfig.CuebotHostnameOrIp)) { commandLine += GetParameterSet(isWindows, "cuebotHost", openCueConfig.CuebotHostnameOrIp); } if (!string.IsNullOrWhiteSpace(openCueConfig.Facility)) { commandLine += GetParameterSet(isWindows, "facility", openCueConfig.Facility); } var groups = $"azure,{poolConfiguration.PoolName}"; if (poolConfiguration.AdditionalGroups != null && poolConfiguration.AdditionalGroups.Any()) { groups += $",{string.Join(',', poolConfiguration.AdditionalGroups)}"; } if (!string.IsNullOrWhiteSpace(groups)) { commandLine += GetParameterSet(isWindows, "groups", groups); } if (openCuePackage != null && !string.IsNullOrEmpty(openCuePackage.Container)) { resourceFiles.Add(GetContainerResourceFile(openCuePackage.Container, openCuePackage.PackageName)); commandLine += GetParameterSet(isWindows, "installerPath", openCuePackage.PackageName); } commandLine += ";"; startTask.CommandLine = commandLine; startTask.ResourceFiles = resourceFiles; }
private async Task AppendGpu(StartTask startTask, InstallationPackage gpuPackage) { if (gpuPackage != null) { var resourceFiles = new List <ResourceFile>(startTask.ResourceFiles); resourceFiles.Add(GetContainerResourceFile(gpuPackage.Container, gpuPackage.PackageName)); startTask.ResourceFiles = resourceFiles; if (!string.IsNullOrWhiteSpace(gpuPackage.PackageInstallCommand)) { var cmd = gpuPackage.PackageInstallCommand.Replace("{filename}", resourceFiles.First().FilePath); startTask.CommandLine += $"cd {gpuPackage.PackageName}; {cmd}; cd..; "; } } }
public void Update(UpdateTestItemRequest request) { if (FinishTask == null || !FinishTask.IsCompleted) { if (_additionalTasks == null) { _additionalTasks = new ConcurrentBag <Task>(); } _additionalTasks.Add(StartTask.ContinueWith(async(a) => { await _service.UpdateTestItemAsync(TestInfo.Id, request); }).Unwrap()); } }
private void AppendGpu(StartTask startTask, InstallationPackage gpuPackage) { if (gpuPackage != null) { var resourceFile = GetContainerResourceFile(gpuPackage.Container, gpuPackage.PackageName); startTask.ResourceFiles = new List <ResourceFile>(startTask.ResourceFiles) { resourceFile }; if (!string.IsNullOrWhiteSpace(gpuPackage.PackageInstallCommand)) { startTask.CommandLine += $"pushd {gpuPackage.PackageName}; {gpuPackage.PackageInstallCommand}; popd; "; } } }
private async Task AppendGeneralPackages(StartTask startTask, IEnumerable <InstallationPackage> generalPackages) { if (generalPackages != null && generalPackages.Any()) { foreach (var package in generalPackages) { var resourceFiles = new List <ResourceFile>(startTask.ResourceFiles); resourceFiles.Add(GetContainerResourceFile(package.Container, package.PackageName)); startTask.ResourceFiles = resourceFiles; if (!string.IsNullOrWhiteSpace(package.PackageInstallCommand)) { startTask.CommandLine += $"cd {package.PackageName}; {package.PackageInstallCommand}; cd ..; "; } } } }
/// <summary> /// Called to request that the task runner start a task. /// </summary> /// <param name="startTask"> /// The <see cref="StartTask"/> request message. /// </param> void OnStartTask(StartTask startTask) { if (startTask == null) { throw new ArgumentNullException("startTask"); } Log.Information( "{ActorPath}: Runner is starting task: {What}", Self.Path.ToUserRelativePath(), startTask.What ); // Report to controller. _taskController.Tell( new TaskStarted( startTask.What, byWho: Self.Path.Name ) ); TimeSpan simulatedWorkDelay = GetRandomDelay(); Log.Information( "{ActorPath}: Runner is pausing for {SimulatedDelay}ms", Self.Path.ToUserRelativePath(), simulatedWorkDelay.TotalMilliseconds ); Thread.Sleep(simulatedWorkDelay); Log.Information( "{ActorPath}: Runner has completed task: {What} after {SimulatedDelay}ms", Self.Path.ToUserRelativePath(), startTask.What, simulatedWorkDelay.TotalMilliseconds ); // Report to controller. _taskController.Tell( new TaskCompleted( startTask.What, byWho: Self.Path.Name, runTime: simulatedWorkDelay ) ); }
private void AppendDomainSetup( StartTask startTask, RenderingEnvironment environment) { if (environment.Domain != null && environment.Domain.JoinDomain) { var resourceFile = GetJoinDomainResourceFile(); startTask.ResourceFiles.Add(resourceFile); startTask.CommandLine += $".\\{resourceFile.FilePath} " + $"-domainName {environment.Domain.DomainName} " + $"-domainOuPath {environment.Domain.DomainWorkerOuPath} " + $"-tenantId {environment.KeyVaultServicePrincipal.TenantId} " + $"-applicationId {environment.KeyVaultServicePrincipal.ApplicationId} " + $"-keyVaultCertificateThumbprint {environment.KeyVaultServicePrincipal.Thumbprint} " + $"-keyVaultName {environment.KeyVault.Name};"; } }
/// <summary> /// Creates a pool of "small" Windows Server 2012 R2 compute nodes in the Batch service with the specified configuration. /// </summary> /// <param name="batchClient">The client to use for creating the pool.</param> /// <param name="poolId">The id of the pool to create.</param> /// <param name="numberOfNodes">The target number of compute nodes for the pool.</param> /// <param name="appPackageId">The id of the application package to install on the compute nodes.</param> /// <param name="appPackageVersion">The application package version to install on the compute nodes.</param> private static async Task CreatePoolAsync(BatchClient batchClient, string poolId, int numberOfNodes, string appPackageId, string appPackageVersion) { // Create the unbound pool. Until we call CloudPool.Commit() or CommitAsync(), // the pool isn't actually created in the Batch service. This CloudPool instance // is therefore considered "unbound," and we can modify its properties. Console.WriteLine($"Creating pool [{poolId}]..."); CloudPool unboundPool = batchClient.PoolOperations.CreatePool(poolId: poolId, virtualMachineSize: "small", targetDedicatedComputeNodes: numberOfNodes, cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "4")); // REQUIRED for communication between the MS-MPI processes (in this // sample, MPIHelloWorld.exe) running on the different nodes unboundPool.InterComputeNodeCommunicationEnabled = true; // REQUIRED for multi-instance tasks unboundPool.MaxTasksPerComputeNode = 1; // Specify the application and version to deploy to the compute nodes. unboundPool.ApplicationPackageReferences = new List <ApplicationPackageReference> { new ApplicationPackageReference { ApplicationId = appPackageId, Version = appPackageVersion } }; // Create a StartTask for the pool that we use to install MS-MPI on the nodes // as they join the pool. StartTask startTask = new StartTask { CommandLine = $"cmd /c %AZ_BATCH_APP_PACKAGE_{appPackageId.ToUpper()}#{appPackageVersion}%\\MSMpiSetup.exe -unattend -force", UserIdentity = new UserIdentity(new AutoUserSpecification(elevationLevel: ElevationLevel.Admin)), WaitForSuccess = true }; unboundPool.StartTask = startTask; // Commit the fully configured pool to the Batch service to actually create // the pool and its compute nodes. await unboundPool.CommitAsync(); }
private void AppendGeneralPackages(StartTask startTask, IEnumerable <InstallationPackage> generalPackages) { if (generalPackages != null) { foreach (var package in generalPackages) { var resourceFile = GetContainerResourceFile(package.Container, package.PackageName); startTask.ResourceFiles = new List <ResourceFile>(startTask.ResourceFiles) { resourceFile }; if (!string.IsNullOrWhiteSpace(package.PackageInstallCommand)) { startTask.CommandLine += $"pushd {package.PackageName}; {package.PackageInstallCommand}; popd; "; } } } }
private async Task AppendQubeParamsToStartTask( PoolConfigurationModel poolConfiguration, RenderingEnvironment environment, StartTask startTask, QubeConfig qubeConfig, InstallationPackage qubePackage, bool isWindows) { var commandLine = startTask.CommandLine; var resourceFiles = new List <ResourceFile>(startTask.ResourceFiles); var workerGroups = $"azure,{poolConfiguration.PoolName}"; if (poolConfiguration.AdditionalGroups != null && poolConfiguration.AdditionalGroups.Any()) { workerGroups += $",{string.Join(',', poolConfiguration.AdditionalGroups)}"; } commandLine += $"-qubeSupervisorIp {qubeConfig.SupervisorIp} " + $"-workerHostGroups '{workerGroups}'"; if (qubePackage != null && !string.IsNullOrEmpty(qubePackage.Container)) { resourceFiles.AddRange(await GetResourceFilesFromContainer(qubePackage.Container)); // Add qb.conf if one isn't already specified by the package if (!resourceFiles.Any(rf => rf.FilePath.Contains("qb.conf"))) { var qbConfResourceFile = new ResourceFile(httpUrl: _configuration["Qube:QbConf"], filePath: "qb.conf"); resourceFiles.Add(qbConfResourceFile); } } else { // No package, lets just configure commandLine += " -skipInstall "; } commandLine += ";"; startTask.CommandLine = commandLine; startTask.ResourceFiles = resourceFiles; }
/// <summary> /// Called to request that the task runner start a task. /// </summary> /// <param name="startTask"> /// The <see cref="StartTask"/> request message. /// </param> void OnStartTask(StartTask startTask) { if (startTask == null) throw new ArgumentNullException("startTask"); Log.Information( "{ActorPath}: Runner is starting task: {What}", Self.Path.ToUserRelativePath(), startTask.What ); // Report to controller. _taskController.Tell( new TaskStarted( startTask.What, byWho: Self.Path.Name ) ); TimeSpan simulatedWorkDelay = GetRandomDelay(); Log.Information( "{ActorPath}: Runner is pausing for {SimulatedDelay}ms", Self.Path.ToUserRelativePath(), simulatedWorkDelay.TotalMilliseconds ); Thread.Sleep(simulatedWorkDelay); Log.Information( "{ActorPath}: Runner has completed task: {What} after {SimulatedDelay}ms", Self.Path.ToUserRelativePath(), startTask.What, simulatedWorkDelay.TotalMilliseconds ); // Report to controller. _taskController.Tell( new TaskCompleted( startTask.What, byWho: Self.Path.Name, runTime: simulatedWorkDelay ) ); }
private void AppendBYOSParamsToStartTask( PoolConfigurationModel poolConfiguration, RenderingEnvironment environment, StartTask startTask, BYOSConfig byosConfig, bool isWindows) { var commandLine = startTask.CommandLine; var resourceFiles = new List <ResourceFile>(startTask.ResourceFiles); if (environment.KeyVaultServicePrincipal != null) { commandLine += GetParameterSet(isWindows, "tenantId", environment.KeyVaultServicePrincipal.TenantId.ToString()); commandLine += GetParameterSet(isWindows, "applicationId", environment.KeyVaultServicePrincipal.ApplicationId.ToString()); commandLine += GetParameterSet(isWindows, "keyVaultCertificateThumbprint", environment.KeyVaultServicePrincipal.Thumbprint); commandLine += GetParameterSet(isWindows, "keyVaultName", environment.KeyVault.Name); } if (!string.IsNullOrWhiteSpace(byosConfig.SchedulerHostnameOrIp)) { commandLine += GetParameterSet(isWindows, "host", byosConfig.SchedulerHostnameOrIp); } var groups = $"azure,{poolConfiguration.PoolName}"; if (poolConfiguration.AdditionalGroups != null && poolConfiguration.AdditionalGroups.Any()) { groups += $",{string.Join(',', poolConfiguration.AdditionalGroups)}"; } if (!string.IsNullOrWhiteSpace(groups)) { commandLine += GetParameterSet(isWindows, "groups", groups); } commandLine += ";"; startTask.CommandLine = commandLine; startTask.ResourceFiles = resourceFiles; }
/// <summary> /// Vytvoření fondu výpočetních uzlů se systémem windows 2012 R2 ve službě Batch /// </summary> /// <param name="batchClient">klient pro vytvoření fondu</param> /// <param name="poolId">id fondu který chceme vytvořit</param> /// <param name="numberOfNodes">počet výpočetních uzlů pro fond</param> /// <param name="appPackageId">id balíčku aplikace</param> /// <param name="appPackageVersion">verze balíčku</param> private static async Task CreatePoolAsync(BatchClient batchClient, string poolId, int numberOfNodes, string appPackageId, string appPackageVersion) { //vytvoření fondu a poolu kde můžeme upravit vlastnosti Console.WriteLine($"Creating pool [{poolId}]..."); CloudPool unboundPool = batchClient.PoolOperations.CreatePool( poolId: poolId, virtualMachineSize: "standard_d2_v2", //virtualMachineSize: "Standard_H8", targetDedicatedComputeNodes: numberOfNodes, cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "5")); //spuštění komunikace mezi uzly pro ms-mpi unboundPool.InterComputeNodeCommunicationEnabled = true; //potřebné pro víceinstanční úlohy, aby každá část úlohy byla na jednom jádru v pc unboundPool.MaxTasksPerComputeNode = 1; // aplikace a verze která se bude spouštět v uzlech unboundPool.ApplicationPackageReferences = new List <ApplicationPackageReference> { new ApplicationPackageReference { ApplicationId = appPackageId, Version = appPackageVersion } }; //instalace ms-mpi na uzly StartTask startTask = new StartTask { CommandLine = $"cmd /c %AZ_BATCH_APP_PACKAGE_{appPackageId.ToUpper()}#{appPackageVersion}%\\MSMpiSetup.exe -unattend -force", UserIdentity = new UserIdentity(new AutoUserSpecification(elevationLevel: ElevationLevel.Admin)), WaitForSuccess = true }; unboundPool.StartTask = startTask; await unboundPool.CommitAsync(); }
public async Task <StartTask> GetQubeStartTask( string poolName, IEnumerable <string> additionalGroups, RenderingEnvironment environment, InstallationPackage qubePackage, InstallationPackage gpuPackage, IEnumerable <InstallationPackage> generalPackages, bool isWindows) { var resourceFiles = new List <ResourceFile>(); var startTask = new StartTask( "", resourceFiles, GetEnvironmentSettings(environment, isWindows), new UserIdentity( autoUser: new AutoUserSpecification(AutoUserScope.Pool, ElevationLevel.Admin)), 3, // retries true); // waitForSuccess AppendGpu(startTask, gpuPackage); AppendDomainSetup(startTask, environment); AppendGeneralPackages(startTask, generalPackages); await AppendQubeSetupToStartTask( environment, poolName, additionalGroups, startTask, environment.RenderManagerConfig.Qube, qubePackage, isWindows); // Wrap all the start task command startTask.CommandLine = $"powershell.exe -ExecutionPolicy RemoteSigned -NoProfile \"$ErrorActionPreference='Stop'; {startTask.CommandLine}\""; return(startTask); }
/// <summary> /// Creates a test pool for use in Scenario tests. /// </summary> public static void CreateTestPool( BatchController controller, BatchAccountContext context, string poolId, int?targetDedicated, int?targetLowPriority, CertificateReference certReference = null, StartTask startTask = null) { PSCertificateReference[] certReferences = null; if (certReference != null) { certReferences = new PSCertificateReference[] { new PSCertificateReference(certReference) }; } PSStartTask psStartTask = null; if (startTask != null) { psStartTask = new PSStartTask(startTask); } PSCloudServiceConfiguration paasConfiguration = new PSCloudServiceConfiguration("4", "*"); NewPoolParameters parameters = new NewPoolParameters(context, poolId) { VirtualMachineSize = "small", CloudServiceConfiguration = paasConfiguration, TargetDedicatedComputeNodes = targetDedicated, TargetLowPriorityComputeNodes = targetLowPriority, CertificateReferences = certReferences, StartTask = psStartTask, InterComputeNodeCommunicationEnabled = true }; CreatePoolIfNotExists(controller, parameters); }
/// <summary> /// Creates an MPI pool. /// </summary> public static void CreateMpiPoolIfNotExists(BatchController controller, BatchAccountContext context, int targetDedicated = 3) { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); ListPoolOptions listOptions = new ListPoolOptions(context) { PoolId = MpiPoolId }; try { client.ListPools(listOptions); return; // The call returned without throwing an exception, so the pool exists } catch (AggregateException aex) { BatchException innerException = aex.InnerException as BatchException; if (innerException == null || innerException.RequestInformation == null || innerException.RequestInformation.AzureError == null || innerException.RequestInformation.AzureError.Code != BatchErrorCodeStrings.PoolNotFound) { throw; } // We got the pool not found error, so continue and create the pool } string blobUrl = UploadBlobAndGetUrl(MpiSetupFileContainer, MpiSetupFileName, MpiSetupFileLocalPath); StartTask startTask = new StartTask(); startTask.CommandLine = string.Format("cmd /c set & {0} -unattend -force", MpiSetupFileName); startTask.ResourceFiles = new List<ResourceFile>(); startTask.ResourceFiles.Add(new ResourceFile(blobUrl, MpiSetupFileName)); startTask.RunElevated = true; startTask.WaitForSuccess = true; CreateTestPool(controller, context, MpiPoolId, targetDedicated, startTask: startTask); }
public fmTaskStart(StartTask startTask, string userId, string userName) { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); NowTask = startTask; this.UserId = userId; this.UserName = userName; }
public void StartThread() { StartTask del= new StartTask(StartCrow); AsyncCallback callBackWhenDone = new AsyncCallback(this.EndStartThread); del.BeginInvoke(callBackWhenDone,null); }
/// <summary> /// Creates a pool of "small" Windows Server 2012 R2 compute nodes in the Batch service with the specified configuration. /// </summary> /// <param name="batchClient">The client to use for creating the pool.</param> /// <param name="poolId">The id of the pool to create.</param> /// <param name="numberOfNodes">The target number of compute nodes for the pool.</param> /// <param name="appPackageId">The id of the application package to install on the compute nodes.</param> /// <param name="appPackageVersion">The application package version to install on the compute nodes.</param> private static async Task CreatePoolAsync(BatchClient batchClient, string poolId, int numberOfNodes, string appPackageId, string appPackageVersion) { // Create the unbound pool. Until we call CloudPool.Commit() or CommitAsync(), // the pool isn't actually created in the Batch service. This CloudPool instance // is therefore considered "unbound," and we can modify its properties. Console.WriteLine($"Creating pool [{poolId}]..."); CloudPool unboundPool = batchClient.PoolOperations.CreatePool(poolId: poolId, virtualMachineSize: "small", targetDedicated: numberOfNodes, cloudServiceConfiguration: new CloudServiceConfiguration(osFamily: "4")); // REQUIRED for communication between the MS-MPI processes (in this // sample, MPIHelloWorld.exe) running on the different nodes unboundPool.InterComputeNodeCommunicationEnabled = true; // REQUIRED for multi-instance tasks unboundPool.MaxTasksPerComputeNode = 1; // Specify the application and version to deploy to the compute nodes. unboundPool.ApplicationPackageReferences = new List<ApplicationPackageReference> { new ApplicationPackageReference { ApplicationId = appPackageId, Version = appPackageVersion } }; // Create a StartTask for the pool that we use to install MS-MPI on the nodes // as they join the pool. StartTask startTask = new StartTask { CommandLine = $"cmd /c %AZ_BATCH_APP_PACKAGE_{appPackageId.ToUpper()}#{appPackageVersion}%\\MSMpiSetup.exe -unattend -force", RunElevated = true, WaitForSuccess = true }; unboundPool.StartTask = startTask; // Commit the fully configured pool to the Batch service to actually create // the pool and its compute nodes. await unboundPool.CommitAsync(); }
/// <summary> /// Creates a test pool for use in Scenario tests. /// </summary> public static void CreateTestPool(BatchController controller, BatchAccountContext context, string poolId, int targetDedicated, CertificateReference certReference = null, StartTask startTask = null) { BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); PSCertificateReference[] certReferences = null; if (certReference != null) { certReferences = new PSCertificateReference[] { new PSCertificateReference(certReference) }; } PSStartTask psStartTask = null; if (startTask != null) { psStartTask = new PSStartTask(startTask); } NewPoolParameters parameters = new NewPoolParameters(context, poolId) { VirtualMachineSize = "small", OSFamily = "4", TargetOSVersion = "*", TargetDedicated = targetDedicated, CertificateReferences = certReferences, StartTask = psStartTask, InterComputeNodeCommunicationEnabled = true }; client.CreatePool(parameters); }
public FilesEnv(BatchTreeViewItem sender, object obj, string name) { try { Sender = sender; InitializeComponent(); } catch (Exception ex) { System.Windows.MessageBox.Show(string.Format("{0}", ex)); } task = null; pool = null; workitem = null; starttask = null; code = name; if (obj is TaskEntities.Task) { this.task = obj as TaskEntities.Task; this.TaskName = name; } else if (obj is Pool) { this.pool = obj as Pool; } else if (obj is WorkItem && code.Equals("1")) { try { this.workitem = obj as WorkItem; btnFinish.Content = "Next"; } catch (Exception ex) { System.Windows.MessageBox.Show(string.Format("{0}", ex)); } } else if (obj is WorkItem && code.Equals("2")) { try { this.workitem = obj as WorkItem; } catch (Exception ex) { System.Windows.MessageBox.Show(string.Format("{0}", ex)); } } else if (obj is StartTask) { try { btnFinish.Content = "Update"; this.starttask = obj as StartTask; } catch (Exception ex) { MessageBox.Show(string.Format("FilesEnv.xaml.cs:\n{0}", ex)); } } else { System.Windows.MessageBox.Show("FilesEnv.xaml.cs: Improper object passed in"); } dataTable1 = new DataTable(); dataView1 = dataTable1.AsDataView(); filesGrid.ItemsSource = dataView1; dataTable1.Columns.Add("File Name", typeof(string)); dataTable1.Columns.Add("Blob Path", typeof(string)); DataRow row1 = dataTable1.NewRow(); dataTable1.Rows.Add(row1); DataTable dataTable2 = new DataTable(); dataView2 = dataTable2.AsDataView(); envGrid.ItemsSource = dataView2; dataTable2.Columns.Add("Variable Name", typeof(string)); dataTable2.Columns.Add("Value", typeof(string)); DataRow row2 = dataTable2.NewRow(); dataTable2.Rows.Add(row2); Loaded += OnLoaded; MainWindow.Resize(MainGrid); }