Skip to content

Commit 3c625c0

Browse files
committed
Merge FloatingIP support from contributor 'nanderson'. Full cinder support including volumes, volume types and volume snapshots
1 parent 5c44534 commit 3c625c0

28 files changed

+1622
-8
lines changed

src/main/java/org/openstack4j/api/Builders.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.openstack4j.model.common.builder.LinkBuilder;
44
import org.openstack4j.model.compute.builder.FlavorBuilder;
5+
import org.openstack4j.model.compute.builder.FloatingIPBuilder;
56
import org.openstack4j.model.compute.builder.ServerCreateBuilder;
67
import org.openstack4j.model.identity.builder.EndpointBuilder;
78
import org.openstack4j.model.identity.builder.RoleBuilder;
@@ -14,8 +15,11 @@
1415
import org.openstack4j.model.network.builder.PortBuilder;
1516
import org.openstack4j.model.network.builder.RouterBuilder;
1617
import org.openstack4j.model.network.builder.SubnetBuilder;
18+
import org.openstack4j.model.storage.block.builder.VolumeBuilder;
19+
import org.openstack4j.model.storage.block.builder.VolumeSnapshotBuilder;
1720
import org.openstack4j.openstack.common.GenericLink;
1821
import org.openstack4j.openstack.compute.domain.NovaFlavor;
22+
import org.openstack4j.openstack.compute.domain.NovaFloatingIP;
1923
import org.openstack4j.openstack.compute.domain.NovaServerCreate;
2024
import org.openstack4j.openstack.identity.domain.KeystoneEndpoint;
2125
import org.openstack4j.openstack.identity.domain.KeystoneRole;
@@ -28,6 +32,8 @@
2832
import org.openstack4j.openstack.networking.domain.NeutronPort;
2933
import org.openstack4j.openstack.networking.domain.NeutronRouter;
3034
import org.openstack4j.openstack.networking.domain.NeutronSubnet;
35+
import org.openstack4j.openstack.storage.block.domain.CinderVolume;
36+
import org.openstack4j.openstack.storage.block.domain.CinderVolumeSnapshot;
3137

3238
/**
3339
* A utility class to quickly access available Builders within the OpenStack API
@@ -158,4 +164,28 @@ public static RouterBuilder router() {
158164
public static ImageBuilder image() {
159165
return GlanceImage.builder();
160166
}
167+
168+
/**
169+
* The builder to create a Block Volume
170+
* @return the volume builder
171+
*/
172+
public static VolumeBuilder volume() {
173+
return CinderVolume.builder();
174+
}
175+
176+
/**
177+
* The builder to create a Block Volume Snapshot
178+
* @return the snapshot builder
179+
*/
180+
public static VolumeSnapshotBuilder volumeSnapshot() {
181+
return CinderVolumeSnapshot.builder();
182+
}
183+
184+
/**
185+
* The builder to create a Compute/Nova Floating IP
186+
* @return the floating ip builder
187+
*/
188+
public static FloatingIPBuilder floatingIP() {
189+
return NovaFloatingIP.builder();
190+
}
161191
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.openstack4j.api.compute;
2+
3+
import java.util.List;
4+
5+
import org.openstack4j.common.RestService;
6+
import org.openstack4j.model.compute.ActionResponse;
7+
import org.openstack4j.model.compute.FloatingIP;
8+
import org.openstack4j.model.compute.Server;
9+
10+
/**
11+
* OpenStack Compute Floating-IP Operation API.
12+
*
13+
* @author Nathan Anderson
14+
*/
15+
public interface ComputeFloatingIPService extends RestService {
16+
17+
/**
18+
* List floating ips associated with current tenant.
19+
*
20+
* @return the list<? extends floating i p>
21+
*/
22+
List<? extends FloatingIP> list();
23+
24+
/**
25+
* Allocate a floating ip address to tenant.
26+
*
27+
* @param pool the pool
28+
* @return the floating ip
29+
*/
30+
FloatingIP allocateIP(String pool);
31+
32+
/**
33+
* Deallocate ip address from tenant.
34+
*
35+
* @param tenantId the tenant id
36+
* @param id the id of floating ip address
37+
* @return the action response
38+
*/
39+
void deallocateIP(String id);
40+
41+
42+
/**
43+
* Adds floating-ip to server.
44+
*
45+
* @param server the server
46+
* @param fixedIpAddress the fixed ip address
47+
* @param ipAddress the ip address
48+
* @return the action response
49+
*/
50+
ActionResponse addFloatingIP(Server server, String fixedIpAddress, String ipAddress);
51+
52+
/**
53+
* Remove floating-ip from server
54+
*
55+
* @param server the server
56+
* @param ipAddress the ip address
57+
*/
58+
ActionResponse removeFloatingIP(Server server, String ipAddress);
59+
60+
}

src/main/java/org/openstack4j/api/compute/ComputeService.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,38 @@ public interface ComputeService extends RestService {
1818
* @return the flavor service
1919
*/
2020
FlavorService flavors();
21-
21+
2222
/**
2323
* Image Service API
2424
*
2525
* @return the image service
2626
*/
2727
ComputeImageService images();
28-
28+
2929
/**
3030
* Server Service API
3131
*
3232
* @return the server service
3333
*/
3434
ServerService servers();
35-
35+
3636
/**
3737
* Quota-Set Service API
3838
*
3939
* @return the quota set service
4040
*/
4141
QuotaSetService quotaSets();
42-
42+
43+
/**
44+
* Floating IP Service API
45+
*
46+
* @return the floating-ip service
47+
*/
48+
ComputeFloatingIPService floatingIps();
49+
4350
/**
4451
* @return a list of Extensions that have been added against the Compute service
4552
*/
4653
List<? extends Extension> listExtensions();
47-
54+
4855
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package org.openstack4j.api.networking;
2+
3+
import java.util.List;
4+
5+
import org.openstack4j.common.RestService;
6+
7+
import org.openstack4j.model.network.FloatingIP;
8+
9+
10+
/**
11+
* Provides Neutron-based FloatingIP services
12+
*
13+
*
14+
* @author nanderson
15+
*/
16+
public interface FloatingIPService extends RestService {
17+
18+
/**
19+
* Returns list of floating IPs
20+
*
21+
* @return List of FloatingIPs or empty
22+
*/
23+
List<? extends FloatingIP> list();
24+
25+
/**
26+
* Gets a FloatingIP by id
27+
*
28+
* @param id the floating-ip identifier
29+
* @return the FloatingIP
30+
*/
31+
FloatingIP get(String id);
32+
33+
/**
34+
* Deletes FloatingIP by id
35+
*
36+
* @param id floating-ip identifier id
37+
*/
38+
void delete(String id);
39+
40+
/**
41+
* Creates the.
42+
*
43+
* @param floatingIp floating ip
44+
*/
45+
FloatingIP create(FloatingIP floatingIp);
46+
47+
/**
48+
* Update.
49+
*
50+
* @param floatingIp the floating ip
51+
*/
52+
//FloatingIP update(FloatingIP floatingIp);
53+
54+
55+
//FloatingIP associateToPort();
56+
57+
//FloatingIP disassociateFromPort();
58+
59+
}

src/main/java/org/openstack4j/api/networking/NetworkingService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ public interface NetworkingService extends RestService {
2828
* @return the Router Service API
2929
*/
3030
RouterService router();
31+
32+
/**
33+
* @return the FloatingIP Service API
34+
*/
35+
FloatingIPService floatingip();
3136
}

src/main/java/org/openstack4j/api/storage/BlockStorageService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ public interface BlockStorageService extends RestService {
1414
*/
1515
BlockVolumeService volumes();
1616

17+
/**
18+
* @return the Volume Snapshot Service API
19+
*/
20+
BlockVolumeSnapshotService snapshots();
21+
1722
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,27 @@ public interface BlockVolumeService extends RestService {
3333
* @return the volume or null if not found
3434
*/
3535
Volume get(String volumeId);
36+
37+
/**
38+
* Deletes the specified volume
39+
*
40+
* @param volumeId the volume identifier
41+
*/
42+
void delete(String volumeId);
43+
44+
/**
45+
* Creates a new Block Storage Volume
46+
* @param volume the volume for create
47+
* @return the created volume
48+
*/
49+
Volume create(Volume volume);
50+
51+
/**
52+
* OpenStack only allows name or description to be updated. This call enforces that based on the API docs.
53+
*
54+
* @param volumeId the volume id
55+
* @param name the name to update (null indicates no name update)
56+
* @param description the description to update (null indicates no description update)
57+
*/
58+
void update(String volumeId, String name, String description);
3659
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package org.openstack4j.api.storage;
2+
3+
import java.util.List;
4+
5+
import org.openstack4j.common.RestService;
6+
import org.openstack4j.model.storage.block.VolumeSnapshot;
7+
8+
/**
9+
* OpenStack (Cinder) Volume Snapshot Operations API.
10+
*
11+
* @author Jeremy Unruh
12+
*/
13+
public interface BlockVolumeSnapshotService extends RestService {
14+
15+
/**
16+
* Lists detailed information for all Block Storage snapshots that the tenant who submits the request can access.
17+
*
18+
* @return List of VolumeSnapshot
19+
*/
20+
List<? extends VolumeSnapshot> list();
21+
22+
/**
23+
* Shows information for a specified snapshot.
24+
*
25+
* @param snapshotId the snapshot identifier
26+
* @return the volume snapshot or null
27+
*/
28+
VolumeSnapshot get(String snapshotId);
29+
30+
/**
31+
* Deletes a specified snapshot
32+
*
33+
* @param snapshotId the snapshot identifier
34+
*/
35+
void delete(String snapshotId);
36+
37+
/**
38+
* Updates the Name and/or Description for the specified snapshot
39+
*
40+
* @param snapshotId the snapshot identifier
41+
* @param name the new name
42+
* @param description the new description
43+
*/
44+
void update(String snapshotId, String name, String description);
45+
46+
/**
47+
* Creates a snapshot, which is a point-in-time copy of a volume. You can create a volume from the snapshot.
48+
*
49+
* NOTE: the volume ID within the snapshot must be set or an NullPointerException will be thrown
50+
*
51+
* @param snapshot the snapshot to create
52+
* @return the newly created snapshot
53+
*/
54+
VolumeSnapshot create(VolumeSnapshot snapshot);
55+
56+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.openstack4j.model.compute;
2+
3+
import org.openstack4j.common.Buildable;
4+
import org.openstack4j.model.ModelEntity;
5+
import org.openstack4j.model.compute.builder.FloatingIPBuilder;
6+
7+
/**
8+
* The Interface FloatingIP.
9+
*
10+
*
11+
* @author nanderson
12+
*/
13+
public interface FloatingIP extends ModelEntity, Buildable<FloatingIPBuilder> {
14+
15+
/**
16+
* Gets the id.
17+
*
18+
* @return the id
19+
*/
20+
String getId();
21+
22+
/**
23+
* Gets the instance id.
24+
*
25+
* @return the instance id
26+
*/
27+
String getInstanceId();
28+
29+
/**
30+
* Gets the floating ip address.
31+
*
32+
* @return the floating ip address
33+
*/
34+
String getFloatingIpAddress();
35+
36+
/**
37+
* Gets the fixed ip address.
38+
*
39+
* @return the fixed ip address
40+
*/
41+
String getFixedIpAddress();
42+
43+
/**
44+
* Gets the pool.
45+
*
46+
* @return the pool name
47+
*/
48+
String getPool();
49+
}

0 commit comments

Comments
 (0)