Example #1
0
        /// <summary>
        /// Initializes this asset
        /// </summary>
        public override void Validate(ParallelLoopState loopState)
        {
            TraceFactory.Logger.Debug("Validating {0}".FormatWith(_machine.Name));
            try
            {
                _inShutdown = false;

                MapElement.UpdateStatus("Validating", RuntimeState.Validating);

                if (_machine.IsPoweredOn())
                {
                    TraceFactory.Logger.Debug("{0} is already powered on...".FormatWith(_machine.Name));

                    if (JediSimulatorManager.IsSimulatorReady(_machine.Name))
                    {
                        MapElement.UpdateStatus("Simulator is already powered on and ready", RuntimeState.Validated);
                    }
                    else
                    {
                        MapElement.UpdateStatus("Simulator is in an unknown state and will be restarted", RuntimeState.Warning);
                    }
                }
                else
                {
                    MapElement.UpdateStatus("Simulator is powered off and will be started", RuntimeState.Validated);
                }
            }
            catch (Exception ex)
            {
                MapElement.UpdateStatus(RuntimeState.Error, "Validation failure: {0}".FormatWith(ex.Message), ex);
            }
        }
 /// <summary>
 /// Initializes this machine by ensuring it's available and ready to boot
 /// </summary>
 public override void Validate()
 {
     // If the machine is already powered on, then find another one
     while (_machine.IsPoweredOn())
     {
         TraceFactory.Logger.Debug("Machine already powered on {0}, it will be replaced".FormatWith(_machine.Name));
         Replace();
     }
 }
 private void CleanupAssetHostsHandler(DeviceSimulator simulatorMachine)
 {
     using (var machine = new ManagedMachine(simulatorMachine.VirtualMachine, ManagedMachineType.WindowsVirtual))
     {
         try
         {
             MachineStop.Run(machine.Name, () =>
             {
                 if (machine.IsPoweredOn())
                 {
                     machine.Shutdown(wait: true);
                 }
             });
         }
         catch (Exception ex)
         {
             TraceFactory.Logger.Error(ex.Message);
         }
     }
 }