openstack-nova: binding missing fields to CreateVolume requests

This commit is contained in:
Adam Lowe 2012-08-08 09:37:30 +01:00
parent 0e7c963b05
commit 082ec6f008
1 changed files with 12 additions and 6 deletions

View File

@ -46,12 +46,12 @@ public class CreateVolumeOptions implements MapBinder {
@Inject @Inject
private BindToJsonPayload jsonBinder; private BindToJsonPayload jsonBinder;
private String name; protected String name;
private String description; protected String description;
private String volumeType; protected String volumeType;
private String availabilityZone; protected String availabilityZone;
private String snapshotId; protected String snapshotId;
private Map<String, String> metadata = ImmutableMap.of(); protected Map<String, String> metadata = ImmutableMap.of();
@Override @Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) { public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
@ -61,6 +61,12 @@ public class CreateVolumeOptions implements MapBinder {
image.put("display_name", name); image.put("display_name", name);
if (description != null) if (description != null)
image.put("display_description", description); image.put("display_description", description);
if (volumeType != null)
image.put("volume_type", volumeType);
if (availabilityZone != null)
image.put("availability_zone", availabilityZone);
if (snapshotId != null)
image.put("snapshot_id", snapshotId);
if (!metadata.isEmpty()) if (!metadata.isEmpty())
image.put("metadata", metadata); image.put("metadata", metadata);
return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image)); return jsonBinder.bindToRequest(request, ImmutableMap.of("volume", image));