Inheritance: BatchClientParametersBase
        /// <summary>
        /// Deletes the specified file from its compute node.
        /// </summary>
        /// <param name="recursive">If the file-path parameter represents a directory instead of a file, you can set the optional
        /// recursive parameter to true to delete the directory and all of the files and subdirectories in it. If recursive is false
        /// then the directory must be empty or deletion will fail..</param>
        /// <param name="parameters">Specifies which node file to delete.</param>
        public void DeleteNodeFile(bool?recursive, NodeFileOperationParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            switch (parameters.NodeFileType)
            {
            case PSNodeFileType.Task:
            {
                JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
                jobOperations.DeleteNodeFile(parameters.JobId, parameters.TaskId, parameters.NodeFileName, recursive: recursive, additionalBehaviors: parameters.AdditionalBehaviors);
                break;
            }

            case PSNodeFileType.ComputeNode:
            {
                PoolOperations poolOperations = parameters.Context.BatchOMClient.PoolOperations;
                poolOperations.DeleteNodeFile(parameters.PoolId, parameters.ComputeNodeId, parameters.NodeFileName, recursive: recursive, additionalBehaviors: parameters.AdditionalBehaviors);
                break;
            }

            case PSNodeFileType.PSNodeFileInstance:
            {
                parameters.NodeFile.omObject.Delete(recursive: recursive, additionalBehaviors: parameters.AdditionalBehaviors);
                break;
            }

            default:
            {
                throw new ArgumentException(Resources.NoNodeFile);
            }
            }
        }
        public override void ExecuteCmdlet()
        {
            string fileName = this.InputObject == null ? this.Name : this.InputObject.Name;
            NodeFileOperationParameters parameters = new NodeFileOperationParameters(this.BatchContext, this.JobId, this.TaskId, this.PoolId,
                this.ComputeNodeId, this.Name, this.InputObject, this.AdditionalBehaviors);

            ConfirmAction(
                Force.IsPresent,
                string.Format(Resources.RemoveNodeFileConfirm, fileName),
                Resources.RemoveNodeFile,
                fileName,
                () => BatchClient.DeleteNodeFile(Recursive.IsPresent, parameters));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes the specified file from its compute node.
        /// </summary>
        /// <param name="recursive">If the file-path parameter represents a directory instead of a file, you can set the optional 
        /// recursive parameter to true to delete the directory and all of the files and subdirectories in it. If recursive is false 
        /// then the directory must be empty or deletion will fail..</param>
        /// <param name="parameters">Specifies which node file to delete.</param>
        public void DeleteNodeFile(bool? recursive, NodeFileOperationParameters parameters)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            switch (parameters.NodeFileType)
            {
                case PSNodeFileType.Task:
                    {
                        JobOperations jobOperations = parameters.Context.BatchOMClient.JobOperations;
                        jobOperations.DeleteNodeFile(parameters.JobId, parameters.TaskId, parameters.NodeFileName, recursive: recursive, additionalBehaviors: parameters.AdditionalBehaviors);
                        break;
                    }
                case PSNodeFileType.ComputeNode:
                    {
                        PoolOperations poolOperations = parameters.Context.BatchOMClient.PoolOperations;
                        poolOperations.DeleteNodeFile(parameters.PoolId, parameters.ComputeNodeId, parameters.NodeFileName, recursive: recursive, additionalBehaviors: parameters.AdditionalBehaviors);
                        break;
                    }
                case PSNodeFileType.PSNodeFileInstance:
                    {
                        parameters.NodeFile.omObject.Delete(recursive: recursive, additionalBehaviors: parameters.AdditionalBehaviors);
                        break;
                    }
                default:
                    {
                        throw new ArgumentException(Resources.NoNodeFile);
                    }
            }
        }