Beispiel #1
0
        private void _SetBIOS(biosThreadState state)
        {
            // SCP some needed files to it.
            copyDeploymentFilesToBlade(state.blade, state.biosxml, state.connectDeadline);

            // And execute the command to deploy the BIOS via SSH.
            using (hypervisor hyp = _hostManager.makeHypervisorForBlade_LTSP(state.blade))
            {
                executionResult res = hyp.startExecutable("bash", "~/applyBIOS.sh");
                if (res.resultCode != 0)
                {
                    string msg = string.Format("Executing applyBIOS.sh on {0} resulted in error code {1}", state.nodeIP, res.resultCode);
                    msg += "stdout: " + res.stdout;
                    msg += "stderr: " + res.stderr;
                    _hostManager.addLogEvent(msg);
                    state.result = new result(resultCode.genericFail, msg);
                }
                else
                {
                    _hostManager.addLogEvent(string.Format("Deployed BIOS successfully to {0}", state.nodeIP));

                    using (var tmp = new tempLockElevation(state.blade, bladeLockType.lockNone, bladeLockType.lockBIOS))
                    {
                        _hostManager.markLastKnownBIOS(state.blade, state.biosxml);
                    }

                    state.result = new result(resultCode.success);
                }

                // All done, now we can power off and return.
                hyp.powerOff(state.connectDeadline);
            }

            state.isFinished = true;
        }
Beispiel #2
0
        public override executionResult callMockedExecutionHandler(hypervisor sender, string command, string args, string workingdir, cancellableDateTime deadline)
        {
            string commandLine = command + " " + args;

            switch (commandLine)
            {
            case "bash ~/applyBIOS.sh":
                return(new executionResult("bios stuff", "", 0));

            case "esxcfg-nas -l":
                return(new executionResult("esxivms is /mnt/SSDs/esxivms from 10.0.255.254 mounted available", null, 0));

            case @"C:\windows\system32\cmd /c shutdown -s -f -t 01":
                sender.powerOff();
                return(new executionResult("", "", 0));
            }

            if (commandLine.StartsWith("vim-cmd vmsvc/power.off `vim-cmd vmsvc/getallvms | grep"))
            {
                return(new executionResult("", null, 0));
            }
            if (commandLine.StartsWith("vim-cmd vmsvc/unregister `vim-cmd vmsvc/getallvms"))
            {
                return(new executionResult("", null, 0));
            }
            if (commandLine.StartsWith("rm  -rf /vmfs/volumes/esxivms/"))
            {
                return(new executionResult("", null, 0));
            }
            if (commandLine.StartsWith("cp  -R /vmfs/volumes/esxivms/PXETemplate /vmfs/volumes/esxivms/"))
            {
                return(new executionResult("", null, 0));
            }
            if (commandLine.StartsWith("sed  -e "))
            {
                return(new executionResult("", null, 0));
            }
            if (commandLine.StartsWith("vim-cmd  solo/registervm /vmfs/volumes/esxivms/"))
            {
                return(new executionResult("", null, 0));
            }
            if (commandLine.StartsWith("cmd.exe /c c:\\deployed.bat "))
            {
                return(new executionResult("", null, 0));
            }

            throw new Exception("executed unexpected command " + commandLine);
        }
Beispiel #3
0
        private void _GetBIOS(biosThreadState state)
        {
            copyDeploymentFilesToBlade(state.blade, null, state.connectDeadline);

            using (hypervisor hyp = _hostManager.makeHypervisorForBlade_LTSP(state.blade))
            {
                executionResult res = hyp.startExecutable("bash", "~/getBIOS.sh");
                if (res.resultCode != 0)
                {
                    string msg = string.Format("Executing getBIOS.sh on {0} resulted in error code {1}", state.nodeIP, res.resultCode);
                    msg += "stdout: " + res.stdout;
                    msg += "stderr: " + res.stderr;
                    _hostManager.addLogEvent(msg);
                    state.result = new result(resultCode.genericFail, msg);
                }
                else
                {
                    string msg = string.Format("Deployed BIOS successfully to {0}", state.nodeIP);
                    _hostManager.addLogEvent(msg);
                    state.result = new result(resultCode.success, msg);
                }

                // Retrieve the output
                state.biosxml = hyp.getFileFromGuest("currentbios.xml", state.connectDeadline);

                // All done, now we can power off and return.
                hyp.powerOff(state.connectDeadline);
            }

            using (var tmp = new tempLockElevation(state.blade, bladeLockType.lockNone, bladeLockType.lockBIOS))
            {
                _hostManager.markLastKnownBIOS(state.blade, state.biosxml);
            }

            state.isFinished = true;
        }