public DownloadRDPFileOptions(BatchAccountContext context, string poolName, string vmName, PSVM vm, string destinationPath, 
            Stream stream, IEnumerable<BatchClientBehavior> additionalBehaviors = null) : base(context, poolName, vmName, vm, additionalBehaviors)
        {
            if (string.IsNullOrWhiteSpace(destinationPath) && stream == null)
            {
                throw new ArgumentNullException(Resources.NoDownloadDestination);
            }

            this.DestinationPath = destinationPath;
            this.Stream = stream;
        }
        public VMOperationParameters(BatchAccountContext context, string poolName, string vmName, PSVM vm,
            IEnumerable<BatchClientBehavior> additionalBehaviors = null) : base(context, additionalBehaviors)
        {
            if ((string.IsNullOrWhiteSpace(poolName) || string.IsNullOrWhiteSpace(vmName)) && vm == null)
            {
                throw new ArgumentNullException(Resources.NoVM);
            }

            this.PoolName = poolName;
            this.VMName = vmName;
            this.VM = vm;
        }
 private void CopyRDPStream(Stream destinationStream, IBatchClient client, string poolName, string vmName,
                            PSVM vm, IEnumerable <BatchClientBehavior> additionalBehaviors = null)
 {
     if (vm == null)
     {
         using (IPoolManager poolManager = client.OpenPoolManager())
         {
             poolManager.GetRDPFile(poolName, vmName, destinationStream, additionalBehaviors);
         }
     }
     else
     {
         vm.omObject.GetRDPFile(destinationStream, additionalBehaviors);
     }
 }
        /// <summary>
        /// Lists the vms matching the specified filter options
        /// </summary>
        /// <param name="options">The options to use when querying for vms</param>
        /// <returns>The vms matching the specified filter options</returns>
        public IEnumerable<PSVM> ListVMs(ListVMOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            string poolName = options.Pool == null ? options.PoolName : options.Pool.Name;

            // Get the single vm matching the specified name
            if (!string.IsNullOrEmpty(options.VMName))
            {
                WriteVerbose(string.Format(Resources.GBVM_GetByName, options.VMName, poolName));
                using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager())
                {
                    IVM vm = poolManager.GetVM(poolName, options.VMName, additionalBehaviors: options.AdditionalBehaviors);
                    PSVM psVM = new PSVM(vm);
                    return new PSVM[] { psVM };
                }
            }
            // List vms using the specified filter
            else
            {
                ODATADetailLevel odata = null;
                string verboseLogString = null;
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString = string.Format(Resources.GBVM_GetByOData, poolName);
                    odata = new ODATADetailLevel(filterClause: options.Filter);
                }
                else
                {
                    verboseLogString = string.Format(Resources.GBVM_NoFilter, poolName);
                }
                WriteVerbose(verboseLogString);

                using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager())
                {
                    IEnumerableAsyncExtended<IVM> vms = poolManager.ListVMs(poolName, odata, options.AdditionalBehaviors);
                    Func<IVM, PSVM> mappingFunction = v => { return new PSVM(v); };
                    return PSAsyncEnumerable<PSVM, IVM>.CreateWithMaxCount(
                        vms, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount)));
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Lists the vms matching the specified filter options
        /// </summary>
        /// <param name="options">The options to use when querying for vms</param>
        /// <returns>The vms matching the specified filter options</returns>
        public IEnumerable <PSVM> ListVMs(ListVMOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            string poolName = options.Pool == null ? options.PoolName : options.Pool.Name;

            // Get the single vm matching the specified name
            if (!string.IsNullOrEmpty(options.VMName))
            {
                WriteVerbose(string.Format(Resources.GBVM_GetByName, options.VMName, poolName));
                using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager())
                {
                    IVM  vm   = poolManager.GetVM(poolName, options.VMName, additionalBehaviors: options.AdditionalBehaviors);
                    PSVM psVM = new PSVM(vm);
                    return(new PSVM[] { psVM });
                }
            }
            // List vms using the specified filter
            else
            {
                ODATADetailLevel odata            = null;
                string           verboseLogString = null;
                if (!string.IsNullOrEmpty(options.Filter))
                {
                    verboseLogString = string.Format(Resources.GBVM_GetByOData, poolName);
                    odata            = new ODATADetailLevel(filterClause: options.Filter);
                }
                else
                {
                    verboseLogString = string.Format(Resources.GBVM_NoFilter, poolName);
                }
                WriteVerbose(verboseLogString);

                using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager())
                {
                    IEnumerableAsyncExtended <IVM> vms = poolManager.ListVMs(poolName, odata, options.AdditionalBehaviors);
                    Func <IVM, PSVM> mappingFunction   = v => { return(new PSVM(v)); };
                    return(PSAsyncEnumerable <PSVM, IVM> .CreateWithMaxCount(
                               vms, mappingFunction, options.MaxCount, () => WriteVerbose(string.Format(Resources.MaxCount, options.MaxCount))));
                }
            }
        }
 public NewVMUserParameters(BatchAccountContext context, string poolName, string vmName, PSVM vm, IEnumerable <BatchClientBehavior> additionalBehaviors = null)
     : base(context, poolName, vmName, vm, additionalBehaviors)
 {
 }
Esempio n. 7
0
        public DownloadRDPFileOptions(BatchAccountContext context, string poolName, string vmName, PSVM vm, string destinationPath,
                                      Stream stream, IEnumerable <BatchClientBehavior> additionalBehaviors = null) : base(context, poolName, vmName, vm, additionalBehaviors)
        {
            if (string.IsNullOrWhiteSpace(destinationPath) && stream == null)
            {
                throw new ArgumentNullException(Resources.NoDownloadDestination);
            }

            this.DestinationPath = destinationPath;
            this.Stream          = stream;
        }
 public ListVMFileOptions(BatchAccountContext context, string poolName, string vmName, PSVM vm, IEnumerable <BatchClientBehavior> additionalBehaviors = null)
     : base(context, poolName, vmName, vm, additionalBehaviors)
 {
 }
        public VMOperationParameters(BatchAccountContext context, string poolName, string vmName, PSVM vm,
                                     IEnumerable <BatchClientBehavior> additionalBehaviors = null) : base(context, additionalBehaviors)
        {
            if ((string.IsNullOrWhiteSpace(poolName) || string.IsNullOrWhiteSpace(vmName)) && vm == null)
            {
                throw new ArgumentNullException(Resources.NoVM);
            }

            this.PoolName = poolName;
            this.VMName   = vmName;
            this.VM       = vm;
        }
 private void CopyRDPStream(Stream destinationStream, IBatchClient client, string poolName, string vmName,
     PSVM vm, IEnumerable<BatchClientBehavior> additionalBehaviors = null)
 {
     if (vm == null)
     {
         using (IPoolManager poolManager = client.OpenPoolManager())
         {
             poolManager.GetRDPFile(poolName, vmName, destinationStream, additionalBehaviors);
         }
     }
     else
     {
         vm.omObject.GetRDPFile(destinationStream, additionalBehaviors);
     }
 }
 public NewVMUserParameters(BatchAccountContext context, string poolName, string vmName, PSVM vm, IEnumerable<BatchClientBehavior> additionalBehaviors = null) 
     : base(context, poolName, vmName, vm, additionalBehaviors)
 { }