// Lists the node files under a compute node. private IEnumerable <PSNodeFile> ListNodeFilesByComputeNode(ListNodeFileOptions options) { // Get the single node file matching the specified name if (!string.IsNullOrEmpty(options.NodeFileName)) { WriteVerbose(string.Format(Resources.GetNodeFileByComputeNodeByName, options.NodeFileName, options.ComputeNodeId)); PoolOperations poolOperations = options.Context.BatchOMClient.PoolOperations; NodeFile nodeFile = poolOperations.GetNodeFile(options.PoolId, options.ComputeNodeId, options.NodeFileName, options.AdditionalBehaviors); PSNodeFile psNodeFile = new PSNodeFile(nodeFile); return(new PSNodeFile[] { psNodeFile }); } // List node files using the specified filter else { string computeNodeId = options.ComputeNode == null ? options.ComputeNodeId : options.ComputeNode.Id; ODATADetailLevel odata = null; string verboseLogString = null; if (!string.IsNullOrEmpty(options.Filter)) { verboseLogString = string.Format(Resources.GetNodeFileByComputeNodeByOData, computeNodeId); odata = new ODATADetailLevel(filterClause: options.Filter); } else { verboseLogString = string.Format(Resources.GetNodeFileByComputeNodeNoFilter, computeNodeId); } WriteVerbose(verboseLogString); IPagedEnumerable <NodeFile> nodeFiles = null; if (options.ComputeNode != null) { nodeFiles = options.ComputeNode.omObject.ListNodeFiles(options.Recursive, odata, options.AdditionalBehaviors); } else { PoolOperations poolOperations = options.Context.BatchOMClient.PoolOperations; nodeFiles = poolOperations.ListNodeFiles(options.PoolId, options.ComputeNodeId, options.Recursive, odata, options.AdditionalBehaviors); } Func <NodeFile, PSNodeFile> mappingFunction = f => { return(new PSNodeFile(f)); }; return(PSPagedEnumerable <PSNodeFile, NodeFile> .CreateWithMaxCount( nodeFiles, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount)))); } }
/// <summary> /// Downloads a node file using the specified options. /// </summary> /// <param name="options">The download options.</param> public void DownloadNodeFile(DownloadNodeFileOptions options) { if (options == null) { throw new ArgumentNullException("options"); } NodeFile nodeFile = null; switch (options.NodeFileType) { case PSNodeFileType.Task: { JobOperations jobOperations = options.Context.BatchOMClient.JobOperations; nodeFile = jobOperations.GetNodeFile(options.JobId, options.TaskId, options.NodeFileName, options.AdditionalBehaviors); break; } case PSNodeFileType.ComputeNode: { PoolOperations poolOperations = options.Context.BatchOMClient.PoolOperations; nodeFile = poolOperations.GetNodeFile(options.PoolId, options.ComputeNodeId, options.NodeFileName, options.AdditionalBehaviors); break; } case PSNodeFileType.PSNodeFileInstance: { nodeFile = options.NodeFile.omObject; break; } default: { throw new ArgumentException(Resources.NoNodeFile); } } DownloadNodeFileByInstance(nodeFile, options.DestinationPath, options.Stream, options.AdditionalBehaviors); }