Exemplo n.º 1
0
        public string DoControlWithDirectory(string action, dynamic options)
        {
            // TODO: vladi: complete implementation of this method

            StringBuilder output             = new StringBuilder();
            string        cartridgeDirectory = options["cartridgeDir"];

            ProcessCartridges(cartridgeDirectory, delegate(string cartridgeDir)
            {
                string control = Path.Combine(cartridgeDir, "bin", "control.ps1");
                string cmd     = string.Format("{0} -ExecutionPolicy Bypass -InputFormat None -noninteractive -file {1} -command {2}", ProcessExtensions.Get64BitPowershell(), control, action);

                ProcessResult processResult = container.RunProcessInContainerContext(container.ContainerDir, cmd);

                output.AppendLine(processResult.StdOut);
                output.AppendLine(processResult.StdErr);
            });

            return(output.ToString());
        }
Exemplo n.º 2
0
        public string DoControlWithDirectory(string action, dynamic options)
        {
            // TODO: vladi: complete implementation of this method

            StringBuilder output             = new StringBuilder();
            string        cartridgeDirectory = options["cartridgeDir"];

            ProcessCartridges(cartridgeDirectory, delegate(string cartridgeDir)
            {
                bool isExe     = File.Exists(Path.Combine(cartridgeDir, "bin", "control.exe"));
                string control = string.Empty;
                string cmd     = string.Empty;

                if (isExe)
                {
                    control = Path.Combine(cartridgeDir, "bin", "control.exe");
                    cmd     = string.Format("{0} {1}", control, action);
                }
                else
                {
                    control = Path.Combine(cartridgeDir, "bin", "control.ps1");
                    cmd     = string.Format("{0} -ExecutionPolicy Bypass -InputFormat None -noninteractive -file {1} -command {2}", ProcessExtensions.Get64BitPowershell(), control, action);
                }
                ProcessResult processResult = container.RunProcessInContainerContext(container.ContainerDir, cmd);

                output.AppendLine(processResult.StdOut);
                output.AppendLine(processResult.StdErr);

                if (processResult.ExitCode != 0)
                {
                    throw new Exception(string.Format("CLIENT_ERROR: Failed to execute: 'control {0}' for {1}", action, container.ContainerDir));
                }
            });

            return(output.ToString());
        }