File tree Expand file tree Collapse file tree 4 files changed +82
-7
lines changed
core/src/main/java/org/openstack4j Expand file tree Collapse file tree 4 files changed +82
-7
lines changed Original file line number Diff line number Diff line change 1+ package org .openstack4j .model .compute ;
2+
3+ import com .fasterxml .jackson .annotation .JsonCreator ;
4+ import com .fasterxml .jackson .annotation .JsonValue ;
5+
6+ /**
7+ * Block Device Mapping Destination Type
8+ *
9+ * @author Jeremy Unruh
10+ * @see http://docs.openstack.org/developer/nova/block_device_mapping.html
11+ */
12+ public enum BDMDestType {
13+
14+ /** Will either mean an ephemeral blank disk on hypervisor local storage, or a swap disk **/
15+ LOCAL ,
16+ /** Creates a blank Cinder volume and attaches it. This will also require the volume size to be set **/
17+ VOLUME ;
18+
19+ @ JsonCreator
20+ public static BDMDestType value (String v ) {
21+ if (v == null )
22+ return LOCAL ;
23+ try {
24+ return valueOf (v .toUpperCase ());
25+ } catch (IllegalArgumentException e ) {
26+ return LOCAL ;
27+ }
28+ }
29+
30+ @ JsonValue
31+ public String value () {
32+ return name ().toLowerCase ();
33+ }
34+
35+ }
Original file line number Diff line number Diff line change 1+ package org .openstack4j .model .compute ;
2+
3+ import com .fasterxml .jackson .annotation .JsonCreator ;
4+ import com .fasterxml .jackson .annotation .JsonValue ;
5+
6+ /**
7+ * Block Device Mapping Source Type
8+ *
9+ * @author Jeremy Unruh
10+ * @see http://docs.openstack.org/developer/nova/block_device_mapping.html
11+ */
12+ public enum BDMSourceType {
13+ BLANK ,
14+ IMAGE ,
15+ SNAPSHOT ,
16+ VOLUME
17+ ;
18+
19+ @ JsonCreator
20+ public static BDMSourceType value (String v ) {
21+ if (v == null )
22+ return VOLUME ;
23+ try {
24+ return valueOf (v .toUpperCase ());
25+ } catch (IllegalArgumentException e ) {
26+ return VOLUME ;
27+ }
28+ }
29+
30+ @ JsonValue
31+ public String value () {
32+ return name ().toLowerCase ();
33+ }
34+
35+ }
Original file line number Diff line number Diff line change 11package org .openstack4j .model .compute .builder ;
22
33import org .openstack4j .common .Buildable ;
4+ import org .openstack4j .model .compute .BDMDestType ;
5+ import org .openstack4j .model .compute .BDMSourceType ;
46import org .openstack4j .model .compute .BlockDeviceMappingCreate ;
57
68/**
@@ -40,15 +42,15 @@ public interface BlockDeviceMappingBuilder extends Buildable.Builder<BlockDevice
4042 * @param type the destination type
4143 * @return BlockDeviceMappingBuilder
4244 */
43- BlockDeviceMappingBuilder destinationType (String type );
45+ BlockDeviceMappingBuilder destinationType (BDMDestType type );
4446
4547 /**
4648 * Either snap or any other value, including a blank string. snap means that the volume was created from a snapshot.
4749 *
4850 * @param type the source type
4951 * @return BlockDeviceMappingBuilder
5052 */
51- BlockDeviceMappingBuilder sourceType (String type );
53+ BlockDeviceMappingBuilder sourceType (BDMSourceType type );
5254
5355 /**
5456 * Set to True to delete the volume when the instance is deleted. Set to False to retain the volume when the instance is deleted.
Original file line number Diff line number Diff line change 11package org .openstack4j .openstack .compute .domain ;
22
3- import com .fasterxml .jackson .annotation .JsonProperty ;
3+ import org .openstack4j .model .compute .BDMDestType ;
4+ import org .openstack4j .model .compute .BDMSourceType ;
45import org .openstack4j .model .compute .BlockDeviceMappingCreate ;
56import org .openstack4j .model .compute .builder .BlockDeviceMappingBuilder ;
67
8+ import com .fasterxml .jackson .annotation .JsonProperty ;
9+
710/**
811 *
9121013 */
1114public class NovaBlockDeviceMappingCreate implements BlockDeviceMappingCreate {
1215
1316 public String device_name ;
14- public String source_type = "volume" ;
15- public String destination_type = "volume" ;
17+ public BDMSourceType source_type = BDMSourceType . VOLUME ;
18+ public BDMDestType destination_type = BDMDestType . VOLUME ;
1619 public String uuid ;
1720 public String boot_index ;
1821 public Integer volume_size ;
@@ -61,13 +64,13 @@ public BlockDeviceMappingBuilder bootIndex(int i) {
6164 }
6265
6366 @ Override
64- public BlockDeviceMappingBuilder sourceType (String type ){
67+ public BlockDeviceMappingBuilder sourceType (BDMSourceType type ){
6568 create .source_type = type ;
6669 return this ;
6770 }
6871
6972 @ Override
70- public BlockDeviceMappingBuilder destinationType (String type ){
73+ public BlockDeviceMappingBuilder destinationType (BDMDestType type ){
7174 create .destination_type = type ;
7275 return this ;
7376 }
You can’t perform that action at this time.
0 commit comments