Пример #1
0
        //file create image
        private static void CreateImageByFile(ImsClient imsV2Client)
        {
            CreateImageRequest createImsInfoRequest = new CreateImageRequest()
            {
                Body = new CreateImageRequestBody()
                {
                    Name      = "FileCreateImage",
                    ImageUrl  = "obs-494b:test.qcow2",
                    Type      = CreateImageRequestBody.TypeEnum.ECS,
                    OsVersion = "CentOS 7.6 64bit",
                    MinDisk   = 40
                }
            };

            try
            {
                var createIms = imsV2Client.CreateImage(createImsInfoRequest);
                Console.WriteLine(createIms.JobId);
            }
            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);
            }
        }
Пример #2
0
        //create image by instance
        private static void CreateImageByInstance(ImsClient imsV2Client)
        {
            CreateImageRequest createImsInfoRequest = new CreateImageRequest()
            {
                Body = new CreateImageRequestBody()
                {
                    Name       = "instanceCreateImage",
                    InstanceId = "1681268e-d52c-4116-b114-1fb090904368"
                }
            };

            try
            {
                var createIms = imsV2Client.CreateImage(createImsInfoRequest);
                Console.WriteLine(createIms.JobId);
            }
            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);
            }
        }