public Dictionary <string, string> Get(string domain, string state)
        {
            UnixCmdHelper _cmd = new UnixCmdHelper();

            Console.WriteLine(state);

            string consoleresponse = "";

            try {
                switch (state.Trim())
                {
                case "Start":
                    consoleresponse = _cmd.ExecuteShellCMD("/usr/bin/virsh", "start " + domain);
                    break;

                case "Shutdown":
                    consoleresponse = _cmd.ExecuteShellCMD("/usr/bin/virsh", "shutdown " + domain);
                    break;

                case "Suspend":
                    consoleresponse = _cmd.ExecuteShellCMD("/usr/bin/virsh", "suspend --domain " + domain);
                    break;

                case "ForceReset":
                    consoleresponse = _cmd.ExecuteShellCMD("/usr/bin/virsh", "reset " + domain);
                    break;

                case "ForceShutdown":
                    consoleresponse = _cmd.ExecuteShellCMD("/usr/bin/virsh", "destroy " + domain);
                    break;

                default:
                    throw new Exception("Error: Action Not Supported.");
                }

                Dictionary <string, string> restresponse = new Dictionary <string, string> ();
                restresponse.Add("Result", "Success");
                restresponse.Add("Message", consoleresponse);

                return(restresponse);
            } catch (Exception error) {
                Dictionary <string, string> restresponse = new Dictionary <string, string> ();
                restresponse.Add("Result", "Error");
                restresponse.Add("Message", error.Message);

                return(restresponse);
            }
        }
        public List <DomainModel> Get()
        {
            UnixCmdHelper _cmd = new UnixCmdHelper();

            var response = _cmd.ExecuteShellCMD("/usr/bin/virsh", $"list --all");

            return(new Domain().Parse(response));
        }
        public SystemInfoModel Get()
        {
            UnixCmdHelper _cmd = new UnixCmdHelper();

            var response = _cmd.ExecuteShellCMD("/usr/bin/virsh", $"sysinfo");

            Console.WriteLine(response);

            return(new SystemInfo().Parse(response));
        }
        public Dictionary <string, string> Get(EditResourceModel UpdatedResources)
        {
            UnixCmdHelper _cmd            = new UnixCmdHelper();
            string        consoleresponse = "";
            Dictionary <string, string> responseMessage = new Dictionary <string, string> ();

            try {
                foreach (var rec in UpdatedResources.updatedResourceSettings)
                {
                    switch (rec.Key)
                    {
                    case "CPUs":
                        consoleresponse = _cmd.ExecuteShellCMD("/usr/bin/virsh", "setvcpus " + UpdatedResources.modelID + " " + rec.Value + " --current");
                        break;

                    case "MaxMemory":
                        consoleresponse = _cmd.ExecuteShellCMD("/usr/bin/virsh", "setmem " + UpdatedResources.modelID + " " + rec.Value + " --current");
                        break;

                    case "MinMemory":
                        consoleresponse = _cmd.ExecuteShellCMD("/usr/bin/virsh", "setmemmax " + UpdatedResources.modelID + " " + rec.Value + " --current");
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                    if (!string.IsNullOrEmpty(consoleresponse.Trim()))
                    {
                        throw new Exception(consoleresponse);
                    }
                }
                responseMessage.Add("Result", "Success");
                responseMessage.Add("Message", "Resources Successfully Updated");

                return(responseMessage);
            } catch (Exception error) {
                responseMessage.Clear();
                responseMessage.Add("Result", "Error");
                responseMessage.Add("Message", error.Message);
                return(responseMessage);
            }
        }
        public Dictionary <string, string> Get(string Name)
        {
            try
            {
                UnixCmdHelper _cmd = new UnixCmdHelper();

                var response = _cmd.ExecuteShellCMD("/usr/bin/virsh", $"dominfo " + Name);

                return(new DomInfo().Parse(response));
            }
            catch (Exception)
            {
                Dictionary <string, string> errorval = new Dictionary <string, string>();
                errorval.Add("error", "Error Retrieving VM Details");
                return(errorval);
            }
        }