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 1
1
package org .openstack4j .model .compute .builder ;
2
2
3
3
import org .openstack4j .common .Buildable ;
4
+ import org .openstack4j .model .compute .BDMDestType ;
5
+ import org .openstack4j .model .compute .BDMSourceType ;
4
6
import org .openstack4j .model .compute .BlockDeviceMappingCreate ;
5
7
6
8
/**
@@ -40,15 +42,15 @@ public interface BlockDeviceMappingBuilder extends Buildable.Builder<BlockDevice
40
42
* @param type the destination type
41
43
* @return BlockDeviceMappingBuilder
42
44
*/
43
- BlockDeviceMappingBuilder destinationType (String type );
45
+ BlockDeviceMappingBuilder destinationType (BDMDestType type );
44
46
45
47
/**
46
48
* Either snap or any other value, including a blank string. snap means that the volume was created from a snapshot.
47
49
*
48
50
* @param type the source type
49
51
* @return BlockDeviceMappingBuilder
50
52
*/
51
- BlockDeviceMappingBuilder sourceType (String type );
53
+ BlockDeviceMappingBuilder sourceType (BDMSourceType type );
52
54
53
55
/**
54
56
* 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 1
1
package org .openstack4j .openstack .compute .domain ;
2
2
3
- import com .fasterxml .jackson .annotation .JsonProperty ;
3
+ import org .openstack4j .model .compute .BDMDestType ;
4
+ import org .openstack4j .model .compute .BDMSourceType ;
4
5
import org .openstack4j .model .compute .BlockDeviceMappingCreate ;
5
6
import org .openstack4j .model .compute .builder .BlockDeviceMappingBuilder ;
6
7
8
+ import com .fasterxml .jackson .annotation .JsonProperty ;
9
+
7
10
/**
8
11
*
9
12
* @author jaroslav.sovicka@oracle.com
10
13
*/
11
14
public class NovaBlockDeviceMappingCreate implements BlockDeviceMappingCreate {
12
15
13
16
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 ;
16
19
public String uuid ;
17
20
public String boot_index ;
18
21
public Integer volume_size ;
@@ -61,13 +64,13 @@ public BlockDeviceMappingBuilder bootIndex(int i) {
61
64
}
62
65
63
66
@ Override
64
- public BlockDeviceMappingBuilder sourceType (String type ){
67
+ public BlockDeviceMappingBuilder sourceType (BDMSourceType type ){
65
68
create .source_type = type ;
66
69
return this ;
67
70
}
68
71
69
72
@ Override
70
- public BlockDeviceMappingBuilder destinationType (String type ){
73
+ public BlockDeviceMappingBuilder destinationType (BDMDestType type ){
71
74
create .destination_type = type ;
72
75
return this ;
73
76
}
You can’t perform that action at this time.
0 commit comments