Skip to content

Commit

Permalink
Merge pull request woorea#66 from ow2-sirocco/volume-attach
Browse files Browse the repository at this point in the history
Add volume attachment list and show commands, fix detach command
  • Loading branch information
woorea committed Jul 21, 2013
2 parents d44a23c + e56dc40 commit 063a17e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.woorea.openstack.nova.model.ServerForCreate;
import com.woorea.openstack.nova.model.Servers;
import com.woorea.openstack.nova.model.VolumeAttachment;
import com.woorea.openstack.nova.model.VolumeAttachments;

public class ServersResource {

Expand Down Expand Up @@ -429,12 +430,24 @@ public AttachVolume(String serverId, final VolumeAttachment volumeAttachment) {

public class DetachVolume extends OpenStackRequest<Void> {

private String serverId;
public DetachVolume(String serverId, String volumeId) {
super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments/").append(volumeId), null, Void.class);
}

}

public class ListVolumeAttachments extends OpenStackRequest<VolumeAttachments> {

private String volumeId;
public ListVolumeAttachments(String serverId) {
super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments"), null, VolumeAttachments.class);
}

}

public class ShowVolumeAttachment extends OpenStackRequest<VolumeAttachment> {

public DetachVolume(String serverId, String volumeId) {
super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments").append(volumeId), null, Void.class);
public ShowVolumeAttachment(String serverId, String volumeAttachmentId) {
super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments/").append(volumeAttachmentId), null, VolumeAttachment.class);
}

}
Expand All @@ -450,5 +463,13 @@ public DetachVolume detachVolume(String serverId, String volumeId) {
return new DetachVolume(serverId, volumeId);
}

public ListVolumeAttachments listVolumeAttachments(String serverId) {
return new ListVolumeAttachments(serverId);
}

public ShowVolumeAttachment showVolumeAttachment(String serverId, String volumeAttachmentId) {
return new ShowVolumeAttachment(serverId, volumeAttachmentId);
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.woorea.openstack.nova.model;

import java.io.Serializable;
import java.util.Iterator;
import java.util.List;

import org.codehaus.jackson.annotate.JsonProperty;

public class VolumeAttachments implements Iterable<VolumeAttachment>, Serializable {

@JsonProperty("volumeAttachments")
private List<VolumeAttachment> list;

/**
* @return the list
*/
public List<VolumeAttachment> getList() {
return list;
}

@Override
public Iterator<VolumeAttachment> iterator() {
return list.iterator();
}

/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "VolumeAttachments [list=" + list + "]";
}

}

0 comments on commit 063a17e

Please sign in to comment.