Exemple #1
0
 /// <summary>
 /// Blocking call to create or update a user account on the compute node.
 /// </summary>
 /// <param name="addOrUpdate">Selects the type of commit operation to perform.</param>
 /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the CustomBehaviors on the current object.</param>
 public void Commit(ComputeNodeUserCommitSemantics addOrUpdate = ComputeNodeUserCommitSemantics.AddUser, IEnumerable <BatchClientBehavior> additionalBehaviors = null)
 {
     using (Task asyncTask = CommitAsync(addOrUpdate, additionalBehaviors))
     {
         asyncTask.WaitAndUnaggregateException(this.CustomBehaviors, additionalBehaviors);
     }
 }
Exemple #2
0
        /// <summary>
        /// Begins an asynchronous call to create or update a user account on the compute node.
        /// </summary>
        /// <param name="addOrUpdate">Selects the type of commit operation to perform.</param>
        /// <param name="additionalBehaviors">A collection of BatchClientBehavior instances that are applied after the CustomBehaviors on the current object.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> for controlling the lifetime of the asynchronous operation.</param>
        /// <returns>A <see cref="System.Threading.Tasks.Task"/> object that represents the asynchronous operation.</returns>
        public Task CommitAsync(
            ComputeNodeUserCommitSemantics addOrUpdate            = ComputeNodeUserCommitSemantics.AddUser,
            IEnumerable <BatchClientBehavior> additionalBehaviors = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            // create the behavior managaer
            BehaviorManager bhMgr = new BehaviorManager(this.CustomBehaviors, additionalBehaviors);
            Task            asyncTask;

            if (ComputeNodeUserCommitSemantics.AddUser == addOrUpdate)
            {
                Models.ComputeNodeUser protoUser = new Models.ComputeNodeUser()
                {
                    Name     = this.Name,
                    Password = this.Password,
                };
                protoUser.ExpiryTime   = this.ExpiryTime;
                protoUser.IsAdmin      = this.IsAdmin;
                protoUser.SshPublicKey = this.SshPublicKey;

                // begin the adduser call
                asyncTask = this.parentBatchClient.ProtocolLayer.AddComputeNodeUser(this.parentPoolId, this.parentNodeId, protoUser, bhMgr, cancellationToken);
            }
            else
            {
                // begin the update call
                asyncTask = this.parentBatchClient.ProtocolLayer.UpdateComputeNodeUser(
                    this.parentPoolId,
                    this.parentNodeId,
                    this.Name,
                    this.Password,
                    this.ExpiryTime,
                    this.SshPublicKey,
                    bhMgr,
                    cancellationToken);
            }

            return(asyncTask);
        }