Esempio n. 1
0
        internal string CreateVolume()
        {
            var session = new Client(serviceUri, apiKey, secretKey);
            string volId = string.Empty;

            try
            {
                ListDiskOfferingsRequest request = new ListDiskOfferingsRequest();
                ListDiskOfferingsResponse doffers = session.ListDiskOfferings(request);

                DiskOffering customOffering = null;
                foreach (var offer in doffers.DiskOffering)
                {
                    if (offer.IsCustomized)
                    {
                        customOffering = offer;
                        break;
                    }
                }
                System.Diagnostics.Debug.Assert(customOffering != null, "There should be at least one custom disk offering defined");
                CreateVolumeRequest req = new CreateVolumeRequest()
                {
                    DiskOfferingId = customOffering.Id,
                    Size = 16,
                    Name = "testVolume",
                    ZoneId = zoneId
                };
                volId = session.CreateVolume(req);
                logWriter("Created volume id is " + volId);
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.Fail("Not supposed to throw during create volume");
                this.logWriter(ex.Message);
            }
            return volId;
        }