Ejemplo n.º 1
0
        public IWebConsoleInfo[] ListWebConsole()
        {
            _logger.LogInformation("List WebConsoles");
            List <IWebConsoleInfo> result = new List <IWebConsoleInfo>();

            try {
                var webConsoleServices = _client.ListNamespacedService(
                    _namespace,
                    labelSelector: $"{WEB_CONSOLE_LABEL_KEY}={WEB_CONSOLE_LABEL_KEY}");

                foreach (var webConsoleService in webConsoleServices.Items)
                {
                    var webConsoleInfo = new K8sWebConsoleInfo {
                        Id = webConsoleService.Metadata.Name
                    };

                    webConsoleInfo.CreationState = RunspaceCreationState.Ready;
                    result.Add(webConsoleInfo);
                }
            } catch (Exception exc) {
                _logger.LogError(exc.ToString());
                throw new RunspaceProviderException(
                          Resources.K8sRunspaceProvider_ListWebConsole_K8sWebConsoleListFail,
                          exc);
            }

            return(result.ToArray());
        }
Ejemplo n.º 2
0
        public IWebConsoleInfo CreateWebConsole(string vc, string token, bool allLinked)
        {
            _logger.LogInformation("Create Runspace");
            K8sWebConsoleInfo result = null;

            try {
                _logger.LogDebug("GenerateWebconsoleId");
                var webConsoleId = GenerateWebconsoleId();
                _logger.LogDebug($"RunspaceId: {webConsoleId}");
                var runspacePod = CreateK8sApp(webConsoleId, vc, token, allLinked);

                result = new K8sWebConsoleInfo {
                    Id            = webConsoleId,
                    CreationState = RunspaceCreationState.Ready
                };
                _logger.LogDebug($"RunspaceInfo.Id: {result.Id}");
            } catch (Exception exc) {
                _logger.LogError(exc.ToString());

                var error = new RunspaceProviderException(
                    Resources.K8sRunspaceProvider_Create_K8sRunspaceCreateFail,
                    exc);

                result = new K8sWebConsoleInfo {
                    Id            = result?.Id,
                    CreationState = RunspaceCreationState.Error,
                    CreationError = error
                };
            }

            return(result);
        }