Skip to content

Commit e444b9f

Browse files
committed
New commands for blockVolume
extend reset_status
1 parent f52d2ed commit e444b9f

File tree

4 files changed

+117
-19
lines changed

4 files changed

+117
-19
lines changed

core/src/main/java/org/openstack4j/api/storage/BlockVolumeService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,24 @@ public interface BlockVolumeService extends RestService {
6363
*/
6464
ActionResponse forceDelete(String volumeId);
6565

66+
/**
67+
* Resets the specified volume status.
68+
*
69+
* @param volumeId the volume id
70+
* @param status new volume status
71+
* @return the action response
72+
*/
73+
ActionResponse resetState(String volumeId, Volume.Status status);
74+
75+
/**
76+
* Extends the specified volume size.
77+
*
78+
* @param volumeId the volume id
79+
* @param newSize new volume size
80+
* @return the action response
81+
*/
82+
ActionResponse extend(String volumeId, Integer newSize);
83+
6684
/**
6785
* Creates a new Block Storage Volume
6886
* @param volume the volume for create
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.openstack4j.openstack.storage.block.domain;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.annotation.JsonRootName;
5+
import org.openstack4j.model.ModelEntity;
6+
import org.openstack4j.model.storage.block.Volume;
7+
8+
@JsonRootName("os-extend")
9+
public class ExtendAction implements ModelEntity {
10+
11+
private static final long serialVersionUID = 1L;
12+
13+
@JsonProperty("new_size")
14+
private final Integer newSize;
15+
16+
public ExtendAction(Integer newSize) {
17+
this.newSize = newSize;
18+
}
19+
20+
public static ExtendAction create(Integer newSize) {
21+
return new ExtendAction(newSize);
22+
}
23+
24+
public Integer getNewSize() {
25+
return newSize;
26+
}
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.openstack4j.openstack.storage.block.domain;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.annotation.JsonRootName;
5+
import org.openstack4j.model.ModelEntity;
6+
import org.openstack4j.model.storage.block.Volume;
7+
8+
@JsonRootName("os-reset_status")
9+
public class ResetStatusAction implements ModelEntity {
10+
11+
private static final long serialVersionUID = 1L;
12+
13+
@JsonProperty("status")
14+
private final Volume.Status status;
15+
16+
public ResetStatusAction(Volume.Status status) {
17+
this.status = status;
18+
}
19+
20+
public static ResetStatusAction create(Volume.Status status) {
21+
return new ResetStatusAction(status);
22+
}
23+
24+
public Volume.Status getStatus() {
25+
return status;
26+
}
27+
}

core/src/main/java/org/openstack4j/openstack/storage/block/internal/BlockVolumeServiceImpl.java

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import org.openstack4j.openstack.storage.block.domain.CinderVolume.Volumes;
2020
import org.openstack4j.openstack.storage.block.domain.CinderVolumeMigration;
2121
import org.openstack4j.openstack.storage.block.domain.CinderVolumeType.VolumeTypes;
22+
import org.openstack4j.openstack.storage.block.domain.ExtendAction;
2223
import org.openstack4j.openstack.storage.block.domain.ForceDeleteAction;
2324
import org.openstack4j.openstack.storage.block.domain.CinderVolumeUploadImage;
25+
import org.openstack4j.openstack.storage.block.domain.ResetStatusAction;
2426

2527
/**
2628
* Manages Volumes and Volume Type based operations against Block Storage (Cinder)
@@ -72,25 +74,49 @@ public ActionResponse delete(String volumeId) {
7274
return deleteWithResponse(uri("/volumes/%s", volumeId)).execute();
7375
}
7476

75-
/**
76-
* {@inheritDoc}
77-
*/
78-
@Override
79-
public ActionResponse forceDelete(String volumeId) {
80-
checkNotNull(volumeId);
81-
return post(ActionResponse.class, uri("/volumes/%s/action", volumeId))
82-
.entity(new ForceDeleteAction())
83-
.execute();
84-
}
85-
86-
/**
87-
* {@inheritDoc}
88-
*/
89-
@Override
90-
public Volume create(Volume volume) {
91-
checkNotNull(volume);
92-
return post(CinderVolume.class, uri("/volumes")).entity(volume).execute();
93-
}
77+
/**
78+
* {@inheritDoc}
79+
*/
80+
@Override
81+
public ActionResponse forceDelete(String volumeId) {
82+
checkNotNull(volumeId);
83+
return post(ActionResponse.class, uri("/volumes/%s/action", volumeId))
84+
.entity(new ForceDeleteAction())
85+
.execute();
86+
}
87+
88+
/**
89+
* {@inheritDoc}
90+
*/
91+
@Override
92+
public ActionResponse resetState(String volumeId, Volume.Status status) {
93+
checkNotNull(volumeId);
94+
checkNotNull(status);
95+
return post(ActionResponse.class, uri("/volumes/%s/action", volumeId))
96+
.entity(new ResetStatusAction(status))
97+
.execute();
98+
}
99+
100+
/**
101+
* {@inheritDoc}
102+
*/
103+
@Override
104+
public ActionResponse extend(String volumeId, Integer newSize) {
105+
checkNotNull(volumeId);
106+
checkNotNull(newSize);
107+
return post(ActionResponse.class, uri("/volumes/%s/action", volumeId))
108+
.entity(new ExtendAction(newSize))
109+
.execute();
110+
}
111+
112+
/**
113+
* {@inheritDoc}
114+
*/
115+
@Override
116+
public Volume create(Volume volume) {
117+
checkNotNull(volume);
118+
return post(CinderVolume.class, uri("/volumes")).entity(volume).execute();
119+
}
94120

95121
/**
96122
* {@inheritDoc}

0 commit comments

Comments
 (0)