Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Parser      parser     = new CommandLine.Parser();
            hyptoolargs parsedArgs = new hyptoolargs();

            if (parser.ParseArgumentsStrict(args, parsedArgs, () => { Console.Write(HelpText.AutoBuild(parsedArgs).ToString()); }))
            {
                _Main(parsedArgs);
            }
            else
            {
                Console.WriteLine("Valid action values:");
                foreach (string actionName in Enum.GetNames(typeof(hypervisorAction)))
                {
                    Console.WriteLine(" * '" + actionName + "'");
                }
            }
        }
Exemplo n.º 2
0
        private static void _Main(hyptoolargs args)
        {
            using (hypervisor_iLo_HTTP hyp = new hypervisor_iLo_HTTP(args.hypIP, args.hypUsername, args.hypPassword))
            {
                hyp.retries = args.retries;
                hyp.connect();
                switch (args.action)
                {
                case hypervisorAction.powerOn:
                    hyp.powerOn();
                    break;

                case hypervisorAction.powerOff:
                    hyp.powerOff();
                    break;

                case hypervisorAction.getPowerStatus:
                    if (hyp.getPowerStatus())
                    {
                        Console.WriteLine(args.numeric ? "1" : "ON");
                    }
                    else
                    {
                        Console.WriteLine(args.numeric ? "0" : "OFF");
                    }
                    break;

                case hypervisorAction.getPowerUse:
                    Console.WriteLine(hyp.getCurrentPowerUseW());
                    break;

                case hypervisorAction.updateZabbix:
                    doZabbix(args.zabbixServer.Trim(), args.zabbixHostname.Trim(), hyp);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }