// Apply button on properties tab
        private void ApplyButton_Click(object sender, EventArgs e)
        {
            if (this.configChanged && changedConfigs.Count > 0)
            {
                SetUnsetConfig r = TaskHandlers.SetConfig(changedConfigs);
                if (r.Error == String.Empty)
                {
                    DisplayMessageBox.Info("Properties configured: " + String.Join(",", r.Properties), "CodeReady Containers - Settings Applied");
                }
                else
                {
                    DisplayMessageBox.Error(r.Error);
                }
            }

            if (this.configsNeedingUnset.Count > 0)
            {
                SetUnsetConfig r = TaskHandlers.UnsetConfig(configsNeedingUnset);
                if (r.Error == String.Empty)
                {
                    DisplayMessageBox.Info("Properties unset: " + String.Join(",", r.Properties), "CodeReady Containers - Settings Applied");
                }
                else
                {
                    DisplayMessageBox.Error(r.Error);
                }
            }

            // Load the configs again and reset the change trackers
            getConfigurationAndResetChanged();
        }
Exemple #2
0
 private void GetVersion(object sender, EventArgs e)
 {
     version = TaskHandlers.Version();
     if (version.Success)
     {
         CrcVersionLabel.Text = String.Format("{0}+{1}", version.CrcVersion, version.CommitSha);
         OcpVersion.Text      = version.OpenshiftVersion;
     }
     else
     {
         DisplayMessageBox.Warn("Unable to fetch version information from daemon");
     }
 }
Exemple #3
0
        async private void StopMenu_Click(object sender, EventArgs e)
        {
            ShowNotification(@"Stopping Cluster", ToolTipIcon.Info);
            var stopResult = await Task.Run(() => TaskHandlers.Stop());

            if (stopResult != null)
            {
                if (stopResult.Success)
                {
                    DisplayMessageBox.Info(@"CodeReady Containers Cluster has stopped", @"Cluster Stopped");
                }
                else
                {
                    DisplayMessageBox.Warn(@"Cluster did not stop. Please check detailed status");
                }
            }
        }
Exemple #4
0
        async private void DeleteMenu_Click(object sender, EventArgs e)
        {
            ShowNotification(@"Deleting Cluster", ToolTipIcon.Warning);
            var deleteResult = await Task.Run(() => TaskHandlers.Delete());

            if (deleteResult != null)
            {
                if (deleteResult.Success)
                {
                    DisplayMessageBox.Info(@"CodeReady Containers Cluster has been deleted", @"Cluster Deleted");
                }
                else
                {
                    DisplayMessageBox.Warn(@"Could not delete the cluster");
                }
            }
        }
Exemple #5
0
        public static long SizeInBytes(string path)
        {
            long size = 0;

            var dirInfo = new DirectoryInfo(path);

            try
            {
                foreach (FileInfo fi in dirInfo.GetFiles("*", SearchOption.AllDirectories))
                {
                    size += fi.Length;
                }
            }
            catch (Exception e)
            {
                DisplayMessageBox.Error(string.Format("Unexpected Error, did you run 'crc setup'? Error: {0}", e.Message));
            }
            return(size);
        }
Exemple #6
0
        async private void StartMenu_Click(object sender, EventArgs e)
        {
            // Check using get-config if pullSecret is configured
            var configs = TaskHandlers.ConfigView();

            if (configs.Configs.PullSecretFile == "")
            {
                var pullSecretForm = new PullSecretPickerForm();
                var pullSecretPath = pullSecretForm.ShowFilePicker();
                if (pullSecretPath == "")
                {
                    DisplayMessageBox.Warn("No Pull Secret was provided, Cannot start cluster without pull secret.");
                    return;
                }
                Dictionary <String, dynamic> pullSecretConfig = new Dictionary <String, dynamic>
                {
                    ["pull-secret-file"] = pullSecretPath
                };
                TaskHandlers.SetConfig(pullSecretConfig);
            }

            ShowNotification(@"Starting Cluster", ToolTipIcon.Info);
            var startResult = await Task.Run(() => TaskHandlers.Start());

            if (startResult == null)
            {
                return;
            }
            if (startResult.KubeletStarted)
            {
                DisplayMessageBox.Info(@"CodeReady Containers Cluster has started", @"Cluster Started");
            }
            else
            {
                DisplayMessageBox.Warn(@"Cluster did not start. Please check detailed status");
            }
        }
Exemple #7
0
        private void StartDaemon()
        {
            var process = new Process();

            process.StartInfo.CreateNoWindow        = true;
            process.StartInfo.UseShellExecute       = false;
            process.StartInfo.RedirectStandardInput = true;
            process.StartInfo.FileName = string.Format("{0}\\{1}\\crc.exe",
                                                       Environment.GetEnvironmentVariable("ProgramW6432"), @"CodeReady Containers");
#if DEBUG
            process.StartInfo.FileName = string.Format("{0}\\bin\\crc.exe", Environment.GetEnvironmentVariable("GOPATH"));
#endif
            process.StartInfo.Arguments        = @"daemon --watchdog";
            process.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
            Console.WriteLine(process.StartInfo.FileName);
            try
            {
                process.Start();
                System.IO.StreamWriter daemonStdinWriter = process.StandardInput;
            }
            catch (Exception e)
            {
                DisplayMessageBox.Error(string.Format("Cannot start the daemon, Check the logs and restart the application, Error: {0}", e.Message));
                QuitApp();
            }
            process.WaitForExit();
            if (process.ExitCode == 2)
            {
                DisplayMessageBox.Error("Setup incomplete, Open a terminal, run 'crc setup', and start again this application.");
            }
            else
            {
                DisplayMessageBox.Error("Daemon crashed, check the logs and restart the application");
            }
            QuitApp();
        }