The Volume object passed to create_volume() has several attributes that are useful:
- size is the expected size of the new volume;
- id is the UUID of the new volume. It is already set on the call to create_volume();
- name is volume name as assigned by Cinder;
So the job of create_volume() is:
- Do whatever is needed on the backend to obtain an NFS share that can host a file of the size specified in the volume 'size' attribute.
- Create actual file of specified size. The filename should be exactly the value of the volume 'name' property and it should be created on the NFS share that you found or created.
- Set file permissions to either 666 or 660 depending on security settings provided in options.
- Return a dictionary of volume attributes that you would like to set. It should at least include 'provider_location' which is a string in 'host:/path/to/share' format (which doesn't include the actual file name!). This is used by other components (mostly Nova) to mount the file and use it as a backing store for the volume. It is very important that the share should be mountable from both the Cinder node (which needs to mount for some operations) and the Nova node (which always mounts it when the volume is attached to a VM instance).
- You can also set 'provider_id' attribute in the return dictionary which is a string that only has a meaning to the driver. In my case, for example, I use the UUID of the newly created share, It can be used later to associate the volume with something that has meaning on your backend.