public async Task <IActionResult> GetResourceByContainerName([FromRoute] long tenantId, [FromRoute] string name) { //入力チェック if (string.IsNullOrWhiteSpace(name)) { return(JsonBadRequest("Name is required.")); } //データの存在チェック var tenant = tenantRepository.Get(tenantId); if (tenant == null) { return(JsonNotFound($"Tenant ID {tenantId} is not found.")); } var info = await clusterManagementLogic.GetContainerDetailsInfoAsync(name, tenant.Name, true); if (info.Status == ContainerStatus.None) { return(JsonNotFound($"Container named {name} is not found.")); } var result = new ContainerDetailsOutputModel(info) { TenantId = tenant.Id, TenantName = tenant.Name, DisplayName = tenant.DisplayName, ContainerType = CheckContainerType(name, true).Item1, //コンテナの種別を確認 CreatedBy = userRepository.GetUserName(info.CreatedBy) }; return(JsonOK(result)); }
/// <summary> /// 学習履歴コンテナを削除し、ステータスを変更する。 /// </summary> /// <param name="trainingHistory">対象学習履歴</param> /// <param name="status">変更後のステータス</param> /// <param name="force">他テナントに対する変更を許可するか</param> public async Task ExitAsync(TrainingHistory trainingHistory, ContainerStatus status, bool force) { //コンテナの生存確認 if (trainingHistory.GetStatus().Exist()) { var info = await clusterManagementLogic.GetContainerDetailsInfoAsync(trainingHistory.Key, CurrentUserInfo.SelectedTenant.Name, force); if (info.Status.Exist()) { //再確認してもまだ存在していたら、コンテナ削除 await clusterManagementLogic.DeleteContainerAsync( ContainerType.Training, trainingHistory.Key, CurrentUserInfo.SelectedTenant.Name, force); } await trainingHistoryRepository.UpdateStatusAsync(trainingHistory.Id, status, info.CreatedAt, DateTime.Now, force); } else { await trainingHistoryRepository.UpdateStatusAsync(trainingHistory.Id, status, force); } //実コンテナ削除の結果は確認せず、DBの更新を確定する(コンテナがいないなら、そのまま消しても問題ない想定) unitOfWork.Commit(); }
public async Task <IActionResult> GetDetail(long?id) { if (id == null) { return(JsonBadRequest("Training ID is required.")); } var history = await trainingHistoryRepository.GetIncludeAllAsync(id.Value); if (history == null) { return(JsonNotFound($"Training ID {id.Value} is not found.")); } var model = new DetailsOutputModel(history); model.Tags = tagLogic.GetAllTrainingHistoryTag(history.Id).Select(t => t.Name); var status = history.GetStatus(); model.StatusType = status.StatusType; if (status.Exist()) { //コンテナがまだ存在している場合、情報を更新する var details = await clusterManagementLogic.GetContainerDetailsInfoAsync(history.Key, CurrentUserInfo.SelectedTenant.Name, false); model.Status = details.Status.Name; model.StatusType = details.Status.StatusType; //ステータスを更新 history.Status = details.Status.Key; unitOfWork.Commit(); model.ConditionNote = details.ConditionNote; if (details.Status.IsRunning()) { // 開放ポート未指定時には行わない if (model.Ports != null && model.Ports.Count > 0) { var endpointInfo = await clusterManagementLogic.GetContainerEndpointInfoAsync(history.Key, CurrentUserInfo.SelectedTenant.Name, false); foreach (var endpoint in endpointInfo.EndPoints ?? new List <EndPointInfo>()) { //ノードポート番号を返す model.NodePorts.Add(new KeyValuePair <string, string>(endpoint.Key, endpoint.Port.ToString())); } } } } //Gitの表示用URLを作る model.GitModel.Url = gitLogic.GetTreeUiUrl(history.ModelGitId, history.ModelRepository, history.ModelRepositoryOwner, history.ModelCommitId); return(JsonOK(model)); }
public async Task <IActionResult> GetDetail(long?id) { if (id == null) { return(JsonBadRequest("Training ID is required.")); } var history = await trainingHistoryRepository.GetIncludeAllAsync(id.Value); if (history == null) { return(JsonNotFound($"Training ID {id.Value} is not found.")); } var model = new DetailsOutputModel(history); var status = history.GetStatus(); model.StatusType = status.StatusType; if (status.Exist()) { //コンテナがまだ存在している場合、情報を更新する var details = await clusterManagementLogic.GetContainerDetailsInfoAsync(history.Key, CurrentUserInfo.SelectedTenant.Name, false); model.Status = details.Status.Name; model.StatusType = details.Status.StatusType; //ステータスを更新 history.Status = details.Status.Key; unitOfWork.Commit(); model.ConditionNote = details.ConditionNote; } //Gitの表示用URLを作る model.GitModel.Url = gitLogic.GetTreeUiUrl(history.ModelGitId, history.ModelRepository, history.ModelRepositoryOwner, history.ModelCommitId); return(JsonOK(model)); }