Welcome, Guest
Username Password: Remember me

API call to create a data disk with a user-defined size?
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: API call to create a data disk with a user-defined size?

API call to create a data disk with a user-defined size? 3 months, 2 weeks ago #8874

'createVolume' allows you to create a size from a disk offering id. However, it also has a 'size' input parameter, so it might seem that in principle you're free to create a disk of a different size from whatever is defined in zone-wide disk offerings.
I also seem to remember there was a special 'diskOfferingId' that meant "user defined" that allowed to use the 'size' parameter in exactly the way I just described ... But can't remember its value, the obvious options '0' and '-1' do not work and I cant find anything related on the documentation.
Am I simply misremembering the whole thing? Is there a way to achieve what I want with 'createVolume', or do I need to use a different call? I could create an ad-hoc disk offering for any requested size and then a volume off that, but that's probably not how the API is intended to be used.
Any help greatly appreciated. Thanks in advance.

Re: API call to create a data disk with a user-defined size? 3 months, 2 weeks ago #8879

From what I understand, you want to create a volume with an arbitrary size. To accomplish this, first create a disk offering (createDiskOffering) with customized=true.
download.cloud.com/releases/2.2.0/api_2....ateDiskOffering.html

Then use createVolume using that offering with size=N, where the volume will be N GB.
download.cloud.com/releases/2.2.0/api_2....in/createVolume.html
The following user(s) said Thank You: ke4qqq

Re: API call to create a data disk with a user-defined size? 3 months, 1 week ago #8940

  • chirauki
  • OFFLINE
  • Expert Boarder
  • Posts: 141
  • Karma: 10
Hi,

kirkkosinski is right. You need to create a disk offering which allows custom size (it can be done from the UI since only need to be done once), and then, you have to call createVolume whit the disk offering0s id you just created and the desired size.

thx.

Re: API call to create a data disk with a user-defined size? 3 months, 1 week ago #8963

Yeah, that worked, thanks.
However, looking up the disk offering by name doesn't seem to work, I have to list all the offerings and search the one where 'iscustomized' is true in order to get its ID to then be able to create the volume. Is that by design or should the look up by name work?
That's a minor detail, tho, kirkkosinki's suggestion indeed works so the main point of the thread is fulfilled.

Re: API call to create a data disk with a user-defined size? 3 months, 1 week ago #8964

listDiskOfferings&name=blah works for me. Does your offering have any spaces or special characters? If so make sure to url encode it.

[root@cs1 ~]# curl 'http://localhost:8096/?command=listDiskOfferings&name=Custom' 2>/dev/null | xmllint --format - -o -
<?xml version="1.0" encoding="ISO-8859-1"?>
<listdiskofferingsresponse cloud-stack-version="2.2.13.20111117130644">
  <count>1</count>
  <diskoffering>
    <id>16</id>
    <name>Custom</name>
    <displaytext>Custom</displaytext>
    <disksize>0</disksize>
    <created>2012-02-07T11:46:04-0800</created>
    <iscustomized>true</iscustomized>
  </diskoffering>
</listdiskofferingsresponse>

Re: API call to create a data disk with a user-defined size? 3 months, 1 week ago #8965

Ah, I see ... It's also up there in the docs: you have to use the admin port. Through the unprivileged port (i.e., the User API) there is indeed nothing better than listing/filtering. Thanks again!
  • Page:
  • 1
Time to create page: 0.51 seconds

Resources

Open Source Resources Discuss Site Info

The CloudStack™project is in the process of moving to the Apache Foundation as a podling in the Apache Incubator. Going forward CloudStack will be developed and governed in the Apache way. CloudStack is available under the Apache License 2.0