Example #1
0
 /// <summary>
 /// Powers on a VM.
 /// </summary>
 /// <param name="setInUse">if set to <c>true</c> then set the VM to in use in the asset inventory system.</param>
 public void PowerOn(bool setInUse = true)
 {
     VMController.PowerOnMachine(Name);
     if (setInUse)
     {
         VMInventoryManager.SetInUse(Name);
     }
 }
Example #2
0
        /// <summary>
        /// Releases the reservation on this VM.
        /// </summary>
        public void ReleaseReservation()
        {
            if (_reservationReleased)
            {
                throw new InvalidOperationException("Reservation was never made for " + Name);
            }

            VMInventoryManager.ReleaseReservation(Name);
            _reservationReleased = true;
        }
Example #3
0
        /// <summary>
        /// Reserves the requested block of VMs.
        /// </summary>
        /// <param name="sessionId">The session Id.</param>
        /// <param name="credential">Credentials for reserving the VMs</param>
        /// <param name="requestedVMs">The platforms of the requested VMs.</param>
        /// <param name="requiredVMQuantity">The quantity per platform of requested VMs.</param>
        /// <returns>Whether or not the requested VMs were reserved.</returns>
        public static Collection <VirtualMachine> RequestVMs(string sessionId, UserCredential credential, RequestedVMDictionary requestedVMs, VMQuantityDictionary requiredVMQuantity)
        {
            bool reserved;

            lock (_resourceLock)
            {
                TraceFactory.Logger.Debug("Reserving virtual machines...");
                reserved = VMInventoryManager.Reserve(sessionId, credential, requestedVMs, requiredVMQuantity);
            }

            if (!reserved)
            {
                throw new VMInventoryException("Unable to reserve requested virtual machines");
            }

            var reservedVMs = VMInventoryManager.GetReservedList(sessionId);

            TraceFactory.Logger.Info("Successfully reserved {0} virtual machines".FormatWith(reservedVMs.Count));

            return(reservedVMs);
        }