Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// <see cref="ContainerDetailsOutputModel.TenantId"/>をセットする
        /// </summary>
        private ContainerDetailsOutputModel CreateContainerDetailsOutputModel(ContainerDetailsInfo info)
        {
            var model = new ContainerDetailsOutputModel(info)
            {
                CreatedBy = userRepository.GetUserName(info.CreatedBy)
            };
            var tenant = tenantRepository.GetFromTenantName(info.TenantName);

            if (tenant == null)
            {
                if (info.TenantName == containerManageOptions.KqiAdminNamespace)
                {
                    // KqiAdminNamespace の場合、KQI管理者用とする。
                    model.TenantName = containerManageOptions.KqiAdminNamespace;
                    model.TenantId   = 0;
                }
                else
                {
                    //知らないテナントのコンテナが起動している
                    LogError($"There is a container for the unknown tenant {model.TenantName}");
                    model.TenantName = "Unknown:" + model.TenantName;
                    model.TenantId   = -1;
                }
            }
            else
            {
                model.TenantId   = tenant.Id;
                model.TenantName = tenant.DisplayName;
            }
            return(model);
        }