Пример #1
0
        private bool Initialize(string snapshot)
        {
            bool result = true;

            if (mTesting == false)
            {
                mBusy = true;

                // Refresh data in case the VM name has changed.....
                mData = VMInstanceData.SelectByIP(mData.IPAddress);

                // Stop the heartbeat timer because rolling it back might cause it to actually miss a heartbeat.
                StopHeartbeatTimer();
                PowerCLI powerCLI = PowerCLI.Instance(mNetworkCredentials);
                result = powerCLI.RollbackVM(mData.VMName, snapshot, mLogFile);
                if (result == false)
                {
                    DatabaseLog.Insert("Rollback failed on VM " + mData.VMName, "There might be an issue with PowerCLI. Please check the logs.", 1);
                }
                StartHeartbeatTimer();
                mBusy = false;
            }

            return(result);
        }
Пример #2
0
        private void InactivityTimeout(object state)
        {
            // Error situation
            Log("Error: inactivity timer expired. Reseting VM.", true);

            mData = VMInstanceData.SelectByIP(mData.IPAddress);
            Log("Fetched updated information for VM. VMState: " + mData.State);
            if (mData.State == 1)
            {
                CleanupVM();
            }
        }
Пример #3
0
        internal StartClientResponse HandleStartMessage()
        {
            Log("Start message received.");

            // Get latest state
            mData = VMInstanceData.SelectByIP(mData.IPAddress);

            // Reset local flags that represent the state of the VM
            mBusy = false;

            StartClientResponse response = new StartClientResponse()
            {
                Enabled = (mData.State == 1),
                OSType  = mData.OperatingSystemID
            };

            Log("Start response: Enabled=" + response.Enabled + "; OS=" + response.OSType);
            return(response);
        }
Пример #4
0
        private void HeartbeatTimerTimeout(object state)
        {
            lock (this)
            {
                mHeartbeatsMissed++;
            }

            if (mHeartbeatsMissed > mMaxHeartBeatMissed)
            {
                mHeartbeatsMissed = 0;

                Log(mMaxHeartBeatMissed + " or more heartbeats missed for VM " + mData.VMName, true);
                TestJobData.Cancel(mData.VMInstanceID, "VM missed " + mMaxHeartBeatMissed + " heart beats.");

                try
                {
                    // Refresh data to see if the VM is Disabled
                    mData = VMInstanceData.SelectByIP(mData.IPAddress);
                    Log("Fetched updated information. VMState: " + mData.State);
                }
                catch (Exception ex)
                {
                    Log("ERROR: " + ex.ToString(), true);
                }

                if (mData.State == 1)
                {
                    mBusy = true;
                    //CreateSnapshot("HBFailure_" + DateTime.Now.ToString("yyyy-dd-MM-HH-mm-ss"));
                    mBusy = false;

                    CleanupVM();
                }
            }
            else if (mHeartbeatsMissed > 1)
            {
                Log("Heartbeats missed: " + mHeartbeatsMissed, true);
            }
        }
Пример #5
0
        private bool RebootVM()
        {
            bool result = true;

            if (mTesting == false)
            {
                // Refresh data in case the VM name has changed.....
                mData = VMInstanceData.SelectByIP(mData.IPAddress);

                Log("Rebooting VM " + mData.VMName);
                StopHeartbeatTimer();
                PowerCLI powerCLI = PowerCLI.Instance(mNetworkCredentials);
                result = powerCLI.Reboot(mData.VMName, mLogFile);
                if (result == false)
                {
                    DatabaseLog.Insert("Rebooting failed for VM " + mData.VMName, "There might be an issue with PowerCLI. Please check the logs.", 1);
                }
                StartHeartbeatTimer();
            }

            return(result);
        }