Beispiel #1
0
        private static void NovaShowServer(EcsClient client)
        {
            var req = new NovaShowServerRequest
            {
                ServerId            = "2bae7f47-d49f-4d9d-b415-f53e6835bb4b",
                OpenStackAPIVersion = "compute 2.26"
            };

            try
            {
                var resp           = client.NovaShowServer(req);
                var respStatusCode = resp.HttpStatusCode;
                var respServer     = resp.Server;
                Console.WriteLine(respStatusCode);
                Console.WriteLine(respServer.Id);
            }
            catch (RequestTimeoutException requestTimeoutException)
            {
                Console.WriteLine(requestTimeoutException.ErrorMessage);
            }
            catch (ServiceResponseException clientRequestException)
            {
                Console.WriteLine(clientRequestException.HttpStatusCode);
                Console.WriteLine(clientRequestException.ErrorCode);
                Console.WriteLine(clientRequestException.ErrorMsg);
            }
            catch (ConnectionException connectionException)
            {
                Console.WriteLine(connectionException.ErrorMessage);
            }
        }
        /// <summary>
        /// 查询云服务器详情
        /// </summary>
        public NovaShowServerResponse NovaShowServer(NovaShowServerRequest novaShowServerRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("server_id", novaShowServerRequest.ServerId.ToString());
            string      urlPath  = HttpUtils.AddUrlPath("/v2.1/{project_id}/servers/{server_id}", urlParam);
            SdkRequest  request  = HttpUtils.InitSdkRequest(urlPath, novaShowServerRequest);
            SdkResponse response = DoHttpRequest("GET", request);

            return(JsonUtils.DeSerialize <NovaShowServerResponse>(response));
        }
Beispiel #3
0
        /// <summary>
        /// 查询云服务器详情
        /// </summary>
        public async Task <NovaShowServerResponse> NovaShowServerAsync(NovaShowServerRequest novaShowServerRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("server_id", novaShowServerRequest.ServerId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v2.1/{project_id}/servers/{server_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json", novaShowServerRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("GET", request);

            return(JsonUtils.DeSerialize <NovaShowServerResponse>(response));
        }