Skip to content

Commit 49f6294

Browse files
committed
fb
1 parent e189d88 commit 49f6294

File tree

4 files changed

+97
-12
lines changed

4 files changed

+97
-12
lines changed

openstack-api/src/main/java/org/openstack/api/compute/ext/SnapshotsResource.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77
import org.openstack.api.common.Resource;
88
import org.openstack.model.compute.Snapshot;
99
import org.openstack.model.compute.SnapshotList;
10-
import org.openstack.model.compute.Volume;
11-
import org.openstack.model.compute.VolumeList;
1210
import org.openstack.model.compute.nova.snapshot.NovaSnapshot;
1311
import org.openstack.model.compute.nova.snapshot.NovaSnapshotList;
14-
import org.openstack.model.compute.nova.volume.NovaVolume;
15-
import org.openstack.model.compute.nova.volume.NovaVolumeList;
16-
import org.openstack.model.compute.nova.volume.VolumeForCreate;
12+
import org.openstack.model.compute.nova.snapshot.SnapshotForCreate;
1713

1814
public class SnapshotsResource extends Resource {
1915

@@ -36,7 +32,7 @@ public SnapshotList get() {
3632
* @param flavor
3733
* @return
3834
*/
39-
public Snapshot post(VolumeForCreate volume) {
35+
public Snapshot post(SnapshotForCreate volume) {
4036
return target.request(MediaType.APPLICATION_JSON).post(Entity.entity(volume, MediaType.APPLICATION_JSON), NovaSnapshot.class);
4137
}
4238

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package org.openstack.model.compute.nova.snapshot;
2+
3+
import java.io.Serializable;
4+
5+
import javax.xml.bind.annotation.XmlAccessType;
6+
import javax.xml.bind.annotation.XmlAccessorType;
7+
import javax.xml.bind.annotation.XmlAttribute;
8+
import javax.xml.bind.annotation.XmlRootElement;
9+
10+
import org.openstack.model.compute.Snapshot;
11+
12+
13+
@XmlRootElement(namespace="")
14+
@XmlAccessorType(XmlAccessType.NONE)
15+
public class NovaSnapshotForCreate implements Serializable, SnapshotForCreate {
16+
17+
@XmlAttribute(name="volume_id")
18+
private Integer volumeId;
19+
20+
@XmlAttribute
21+
private Boolean force;
22+
23+
@XmlAttribute(name="display_name")
24+
private String name;
25+
26+
@XmlAttribute(name="display_description")
27+
private String description;
28+
29+
/* (non-Javadoc)
30+
* @see org.openstack.model.compute.nova.snapshot.SnapshotForCreate#getVolumeId()
31+
*/
32+
@Override
33+
public Integer getVolumeId() {
34+
return volumeId;
35+
}
36+
37+
public void setVolumeId(Integer volumeId) {
38+
this.volumeId = volumeId;
39+
}
40+
41+
/* (non-Javadoc)
42+
* @see org.openstack.model.compute.nova.snapshot.SnapshotForCreate#getForce()
43+
*/
44+
@Override
45+
public Boolean getForce() {
46+
return force;
47+
}
48+
49+
public void setForce(Boolean force) {
50+
this.force = force;
51+
}
52+
53+
/* (non-Javadoc)
54+
* @see org.openstack.model.compute.nova.snapshot.SnapshotForCreate#getName()
55+
*/
56+
@Override
57+
public String getName() {
58+
return name;
59+
}
60+
61+
public void setName(String name) {
62+
this.name = name;
63+
}
64+
65+
/* (non-Javadoc)
66+
* @see org.openstack.model.compute.nova.snapshot.SnapshotForCreate#getDescription()
67+
*/
68+
@Override
69+
public String getDescription() {
70+
return description;
71+
}
72+
73+
public void setDescription(String description) {
74+
this.description = description;
75+
}
76+
77+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.openstack.model.compute.nova.snapshot;
2+
3+
public interface SnapshotForCreate {
4+
5+
Integer getVolumeId();
6+
7+
Boolean getForce();
8+
9+
String getName();
10+
11+
String getDescription();
12+
13+
}

openstack-api/src/test/java/org/openstack/client/compute/ITSnapshots.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
import org.openstack.model.compute.Snapshot;
77
import org.openstack.model.compute.SnapshotList;
8-
import org.openstack.model.compute.nova.volume.NovaSnapshotAttachment;
9-
import org.openstack.model.compute.nova.volume.NovaSnapshotForCreate;
8+
import org.openstack.model.compute.nova.snapshot.NovaSnapshotForCreate;
109
import org.testng.annotations.Test;
1110

1211
public class ITSnapshots extends ComputeIntegrationTest {
@@ -15,22 +14,22 @@ public class ITSnapshots extends ComputeIntegrationTest {
1514

1615
@Test
1716
public void listSnapshots() {
18-
SnapshotList volumes = compute.volumes().get();
17+
SnapshotList volumes = compute.snapshots().get();
1918
}
2019

2120
@Test
2221
public void createSnapshot() throws Exception {
2322
NovaSnapshotForCreate nv = new NovaSnapshotForCreate();
2423
nv.setName("v2");
25-
nv.setSizeInGB(1);
26-
volume = compute.volumes().post(nv);
24+
nv.setDescription("desc");
25+
volume = compute.snapshots().post(nv);
2726
System.out.println(volume);
2827
waitForState("available");
2928
}
3029

3130
@Test(dependsOnMethods="createSnapshot", priority=1)
3231
public void showSnapshot() throws Exception {
33-
volume = compute.volumes().volume(volume.getId()).get();
32+
volume = compute.snapshots().snapshot(volume.getId()).get();
3433
System.out.println(volume);
3534
}
3635

0 commit comments

Comments
 (0)