-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #500 - Use enums for Block Device Mappings
- Loading branch information
Showing
4 changed files
with
82 additions
and
7 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
core/src/main/java/org/openstack4j/model/compute/BDMDestType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.openstack4j.model.compute; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* Block Device Mapping Destination Type | ||
* | ||
* @author Jeremy Unruh | ||
* @see http://docs.openstack.org/developer/nova/block_device_mapping.html | ||
*/ | ||
public enum BDMDestType { | ||
|
||
/** Will either mean an ephemeral blank disk on hypervisor local storage, or a swap disk **/ | ||
LOCAL, | ||
/** Creates a blank Cinder volume and attaches it. This will also require the volume size to be set **/ | ||
VOLUME; | ||
|
||
@JsonCreator | ||
public static BDMDestType value(String v) { | ||
if (v == null) | ||
return LOCAL; | ||
try { | ||
return valueOf(v.toUpperCase()); | ||
} catch (IllegalArgumentException e) { | ||
return LOCAL; | ||
} | ||
} | ||
|
||
@JsonValue | ||
public String value() { | ||
return name().toLowerCase(); | ||
} | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
core/src/main/java/org/openstack4j/model/compute/BDMSourceType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.openstack4j.model.compute; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* Block Device Mapping Source Type | ||
* | ||
* @author Jeremy Unruh | ||
* @see http://docs.openstack.org/developer/nova/block_device_mapping.html | ||
*/ | ||
public enum BDMSourceType { | ||
BLANK, | ||
IMAGE, | ||
SNAPSHOT, | ||
VOLUME | ||
; | ||
|
||
@JsonCreator | ||
public static BDMSourceType value(String v) { | ||
if (v == null) | ||
return VOLUME; | ||
try { | ||
return valueOf(v.toUpperCase()); | ||
} catch (IllegalArgumentException e) { | ||
return VOLUME; | ||
} | ||
} | ||
|
||
@JsonValue | ||
public String value() { | ||
return name().toLowerCase(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters