예제 #1
0
        public IRunspaceInfo[] List()
        {
            List <IRunspaceInfo> result = new List <IRunspaceInfo>();

            try {
                var runningRunspaceContainerList = _containerApi.ContainerList();
                foreach (var runspaceContainer in runningRunspaceContainerList)
                {
                    if (runspaceContainer != null &&
                        runspaceContainer.Image == _runspaceContainerCreateSpec.ImageName &&
                        runspaceContainer.State.ToLower() == "running")
                    {
                        var containerInspectResponse = _containerApi.ContainerInspect(runspaceContainer.Id);

                        result.Add(DockerRunspaceInfo.FromContainerInspectResponse(
                                       containerInspectResponse,
                                       _runspaceContainerCreateSpec.NetworkName));
                    }
                }
            } catch (ApiException dockerApiException) {
                throw new RunspaceProviderException(
                          Resources.Resources.DockerRunspaceProvider_Get_ContainerDockerAPIFail,
                          dockerApiException);
            }

            // Populate Result from ContainerInspectResponse
            return(result.ToArray());
        }
예제 #2
0
        public IRunspaceInfo Get(string id)
        {
            ContainerInspectResponse containerInspectResponse;

            try {
                // Get Container Details
                containerInspectResponse = _containerApi.ContainerInspect(id);
            } catch (ApiException dockerApiException) {
                throw new RunspaceProviderException(
                          Resources.Resources.DockerRunspaceProvider_Get_ContainerDockerAPIFail,
                          dockerApiException);
            }

            // Populate Result from ContainerInspectResponse
            return(containerInspectResponse.State.Status == ContainerInspectResponseState.StatusEnum.Running ?
                   DockerRunspaceInfo.FromContainerInspectResponse(
                       containerInspectResponse,
                       _runspaceContainerCreateSpec.NetworkName) :
                   null);
        }