public static JobManagerTask ToJobManagerTask(this APSIMJob job, Guid jobId, CloudBlobClient blobClient, bool shouldSubmitTasks, bool autoScale) { var cmd = string.Format("cmd.exe /c {0} job-manager {1} {2} {3} {4} {5} {6} {7} {8} {9}", BatchConstants.GetJobManagerPath(jobId), job.BatchAuth.Url, job.BatchAuth.Account, job.BatchAuth.Key, job.StorageAuth.Account, job.StorageAuth.Key, jobId, BatchConstants.GetModelPath(jobId), shouldSubmitTasks, autoScale ); return(new JobManagerTask { CommandLine = cmd, DisplayName = "Job manager task", KillJobOnCompletion = true, Id = BatchConstants.JobManagerName, RunExclusive = false, ResourceFiles = GetResourceFiles(job, blobClient).ToList() }); }
/// <summary> /// Returns the zipped Apsim file and helpers like AzCopy and 7zip /// </summary> /// <param name="job"></param> /// <param name="blobClient"></param> /// <returns></returns> private static IEnumerable <ResourceFile> GetResourceFiles(APSIMJob job, CloudBlobClient blobClient) { yield return(new ResourceFile(job.ModelZipFileSas, BatchConstants.ModelZipFileName)); var toolsRef = blobClient.GetContainerReference("tools"); foreach (CloudBlockBlob listBlobItem in toolsRef.ListBlobs()) { var sas = listBlobItem.GetSharedAccessSignature(new SharedAccessBlobPolicy { SharedAccessStartTime = DateTime.UtcNow.AddHours(-1), SharedAccessExpiryTime = DateTime.UtcNow.AddMonths(2), Permissions = SharedAccessBlobPermissions.Read, }); yield return(new ResourceFile(listBlobItem.Uri.AbsoluteUri + sas, listBlobItem.Name)); } var apsimRef = blobClient.GetContainerReference("apsim"); foreach (CloudBlockBlob listBlobItem in apsimRef.ListBlobs()) { if (listBlobItem.Name.ToLower().Contains(job.ApsimApplicationPackageVersion.ToLower())) { var sas = listBlobItem.GetSharedAccessSignature(new SharedAccessBlobPolicy { SharedAccessStartTime = DateTime.UtcNow.AddHours(-1), SharedAccessExpiryTime = DateTime.UtcNow.AddMonths(2), Permissions = SharedAccessBlobPermissions.Read }); yield return(new ResourceFile(listBlobItem.Uri.AbsoluteUri + sas, listBlobItem.Name)); } } }
public static JobPreparationTask ToJobPreparationTask(this APSIMJob job, Guid jobId, CloudBlobClient blobClient) { return(new JobPreparationTask { CommandLine = "cmd.exe /c jobprep.cmd", ResourceFiles = GetResourceFiles(job, blobClient).ToList(), WaitForSuccess = true }); }
private static IEnumerable <ResourceFile> GetResourceFiles(APSIMJob job, CloudBlobClient blobClient) { var toolsRef = blobClient.GetContainerReference("jobmanager"); foreach (CloudBlockBlob listBlobItem in toolsRef.ListBlobs()) { var sas = listBlobItem.GetSharedAccessSignature(new SharedAccessBlobPolicy { SharedAccessStartTime = DateTime.UtcNow.AddHours(-1), SharedAccessExpiryTime = DateTime.UtcNow.AddMonths(2), Permissions = SharedAccessBlobPermissions.Read, }); yield return(new ResourceFile(listBlobItem.Uri.AbsoluteUri + sas, listBlobItem.Name)); } }
public static JobReleaseTask ToJobReleaseTask(this APSIMJob job, Guid jobId, CloudBlobClient blobClient) { return(new JobReleaseTask { CommandLine = "cmd.exe /c jobrelease.cmd", ResourceFiles = GetResourceFiles(job, blobClient).ToList(), EnvironmentSettings = new[] { new EnvironmentSetting("APSIM_STORAGE_ACCOUNT", job.StorageAuth.Account), new EnvironmentSetting("APSIM_STORAGE_KEY", job.StorageAuth.Key), new EnvironmentSetting("JOBNAME", job.DisplayName), new EnvironmentSetting("RECIPIENT", job.Recipient) } }); }