diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 000000000..1ebc1c989 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,50 @@ +# 3.2.9 / 2020-04-07 +* glance: Add Support for Image Service API v2 + +# 3.2.8 / 2020-01-29 +* jackson upgraded to com.fasterxml version 2.9.x +* commons-httpclient upgraded to org.apache.httpcomponents 4.5 + +# 3.2.7 / 2019-05-03 +* Remove maven-gpg-plugin + +# 3.2.6 / 2019-05-03 +* RESTEasyConnector: Support RESTEasy 3.6.3.Final + +# 3.2.5 / 2018-11-14 +* neutron: Add support for `port_security_enabled` on Networks + +# 3.2.4 / 2018 +* Improved backward compatibility to 3.1.3 + +# 3.2.3 / 2018-06-24 +* No user visible changes + +# 3.2.2 / 2018-06-23 +* Add keystone v3 support +* Add missing nova utility methods for server actions +* Add heat support +* Add router support +* All fixes and improvements up to 3.1.3 + +# 3.1.3 / 2018-05-18 +* Cinder: Add support for `os-terminate_connection` +* neutron: Support parameter mtu + +# 3.1.2 / 2017-01-28 +* RESTEasyConnector: Isolate the creation of ClientExecutor + +# 3.1.1 / 2015-05-06 +* cinder: introduce client and model +* java 7 +* Fixes and improvements up to 3.0.6 + +# 3.2.1 / 2013-07-26 +* No user visible changes + +# 3.2.0 / 2013-07-26 +* support quota/limits/usage operations +* logging enhancements + +# 3.1.0 / 2013-07-21 + diff --git a/ceilometer-client/pom.xml b/ceilometer-client/pom.xml index b6889ddae..0c0ea41c1 100644 --- a/ceilometer-client/pom.xml +++ b/ceilometer-client/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT ceilometer-client OpenStack Ceilometer Client @@ -12,12 +12,12 @@ com.woorea openstack-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT com.woorea ceilometer-model - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT diff --git a/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/ResourcesResource.java b/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/ResourcesResource.java index 405f04fb9..900168719 100644 --- a/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/ResourcesResource.java +++ b/ceilometer-client/src/main/java/com/woorea/openstack/ceilometer/v2/api/ResourcesResource.java @@ -2,7 +2,6 @@ import java.util.List; - import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.ceilometer.QueriableCeilometerCommand; @@ -25,7 +24,7 @@ public ResourceList() { } - public class ResourceShow extends OpenStackRequest { + public class ResourceShow extends OpenStackRequest { private String id; diff --git a/ceilometer-model/pom.xml b/ceilometer-model/pom.xml index 0ebd3d973..d2fd429ac 100644 --- a/ceilometer-model/pom.xml +++ b/ceilometer-model/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT ceilometer-model OpenStack Ceilometer Model diff --git a/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Meter.java b/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Meter.java index df9182f9c..53f192b54 100644 --- a/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Meter.java +++ b/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Meter.java @@ -1,6 +1,6 @@ package com.woorea.openstack.ceilometer.v2.model; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Meter { diff --git a/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Resource.java b/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Resource.java index 24e14aa3d..7ca1fb089 100644 --- a/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Resource.java +++ b/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Resource.java @@ -2,7 +2,7 @@ import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Resource { //{"resource_id": "23b55841eedd41e99d5f3f32149ca086", "timestamp": "2013-03-03T15:19:00", "project_id": "23b55841eedd41e99d5f3f32149ca086", "user_id": null, "metadata": {}} diff --git a/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Sample.java b/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Sample.java index 8827de466..c17d34159 100644 --- a/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Sample.java +++ b/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Sample.java @@ -2,7 +2,7 @@ import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Sample { diff --git a/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Statistics.java b/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Statistics.java index 5a34fe54b..f8236aa21 100644 --- a/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Statistics.java +++ b/ceilometer-model/src/main/java/com/woorea/openstack/ceilometer/v2/model/Statistics.java @@ -2,7 +2,7 @@ import java.math.BigDecimal; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Statistics { diff --git a/cinder-client/pom.xml b/cinder-client/pom.xml new file mode 100644 index 000000000..e953379d9 --- /dev/null +++ b/cinder-client/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + + com.woorea + openstack-java-sdk + 3.2.10-SNAPSHOT + + cinder-client + OpenStack Cinder Client + OpenStack Cinder Client + + + com.woorea + openstack-client + 3.2.10-SNAPSHOT + + + + com.woorea + cinder-model + 3.2.10-SNAPSHOT + + + \ No newline at end of file diff --git a/cinder-client/src/main/java/com/woorea/openstack/cinder/Cinder.java b/cinder-client/src/main/java/com/woorea/openstack/cinder/Cinder.java new file mode 100644 index 000000000..4230e8b12 --- /dev/null +++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/Cinder.java @@ -0,0 +1,50 @@ +package com.woorea.openstack.cinder; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackClientConnector; + +public class Cinder extends OpenStackClient { + + private final VolumesExtension VOLUMES; + + private final SnapshotsExtension SNAPSHOTS; + + private final VolumeTypesExtension VOLUME_TYPES; + + private final LimitsExtension LIMITS; + + private final SchedulerStatsExtension SCHEDULER_STATS; + + public Cinder(String endpoint, OpenStackClientConnector connector) { + super(endpoint, connector); + VOLUMES = new VolumesExtension(this); + SNAPSHOTS = new SnapshotsExtension(this); + VOLUME_TYPES = new VolumeTypesExtension(this); + LIMITS = new LimitsExtension(this); + SCHEDULER_STATS = new SchedulerStatsExtension(this); + } + + public Cinder(String endpoint) { + this(endpoint, null); + } + + public final VolumesExtension volumes() { + return VOLUMES; + } + + public final SnapshotsExtension snapshots() { + return SNAPSHOTS; + } + + public final VolumeTypesExtension volumeTypes() { + return VOLUME_TYPES; + } + + public final LimitsExtension limits() { + return LIMITS; + } + + public final SchedulerStatsExtension schedulerStats() { + return SCHEDULER_STATS; + } +} diff --git a/cinder-client/src/main/java/com/woorea/openstack/cinder/LimitsExtension.java b/cinder-client/src/main/java/com/woorea/openstack/cinder/LimitsExtension.java new file mode 100644 index 000000000..0d4a78597 --- /dev/null +++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/LimitsExtension.java @@ -0,0 +1,28 @@ +package com.woorea.openstack.cinder; + +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.cinder.model.Limits; + +public class LimitsExtension { + + private final OpenStackClient CLIENT; + + public LimitsExtension(OpenStackClient client) { + CLIENT = client; + } + + public List list() { + return new List(); + } + + public class List extends OpenStackRequest { + + public List() { + super(CLIENT, HttpMethod.GET, "/limits", null, Limits.class); + } + + } + +} diff --git a/cinder-client/src/main/java/com/woorea/openstack/cinder/SchedulerStatsExtension.java b/cinder-client/src/main/java/com/woorea/openstack/cinder/SchedulerStatsExtension.java new file mode 100644 index 000000000..7af0f273a --- /dev/null +++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/SchedulerStatsExtension.java @@ -0,0 +1,30 @@ +package com.woorea.openstack.cinder; + +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.cinder.model.Pools; + +/** + * Cinder Scheduler Stats Management + */ +public class SchedulerStatsExtension { + + private final OpenStackClient CLIENT; + + public SchedulerStatsExtension(OpenStackClient client) { + this.CLIENT = client; + } + + public List list(boolean detail) { + return new List(detail); + } + + public class List extends OpenStackRequest { + + public List(boolean detail) { + super(CLIENT, HttpMethod.GET, (new StringBuilder("/scheduler-stats/get_pools")).append(detail ? "?detail=True":""), null, Pools.class); + } + } + +} diff --git a/cinder-client/src/main/java/com/woorea/openstack/cinder/SnapshotsExtension.java b/cinder-client/src/main/java/com/woorea/openstack/cinder/SnapshotsExtension.java new file mode 100644 index 000000000..c5bab0743 --- /dev/null +++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/SnapshotsExtension.java @@ -0,0 +1,111 @@ +package com.woorea.openstack.cinder; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.cinder.model.Metadata; +import com.woorea.openstack.cinder.model.Snapshot; +import com.woorea.openstack.cinder.model.SnapshotForCreate; +import com.woorea.openstack.cinder.model.SnapshotForUpdate; +import com.woorea.openstack.cinder.model.Snapshots; + +public class SnapshotsExtension { + + private final OpenStackClient CLIENT; + + public SnapshotsExtension(OpenStackClient client) { + CLIENT = client; + } + + public List list(boolean detail) { + return new List(detail); + } + + public Create create(SnapshotForCreate snapshotForCreate) { + return new Create(snapshotForCreate); + } + + public Show show(String id) { + return new Show(id); + } + + public ShowMetadata showMetadata(String snapshotId) { + return new ShowMetadata(snapshotId); + } + + public UpdateMetadata updateMetadata(String snapshotId, Metadata metadata) { + return new UpdateMetadata(snapshotId, metadata); + } + + public Delete delete(String id) { + return new Delete(id); + } + + public Update update(String id, SnapshotForUpdate snapshot) { + return new Update(id, snapshot); + } + + public class List extends OpenStackRequest { + + public List(boolean detail) { + super(CLIENT, HttpMethod.GET, detail ? "/snapshots/detail" : "/snapshots", null, Snapshots.class); + } + + } + + public class Create extends OpenStackRequest { + + public Create(SnapshotForCreate snapshotForCreate) { + super(CLIENT, HttpMethod.POST, "/snapshots", Entity.json(snapshotForCreate), Snapshot.class); + } + + } + + public class Show extends OpenStackRequest { + + public Show(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/snapshots/").append(id).toString(), null, Snapshot.class); + } + + } + + public class Delete extends OpenStackRequest { + + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/snapshots/").append(id).toString(), null, Void.class); + } + + } + + public class Update extends OpenStackRequest { + + public Update(String id, SnapshotForUpdate snapshot) { + super(CLIENT, HttpMethod.PUT, new StringBuilder("/snapshots/").append(id).toString(), + Entity.json(snapshot), Void.class); + } + + } + + public class ShowMetadata extends OpenStackRequest { + + public ShowMetadata(String id) { + super(CLIENT, + HttpMethod.GET, + new StringBuilder("/snapshots/").append(id).append("/metadata").toString(), + null, + Metadata.class); + } + + } + + public class UpdateMetadata extends OpenStackRequest { + + public UpdateMetadata(String snapshotId, Metadata metadata) { + super(CLIENT, HttpMethod.PUT, new StringBuilder("/snapshots/").append(snapshotId) + .append("/metadata") + .toString(), Entity.json(metadata), Void.class); + } + + } +} diff --git a/cinder-client/src/main/java/com/woorea/openstack/cinder/VolumeTypesExtension.java b/cinder-client/src/main/java/com/woorea/openstack/cinder/VolumeTypesExtension.java new file mode 100644 index 000000000..5951e1cfd --- /dev/null +++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/VolumeTypesExtension.java @@ -0,0 +1,70 @@ +package com.woorea.openstack.cinder; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.cinder.model.VolumeType; +import com.woorea.openstack.cinder.model.VolumeTypeForCreate; +import com.woorea.openstack.cinder.model.VolumeTypes; + +public class VolumeTypesExtension { + + private final OpenStackClient CLIENT; + + public VolumeTypesExtension(OpenStackClient client) { + CLIENT = client; + } + + public List list() { + return new List(); + } + + public Create create(VolumeTypeForCreate volumeTypeForCreate) { + return new Create(volumeTypeForCreate); + } + + public Show show(String id) { + return new Show(id); + } + + public Delete delete(String id) { + return new Delete(id); + } + + public class List extends OpenStackRequest { + + public List() { + super(CLIENT, HttpMethod.GET, "/types", null, VolumeTypes.class); + } + + } + + public class Create extends OpenStackRequest { + + private VolumeTypeForCreate volumeTypeForCreate; + + public Create(VolumeTypeForCreate volumeTypeForCreate) { + super(CLIENT, HttpMethod.POST, "/types", Entity.json(volumeTypeForCreate), VolumeType.class); + this.volumeTypeForCreate = volumeTypeForCreate; + } + + } + + public class Show extends OpenStackRequest { + + public Show(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/types/").append(id).toString(), null, VolumeType.class); + } + + } + + public class Delete extends OpenStackRequest { + + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/types/").append(id).toString(), null, Void.class); + } + + } + +} diff --git a/cinder-client/src/main/java/com/woorea/openstack/cinder/VolumesExtension.java b/cinder-client/src/main/java/com/woorea/openstack/cinder/VolumesExtension.java new file mode 100644 index 000000000..39bcc0e4d --- /dev/null +++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/VolumesExtension.java @@ -0,0 +1,164 @@ +package com.woorea.openstack.cinder; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.cinder.model.ConnectionForInitialize; +import com.woorea.openstack.cinder.model.ConnectionForTerminate; +import com.woorea.openstack.cinder.model.ConnectionInfo; +import com.woorea.openstack.cinder.model.Metadata; +import com.woorea.openstack.cinder.model.Volume; +import com.woorea.openstack.cinder.model.VolumeForCreate; +import com.woorea.openstack.cinder.model.VolumeForExtend; +import com.woorea.openstack.cinder.model.VolumeForImageCreate; +import com.woorea.openstack.cinder.model.VolumeForUpdate; +import com.woorea.openstack.cinder.model.Volumes; + +public class VolumesExtension { + + private final OpenStackClient CLIENT; + + public VolumesExtension(OpenStackClient client) { + CLIENT = client; + } + + public List list(boolean detail) { + return new List(detail); + } + + public Create create(VolumeForCreate volume) { + return new Create(volume); + } + + public UploadToImage uploadToImage(VolumeForImageCreate volumeForImage) { + return new UploadToImage(volumeForImage); + } + + public Show show(String id) { + return new Show(id); + } + + public ShowMetadata showMetadata(String id) { + return new ShowMetadata(id); + } + + public Delete delete(String id) { + return new Delete(id); + } + + public Update update(String id, VolumeForUpdate volume) { + return new Update(id, volume); + } + + public Extend extend(String id, int newSize) { + VolumeForExtend volume = new VolumeForExtend(); + volume.setSize(newSize); + return new Extend(id, volume); + } + + public InitializeConnection initializeConnection(String id, ConnectionForInitialize connectionForInitialize) { + return new InitializeConnection(id, connectionForInitialize); + } + + public TerminateConnection terminateConnection(String id, ConnectionForTerminate connectionForTerminate) { + return new TerminateConnection(id, connectionForTerminate); + } + + public class List extends OpenStackRequest { + + public List(boolean detail) { + super(CLIENT, HttpMethod.GET, detail ? "/volumes/detail" + : "/volumes", null, Volumes.class); + } + + } + + public class Create extends OpenStackRequest { + + public Create(VolumeForCreate volume) { + super(CLIENT, HttpMethod.POST, "/volumes", Entity.json(volume), + Volume.class); + } + + } + + // Upload volume to image service as image + + public class UploadToImage extends OpenStackRequest { + + public UploadToImage(VolumeForImageCreate volumeForImageCreate) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/volumes/") + .append(volumeForImageCreate.getVolumeId() + "/action").toString(), + Entity.json(volumeForImageCreate), Void.class); + } + + } + + public class Show extends OpenStackRequest { + + public Show(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/volumes/") + .append(id).toString(), null, Volume.class); + } + + } + + public class ShowMetadata extends OpenStackRequest { + + public ShowMetadata(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/volumes/") + .append(id).append("/metadata").toString(), null, + Metadata.class); + } + + } + + public class Delete extends OpenStackRequest { + + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/volumes/") + .append(id).toString(), null, Void.class); + } + + } + + public class Update extends OpenStackRequest { + + public Update(String id, VolumeForUpdate volume) { + super(CLIENT, HttpMethod.PUT, new StringBuilder("/volumes/").append(id).toString(), + Entity.json(volume), Void.class); + } + + } + + public class Extend extends OpenStackRequest { + + public Extend(String id, VolumeForExtend volume) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/volumes/").append(id).append("/action").toString(), + Entity.json(volume), Void.class); + } + + } + + public class InitializeConnection extends OpenStackRequest { + + public InitializeConnection(String id, ConnectionForInitialize connectionForInitialize) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/volumes/") + .append(id).append("/action").toString(), + Entity.json(connectionForInitialize), ConnectionInfo.class); + } + + } + + public class TerminateConnection extends OpenStackRequest { + + public TerminateConnection(String id, ConnectionForTerminate connectionForTerminate) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/volumes/") + .append(id).append("/action").toString(), + Entity.json(connectionForTerminate), Void.class); + } + + } + +} diff --git a/cinder-model/pom.xml b/cinder-model/pom.xml new file mode 100644 index 000000000..b5fcc3577 --- /dev/null +++ b/cinder-model/pom.xml @@ -0,0 +1,11 @@ + + 4.0.0 + + com.woorea + openstack-java-sdk + 3.2.10-SNAPSHOT + + cinder-model + OpenStack Cinder Model + OpenStack Cinder Model + \ No newline at end of file diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/BaseConnection.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/BaseConnection.java new file mode 100644 index 000000000..e2fc8c2ed --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/BaseConnection.java @@ -0,0 +1,28 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public abstract class BaseConnection implements Serializable { + @JsonProperty("connector") + private Map connector = new HashMap(); + + /** + * @return the connector + */ + public Map getConnector() { + return connector; + } + + /** + * @param connector + * the connector to set + */ + public void setConnector(Map connector) { + this.connector = connector; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Capabilities.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Capabilities.java new file mode 100644 index 000000000..c8cd98b6b --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Capabilities.java @@ -0,0 +1,139 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +/** + * Model for Volume + */ +@JsonRootName("capabilities") +public class Capabilities implements Serializable { + + @JsonProperty("pool_name") + private String poolName; + @JsonProperty("QoS_support") + private boolean qosSupport; + @JsonProperty("allocated_capacity_gb") + private Long allocatedCapacityGb; + @JsonProperty("driver_version") + private String driverVersion; + @JsonProperty("free_capacity_gb") + private Long freeCapacityGb; + @JsonProperty("location_info") + private String locationInfo; + + private String timestamp; + @JsonProperty("volume_backend_name") + private String volumeBackendName; + @JsonProperty("total_capacity_gb") + private Long totalCapacityGb; + @JsonProperty("reserved_percentage") + private Integer reservedPercentage; + @JsonProperty("vendor_name") + private String vendorName; + @JsonProperty("storage_protocol") + private String storageProtocol; + @JsonProperty("extra_specs") + private Map extraSpecs; + + public String getPoolName() { + return poolName; + } + public void setPoolName(String poolName) { + this.poolName = poolName; + } + public boolean isQosSupport() { + return qosSupport; + } + public void setQosSupport(boolean qosSupport) { + this.qosSupport = qosSupport; + } + public Long getAllocatedCapacityGb() { + return allocatedCapacityGb; + } + public void setAllocatedCapacityGb(Long allocatedCapacityGb) { + this.allocatedCapacityGb = allocatedCapacityGb; + } + public String getDriverVersion() { + return driverVersion; + } + public void setDriverVersion(String driverVersion) { + this.driverVersion = driverVersion; + } + public Long getFreeCapacityGb() { + return freeCapacityGb; + } + public void setFreeCapacityGb(Long freeCapacityGb) { + this.freeCapacityGb = freeCapacityGb; + } + public String getLocationInfo() { + return locationInfo; + } + public void setLocationInfo(String locationInfo) { + this.locationInfo = locationInfo; + } + public String getTimestamp() { + return timestamp; + } + public void setTimestamp(String timestamp) { + this.timestamp = timestamp; + } + public String getVolumeBackendName() { + return volumeBackendName; + } + public void setVolumeBackendName(String volumeBackendName) { + this.volumeBackendName = volumeBackendName; + } + public Long getTotalCapacityGb() { + return totalCapacityGb; + } + public void setTotalCapacityGb(Long totalCapacityGb) { + this.totalCapacityGb = totalCapacityGb; + } + public Integer getReservedPercentage() { + return reservedPercentage; + } + public void setReservedPercentage(Integer reservedPercentage) { + this.reservedPercentage = reservedPercentage; + } + public String getVendorName() { + return vendorName; + } + public void setVendorName(String vendorName) { + this.vendorName = vendorName; + } + public String getStorageProtocol() { + return storageProtocol; + } + public void setStorageProtocol(String storageProtocol) { + this.storageProtocol = storageProtocol; + } + public Map getExtraSpecs() { + return extraSpecs; + } + public void setExtraSpecs(Map extraSpecs) { + this.extraSpecs = extraSpecs; + } + + @Override + public String toString() { + return "Capabilities{" + + "poolName='" + poolName + + ", qosSupport='" + qosSupport + + ", allocatedCapacityGb='" + allocatedCapacityGb + + ", driverVersion='" + driverVersion + + ", freeCapacityGb='" + freeCapacityGb + + ", locationInfo='" + locationInfo + + ", timestamp='" + timestamp + + ", volumeBackendName='" + volumeBackendName + + ", totalCapacityGb='" + totalCapacityGb + + ", reservedPercentage='" + reservedPercentage + + ", vendorName='" + vendorName + + ", storageProtocol='" + storageProtocol + + ", extraSpecs='" + extraSpecs + + '}'; + } +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionForInitialize.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionForInitialize.java new file mode 100644 index 000000000..47218054c --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionForInitialize.java @@ -0,0 +1,20 @@ +package com.woorea.openstack.cinder.model; + +import com.fasterxml.jackson.annotation.JsonRootName; + +import java.io.Serializable; + +@JsonRootName("os-initialize_connection") +public class ConnectionForInitialize extends BaseConnection implements Serializable { + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ConnectionForInitialize [connector=" + getConnector() + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionForTerminate.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionForTerminate.java new file mode 100644 index 000000000..7fee326b4 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionForTerminate.java @@ -0,0 +1,20 @@ +package com.woorea.openstack.cinder.model; + +import com.fasterxml.jackson.annotation.JsonRootName; + +import java.io.Serializable; + +@JsonRootName("os-terminate_connection") +public class ConnectionForTerminate extends BaseConnection implements Serializable { + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ConnectionForInitialize [connector=" + getConnector() + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionInfo.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionInfo.java new file mode 100644 index 000000000..362aaca02 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/ConnectionInfo.java @@ -0,0 +1,58 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("connection_info") +public class ConnectionInfo implements Serializable { + + @JsonProperty("driver_volume_type") + private String driverVolumeType; + + private Map data; + + /** + * @return the driverVolumeType + */ + public String getDriverVolumeType() { + return driverVolumeType; + } + + /** + * @param driverVolumeType + * the driverVolumeType to set + */ + public void setDriverVolumeType(String driverVolumeType) { + this.driverVolumeType = driverVolumeType; + } + + /** + * @return the data + */ + public Map getData() { + return data; + } + + /** + * @param data + * the data to set + */ + public void setData(Map data) { + this.data = data; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ConnectionInfo [driverVolumeType=" + driverVolumeType + "," + + " data=" + data + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Limits.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Limits.java new file mode 100644 index 000000000..d6ef7762d --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Limits.java @@ -0,0 +1,246 @@ +package com.woorea.openstack.cinder.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.List; + +@JsonRootName("limits") +public class Limits implements Serializable { + + public static final class RateLimit implements Serializable { + + public static final class LimitEntry implements Serializable { + + @JsonProperty("next-available") + private Calendar nextAvailable; + + private String unit; + + private String verb; + + private Integer remaining; + + private Integer available; + + private Integer value; + + /** + * @return the nextAvailable + */ + public Calendar getNextAvailable() { + return nextAvailable; + } + + /** + * @return the unit + */ + public String getUnit() { + return unit; + } + + /** + * @return the verb + */ + public String getVerb() { + return verb; + } + + /** + * @return the remaining + */ + public Integer getRemaining() { + return remaining; + } + + /** + * @return the available + */ + public Integer getAvailable() { + return available; + } + + /** + * @return the value + */ + public Integer getValue() { + return value; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "LimitEntry [nextAvailable=" + nextAvailable + ", unit=" + + unit + ", verb=" + verb + ", remaining=" + remaining + + ", available=" + available + ", value=" + value + "]"; + } + + } + + private String regex; + + private String uri; + + private List limit; + + /** + * @return the regex + */ + public String getRegex() { + return regex; + } + + /** + * @return the uri + */ + public String getUri() { + return uri; + } + + /** + * @return the limit + */ + public List getLimit() { + return limit; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "RateLimit [regex=" + regex + ", uri=" + uri + ", limit=" + + limit + "]"; + } + + } + + public static final class AbsoluteLimit { + + private Integer maxTotalVolumes; + private Integer totalVolumesUsed; + + private Integer maxTotalSnapshots; + private Integer totalSnapshotsUsed; + + private Integer maxTotalVolumeGigabytes; + private Integer totalGigabytesUsed; + + private Integer maxTotalBackups; + private Integer totalBackupsUsed; + + private Integer maxTotalBackupGigabytes; + private Integer totalBackupGigabytesUsed; + + /** + * @return the maxTotalVolumes + */ + public Integer getMaxTotalVolumes() { + return maxTotalVolumes; + } + + /** + * @return the totalVolumesUsed + */ + public Integer getTotalVolumesUsed() { + return totalVolumesUsed; + } + + /** + * @return the maxTotalSnapshots + */ + public Integer getMaxTotalSnapshots() { + return maxTotalSnapshots; + } + + /** + * @return the totalSnapshotsUsed + */ + public Integer getTotalSnapshotsUsed() { + return totalSnapshotsUsed; + } + + /** + * @return the maxTotalVolumeGigabytes + */ + public Integer getMaxTotalVolumeGigabytes() { + return maxTotalVolumeGigabytes; + } + + /** + * @return the totalGigabytesUsed + */ + public Integer getTotalGigabytesUsed() { + return totalGigabytesUsed; + } + + /** + * @return the maxTotalBackupGigabytes + */ + public Integer getMaxTotalBackupGigabytes() { + return maxTotalBackupGigabytes; + } + + /** + * @return the totalBackupGigabytesUsed + */ + public Integer getTotalBackupGigabytesUsed() { + return totalBackupGigabytesUsed; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "AbsoluteLimit [maxTotalVolumes=" + maxTotalVolumes + + ", totalVolumesUsed=" + totalVolumesUsed + + ", maxTotalSnapshots=" + maxTotalSnapshots + + ", totalSnapshotsUsed=" + totalSnapshotsUsed + + ", maxTotalVolumeGigabytes=" + maxTotalVolumeGigabytes + + ", totalGigabytesUsed=" + totalGigabytesUsed + + ", maxTotalBackupGigabytes=" + maxTotalBackupGigabytes + + ", totalBackupGigabytesUsed=" + totalBackupGigabytesUsed +"]"; + } + + } + + private List rate; + + private AbsoluteLimit absolute; + + /** + * @return the rate + */ + public List getRate() { + return rate; + } + + /** + * @return the absolute + */ + public AbsoluteLimit getAbsolute() { + return absolute; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Limits [rate=" + rate + ", absolute=" + absolute + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Metadata.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Metadata.java new file mode 100644 index 000000000..3949a853e --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Metadata.java @@ -0,0 +1,35 @@ +package com.woorea.openstack.cinder.model; + +import java.util.Map; + +public class Metadata { + + private Map metadata; + + /** + * @return the metadata + */ + public Map getMetadata() { + return metadata; + } + + /** + * Set the metadata + * + * @param metadata + */ + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Metadata [metadata=" + metadata + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Pool.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Pool.java new file mode 100644 index 000000000..1e8da7166 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Pool.java @@ -0,0 +1,42 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +/** + * Model for Pool + */ +@JsonRootName("pool") +public class Pool implements Serializable { + + private String name; + + private Capabilities capabilities; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Capabilities getCapabilities() { + return capabilities; + } + + public void setCapabilities(Capabilities capabilities) { + this.capabilities = capabilities; + } + + @Override + public String toString() { + return "Pool{" + + "name='" + name + + ", capabilities='" + capabilities + + '}'; + } +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Pools.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Pools.java new file mode 100644 index 000000000..3816362f7 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Pools.java @@ -0,0 +1,33 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model for List of pools + */ +public class Pools implements Iterable, Serializable { + + @JsonProperty("pools") + private List list; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + + @Override + public String toString() { + return "Pools [list=" + list + "]"; + } +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Snapshot.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Snapshot.java new file mode 100644 index 000000000..60b7ef13f --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Snapshot.java @@ -0,0 +1,99 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("snapshot") +public class Snapshot implements Serializable { + + private String id; + + private String status; + + private String name; + + private String description; + + @JsonProperty("volume_id") + private String volumeId; + + private Integer size; + + @JsonProperty("created_at") + private String createdAt; + + private Map metadata; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @return the volumeId + */ + public String getVolumeId() { + return volumeId; + } + + /** + * @return the size + */ + public Integer getSize() { + return size; + } + + /** + * @return the createdAt + */ + public String getCreatedAt() { + return createdAt; + } + + /** + * @return the metadata + */ + public Map getMetadata() { + return metadata; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Snapshot [id=" + id + ", status=" + status + + ", name=" + name + ", description=" + description + + ", volumeId=" + volumeId + ", size=" + size + + ", createdAt=" + createdAt + ", metadata=" + metadata + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/SnapshotForCreate.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/SnapshotForCreate.java new file mode 100644 index 000000000..3634fcb0a --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/SnapshotForCreate.java @@ -0,0 +1,91 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("snapshot") +public class SnapshotForCreate implements Serializable { + + @JsonProperty("volume_id") + private String volumeId; + + private Boolean force; + + private String name; + + private String description; + + /** + * @return the volumeId + */ + public String getVolumeId() { + return volumeId; + } + + /** + * @param volumeId + * the volumeId to set + */ + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + /** + * @return the force + */ + public Boolean getForce() { + return force; + } + + /** + * @param force + * the force to set + */ + public void setForce(Boolean force) { + this.force = force; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description + * the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "SnapshotForCreate [volumeId=" + volumeId + ", force=" + force + + ", name=" + name + ", description=" + description + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/SnapshotForUpdate.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/SnapshotForUpdate.java new file mode 100644 index 000000000..525ef3c31 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/SnapshotForUpdate.java @@ -0,0 +1,54 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("snapshot") +public class SnapshotForUpdate implements Serializable { + + private String name; + + private String description; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description + * the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "SnapshotForUpdate [name=" + name + ", description=" + description + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Snapshots.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Snapshots.java new file mode 100644 index 000000000..176b1c459 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Snapshots.java @@ -0,0 +1,36 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Snapshots implements Iterable, Serializable { + + @JsonProperty("snapshots") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Snapshots [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Volume.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Volume.java new file mode 100644 index 000000000..a5fda3f20 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Volume.java @@ -0,0 +1,166 @@ +package com.woorea.openstack.cinder.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + +@JsonRootName("volume") +public class Volume implements Serializable { + + private String id; + + private String status; + + private String name; + + private String description; + + @JsonProperty("availability_zone") + private String availabilityZone; + + @JsonProperty("volume_type") + private String volumeType; + + @JsonProperty("snapshot_id") + private String snapshotId; + + @JsonProperty("source_volid") + private String sourceVolid; + + @JsonProperty("bootable") + private Boolean bootable; + + private List> attachments; + + private Map metadata; + + @JsonProperty("created_at") + private String createdAt; + + private Integer size; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the status + */ + public String getStatus() { + return status; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @return the availabilityZone + */ + public String getAvailabilityZone() { + return availabilityZone; + } + + /** + * @return the volumeType + */ + public String getVolumeType() { + return volumeType; + } + + /** + * @return the snapshotId + */ + public String getSnapshotId() { + return snapshotId; + } + + /** + * @return the ID of an existing volume (specify in order to create a volume from an existing volume) + */ + public String getSourceVolid() { + return sourceVolid; + } + + /** + * @param sourceVolid + * to set + */ + public void setSourceVolid(String sourceVolid) { + this.sourceVolid = sourceVolid; + } + + /** + * @param volumeType + * to set + */ + public void setVolumeType(String volumeType) { + this.volumeType = volumeType; + } + + /** + * @return the bootable flag to set + */ + public Boolean getBootable() { + return bootable; + } + + /** + * @return the attachments + */ + public List> getAttachments() { + return attachments; + } + + /** + * @return the metadata + */ + public Map getMetadata() { + return metadata; + } + + /** + * @return the createdAt + */ + public String getCreatedAt() { + return createdAt; + } + + /** + * @return the size + */ + public Integer getSize() { + return size; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Volume [id=" + id + ", status=" + status + + ", name=" + name + ", description=" + description + + ", availabilityZone=" + availabilityZone + ", volumeType=" + volumeType + + ", snapshotId=" + snapshotId + ", attachments=" + attachments + + ", metadata=" + metadata + ", createdAt=" + createdAt + ", size=" + size + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForCreate.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForCreate.java new file mode 100644 index 000000000..44e6eced8 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForCreate.java @@ -0,0 +1,211 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("volume") +public class VolumeForCreate implements Serializable { + + private Integer size; + + @JsonProperty("availability_zone") + private String availabilityZone; + + @JsonProperty("display_name") + private String name; + + @JsonProperty("display_description") + private String description; + + @JsonProperty("snapshot_id") + private String snapshotId; + + @JsonProperty("source_volid") + private String sourceVolid; + + @JsonProperty("imageRef") + private String imageRef; + + @JsonProperty("volume_type") + private String volumeType; + + @JsonProperty("bootable") + private Boolean bootable; + + private Map metadata; + + /** + * @return the size + */ + public Integer getSize() { + return size; + } + + /** + * @param size + * the size to set + */ + public void setSize(Integer size) { + this.size = size; + } + + /** + * @return the availabilityZone + */ + public String getAvailabilityZone() { + return availabilityZone; + } + + /** + * @param availabilityZone + * the availabilityZone to set + */ + public void setAvailabilityZone(String availabilityZone) { + this.availabilityZone = availabilityZone; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description + * the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the snapshotId + */ + public String getSnapshotId() { + return snapshotId; + } + + /** + * @param snapshotId + * the snapshotId to set + */ + public void setSnapshotId(String snapshotId) { + this.snapshotId = snapshotId; + } + + /** + * @return the ID of an existing volume (specify in order to create a volume from an existing volume) + */ + public String getSourceVolid() { + return sourceVolid; + } + + /** + * @param sourceVolid + * to set + */ + public void setSourceVolid(String sourceVolid) { + this.sourceVolid = sourceVolid; + } + + /** + * @return the ID of the image from which you want to create the volume (required to create a bootable volume) + */ + public String getImageRef() { + return imageRef; + } + + /** + * @param imageRef + * to set + */ + public void setImageRef(String imageRef) { + this.imageRef = imageRef; + } + + /** + * @return the associated volume type + */ + public String getVolumeType() { + return volumeType; + } + + /** + * @param volumeType + * to set + */ + public void setVolumeType(String volumeType) { + this.volumeType = volumeType; + } + + /** + * @return the bootable flag to set + */ + public Boolean getBootable() { + return bootable; + } + + /** + * Enables or disables the bootable attribute. You can boot an instance from a bootable volume. + * + * @param bootable + * flag + */ + public void setBootable(Boolean bootable) { + this.bootable = bootable; + } + + /** + * @return the metadata + */ + public Map getMetadata() { + return metadata; + } + + /** + * @param metadata + * the metadata to set + */ + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "VolumeForCreate [size=" + size + + ", availabilityZone=" + availabilityZone + + ", name=" + name + + ", description=" + description + + ", snapshotId=" + snapshotId + + ", source_volid=" + sourceVolid + + ", imageRef=" + imageRef + + ", volume_type=" + volumeType + + ", bootable=" + bootable + + ", metadata=" + metadata + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForExtend.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForExtend.java new file mode 100644 index 000000000..5a73dc870 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForExtend.java @@ -0,0 +1,39 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("os-extend") +public class VolumeForExtend implements Serializable { + + @JsonProperty("new_size") + private Integer size; + + /** + * @return the size + */ + public Integer getSize() { + return size; + } + + /** + * @param size + * the size to set + */ + public void setSize(Integer size) { + this.size = size; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "VolumeForExtend [size=" + size + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForImageCreate.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForImageCreate.java new file mode 100644 index 000000000..4e67566f6 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForImageCreate.java @@ -0,0 +1,71 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("os-volume_upload_image") +public class VolumeForImageCreate implements Serializable { + String volumeId; + String tenantId; + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + @JsonProperty("force") + private Boolean force; + + public Boolean getForce() { + return force; + } + + public void setForce(Boolean force) { + this.force = force; + } + + @JsonProperty("container_format") + String container_format; + @JsonProperty("disk_format") + String disk_format; + @JsonProperty("image_name") + String image_name; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public String getContainer_format() { + return container_format; + } + + public void setContainer_format(String container_format) { + this.container_format = container_format; + } + + public String getDisk_format() { + return disk_format; + } + + public void setDisk_format(String disk_format) { + this.disk_format = disk_format; + } + + public String getImage_name() { + return image_name; + } + + public void setImage_name(String image_name) { + this.image_name = image_name; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForUpdate.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForUpdate.java new file mode 100644 index 000000000..6ea3306ca --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeForUpdate.java @@ -0,0 +1,54 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("volume") +public class VolumeForUpdate implements Serializable { + + private String name; + + private String description; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description + * the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "VolumeForUpdate [name=" + name + ", description=" + description + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeType.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeType.java new file mode 100644 index 000000000..702fc41b2 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeType.java @@ -0,0 +1,50 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("volume_type") +public class VolumeType implements Serializable { + + private String id; + + private String name; + + @JsonProperty("extra_specs") + private Map extraSpecs; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @return the extra_specs + */ + public Map getExtraSpecs() { + return extraSpecs; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "VolumeType [id=" + id + ", name=" + name + ", extra_specs=" + extraSpecs + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeTypeForCreate.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeTypeForCreate.java new file mode 100644 index 000000000..aaa6992e4 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeTypeForCreate.java @@ -0,0 +1,57 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("volume_type") +public class VolumeTypeForCreate implements Serializable { + + private String name; + + @JsonProperty("extra_specs") + private Map extraSpecs; + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the extraSpecs + */ + public Map getExtraSpecs() { + return extraSpecs; + } + + /** + * @param extraSpecs + * the extra_specs to set + */ + public void setExtraSpecs(Map extraSpecs) { + this.extraSpecs = extraSpecs; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "VolumeForCreate [name=" + name + ", metadata=" + extraSpecs + "]"; + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeTypes.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeTypes.java new file mode 100644 index 000000000..f341cafdd --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/VolumeTypes.java @@ -0,0 +1,36 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class VolumeTypes implements Iterable, Serializable { + + @JsonProperty("volume_types") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Volume Types [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Volumes.java b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Volumes.java new file mode 100644 index 000000000..6de026556 --- /dev/null +++ b/cinder-model/src/main/java/com/woorea/openstack/cinder/model/Volumes.java @@ -0,0 +1,36 @@ +package com.woorea.openstack.cinder.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Volumes implements Iterable, Serializable { + + @JsonProperty("volumes") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Volumes [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/glance-client/pom.xml b/glance-client/pom.xml index d1d30403b..c0af557fa 100644 --- a/glance-client/pom.xml +++ b/glance-client/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT glance-client OpenStack Glance Client @@ -12,13 +12,13 @@ com.woorea openstack-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT com.woorea glance-model - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT \ No newline at end of file diff --git a/glance-client/src/main/java/com/woorea/openstack/glance/ImagesResource.java b/glance-client/src/main/java/com/woorea/openstack/glance/ImagesResource.java index ae46548db..aa56b7a0b 100644 --- a/glance-client/src/main/java/com/woorea/openstack/glance/ImagesResource.java +++ b/glance-client/src/main/java/com/woorea/openstack/glance/ImagesResource.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; import com.woorea.openstack.base.client.Entity; import com.woorea.openstack.base.client.HttpMethod; diff --git a/glance-client/src/main/java/com/woorea/openstack/glance/v2/Glance.java b/glance-client/src/main/java/com/woorea/openstack/glance/v2/Glance.java new file mode 100644 index 000000000..ecfc4fc83 --- /dev/null +++ b/glance-client/src/main/java/com/woorea/openstack/glance/v2/Glance.java @@ -0,0 +1,22 @@ +package com.woorea.openstack.glance.v2; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackClientConnector; + +public class Glance extends OpenStackClient { + + private final ImagesResource IMAGES; + + public Glance(String endpoint, OpenStackClientConnector connector) { + super(endpoint, connector); + IMAGES = new ImagesResource(this); + } + + public Glance(String endpoint) { + this(endpoint, null); + } + + public final ImagesResource images() { + return IMAGES; + } +} diff --git a/glance-client/src/main/java/com/woorea/openstack/glance/v2/ImagesResource.java b/glance-client/src/main/java/com/woorea/openstack/glance/v2/ImagesResource.java new file mode 100644 index 000000000..3b850689b --- /dev/null +++ b/glance-client/src/main/java/com/woorea/openstack/glance/v2/ImagesResource.java @@ -0,0 +1,90 @@ +package com.woorea.openstack.glance.v2; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.base.client.OpenStackResponse; +import com.woorea.openstack.glance.model.v2.Image; +import com.woorea.openstack.glance.model.v2.ImageDownload; +import com.woorea.openstack.glance.model.v2.Images; + +public class ImagesResource { + + private final OpenStackClient CLIENT; + + public ImagesResource(OpenStackClient client) { + CLIENT = client; + } + + public List list(boolean detail) { + return new List(detail); + } + + public Create create(Image image) { + return new Create(image); + } + + public Show show(String id) { + return new Show(id); + } + + public Delete delete(String id) { + return new Delete(id); + } + + public Download download(String id) { + return new Download(id); + } + + public class List extends OpenStackRequest { + + public List(boolean detail) { + super(CLIENT, HttpMethod.GET, "/images", null, Images.class); + } + + } + + public class Create extends OpenStackRequest { + + public Create(Image image) { + super(CLIENT, HttpMethod.POST, "/images", Entity.json(image), Image.class); + } + + } + + public class Delete extends OpenStackRequest { + + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/images/").append(id).toString(), null, Void.class); + } + + } + + public class Show extends OpenStackRequest { + + public Show(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/images/").append(id).toString(), null, Image.class); + } + + } + + public class Download extends OpenStackRequest { + + public Download(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/images/").append(id).append("/file").toString(), + null, ImageDownload.class); + header("Accept", "application/octet-stream"); + } + + @Override + public ImageDownload execute() { + // custom parsing here + OpenStackResponse response = CLIENT.request(this); + ImageDownload imageDownload = new ImageDownload(); + imageDownload.setInputStream(response.getInputStream()); + return imageDownload; + } + + } +} diff --git a/glance-model/pom.xml b/glance-model/pom.xml index 2577a68f7..1d0431c4c 100644 --- a/glance-model/pom.xml +++ b/glance-model/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT glance-model OpenStack Glance Model diff --git a/glance-model/src/main/java/com/woorea/openstack/glance/model/Image.java b/glance-model/src/main/java/com/woorea/openstack/glance/model/Image.java index 491fde640..3ad874629 100644 --- a/glance-model/src/main/java/com/woorea/openstack/glance/model/Image.java +++ b/glance-model/src/main/java/com/woorea/openstack/glance/model/Image.java @@ -5,10 +5,12 @@ import java.util.HashMap; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("image") +@JsonIgnoreProperties(ignoreUnknown = true) public class Image implements Serializable { private String id; @@ -24,6 +26,9 @@ public class Image implements Serializable { private String containerFormat; private Long size; + + @JsonProperty("virtual_size") + private Long virtualSize; private String checksum; @@ -141,6 +146,20 @@ public void setSize(Long size) { this.size = size; } + /** + * @return the virtual size + */ + public Long getVirtualSize() { + return virtualSize; + } + + /** + * @param virtualSize the virtual size to set + */ + public void setVirtualSize(Long virtualSize) { + this.virtualSize = virtualSize; + } + /** * @return the checksum */ diff --git a/glance-model/src/main/java/com/woorea/openstack/glance/model/ImageMember.java b/glance-model/src/main/java/com/woorea/openstack/glance/model/ImageMember.java index 4b8c3e753..0977fa34e 100644 --- a/glance-model/src/main/java/com/woorea/openstack/glance/model/ImageMember.java +++ b/glance-model/src/main/java/com/woorea/openstack/glance/model/ImageMember.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class ImageMember implements Serializable { diff --git a/glance-model/src/main/java/com/woorea/openstack/glance/model/ImageMembers.java b/glance-model/src/main/java/com/woorea/openstack/glance/model/ImageMembers.java index 68aa17612..fc5193253 100644 --- a/glance-model/src/main/java/com/woorea/openstack/glance/model/ImageMembers.java +++ b/glance-model/src/main/java/com/woorea/openstack/glance/model/ImageMembers.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class ImageMembers implements Iterable, Serializable { diff --git a/glance-model/src/main/java/com/woorea/openstack/glance/model/Images.java b/glance-model/src/main/java/com/woorea/openstack/glance/model/Images.java index af612ba1d..348ac29c1 100644 --- a/glance-model/src/main/java/com/woorea/openstack/glance/model/Images.java +++ b/glance-model/src/main/java/com/woorea/openstack/glance/model/Images.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Images implements Iterable, Serializable { diff --git a/glance-model/src/main/java/com/woorea/openstack/glance/model/SharedImages.java b/glance-model/src/main/java/com/woorea/openstack/glance/model/SharedImages.java index 111d0942b..78ca09764 100644 --- a/glance-model/src/main/java/com/woorea/openstack/glance/model/SharedImages.java +++ b/glance-model/src/main/java/com/woorea/openstack/glance/model/SharedImages.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class SharedImages implements Iterable, Serializable { diff --git a/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/Image.java b/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/Image.java new file mode 100644 index 000000000..fe0531b65 --- /dev/null +++ b/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/Image.java @@ -0,0 +1,212 @@ +package com.woorea.openstack.glance.model.v2; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.Calendar; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class Image implements Serializable { + + private String id; + + private String self; + + private String name; + + private String file; + + @JsonProperty("disk_format") + private String diskFormat; + + @JsonProperty("container_format") + private String containerFormat; + + private Long size; + + @JsonProperty("virtual_size") + private Long virtualSize; + + private String checksum; + + @JsonProperty("created_at") + private Calendar createdAt; + + @JsonProperty("updated_at") + private Calendar updatedAt; + + private String status; + + private String visibility; + + @JsonProperty("min_ram") + private Integer minRam; + + @JsonProperty("min_disk") + private Integer minDisk; + + private String owner; + + @JsonProperty("protected") + private boolean isProtected; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getSelf() { + return self; + } + + public void setSelf(String self) { + this.self = self; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDiskFormat() { + return diskFormat; + } + + public void setDiskFormat(String diskFormat) { + this.diskFormat = diskFormat; + } + + public String getContainerFormat() { + return containerFormat; + } + + public void setContainerFormat(String containerFormat) { + this.containerFormat = containerFormat; + } + + public Long getSize() { + return size; + } + + public void setSize(Long size) { + this.size = size; + } + + public Long getVirtualSize() { + return virtualSize; + } + + public void setVirtualSize(Long virtualSize) { + this.virtualSize = virtualSize; + } + + public String getChecksum() { + return checksum; + } + + public void setChecksum(String checksum) { + this.checksum = checksum; + } + + public Calendar getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Calendar createdAt) { + this.createdAt = createdAt; + } + + public Calendar getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(Calendar updatedAt) { + this.updatedAt = updatedAt; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Integer getMinRam() { + return minRam; + } + + public void setMinRam(Integer minRam) { + this.minRam = minRam; + } + + public Integer getMinDisk() { + return minDisk; + } + + public void setMinDisk(Integer minDisk) { + this.minDisk = minDisk; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String owner) { + this.owner = owner; + } + + public boolean isProtected() { + return isProtected; + } + + public void setProtected(boolean aProtected) { + isProtected = aProtected; + } + + public String getFile() { + return file; + } + + public void setFile(String file) { + this.file = file; + } + + public String getVisibility() { + return visibility; + } + + public void setVisibility(String visibility) { + this.visibility = visibility; + } + + @Override + public String toString() { + return "Image{" + + "id='" + id + '\'' + + ", self='" + self + '\'' + + ", name='" + name + '\'' + + ", file='" + file + '\'' + + ", diskFormat='" + diskFormat + '\'' + + ", containerFormat='" + containerFormat + '\'' + + ", size=" + size + + ", virtualSize=" + virtualSize + + ", checksum='" + checksum + '\'' + + ", createdAt=" + createdAt + + ", updatedAt=" + updatedAt + + ", status='" + status + '\'' + + ", visibility='" + visibility + '\'' + + ", minRam=" + minRam + + ", minDisk=" + minDisk + + ", owner='" + owner + '\'' + + ", isProtected=" + isProtected + + '}'; + } +} diff --git a/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/ImageDownload.java b/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/ImageDownload.java new file mode 100644 index 000000000..56f2cdce4 --- /dev/null +++ b/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/ImageDownload.java @@ -0,0 +1,23 @@ +package com.woorea.openstack.glance.model.v2; + +import java.io.InputStream; + +public class ImageDownload { + + private InputStream inputStream; + + /** + * @return the inputStream + */ + public InputStream getInputStream() { + return inputStream; + } + + /** + * @param inputStream the inputStream to set + */ + public void setInputStream(InputStream inputStream) { + this.inputStream = inputStream; + } + +} diff --git a/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/Images.java b/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/Images.java new file mode 100644 index 000000000..0fed85be2 --- /dev/null +++ b/glance-model/src/main/java/com/woorea/openstack/glance/model/v2/Images.java @@ -0,0 +1,26 @@ +package com.woorea.openstack.glance.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +public class Images implements Iterable, Serializable { + + @JsonProperty("images") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/heat-client/pom.xml b/heat-client/pom.xml new file mode 100644 index 000000000..b3ad84354 --- /dev/null +++ b/heat-client/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + + com.woorea + openstack-java-sdk + 3.2.10-SNAPSHOT + + heat-client + OpenStack Heat Client + OpenStack Heat Client + + + com.woorea + openstack-client + 3.2.10-SNAPSHOT + + + + com.woorea + heat-model + 3.2.10-SNAPSHOT + + + \ No newline at end of file diff --git a/heat-client/src/main/java/com/woorea/openstack/heat/Heat.java b/heat-client/src/main/java/com/woorea/openstack/heat/Heat.java new file mode 100644 index 000000000..96e9cd78b --- /dev/null +++ b/heat-client/src/main/java/com/woorea/openstack/heat/Heat.java @@ -0,0 +1,31 @@ +package com.woorea.openstack.heat; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackClientConnector; + +/** + * Reference: http://api.openstack.org/api-ref-orchestration.html + */ +public class Heat extends OpenStackClient { + + private final StackResource stacks; + private final ResourcesResource resources; + + public Heat(String endpoint, OpenStackClientConnector connector) { + super(endpoint, connector); + stacks = new StackResource(this); + resources = new ResourcesResource(this); + } + + public Heat(String endpoint) { + this(endpoint, null); + } + + public StackResource getStacks() { + return stacks; + } + + public ResourcesResource getResources() { + return resources; + } +} diff --git a/heat-client/src/main/java/com/woorea/openstack/heat/ResourcesResource.java b/heat-client/src/main/java/com/woorea/openstack/heat/ResourcesResource.java new file mode 100644 index 000000000..c3635bcbe --- /dev/null +++ b/heat-client/src/main/java/com/woorea/openstack/heat/ResourcesResource.java @@ -0,0 +1,31 @@ +package com.woorea.openstack.heat; + +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.heat.model.Resources; + + +/** + * v1/​{tenant_id}​/stacks/​{stack_name}​/resources + */ +public class ResourcesResource { + private final OpenStackClient client; + + public ResourcesResource(OpenStackClient client) { + this.client = client; + } + + public ListResources listResources(String name) { + return new ListResources(name); + } + + /** + * v1/​{tenant_id}​/stacks/​{stack_name}​/resources + */ + public class ListResources extends OpenStackRequest { + public ListResources(String name) { + super(client, HttpMethod.GET, "/stacks/" + name + "/resources", null, Resources.class); + } + } +} diff --git a/heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java b/heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java new file mode 100644 index 000000000..de4577d3c --- /dev/null +++ b/heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java @@ -0,0 +1,61 @@ +package com.woorea.openstack.heat; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.heat.model.CreateStackParam; +import com.woorea.openstack.heat.model.Stack; +import com.woorea.openstack.heat.model.Stacks; + +public class StackResource { + + private final OpenStackClient client; + + public StackResource(OpenStackClient client) { + this.client = client; + } + + public CreateStack create(CreateStackParam param) { + return new CreateStack(param); + } + + public List list() { + return new List(); + } + + public GetStack byName(String name) { + return new GetStack(name); + } + + public DeleteStack deleteByName(String name) { + return new DeleteStack(name); + } + + public class CreateStack extends OpenStackRequest { + public CreateStack(CreateStackParam params) { + super(client, HttpMethod.POST, "/stacks", Entity.json(params), Stack.class); + } + } + + public class DeleteStack extends OpenStackRequest { + public DeleteStack(String name) { + super(client, HttpMethod.DELETE, "/stacks/" + name, null, Void.class); + } + } + + + public class GetStack extends OpenStackRequest { + public GetStack(String name) { + super(client, HttpMethod.GET, "/stacks/" + name, null, Stack.class); + } + } + + public class List extends OpenStackRequest { + public List() { + super(client, HttpMethod.GET, "/stacks", null, Stacks.class); + } + } + + +} diff --git a/heat-model/pom.xml b/heat-model/pom.xml new file mode 100644 index 000000000..6b93b0149 --- /dev/null +++ b/heat-model/pom.xml @@ -0,0 +1,11 @@ + + 4.0.0 + + com.woorea + openstack-java-sdk + 3.2.10-SNAPSHOT + + heat-model + OpenStack Heat Model + OpenStack Heat Model + \ No newline at end of file diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java new file mode 100644 index 000000000..f602719d6 --- /dev/null +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java @@ -0,0 +1,100 @@ +package com.woorea.openstack.heat.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Map; + +public class CreateStackParam { + @JsonProperty("stack_name") + private String stackName; + + @JsonProperty("template_url") + private String templateUrl; + + @JsonProperty + private String template; + + @JsonProperty("parameters") + private Map parameters; + + @JsonProperty("timeout_mins") + private int timeoutMinutes; + + @JsonProperty("environment") + private String environment; + + public String getStackName() { + return stackName; + } + + public void setStackName(String stackName) { + this.stackName = stackName; + } + + public String getTemplateUrl() { + return templateUrl; + } + + /** + * The URL of the template to instantiate. This value is ignored if the template is supplied inline. + * + * @param templateUrl a template url. + */ + public void setTemplateUrl(String templateUrl) { + this.templateUrl = templateUrl; + } + + public Map getParameters() { + return parameters; + } + + public String getTemplate() { + return template; + } + + /** + * A JSON template to instantiate. This value takes precedence over the template URL if both are supplied. + * + * @param template a template json. + */ + public void setTemplate(String template) { + this.template = template; + } + + public void setParameters(Map parameters) { + this.parameters = parameters; + } + + public int getTimeoutMinutes() { + return timeoutMinutes; + } + + public void setTimeoutMinutes(int timeoutMinutes) { + this.timeoutMinutes = timeoutMinutes; + } + + public String getEnvironment() { + return environment; + } + + /** + * A JSON environment for the stack. + * + * @param environment a environment. + */ + public void setEnvironment(String environment) { + this.environment = environment; + } + + @Override + public String toString() { + return "CreateStackParam{" + + "stackName='" + stackName + '\'' + + ", templateUrl='" + templateUrl + '\'' + + ", template='" + template + '\'' + + ", parameters=" + parameters + + ", timeoutMinutes=" + timeoutMinutes + + ", environment='" + environment + '\'' + + '}'; + } +} diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java new file mode 100644 index 000000000..b14577418 --- /dev/null +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java @@ -0,0 +1,28 @@ +package com.woorea.openstack.heat.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("error") +public class Explanation { + @JsonProperty("explanation") + private String explanation; + + @JsonProperty("code") + private int code; + + @JsonRootName("error") + public static class Error { + @JsonProperty("message") + private String message; + + @JsonProperty("traceback") + private String traceback; + + @JsonProperty("type") + private String type; + + @JsonProperty("title") + private String title; + } +} diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java new file mode 100644 index 000000000..1f9d5826e --- /dev/null +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java @@ -0,0 +1,35 @@ +package com.woorea.openstack.heat.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Link { + @JsonProperty("href") + private String href; + + @JsonProperty("rel") + private String rel; + + public String getHref() { + return href; + } + + public void setHref(String href) { + this.href = href; + } + + public String getRel() { + return rel; + } + + public void setRel(String rel) { + this.rel = rel; + } + + @Override + public String toString() { + return "Link{" + + "href='" + href + '\'' + + ", rel='" + rel + '\'' + + '}'; + } +} diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java new file mode 100644 index 000000000..58c1a1ae4 --- /dev/null +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resource.java @@ -0,0 +1,122 @@ +package com.woorea.openstack.heat.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Date; +import java.util.List; + +public class Resource { + @JsonProperty("resource_name") + private String name; + + @JsonProperty("links") + private List links; + + @JsonProperty("resource_status") + private String status; + + @JsonProperty("physical_resource_id") + private String physicalResourceId; + + @JsonProperty("logical_resource_id") + private String logicalResourceId; + + @JsonProperty("required_by") + private List requiredBy; + + @JsonProperty("updated_time") + private Date updatedTime; + + @JsonProperty("resource_type") + private String type; + + @JsonProperty("resource_status_reason") + private String statusReason; + + public String getStatusReason() { + return statusReason; + } + + public void setStatusReason(String statusReason) { + this.statusReason = statusReason; + } + + public String getLogicalResourceId() { + return logicalResourceId; + } + + public void setLogicalResourceId(String logicalResourceId) { + this.logicalResourceId = logicalResourceId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getPhysicalResourceId() { + return physicalResourceId; + } + + public void setPhysicalResourceId(String physicalResourceId) { + this.physicalResourceId = physicalResourceId; + } + + public List getRequiredBy() { + return requiredBy; + } + + public void setRequiredBy(List requiredBy) { + this.requiredBy = requiredBy; + } + + public Date getUpdatedTime() { + return updatedTime; + } + + public void setUpdatedTime(Date updatedTime) { + this.updatedTime = updatedTime; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getLinks() { + return links; + } + + public void setLinks(List links) { + this.links = links; + } + + @Override + public String toString() { + return "Resource{" + + "name='" + name + '\'' + + ", links=" + links + + ", status='" + status + '\'' + + ", physicalResourceId='" + physicalResourceId + '\'' + + ", logicalResourceId='" + logicalResourceId + '\'' + + ", requiredBy=" + requiredBy + + ", updatedTime=" + updatedTime + + ", type='" + type + '\'' + + ", statusReason='" + statusReason + '\'' + + '}'; + } +} diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java new file mode 100644 index 000000000..a8d9023f8 --- /dev/null +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Resources.java @@ -0,0 +1,28 @@ +package com.woorea.openstack.heat.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +public class Resources implements Iterable, Serializable { + @JsonProperty("resources") + private List list; + + public List getList() { + return list; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + + @Override + public String toString() { + return "Resources{" + + "list=" + list + + '}'; + } +} \ No newline at end of file diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java new file mode 100644 index 000000000..b27bbc1ab --- /dev/null +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stack.java @@ -0,0 +1,115 @@ +package com.woorea.openstack.heat.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +import java.util.Date; +import java.util.List; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonRootName("stack") +public class Stack { + @JsonProperty("description") + private String description; + + @JsonProperty("links") + private List links; + + @JsonProperty("stack_status_reason") + private String stackStatusReason; + + @JsonProperty("stack_name") + private String stackName; + + @JsonProperty("updated_time") + private Date updatedTime; + + @JsonProperty("creation_time") + private Date creationTime; + + @JsonProperty("stack_status") + private String stackStatus; + + @JsonProperty("id") + private String id; + + public Date getUpdatedTime() { + return updatedTime; + } + + public void setUpdatedTime(Date updatedTime) { + this.updatedTime = updatedTime; + } + + public String getStackStatus() { + return stackStatus; + } + + public void setStackStatus(String stackStatus) { + this.stackStatus = stackStatus; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Date getCreationTime() { + return creationTime; + } + + public void setCreationTime(Date creationTime) { + this.creationTime = creationTime; + } + + public String getStackName() { + return stackName; + } + + public void setStackName(String stackName) { + this.stackName = stackName; + } + + public String getStackStatusReason() { + return stackStatusReason; + } + + public void setStackStatusReason(String stackStatusReason) { + this.stackStatusReason = stackStatusReason; + } + + public List getLinks() { + return links; + } + + public void setLinks(List links) { + this.links = links; + } + + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "Stack{" + + "description='" + description + '\'' + + ", links=" + links + + ", stackStatusReason='" + stackStatusReason + '\'' + + ", stackName='" + stackName + '\'' + + ", updatedTime=" + updatedTime + + ", creationTime=" + creationTime + + ", stackStatus='" + stackStatus + '\'' + + ", id='" + id + '\'' + + '}'; + } +} diff --git a/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java new file mode 100644 index 000000000..5731f5b7a --- /dev/null +++ b/heat-model/src/main/java/com/woorea/openstack/heat/model/Stacks.java @@ -0,0 +1,17 @@ +package com.woorea.openstack.heat.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +public class Stacks implements Iterable, Serializable { + @JsonProperty("stacks") + private List list; + + @Override + public Iterator iterator() { + return list.iterator(); + } +} diff --git a/keystone-client/pom.xml b/keystone-client/pom.xml index 537154bf2..8c190e32b 100644 --- a/keystone-client/pom.xml +++ b/keystone-client/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT keystone-client OpenStack Keystone Client @@ -12,12 +12,12 @@ com.woorea openstack-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT com.woorea keystone-model - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT \ No newline at end of file diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/Authenticate.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/api/Authenticate.java deleted file mode 100644 index 0d5d519f0..000000000 --- a/keystone-client/src/main/java/com/woorea/openstack/keystone/api/Authenticate.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.woorea.openstack.keystone.api; - - -import com.woorea.openstack.base.client.HttpMethod; -import com.woorea.openstack.base.client.OpenStackRequest; -import com.woorea.openstack.keystone.model.Access; -import com.woorea.openstack.keystone.model.Authentication; -import com.woorea.openstack.keystone.model.authentication.AccessKey; -import com.woorea.openstack.keystone.model.authentication.TokenAuthentication; -import com.woorea.openstack.keystone.model.authentication.UsernamePassword; - -public class Authenticate extends OpenStackRequest { - - private Authentication authentication; - - public Authenticate(Authentication authentication) { - method(HttpMethod.POST); - path("/tokens"); - json(authentication); - header("Accept", "application/json"); - returnType(Access.class); - } - - public Authenticate withTenantId(String tenantId) { - authentication.setTenantId(tenantId); - return this; - } - - public Authenticate withTenantName(String tenantName) { - authentication.setTenantName(tenantName); - return this; - } - - public class Builder { - - public Authenticate withUsernamePassword(String username, String password) { - authentication = new UsernamePassword(username, password); - return Authenticate.this; - } - - public Authenticate withToken(String token) { - authentication = new TokenAuthentication(token); - return Authenticate.this; - } - - public Authenticate withAccessKey(String accessKey, String secretKey) { - authentication = new AccessKey(accessKey, secretKey); - return Authenticate.this; - } - - } - -} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/Keystone.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/Keystone.java new file mode 100644 index 000000000..6ff889cb5 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/Keystone.java @@ -0,0 +1,73 @@ +package com.woorea.openstack.keystone.v3; + +import com.woorea.openstack.keystone.v3.api.DomainsResource; +import com.woorea.openstack.keystone.v3.api.EndpointsResource; +import com.woorea.openstack.keystone.v3.api.RolesResource; +import com.woorea.openstack.keystone.v3.api.ServicesResource; +import com.woorea.openstack.keystone.v3.api.ProjectsResource; +import com.woorea.openstack.keystone.v3.api.TokensResource; +import com.woorea.openstack.keystone.v3.api.UsersResource; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackClientConnector; + +public class Keystone extends OpenStackClient { + + private final TokensResource TOKENS; + + private final DomainsResource DOMAINS; + + private final ProjectsResource PROJECTS; + + private final UsersResource USERS; + + private final RolesResource ROLES; + + private final ServicesResource SERVICES; + + private final EndpointsResource ENDPOINTS; + + public Keystone(String endpoint, OpenStackClientConnector connector) { + super(endpoint, connector); + TOKENS = new TokensResource(this); + DOMAINS = new DomainsResource(this); + PROJECTS = new ProjectsResource(this); + USERS = new UsersResource(this); + ROLES = new RolesResource(this); + SERVICES = new ServicesResource(this); + ENDPOINTS = new EndpointsResource(this); + } + + public Keystone(String endpoint) { + this(endpoint, null); + } + + public TokensResource tokens() { + return TOKENS; + } + + public DomainsResource domains() { + return DOMAINS; + } + + public ProjectsResource projects() { + return PROJECTS; + } + + public UsersResource users() { + return USERS; + } + + public RolesResource roles() { + return ROLES; + } + + public ServicesResource services() { + return SERVICES; + } + + public EndpointsResource endpoints() { + return ENDPOINTS; + } + +} + diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/CredentialsResources.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/CredentialsResources.java new file mode 100644 index 000000000..7be2620da --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/CredentialsResources.java @@ -0,0 +1,13 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.keystone.v3.model.Credential; +import com.woorea.openstack.keystone.v3.model.Credentials; + +public class CredentialsResources extends GenericResource { + + public CredentialsResources(OpenStackClient client) { + super(client, "/credentials", Credential.class, Credentials.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainGroupRolesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainGroupRolesResource.java new file mode 100644 index 000000000..a041ba20b --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainGroupRolesResource.java @@ -0,0 +1,13 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.keystone.v3.model.Role; +import com.woorea.openstack.keystone.v3.model.Roles; + +public class DomainGroupRolesResource extends GenericResource { + + public DomainGroupRolesResource(OpenStackClient client, String path) { + super(client, path, Role.class, Roles.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainUserRolesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainUserRolesResource.java new file mode 100644 index 000000000..9a6e8e566 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainUserRolesResource.java @@ -0,0 +1,24 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Role; +import com.woorea.openstack.keystone.model.Roles; + +public class DomainUserRolesResource extends GenericResource { + + public DomainUserRolesResource(OpenStackClient client, String path) { + super(client, path, Role.class, Roles.class); + } + + public OpenStackRequest add(String roleId) { + return new OpenStackRequest(CLIENT, HttpMethod.PUT, new StringBuilder(path).append("/").append(roleId).toString(), Entity.json(""), Void.class); + } + + public OpenStackRequest remove(String roleId) { + return new OpenStackRequest(CLIENT, HttpMethod.DELETE, new StringBuilder(path).append("/").append(roleId).toString(), null, Void.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainsResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainsResource.java new file mode 100644 index 000000000..28015eec4 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/DomainsResource.java @@ -0,0 +1,21 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.keystone.v3.model.Domain; +import com.woorea.openstack.keystone.v3.model.Domains; + +public class DomainsResource extends GenericResource { + + public DomainsResource(OpenStackClient client) { + super(client, "/domains", Domain.class, Domains.class); + } + + public DomainUserRolesResource userRoles(String domainId, String userId) { + return new DomainUserRolesResource(CLIENT, new StringBuilder(path).append("/").append(domainId).append("/users/").append(userId).append("/roles").toString()); + } + + public DomainUserRolesResource groupRoles(String domainId, String groupId) { + return new DomainUserRolesResource(CLIENT, new StringBuilder(path).append("/").append(domainId).append("/groups/").append(groupId).append("/roles").toString()); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/EndpointsResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/EndpointsResource.java new file mode 100644 index 000000000..d1db88a14 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/EndpointsResource.java @@ -0,0 +1,13 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.keystone.v3.model.Endpoint; +import com.woorea.openstack.keystone.v3.model.Endpoints; + +public class EndpointsResource extends GenericResource { + + public EndpointsResource(OpenStackClient client) { + super(client, "/endpoints", Endpoint.class, Endpoints.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GenericResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GenericResource.java new file mode 100644 index 000000000..117e941df --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GenericResource.java @@ -0,0 +1,44 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; + +public class GenericResource { + + protected final OpenStackClient CLIENT; + + protected CharSequence path; + + protected Class oneClass; + protected Class manyClass; + + public GenericResource(OpenStackClient client, CharSequence path, Class oneClass, Class manyClass) { + CLIENT = client; + this.path = path; + this.oneClass = oneClass; + this.manyClass = manyClass; + } + + public OpenStackRequest list() { + return new OpenStackRequest(CLIENT, HttpMethod.GET, path, null, manyClass); + } + + public OpenStackRequest create(One one) { + return new OpenStackRequest(CLIENT, HttpMethod.POST, path, Entity.json(one), oneClass); + } + + public OpenStackRequest show(String id) { + return new OpenStackRequest(CLIENT, HttpMethod.GET, new StringBuilder(path).append("/").append(id).toString(), null, oneClass); + } + + public OpenStackRequest update(String id, One one) { + return new OpenStackRequest(CLIENT, HttpMethod.PATCH, new StringBuilder(path).append("/").append(id).toString(), Entity.json(one), oneClass); + } + + public OpenStackRequest delete(String id) { + return new OpenStackRequest(CLIENT, HttpMethod.DELETE, new StringBuilder(path).append("/").append(id).toString(), null, oneClass); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GroupUsersResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GroupUsersResource.java new file mode 100644 index 000000000..60cce41c4 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GroupUsersResource.java @@ -0,0 +1,14 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.keystone.v3.model.User; +import com.woorea.openstack.keystone.v3.model.Users; + + +public class GroupUsersResource extends GenericResource { + + public GroupUsersResource(OpenStackClient client, String path) { + super(client, path, User.class, Users.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GroupsResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GroupsResource.java new file mode 100644 index 000000000..be380cc87 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/GroupsResource.java @@ -0,0 +1,17 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.keystone.v3.model.Group; +import com.woorea.openstack.keystone.v3.model.Groups; + +public class GroupsResource extends GenericResource { + + public GroupsResource(OpenStackClient client) { + super(client, "/groups", Group.class, Groups.class); + } + + public DomainUserRolesResource userRoles(String domainId, String userId) { + return new DomainUserRolesResource(CLIENT, new StringBuilder(path).append("/").append(domainId).append("/users/").append(userId).append("/roles").toString()); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/PoliciesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/PoliciesResource.java new file mode 100644 index 000000000..ba16a4657 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/PoliciesResource.java @@ -0,0 +1,15 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.keystone.model.Role; +import com.woorea.openstack.keystone.model.Roles; +import com.woorea.openstack.keystone.v3.model.Policies; +import com.woorea.openstack.keystone.v3.model.Policy; + +public class PoliciesResource extends GenericResource { + + public PoliciesResource(OpenStackClient client) { + super(client, "/policies", Policy.class, Policies.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectGroupRolesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectGroupRolesResource.java new file mode 100644 index 000000000..caed8acd7 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectGroupRolesResource.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Role; +import com.woorea.openstack.keystone.model.Roles; + +public class ProjectGroupRolesResource extends GenericResource { + + public ProjectGroupRolesResource(OpenStackClient client, String path) { + super(client, path, Role.class, Roles.class); + } + + @Override + public OpenStackRequest create(Role one) { + throw new UnsupportedOperationException(); + } + + @Override + public OpenStackRequest show(String id) { + throw new UnsupportedOperationException(); + } + + @Override + public OpenStackRequest update(String id, Role one) { + throw new UnsupportedOperationException(); + } + + @Override + public OpenStackRequest delete(String id) { + throw new UnsupportedOperationException(); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectRolesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectRolesResource.java new file mode 100644 index 000000000..7e7e2fa30 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectRolesResource.java @@ -0,0 +1,27 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; + +public class ProjectRolesResource { + + private final OpenStackClient CLIENT; + + private final String PATH; + + public ProjectRolesResource(OpenStackClient client, String path) { + this.CLIENT = client; + this.PATH = path; + } + + public OpenStackRequest add(String roleId) { + return new OpenStackRequest(CLIENT, HttpMethod.PUT, new StringBuilder(PATH).append("/").append(roleId).toString(), Entity.json(""), Void.class); + } + + public OpenStackRequest remove(String roleId) { + return new OpenStackRequest(CLIENT, HttpMethod.DELETE, new StringBuilder(PATH).append("/").append(roleId).toString(), null, Void.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectUserRolesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectUserRolesResource.java new file mode 100644 index 000000000..9f3dc50d2 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectUserRolesResource.java @@ -0,0 +1,24 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Role; +import com.woorea.openstack.keystone.model.Roles; + +public class ProjectUserRolesResource extends GenericResource { + + public ProjectUserRolesResource(OpenStackClient client, String path) { + super(client, path, Role.class, Roles.class); + } + + public OpenStackRequest add(String roleId) { + return new OpenStackRequest(CLIENT, HttpMethod.PUT, new StringBuilder(path).append("/").append(roleId).toString(), Entity.json(""), Void.class); + } + + public OpenStackRequest remove(String roleId) { + return new OpenStackRequest(CLIENT, HttpMethod.DELETE, new StringBuilder(path).append("/").append(roleId).toString(), null, Void.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectsResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectsResource.java new file mode 100644 index 000000000..2e9fd9ac9 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ProjectsResource.java @@ -0,0 +1,27 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Users; +import com.woorea.openstack.keystone.v3.model.Project; +import com.woorea.openstack.keystone.v3.model.Projects; + +public class ProjectsResource extends GenericResource { + + public ProjectsResource(OpenStackClient client) { + super(client, "/projects", Project.class, Projects.class); + } + + public OpenStackRequest users(String projectId) { + return CLIENT.get(new StringBuilder(path).append("/").append(projectId).append("/users/").toString(), Users.class); + } + + public ProjectUserRolesResource userRoles(String projectId, String userId) { + return new ProjectUserRolesResource(CLIENT, new StringBuilder(path).append("/").append(projectId).append("/users/").append(userId).append("/roles").toString()); + } + + public ProjectUserRolesResource groupRoles(String projectId, String groupId) { + return new ProjectUserRolesResource(CLIENT, new StringBuilder(path).append("/").append(projectId).append("/groups/").append(groupId).append("/roles").toString()); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/RolesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/RolesResource.java new file mode 100644 index 000000000..2c28a1bfa --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/RolesResource.java @@ -0,0 +1,19 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.v3.model.Role; +import com.woorea.openstack.keystone.v3.model.Roles; +import com.woorea.openstack.keystone.v3.model.Users; + +public class RolesResource extends GenericResource { + + public RolesResource(OpenStackClient client) { + super(client, "/roles", Role.class, Roles.class); + } + + public OpenStackRequest users(String domainId, String userId) { + return CLIENT.get(new StringBuilder(path).append("/").append(domainId).append("/users/").append(userId).append("/roles").toString(), Users.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ServicesResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ServicesResource.java new file mode 100644 index 000000000..4742a2f04 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/ServicesResource.java @@ -0,0 +1,13 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.keystone.model.Service; +import com.woorea.openstack.keystone.model.Services; + +public class ServicesResource extends GenericResource { + + public ServicesResource(OpenStackClient client) { + super(client, "/services", Service.class, Services.class); + } + +} diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/TokensResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/TokensResource.java new file mode 100644 index 000000000..c2d53b300 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/TokensResource.java @@ -0,0 +1,42 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.v3.model.Authentication; +import com.woorea.openstack.keystone.v3.model.Token; + +public class TokensResource { + + private final OpenStackClient CLIENT; + + public TokensResource(OpenStackClient client) { + CLIENT = client; + } + + public Authenticate authenticate(Authentication authentication) { + return new Authenticate(authentication); + } + + public OpenStackRequest show() { + return CLIENT.get("/auth/tokens", Token.class); + } + + public class Authenticate extends OpenStackRequest { + + private Authentication authentication; + + public Authenticate() { + + } + + public Authenticate(Authentication authentication) { + super(CLIENT, HttpMethod.POST, "/auth/tokens", Entity.json(authentication), Token.class); + this.authentication = authentication; + } + + } + +} + diff --git a/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/UsersResource.java b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/UsersResource.java new file mode 100644 index 000000000..d6a6d1400 --- /dev/null +++ b/keystone-client/src/main/java/com/woorea/openstack/keystone/v3/api/UsersResource.java @@ -0,0 +1,27 @@ +package com.woorea.openstack.keystone.v3.api; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.keystone.model.Services; +import com.woorea.openstack.keystone.v3.model.User; +import com.woorea.openstack.keystone.v3.model.Users; + +public class UsersResource extends GenericResource { + + public UsersResource(OpenStackClient client) { + super(client, "/users", User.class, Users.class); + } + + public OpenStackRequest groups(String userId) { + return CLIENT.get(new StringBuilder(path).append("/").append(userId).append("/groups").toString(), Services.class); + } + + public OpenStackRequest projects(String userId) { + return CLIENT.get(new StringBuilder(path).append("/").append(userId).append("/projects").toString(), Services.class); + } + + public OpenStackRequest roles(String userId) { + return CLIENT.get(new StringBuilder(path).append("/").append(userId).append("/roles").toString(), Services.class); + } + +} diff --git a/keystone-model/pom.xml b/keystone-model/pom.xml index c2cd24197..2ee5b28f3 100644 --- a/keystone-model/pom.xml +++ b/keystone-model/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT keystone-model OpenStack Keystone Model diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Access.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Access.java index a7968ff44..f4f37d80a 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Access.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Access.java @@ -4,9 +4,9 @@ import java.util.List; import java.util.Map; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("access") public class Access implements Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Authentication.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Authentication.java index f5c8f5c9d..b795b3d05 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Authentication.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Authentication.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; public abstract class Authentication implements Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Endpoint.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Endpoint.java index f179e2542..77f195d7d 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Endpoint.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Endpoint.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("endpoint") public class Endpoint implements Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Endpoints.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Endpoints.java index d7a58983c..395ce3671 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Endpoints.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Endpoints.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Endpoints implements Iterable, Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Error.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Error.java index 5549f4c83..b8997c565 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Error.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Error.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("error") public class Error implements Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Role.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Role.java index 993b0d9e2..cddd06ee7 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Role.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Role.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("role") public class Role implements Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Roles.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Roles.java index 22e18ed95..669612b57 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Roles.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Roles.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Roles implements Iterable, Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Service.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Service.java index ed9eb53ec..b4c85a8f5 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Service.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Service.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("OS-KSADM:service") public class Service implements Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Services.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Services.java index 5c7958cf1..8596ad34f 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Services.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Services.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Services implements Iterable, Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Tenant.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Tenant.java index a20b71b7e..1498082da 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Tenant.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Tenant.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("tenant") @JsonIgnoreProperties(ignoreUnknown=true) diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Tenants.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Tenants.java index 51e370c02..3af7c3486 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Tenants.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Tenants.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Tenants implements Iterable, Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Token.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Token.java index 92d34ee61..934387bcd 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Token.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Token.java @@ -1,7 +1,10 @@ package com.woorea.openstack.keystone.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + import java.util.Calendar; +@JsonIgnoreProperties(ignoreUnknown=true) public final class Token { private String id; diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/User.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/User.java index 53271f46b..cce8cfb27 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/User.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/User.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("user") public class User implements Serializable { @@ -12,7 +12,7 @@ public class User implements Serializable { private String username; - @JsonProperty("OS_KSADM_password") + @JsonProperty("OS-KSADM:password") private String password; private String tenantId; diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Users.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Users.java index c88aabcf9..772b0050a 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Users.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/Users.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Users implements Iterable, Serializable { diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/AccessKey.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/AccessKey.java index 4767450a5..40e99822b 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/AccessKey.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/AccessKey.java @@ -1,6 +1,6 @@ package com.woorea.openstack.keystone.model.authentication; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; import com.woorea.openstack.keystone.model.Authentication; diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/TokenAuthentication.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/TokenAuthentication.java index 68cfcd2c5..99ea64efb 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/TokenAuthentication.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/TokenAuthentication.java @@ -1,6 +1,6 @@ package com.woorea.openstack.keystone.model.authentication; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; import com.woorea.openstack.keystone.model.Authentication; diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/UsernamePassword.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/UsernamePassword.java index ee94692bd..69f7c6573 100644 --- a/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/UsernamePassword.java +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/model/authentication/UsernamePassword.java @@ -1,6 +1,6 @@ package com.woorea.openstack.keystone.model.authentication; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; import com.woorea.openstack.keystone.model.Authentication; diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Authentication.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Authentication.java new file mode 100644 index 000000000..df5236383 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Authentication.java @@ -0,0 +1,284 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("auth") +public class Authentication implements Serializable { + + public static final class Identity { + + public static final Identity password(String userId, String password) { + Identity identity = new Identity(); + identity.getMethods().add("password"); + Password method = new Password(); + method.getUser().setId(userId); + method.getUser().setPassword(password); + identity.setPassword(method); + return identity; + } + + public static final Identity password(String domainName, String username, String password) { + Identity identity = new Identity(); + identity.getMethods().add("password"); + Password method = new Password(); + com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User.Domain domain = new com.woorea.openstack.keystone.v3.model.Authentication.Identity.Password.User.Domain(); + domain.setName(domainName); + method.getUser().setDomain(domain); + method.getUser().setName(username); + method.getUser().setPassword(password); + identity.setPassword(method); + return identity; + } + + public static final Identity token(String token) { + Identity identity = new Identity(); + identity.getMethods().add("token"); + Token method = new Token(); + method.setId(token); + identity.setToken(method); + return identity; + } + + private List methods = new ArrayList(); + + public static final class Password { + + public static final class User { + + public static final class Domain { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + private Domain domain; + + private String id; + + private String name; + + private String password; + + public Domain getDomain() { + return domain; + } + + public void setDomain(Domain domain) { + this.domain = domain; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + } + + private User user = new User(); + + public User getUser() { + return user; + } + + public void setUser(User user) { + this.user = user; + } + + } + + private Password password; + + public static final class Token { + + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + } + + private Token token; + + public List getMethods() { + return methods; + } + + public void setMethods(List methods) { + this.methods = methods; + } + + public Password getPassword() { + return password; + } + + public void setPassword(Password password) { + this.password = password; + } + + public Token getToken() { + return token; + } + + public void setToken(Token token) { + this.token = token; + } + + } + + private Identity identity; + + public static final class Scope { + + public static Scope project(String id) { + Scope scope = new Scope(); + Project project = new Project(); + project.setId(id); + scope.setProject(project); + return scope; + } + + public static Scope project(String domainName, String projectName) { + Scope scope = new Scope(); + com.woorea.openstack.keystone.v3.model.Authentication.Scope.Project.Domain domain = new com.woorea.openstack.keystone.v3.model.Authentication.Scope.Project.Domain(); + domain.setName(domainName); + Project project = new Project(); + project.setDomain(domain); + project.setName(projectName); + scope.setProject(project); + return scope; + } + + public static final class Project { + + public static final class Domain { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + } + + private String id; + + private Domain domain; + + private String name; + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Domain getDomain() { + return domain; + } + + public void setDomain(Domain domain) { + this.domain = domain; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + } + + private Project project; + + public Project getProject() { + return project; + } + + public void setProject(Project project) { + this.project = project; + } + + } + + private Scope scope; + + public Identity getIdentity() { + return identity; + } + + public void setIdentity(Identity identity) { + this.identity = identity; + } + + public Scope getScope() { + return scope; + } + + public void setScope(Scope scope) { + this.scope = scope; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Credential.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Credential.java new file mode 100644 index 000000000..a0c14ce67 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Credential.java @@ -0,0 +1,61 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("credential") +public class Credential { + + private String id; + + private String projectId; + + private String type; + + private String userId; + + private Map blob = new HashMap(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Map getBlob() { + return blob; + } + + public void setBlob(Map blob) { + this.blob = blob; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Credentials.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Credentials.java new file mode 100644 index 000000000..39ba56771 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Credentials.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Credentials implements Iterable, Serializable { + + @JsonProperty("credentials") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Credentials [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Domain.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Domain.java new file mode 100644 index 000000000..875c4b63c --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Domain.java @@ -0,0 +1,48 @@ +package com.woorea.openstack.keystone.v3.model; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("domain") +public class Domain { + + private String id; + + private String name; + + private String description; + + private Boolean enabled; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Domains.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Domains.java new file mode 100644 index 000000000..ee03fbc47 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Domains.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Domains implements Iterable, Serializable { + + @JsonProperty("domains") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Domains [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Endpoint.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Endpoint.java new file mode 100644 index 000000000..08456bc1f --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Endpoint.java @@ -0,0 +1,51 @@ +package com.woorea.openstack.keystone.v3.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("endpoint") +public class Endpoint { + + private String id; + + @JsonProperty("interface") + private String iface; + + private String name; + + @JsonProperty("service_id") + private String serviceId; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getInterface() { + return iface; + } + + public void setInterface(String iface) { + this.iface = iface; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getServiceId() { + return serviceId; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Endpoints.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Endpoints.java new file mode 100644 index 000000000..617db7edd --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Endpoints.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Endpoints implements Iterable, Serializable { + + @JsonProperty("endpoints") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Endpoints [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Group.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Group.java new file mode 100644 index 000000000..7cd28ad7a --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Group.java @@ -0,0 +1,50 @@ +package com.woorea.openstack.keystone.v3.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("group") +public class Group { + + private String id; + + @JsonProperty("domain_id") + private String domainId; + + private String name; + + private String description; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Groups.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Groups.java new file mode 100644 index 000000000..4085636d2 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Groups.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Groups implements Iterable, Serializable { + + @JsonProperty("groups") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Groups [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Policies.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Policies.java new file mode 100644 index 000000000..25e10c106 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Policies.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Policies implements Iterable, Serializable { + + @JsonProperty("policies") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Policies [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Policy.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Policy.java new file mode 100644 index 000000000..d0ccde815 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Policy.java @@ -0,0 +1,61 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.util.HashMap; +import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("policy") +public class Policy { + + private String id; + + private String projectId; + + private String type; + + private String userId; + + private Map blob = new HashMap(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public Map getBlob() { + return blob; + } + + public void setBlob(Map blob) { + this.blob = blob; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Project.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Project.java new file mode 100644 index 000000000..cca3d73c1 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Project.java @@ -0,0 +1,50 @@ +package com.woorea.openstack.keystone.v3.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("project") +public class Project { + + private String id; + + @JsonProperty("domain_id") + private String domainId; + + private String name; + + private Boolean enabled; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Projects.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Projects.java new file mode 100644 index 000000000..1826fb8b9 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Projects.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Projects implements Iterable, Serializable { + + @JsonProperty("projects") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Projects [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Role.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Role.java new file mode 100644 index 000000000..bd2933b1d --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Role.java @@ -0,0 +1,67 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("role") +public class Role implements Serializable { + + private String id; + + private String name; + + private String description; + + private String enabled; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the enabled + */ + public String getEnabled() { + return enabled; + } + + /** + * @param enabled the enabled to set + */ + public void setEnabled(String enabled) { + this.enabled = enabled; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Roles.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Roles.java new file mode 100644 index 000000000..92b688dc9 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Roles.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Roles implements Iterable, Serializable { + + @JsonProperty("roles") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Roles [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Service.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Service.java new file mode 100644 index 000000000..6e123603b --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Service.java @@ -0,0 +1,48 @@ +package com.woorea.openstack.keystone.v3.model; + +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("service") +public class Service { + + private String id; + + private String type; + + private String name; + + private String description; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Services.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Services.java new file mode 100644 index 000000000..7066fe45a --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Services.java @@ -0,0 +1,36 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import com.woorea.openstack.keystone.model.Service; + +public class Services implements Iterable, Serializable { + + @JsonProperty("services") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Services [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Token.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Token.java new file mode 100644 index 000000000..3151adfcd --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Token.java @@ -0,0 +1,370 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("token") +@JsonIgnoreProperties(ignoreUnknown=true) +public class Token implements Serializable { + + private String id; + + @JsonProperty("expires_at") + private Calendar expiresAt; + + @JsonProperty("issued_at") + private Calendar issuedAt; + + private List methods; + + @JsonIgnoreProperties(ignoreUnknown=true) + public static final class Domain { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + } + + private Domain domain; + + @JsonIgnoreProperties(ignoreUnknown=true) + public static final class Project { + + private Domain domain; + + private String id; + + private String name; + + public Domain getDomain() { + return domain; + } + + public void setDomain(Domain domain) { + this.domain = domain; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + } + + private Project project; + + @JsonIgnoreProperties(ignoreUnknown=true) + public static final class User { + + @JsonIgnoreProperties(ignoreUnknown=true) + private static final class Domain { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + } + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + } + + private User user; + + @JsonIgnoreProperties(ignoreUnknown=true) + public static final class Role { + + private String id; + + private String name; + + } + + private List roles; + + public static final class Service { + + public static final class Endpoint { + + private String id; + + private String url; + + private String region; + + private Boolean enabled; + + @JsonProperty("legacy_endpoint_id") + private String legacyEndpointId; + + @JsonProperty("interface") + private String iface; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public String getLegacyEndpointId() { + return legacyEndpointId; + } + + public void setLegacyEndpointId(String legacyEndpointId) { + this.legacyEndpointId = legacyEndpointId; + } + + public String getInterface() { + return iface; + } + + public void setInterface(String iface) { + this.iface = iface; + } + + } + + private String id; + + private String type; + + private List endpoints; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getEndpoints() { + return endpoints; + } + + public void setEndpoints(List endpoints) { + this.endpoints = endpoints; + } + + } + + private List catalog; + + + public String getId() { + return id; + } + + + + public void setId(String id) { + this.id = id; + } + + + + public Calendar getExpiresAt() { + return expiresAt; + } + + + + public void setExpiresAt(Calendar expiresAt) { + this.expiresAt = expiresAt; + } + + + + public Calendar getIssuedAt() { + return issuedAt; + } + + + + public void setIssuedAt(Calendar issuedAt) { + this.issuedAt = issuedAt; + } + + + + public List getMethods() { + return methods; + } + + + + public void setMethods(List methods) { + this.methods = methods; + } + + + + public Domain getDomain() { + return domain; + } + + + + public void setDomain(Domain domain) { + this.domain = domain; + } + + + + public Project getProject() { + return project; + } + + + + public void setProject(Project project) { + this.project = project; + } + + + + public User getUser() { + return user; + } + + + + public void setUser(User user) { + this.user = user; + } + + + + public List getRoles() { + return roles; + } + + + + public void setRoles(List roles) { + this.roles = roles; + } + + + + public List getCatalog() { + return catalog; + } + + + + public void setCatalog(List catalog) { + this.catalog = catalog; + } + + + @Override + public String toString() { + return "Token [id=" + id + ", expiresAt=" + expiresAt + ", issuedAt=" + + issuedAt + ", methods=" + methods + ", domain=" + domain + + ", project=" + project + ", user=" + user + ", roles=" + + roles + ", catalog=" + catalog + "]"; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/User.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/User.java new file mode 100644 index 000000000..ed68e16b5 --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/User.java @@ -0,0 +1,91 @@ +package com.woorea.openstack.keystone.v3.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("user") +public class User { + + private String id; + + @JsonProperty("domain_id") + private String domainId; + + @JsonProperty("default_project_id") + private String defaultProjectId; + + private String name; + + private String password; + + private String email; + + private String description; + + private Boolean enabled; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDomainId() { + return domainId; + } + + public void setDomainId(String domainId) { + this.domainId = domainId; + } + + public String getDefaultProjectId() { + return defaultProjectId; + } + + public void setDefaultProjectId(String defaultProjectId) { + this.defaultProjectId = defaultProjectId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean getEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + +} diff --git a/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Users.java b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Users.java new file mode 100644 index 000000000..c7af1899b --- /dev/null +++ b/keystone-model/src/main/java/com/woorea/openstack/keystone/v3/model/Users.java @@ -0,0 +1,36 @@ +package com.woorea.openstack.keystone.v3.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import com.woorea.openstack.keystone.model.User; + +public class Users implements Iterable, Serializable { + + @JsonProperty("users") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Users [list=" + list + "]"; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/nova-client/pom.xml b/nova-client/pom.xml index 1b3ca447b..1338768e9 100644 --- a/nova-client/pom.xml +++ b/nova-client/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT nova-client OpenStack Nova Client @@ -12,12 +12,12 @@ com.woorea openstack-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT com.woorea nova-model - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT \ No newline at end of file diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/Nova.java b/nova-client/src/main/java/com/woorea/openstack/nova/Nova.java index d8710d050..0a0988356 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/Nova.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/Nova.java @@ -6,13 +6,17 @@ import com.woorea.openstack.nova.api.ExtensionsResource; import com.woorea.openstack.nova.api.FlavorsResource; import com.woorea.openstack.nova.api.ImagesResource; +import com.woorea.openstack.nova.api.QuotaSetsResource; import com.woorea.openstack.nova.api.ServersResource; +import com.woorea.openstack.nova.api.ServicesResource; +import com.woorea.openstack.nova.api.HypervisorsResource; import com.woorea.openstack.nova.api.extensions.AggregatesExtension; import com.woorea.openstack.nova.api.extensions.FloatingIpsExtension; import com.woorea.openstack.nova.api.extensions.KeyPairsExtension; import com.woorea.openstack.nova.api.extensions.SecurityGroupsExtension; import com.woorea.openstack.nova.api.extensions.SnapshotsExtension; import com.woorea.openstack.nova.api.extensions.VolumesExtension; +import com.woorea.openstack.nova.api.extensions.HostsExtension; public class Nova extends OpenStackClient { @@ -35,6 +39,14 @@ public class Nova extends OpenStackClient { private final VolumesExtension VOLUMES; private final AggregatesExtension AGGREGATES; + + private final QuotaSetsResource QUOTA_SETS; + + private final HostsExtension HOSTS; + + private final ServicesResource SERVICES; + + private final HypervisorsResource HYPERVISORS; public Nova(String endpoint, OpenStackClientConnector connector) { super(endpoint, connector); @@ -48,6 +60,10 @@ public Nova(String endpoint, OpenStackClientConnector connector) { SNAPSHOTS = new SnapshotsExtension(this); VOLUMES = new VolumesExtension(this); AGGREGATES = new AggregatesExtension(this); + QUOTA_SETS = new QuotaSetsResource(this); + HOSTS = new HostsExtension(this); + SERVICES = new ServicesResource(this); + HYPERVISORS = new HypervisorsResource(this); } public Nova(String endpoint) { @@ -90,4 +106,24 @@ public VolumesExtension volumes() { return VOLUMES; } + public AggregatesExtension aggregates() { + return AGGREGATES; + } + + public QuotaSetsResource quotaSets() { + return QUOTA_SETS; + } + + public HostsExtension hosts() { + return HOSTS; + } + + public ServicesResource services() { + return SERVICES; + } + + public HypervisorsResource hypervisors() { + return HYPERVISORS; + } + } diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/ExtensionsResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/ExtensionsResource.java index 46e16c440..148ec40db 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/ExtensionsResource.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/ExtensionsResource.java @@ -21,7 +21,7 @@ public List list(boolean detail) { public class List extends OpenStackRequest { public List(boolean detail) { - super(CLIENT, HttpMethod.GET, detail ? "extensions/detail" : "extensions", null, Extensions.class); + super(CLIENT, HttpMethod.GET, detail ? buildPath("extensions", "detail") : buildPath("extensions"), null, Extensions.class); } } diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/HypervisorsResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/HypervisorsResource.java new file mode 100644 index 000000000..fe09d0e1d --- /dev/null +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/HypervisorsResource.java @@ -0,0 +1,36 @@ +package com.woorea.openstack.nova.api; + +import java.util.HashMap; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.nova.model.Hypervisor; +import com.woorea.openstack.nova.model.Hypervisors; + +/** + * Model for HypervisorsResource + * + */ + +public class HypervisorsResource { + + private final OpenStackClient CLIENT; + + public HypervisorsResource(OpenStackClient client) { + this.CLIENT = client; + } + + public List list() { + return new List(); + } + + public class List extends OpenStackRequest { + + public List() { + super(CLIENT, HttpMethod.GET, "/os-hypervisors", null, Hypervisors.class); + } + } + +} diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/QuotaSetsResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/QuotaSetsResource.java new file mode 100644 index 000000000..166fb42e3 --- /dev/null +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/QuotaSetsResource.java @@ -0,0 +1,61 @@ +package com.woorea.openstack.nova.api; + + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.nova.model.Limits; +import com.woorea.openstack.nova.model.QuotaSet; +import com.woorea.openstack.nova.model.SimpleTenantUsage; + +public class QuotaSetsResource { + + private final OpenStackClient CLIENT; + + public QuotaSetsResource(OpenStackClient client) { + CLIENT = client; + } + + public ShowQuota showQuota(String tenantId) { + return new ShowQuota(tenantId); + } + + public UpdateQuota updateQuota(String tenantId, QuotaSet quotaSet) { + return new UpdateQuota(tenantId, quotaSet); + } + + public ShowUsage showUsage(String tenantId) { + return new ShowUsage(tenantId); + } + + public ShowUsedLimits showUsedLimits() { + return new ShowUsedLimits(); + } + + public class ShowQuota extends OpenStackRequest { + public ShowQuota(String tenantId) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/os-quota-sets/").append(tenantId), null, QuotaSet.class); + } + + } + + public class UpdateQuota extends OpenStackRequest { + public UpdateQuota(String tenantId, QuotaSet quotaSet) { + super(CLIENT, HttpMethod.PUT, new StringBuilder("/os-quota-sets/").append(tenantId), Entity.json(quotaSet), QuotaSet.class); + } + } + + public class ShowUsage extends OpenStackRequest { + public ShowUsage(String tenantId) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/os-simple-tenant-usage/").append(tenantId), null, SimpleTenantUsage.class); + } + } + + public class ShowUsedLimits extends OpenStackRequest { + public ShowUsedLimits() { + super(CLIENT, HttpMethod.GET, new StringBuilder("/limits"), null, Limits.class); + } + } +} + diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/ServersResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/ServersResource.java index 1a0ad8097..2abf392c0 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/ServersResource.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/ServersResource.java @@ -1,6 +1,8 @@ package com.woorea.openstack.nova.api; +import java.util.Map; + import com.woorea.openstack.base.client.Entity; import com.woorea.openstack.base.client.HttpMethod; import com.woorea.openstack.base.client.OpenStackClient; @@ -33,79 +35,114 @@ import com.woorea.openstack.nova.model.ServerForCreate; import com.woorea.openstack.nova.model.Servers; import com.woorea.openstack.nova.model.VolumeAttachment; +import com.woorea.openstack.nova.model.VolumeAttachments; public class ServersResource { - + private final OpenStackClient CLIENT; - + public ServersResource(OpenStackClient client) { CLIENT = client; } - + public List list(boolean detail) { return new List(detail); } - + public Boot boot(ServerForCreate server) { return new Boot(server); } - + public Show show(String id) { return new Show(id); } - + public ShowMetadata showMetadata(String id) { return new ShowMetadata(id); } - + public CreateOrUpdateMetadata createOrUpdateMetadata(String id,Metadata metadata) { + return new CreateOrUpdateMetadata(id,metadata); + } + + public ReplaceMetadata replaceMetadata(String id,Metadata metadata) { + return new ReplaceMetadata(id,metadata); + } + public DeleteMetadata deleteMetadata(String id, String key) { + return new DeleteMetadata(id,key); + } + public Delete delete(String id) { return new Delete(id); } public class List extends OpenStackRequest { - + public List(boolean detail) { super(CLIENT, HttpMethod.GET, detail ? "/servers/detail" : "/servers", null, Servers.class); } } - + public class Boot extends OpenStackRequest { private ServerForCreate server; - + public Boot(ServerForCreate server) { super(CLIENT, HttpMethod.POST, "/servers", Entity.json(server), Server.class); this.server = server; } - + } - + public class Show extends OpenStackRequest { - + public Show(String id) { super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(id), null, Server.class); } } - + public class ShowMetadata extends OpenStackRequest { - + public ShowMetadata(String id) { super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(id).append("/metadata"), null, Metadata.class); } } + public class CreateOrUpdateMetadata extends OpenStackRequest { + + public CreateOrUpdateMetadata(String id,Metadata metadata) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/metadata"), Entity.json(metadata), Metadata.class); + } + + } + public class ReplaceMetadata extends OpenStackRequest { + + public ReplaceMetadata(String id,Metadata metadata) { + super(CLIENT, HttpMethod.PUT, new StringBuilder("/servers/").append(id).append("/metadata"), Entity.json(metadata), Metadata.class); + } + + } + + public class DeleteMetadata extends OpenStackRequest { + + public DeleteMetadata(String id,String key) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(id).append("/metadata/").append(key), null, Void.class); + } + + } + + public class Delete extends OpenStackRequest { - + public Delete(String id) { super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(id), null, Void.class); } - + } - + public class ShowServerAddresses extends OpenStackRequest { public ShowServerAddresses(String id) { @@ -114,10 +151,10 @@ public ShowServerAddresses(String id) { } - public class UpdateServer extends OpenStackRequest { + public class UpdateServer extends OpenStackRequest { private Server server; - + public UpdateServer(String id, Server server) { super(CLIENT, HttpMethod.PUT, new StringBuilder("/servers/").append(id), Entity.json(server), Server.class); this.server = server; @@ -125,6 +162,14 @@ public UpdateServer(String id, Server server) { } + public UpdateServer update(String serverId, String name, String accessIPv4, String accessIPv6) { + Server server = new Server(); + //server.setName(name); + //server.setAccessIPv4(accessIPv4); + //server.setAccessIPv6(accessIPv6); + return new UpdateServer(serverId, server); + } + public abstract class Action extends OpenStackRequest { public Action(String id, Entity entity, Class returnType) { @@ -142,6 +187,12 @@ public ChangePasswordAction(String id, ChangePassword action) { } } + + public ChangePasswordAction changePassword(String serverId, String adminPass) { + ChangePassword changePassword = new ChangePassword(); + changePassword.setAdminPass(adminPass); + return new ChangePasswordAction(serverId, changePassword); + } public class RebootAction extends Action { @@ -152,7 +203,13 @@ public RebootAction(String id, Reboot action) { } } - + + public RebootAction reboot(String serverId, String rebootType) { + Reboot reboot = new Reboot(); + reboot.setType(rebootType); + return new RebootAction(serverId, reboot); + } + public class RebuildAction extends Action { private Rebuild action; @@ -162,129 +219,139 @@ public RebuildAction(String id, Rebuild action) { } } + + public RebuildAction rebuild(String serverId, Rebuild rebuild) { + return new RebuildAction(serverId, rebuild); + } - public class ResizeAction extends Action { + public class ResizeAction extends Action { private Resize action; public ResizeAction(String id, Resize action) { - super(id, Entity.json(action), Server.class); + super(id, Entity.json(action), Void.class); } } - public class ConfirmResizeAction extends Action { + public ResizeAction resize(String serverId, String flavorId, String diskConfig) { + Resize resize = new Resize(); + resize.setFlavorRef(flavorId); + resize.setDiskConfig(diskConfig); + return new ResizeAction(serverId, resize); + } + + public class ConfirmResizeAction extends Action { public ConfirmResizeAction(String id) { - super(id, Entity.json(new ConfirmResize()), Server.class); + super(id, Entity.json(new ConfirmResize()), Void.class); } } - public class ReverResizeAction extends Action { + public ConfirmResizeAction confirmResize(String serverId) { + return new ConfirmResizeAction(serverId); + } + + public class RevertResizeAction extends Action { - public ReverResizeAction(String id) { + public RevertResizeAction(String id) { super(id, Entity.json(new RevertResize()), Server.class); } } - public class CreateImageAction extends Action { + public RevertResizeAction revertResize(String serverId) { + return new RevertResizeAction(serverId); + } - private CreateImage action; - - public CreateImageAction(String id) { - super(id, Entity.json(new CreateImage()), Server.class); - } + public class CreateImageAction extends Action { + + public CreateImageAction(String id, CreateImage createImage) { + super(id, Entity.json(createImage), Void.class); + } + + } + + public CreateImageAction createImage(String serverId, String name, Map metadata) { + CreateImage createImage = new CreateImage(); + createImage.setName(name); + createImage.setMetadata(metadata); + return new CreateImageAction(serverId, createImage); + } + + public class StartServer extends OpenStackRequest { - } - - // - - public class StartServer extends OpenStackRequest { - private Start action; private String id; - + public StartServer(String id) { - this.id = id; - this.action = new Start(); - - method(HttpMethod.POST); - path("/servers/").path(id).path("/action"); - header("Accept", "application/json"); - json(action); + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Start()), Void.class); } } - - public class StopServer extends OpenStackRequest { - + + public class StopServer extends OpenStackRequest { + private Stop action; private String id; - + public StopServer(String id) { - this.id = id; - this.action = new Stop(); - - method(HttpMethod.POST); - path("/servers/").path(id).path("/action"); - header("Accept", "application/json"); - json(action); + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Stop()), Void.class); } } public StartServer start(String id) { - return new StartServer(id); - } + return new StartServer(id); + } - public StopServer stop(String id) { - return new StopServer(id); - } + public StopServer stop(String id) { + return new StopServer(id); + } + + public class GetVncConsoleServer extends OpenStackRequest { - public class GetVncConsoleServer extends OpenStackRequest { - private GetVncConsole action; private String id; - + public GetVncConsoleServer(String id, GetVncConsole action) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new GetVncConsole()), VncConsole.class); + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), VncConsole.class); } } - + public GetVncConsoleServer getVncConsole(String id, String type) { GetVncConsole action = new GetVncConsole(type); return new GetVncConsoleServer(id, action); } - - public class GetConsoleOutputServer extends OpenStackRequest { - + + public class GetConsoleOutputServer extends OpenStackRequest { + public GetConsoleOutputServer(String id, GetConsoleOutput action) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new GetConsoleOutput()), ConsoleOutput.class); + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), ConsoleOutput.class); } } - + public GetConsoleOutputServer getConsoleOutput(String id, int length) { GetConsoleOutput action = new GetConsoleOutput(length); return new GetConsoleOutputServer(id, action); } - - public class PauseServer extends OpenStackRequest { - + + public class PauseServer extends OpenStackRequest { + public PauseServer(String id) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Pause()), Void.class); } } - - public class UnpauseServer extends OpenStackRequest { - + + public class UnpauseServer extends OpenStackRequest { + public UnpauseServer(String id) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unpause()), Void.class); } @@ -292,163 +359,183 @@ public UnpauseServer(String id) { } - public class LockServer extends OpenStackRequest { - + public class LockServer extends OpenStackRequest { + private Lock action; private String id; - + public LockServer(String id) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Lock()), Void.class); } } - public class UnlockServer extends OpenStackRequest { - + public class UnlockServer extends OpenStackRequest { + private Unlock action; private String id; - + public UnlockServer(String id) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unlock()), Void.class); } } - public class SuspendServer extends OpenStackRequest { - + public class SuspendServer extends OpenStackRequest { + public SuspendServer(String id) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Suspend()), Void.class); } } - public class ResumeServer extends OpenStackRequest { - + public class ResumeServer extends OpenStackRequest { + public ResumeServer(String id) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Resume()), Void.class); } } - public class CreateBackupServer extends OpenStackRequest { - + public class CreateBackupServer extends OpenStackRequest { + public CreateBackupServer(String id, CreateBackup action) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); } } - + public PauseServer pause(String serverId) { return new PauseServer(serverId); } - + public UnpauseServer unpause(String serverId) { return new UnpauseServer(serverId); } - + public LockServer lock(String serverId) { return new LockServer(serverId); } - + public UnlockServer unlock(String serverId) { return new UnlockServer(serverId); } - + public SuspendServer suspend(String serverId) { return new SuspendServer(serverId); } - + public ResumeServer resume(String serverId) { return new ResumeServer(serverId); } - + public CreateBackupServer createBackup(String serverId, CreateBackup action) { return new CreateBackupServer(serverId, action); } - - public class RescueServer extends OpenStackRequest { - + + public class RescueServer extends OpenStackRequest { + public RescueServer(String id, Rescue action) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); } } - public class UnrescueServer extends OpenStackRequest { - + public class UnrescueServer extends OpenStackRequest { + public UnrescueServer(String id) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(new Unrescue()), Void.class); } - + } - + public RescueServer rescue(String serverId, String adminPass) { Rescue action = new Rescue(adminPass); return new RescueServer(serverId, action); } - + public UnrescueServer unrescue(String serverId) { return new UnrescueServer(serverId); } - - public class AssociateFloatingIp extends OpenStackRequest { - + + public class AssociateFloatingIp extends OpenStackRequest { + public AssociateFloatingIp(String id, com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp action) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); } } - - public class DisassociateFloatingIp extends OpenStackRequest { - + + public class DisassociateFloatingIp extends OpenStackRequest { + public DisassociateFloatingIp(String id, com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp action) { super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(id).append("/action"), Entity.json(action), Void.class); } } - + public AssociateFloatingIp associateFloatingIp(String serverId, String floatingIpAddress) { com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp action = new com.woorea.openstack.nova.model.ServerAction.AssociateFloatingIp(floatingIpAddress); return new AssociateFloatingIp(serverId, action); } - + public DisassociateFloatingIp disassociateFloatingIp(String serverId, String floatingIpAddress) { com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp action = new com.woorea.openstack.nova.model.ServerAction.DisassociateFloatingIp(floatingIpAddress); return new DisassociateFloatingIp(serverId, action); } - + public class AttachVolume extends OpenStackRequest { - - public AttachVolume(String serverId, final String volumeId, final String device) { - super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments"), Entity.json(new VolumeAttachment() {{ - setVolumeId(volumeId); - setDevice(device); - }}), Void.class); + + public AttachVolume(String serverId, final VolumeAttachment volumeAttachment) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments"), Entity.json(volumeAttachment), Void.class); } } - + public class DetachVolume extends OpenStackRequest { - - private String serverId; - - private String volumeId; - + public DetachVolume(String serverId, String volumeId) { - super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments").append(volumeId), null, Void.class); + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments/").append(volumeId), null, Void.class); + } + + } + + public class ListVolumeAttachments extends OpenStackRequest { + + public ListVolumeAttachments(String serverId) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments"), null, VolumeAttachments.class); + } + + } + + public class ShowVolumeAttachment extends OpenStackRequest { + + public ShowVolumeAttachment(String serverId, String volumeAttachmentId) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/servers/").append(serverId).append("/os-volume_attachments/").append(volumeAttachmentId), null, VolumeAttachment.class); } } public AttachVolume attachVolume(String serverId, String volumeId, String device) { - return new AttachVolume(serverId, volumeId, device); + VolumeAttachment volumeAttachment = new VolumeAttachment(); + volumeAttachment.setVolumeId(volumeId); + volumeAttachment.setDevice(device); + return new AttachVolume(serverId, volumeAttachment); } - + public DetachVolume detachVolume(String serverId, String volumeId) { return new DetachVolume(serverId, volumeId); } - + + public ListVolumeAttachments listVolumeAttachments(String serverId) { + return new ListVolumeAttachments(serverId); + } + + public ShowVolumeAttachment showVolumeAttachment(String serverId, String volumeAttachmentId) { + return new ShowVolumeAttachment(serverId, volumeAttachmentId); + } + } diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/ServicesResource.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/ServicesResource.java new file mode 100644 index 000000000..c320f4a04 --- /dev/null +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/ServicesResource.java @@ -0,0 +1,60 @@ +package com.woorea.openstack.nova.api; + +import java.util.HashMap; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.nova.model.Service; +import com.woorea.openstack.nova.model.Services; + +/** + * Model for ServicesResource + * + */ + +public class ServicesResource { + + private final OpenStackClient CLIENT; + + public ServicesResource(OpenStackClient client) { + this.CLIENT = client; + } + + public List list() { + return new List(); + } + + public Enable enable(String host, String binary) { + return new Enable(host, binary); + } + + public Disable disable(String host, String binary) { + return new Disable(host, binary); + } + + public class List extends OpenStackRequest { + + public List() { + super(CLIENT, HttpMethod.GET, "/os-services", null, Services.class); + } + } + + public class Enable extends OpenStackRequest { + + public Enable(final String host, final String binary) { + super(CLIENT, HttpMethod.PUT, "/os-services/enable", + Entity.json(new HashMap() {{ put("host", host); put("binary", binary); }}), Void.class); + } + } + + public class Disable extends OpenStackRequest { + + public Disable(final String host, final String binary) { + super(CLIENT, HttpMethod.PUT, "/os-services/disable", + Entity.json(new HashMap() {{ put("host", host); put("binary", binary); }}), Void.class); + } + } + +} diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/AggregatesExtension.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/AggregatesExtension.java index fc6d6aaa0..fa757aff3 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/AggregatesExtension.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/AggregatesExtension.java @@ -3,6 +3,7 @@ import java.util.Map; +import com.woorea.openstack.base.client.Entity; import com.woorea.openstack.base.client.HttpMethod; import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; @@ -26,8 +27,13 @@ public ShowAggregate showAggregate(String id) { } public UpdateAggregateMetadata updateAggregateMetadata(String id, - Map metadata) { - return new UpdateAggregateMetadata(id, metadata); + String name, String availabilityZone) { + return new UpdateAggregateMetadata(id, name, availabilityZone); + } + + public CreateAggregate createAggregate(String aggregateName, + String availabilityZoneName) { + return new CreateAggregate(aggregateName, availabilityZoneName); } public DeleteAggregate deleteAggregate(String id) { @@ -42,11 +48,17 @@ public RemoveHost removeHost(String aggregateId, String hostId) { return new RemoveHost(hostId, aggregateId); } - public class List extends OpenStackRequest { + public SetMetadata setMetadata(String aggregateId, + String key, String value) { + return new SetMetadata(aggregateId, key, value); + } + public class List extends OpenStackRequest { public List() { - super(CLIENT, HttpMethod.GET, "/os-aggregates", null, HostAggregates.class); + super(CLIENT, HttpMethod.GET, "/os-aggregates", + null, + HostAggregates.class); } } @@ -54,29 +66,48 @@ public List() { public class ShowAggregate extends OpenStackRequest { public ShowAggregate(String id) { - method(HttpMethod.GET); - path("/os-aggregates/").path(id); - header("Accept", "application/json"); - returnType(HostAggregate.class); + super(CLIENT, HttpMethod.GET, + new StringBuffer("/os-aggregates/").append(id), + null, + HostAggregate.class); } } public class UpdateAggregateMetadata extends OpenStackRequest { + public UpdateAggregateMetadata(String id, + String name, String availabilityZone) { + super(CLIENT, HttpMethod.PUT, + new StringBuffer("/os-aggregates/").append(id), + availabilityZone == null ? + Entity.json("{\"aggregate\": {\"name\": \"" + name + "\" }}") + : + Entity.json("{\"aggregate\": {\"name\": \"" + + name + + "\", \"availability_zone\": \"" + + availabilityZone + + "\" }}"), + HostAggregate.class); + } - private String id; - - private Map metadata; + } - public UpdateAggregateMetadata(String id, Map metadata) { - this.id = id; - this.metadata = metadata; - - method(HttpMethod.POST); - path("/os-aggregates/").path(id); - header("Accept", "application/json"); - json("{\"set_metadata\" : }"); - returnType(HostAggregate.class); + public class CreateAggregate extends OpenStackRequest { + + public CreateAggregate(String name, String availabilityZone) { + super(CLIENT, HttpMethod.POST, + new StringBuffer("/os-aggregates"), + availabilityZone == null ? + Entity.json("{\"aggregate\": {\"name\": \"" + + name + + "\", \"availability_zone\": null }}") + : + Entity.json("{\"aggregate\": {\"name\": \"" + + name + + "\", \"availability_zone\": \"" + + availabilityZone + + "\" }}"), + HostAggregate.class); } } @@ -84,40 +115,49 @@ public UpdateAggregateMetadata(String id, Map metadata) { public class DeleteAggregate extends OpenStackRequest { public DeleteAggregate(String id) { - method(HttpMethod.DELETE); - path("/os-aggregates/").path(id); - header("Accept", "application/json"); + super(CLIENT, HttpMethod.DELETE, + new StringBuffer("/os-aggregates/").append(id), + null, + null); } - } - public static class AddHost extends OpenStackRequest { - - private String aggregateId; - - private String hostId; + public class AddHost extends OpenStackRequest { public AddHost(String aggregateId, String hostId) { - this.aggregateId = aggregateId; - this.hostId = hostId; - // target.path("os-aggregates").request(MediaType.APPLICATION_JSON).post(Entity.json("{\"add_host\" : }")); + super(CLIENT, HttpMethod.POST, + new StringBuffer("/os-aggregates/") + .append(aggregateId).append("/action"), + Entity.json("{\"add_host\": {\"host\": \"" + + hostId + "\" }}"), + HostAggregate.class); } } - public class RemoveHost extends OpenStackRequest { - - private String aggregateId; - - private String hostId; + public class RemoveHost extends OpenStackRequest { public RemoveHost(String hostId, String aggregateId) { - this.aggregateId = aggregateId; - this.hostId = hostId; - // target.path("os-aggregates").path("aggregate").path("os-volume-attachments").request(MediaType.APPLICATION_JSON).post(Entity.json("{\"remove_host\" : }")); - + super(CLIENT, HttpMethod.POST, + new StringBuffer("/os-aggregates/") + .append(aggregateId).append("/action"), + Entity.json("{\"remove_host\": {\"host\": \"" + + hostId + "\" }}"), + HostAggregate.class); } } + public class SetMetadata extends OpenStackRequest { + + public SetMetadata(String aggregateId, String key, String value) { + super(CLIENT, HttpMethod.POST, + new StringBuffer("/os-aggregates/") + .append(aggregateId).append("/action"), + Entity.json("{\"set_metadata\": {\"metadata\": { \"" + + key + "\": \"" + value + "\" }}}"), + HostAggregate.class); + } + } } + diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/FloatingIpsExtension.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/FloatingIpsExtension.java index 0a1e293dd..0923b7e81 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/FloatingIpsExtension.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/FloatingIpsExtension.java @@ -4,6 +4,7 @@ import java.util.Map; +import com.woorea.openstack.base.client.Entity; import com.woorea.openstack.base.client.HttpMethod; import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; @@ -28,15 +29,8 @@ public List() { public class Allocate extends OpenStackRequest { - private Map body; - - public Allocate(String pool) { - super(CLIENT, HttpMethod.POST, "/os-floating-ips", null, FloatingIp.class); - body = new HashMap(); - if(pool != null) { - body.put("pool", pool); - } - entity(body, "application/json"); + public Allocate(Entity entity) { + super(CLIENT, HttpMethod.POST, "/os-floating-ips", entity, FloatingIp.class); } } @@ -54,7 +48,13 @@ public List list() { } public Allocate allocate(String pool) { - return new Allocate(pool); + Entity entity=null; + if(pool!=null) { + Map body = new HashMap(); + body.put("pool", pool); + entity=Entity.json(body); + } + return new Allocate(entity); } public Deallocate deallocate(String id) { @@ -64,3 +64,4 @@ public Deallocate deallocate(String id) { } + diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/SecurityGroupsExtension.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/SecurityGroupsExtension.java index 37117db33..58dfa4f8d 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/SecurityGroupsExtension.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/SecurityGroupsExtension.java @@ -39,17 +39,32 @@ public Create(SecurityGroupForCreate securityGroupForCreate) { public class Show extends OpenStackRequest { + /** + * @deprecated + * @param id + */ public Show(Integer id) { super(CLIENT, HttpMethod.GET, new StringBuilder("/os-security-groups/").append(id).toString(), null, SecurityGroup.class); } + public Show(String id) { + super(CLIENT, HttpMethod.GET, new StringBuilder("/os-security-groups/").append(id).toString(), null, SecurityGroup.class); + } } public class Delete extends OpenStackRequest { + /** + * + * @param id + * @deprecated + */ public Delete(Integer id) { super(CLIENT, HttpMethod.DELETE, new StringBuilder("/os-security-groups/").append(String.valueOf(id)).toString(), null, Void.class); } + public Delete(String id) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/os-security-groups/").append(id).toString(), null, Void.class); + } } @@ -65,9 +80,18 @@ public CreateRule(SecurityGroupRuleForCreate securityGroupRuleForCreate) { public class DeleteRule extends OpenStackRequest { + /** + * + * @param id + * @deprecated + */ public DeleteRule(Integer id) { super(CLIENT, HttpMethod.DELETE, new StringBuilder("/os-security-group-rules/").append(String.valueOf(id)).toString(), null, Void.class); } + + public DeleteRule(String id) { + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/os-security-group-rules/").append(String.valueOf(id)).toString(), null, Void.class); + } } public List listSecurityGroups() { @@ -84,13 +108,30 @@ public Create createSecurityGroup(String name) { } public Show showSecurityGroup(Integer id) { + return new Show(String.valueOf(id)); + } + + public Show showSecurityGroup(String id) { return new Show(id); } - public Delete deleteSecurityGroup(Integer id) { + return new Delete(String.valueOf(id)); + } + + public Delete deleteSecurityGroup(String id) { return new Delete(id); } + /** + * + * @param parentSecurityGroupId + * @param ipProtocol + * @param fromPort + * @param toPort + * @param cidr + * @return + * @deprecated Use {@link #createSecurityGroupRule(String, String, Integer, Integer, String)} + */ public CreateRule createSecurityGroupRule( Integer parentSecurityGroupId, String ipProtocol, Integer fromPort, Integer toPort, String cidr) { @@ -98,7 +139,16 @@ public CreateRule createSecurityGroupRule( parentSecurityGroupId, ipProtocol, fromPort, toPort, cidr); return new CreateRule(securityGroupRuleForCreate); } - + /** + * + * @param parentSecurityGroupId + * @param ipProtocol + * @param fromPort + * @param toPort + * @param sourceGroupId + * @return + * @deprecated Use {@link #createSecurityGroupRule(String, String, String, Integer, Integer)} + */ public CreateRule createSecurityGroupRule( Integer parentSecurityGroupId, String ipProtocol, Integer fromPort, Integer toPort, Integer sourceGroupId) { @@ -107,9 +157,28 @@ public CreateRule createSecurityGroupRule( sourceGroupId); return new CreateRule(securityGroupRuleForCreate); } + + public CreateRule createSecurityGroupRule( + String parentSecurityGroupId, String ipProtocol, Integer fromPort, + Integer toPort, String cidr) { + SecurityGroupRuleForCreate securityGroupRuleForCreate = new SecurityGroupRuleForCreate( + parentSecurityGroupId, ipProtocol, fromPort, toPort, cidr); + return new CreateRule(securityGroupRuleForCreate); + } - public DeleteRule deleteSecurityGroupRule(Integer id) { + public CreateRule createSecurityGroupRule( + String parentSecurityGroupId,String sourceGroupId,String ipProtocol, Integer fromPort, + Integer toPort) { + SecurityGroupRuleForCreate securityGroupRuleForCreate = new SecurityGroupRuleForCreate( + parentSecurityGroupId, sourceGroupId,ipProtocol, fromPort, toPort + ); + return new CreateRule(securityGroupRuleForCreate); + } + public DeleteRule deleteSecurityGroupRule(String id) { return new DeleteRule(id); } + public DeleteRule deleteSecurityGroupRule(Integer id) { + return new DeleteRule(String.valueOf(id)); + } } diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/SnapshotsExtension.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/SnapshotsExtension.java index 0b72f6ad0..62c2542b6 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/SnapshotsExtension.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/SnapshotsExtension.java @@ -7,6 +7,7 @@ import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.nova.model.Metadata; import com.woorea.openstack.nova.model.Snapshot; +import com.woorea.openstack.nova.model.SnapshotForCreate; import com.woorea.openstack.nova.model.Snapshots; public class SnapshotsExtension { @@ -21,8 +22,8 @@ public List list(boolean detail) { return new List(detail); } - public Create create(Snapshot snapshot) { - return new Create(snapshot); + public Create create(SnapshotForCreate snapshotForCreate) { + return new Create(snapshotForCreate); } public Show show(String id) { @@ -46,13 +47,13 @@ public List(boolean detail) { } - public class Create extends OpenStackRequest { + public class Create extends OpenStackRequest { - private Snapshot snapshot; + private SnapshotForCreate snapshotForCreate; - public Create(Snapshot snapshot) { - super(CLIENT, HttpMethod.POST, "/os-snapshots", Entity.json(snapshot), Snapshot.class); - this.snapshot = snapshot; + public Create(SnapshotForCreate snapshotForCreate) { + super(CLIENT, HttpMethod.POST, "/os-snapshots", Entity.json(snapshotForCreate), SnapshotForCreate.class); + this.snapshotForCreate = snapshotForCreate; } } diff --git a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/VolumesExtension.java b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/VolumesExtension.java index c0d30634f..de3557731 100644 --- a/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/VolumesExtension.java +++ b/nova-client/src/main/java/com/woorea/openstack/nova/api/extensions/VolumesExtension.java @@ -1,85 +1,106 @@ package com.woorea.openstack.nova.api.extensions; - import com.woorea.openstack.base.client.Entity; import com.woorea.openstack.base.client.HttpMethod; import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.nova.model.Metadata; import com.woorea.openstack.nova.model.Volume; +import com.woorea.openstack.nova.model.VolumeForCreate; +import com.woorea.openstack.nova.model.VolumeForImageCreate; import com.woorea.openstack.nova.model.Volumes; public class VolumesExtension { - + private final OpenStackClient CLIENT; - + public VolumesExtension(OpenStackClient client) { CLIENT = client; } - + public List list(boolean detail) { return new List(detail); } - - public Create create(Volume volume) { + + public Create create(VolumeForCreate volume) { return new Create(volume); } - + + public UploadToImage uploadToImage(VolumeForImageCreate volumeForImage) { + return new UploadToImage(volumeForImage); + } + public Show show(String id) { return new Show(id); } - + public ShowMetadata showMetadata(String id) { return new ShowMetadata(id); } - public Delete delete(String id) { return new Delete(id); } public class List extends OpenStackRequest { - + public List(boolean detail) { - super(CLIENT, HttpMethod.GET, detail ? "/os-volumes/detail" : "/os-volumes", null, Volumes.class); + super(CLIENT, HttpMethod.GET, detail ? "/os-volumes/detail" + : "/os-volumes", null, Volumes.class); } } - + public class Create extends OpenStackRequest { - private Volume volume; - - public Create(Volume volume) { - super(CLIENT, HttpMethod.POST, "/os-volumes", Entity.json(volume), Volume.class); - this.volume = volume; + // private Volume volume; + + public Create(VolumeForCreate volume) { + super(CLIENT, HttpMethod.POST, "/os-volumes", Entity.json(volume), + Volume.class); + // this.volume = volume; + } + + } + + // Upload volume to image service as image + + public class UploadToImage extends OpenStackRequest { + + public UploadToImage(VolumeForImageCreate volumeForImageCreate) { + super(CLIENT, HttpMethod.POST, new StringBuilder("/volumes/") + .append(volumeForImageCreate.getVolumeId() + "/action"), + Entity.json(volumeForImageCreate), Void.class); } - + } - + public class Show extends OpenStackRequest { - + public Show(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/os-volumes/").append(id).toString(), null, Volume.class); + super(CLIENT, HttpMethod.GET, new StringBuilder("/os-volumes/") + .append(id).toString(), null, Volume.class); } } - + public class ShowMetadata extends OpenStackRequest { - + public ShowMetadata(String id) { - super(CLIENT, HttpMethod.GET, new StringBuilder("/os-volumes/").append(id).append("/metadata").toString(), null, Metadata.class); + super(CLIENT, HttpMethod.GET, new StringBuilder("/os-volumes/") + .append(id).append("/metadata").toString(), null, + Metadata.class); } } - + public class Delete extends OpenStackRequest { - + public Delete(String id) { - super(CLIENT, HttpMethod.DELETE, new StringBuilder("/os-volumes/").append(id).toString(), null, Void.class); + super(CLIENT, HttpMethod.DELETE, new StringBuilder("/os-volumes/") + .append(id).toString(), null, Void.class); } - + } - -} +} diff --git a/nova-model/pom.xml b/nova-model/pom.xml index bfc08faa2..729308bcd 100644 --- a/nova-model/pom.xml +++ b/nova-model/pom.xml @@ -3,8 +3,15 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT + + + javax.xml.bind + jaxb-api + 2.2.12 + + nova-model OpenStack Nova Model OpenStack Nova Model diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Certificate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Certificate.java index b69eb3c60..d93a978e6 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Certificate.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Certificate.java @@ -1,7 +1,7 @@ package com.woorea.openstack.nova.model; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("certificate") public class Certificate { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Cloudpipe.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Cloudpipe.java index 69d1b5a91..ff3e78445 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Cloudpipe.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Cloudpipe.java @@ -3,7 +3,7 @@ import java.io.Serializable; import java.util.Calendar; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("cloudpipe") public class Cloudpipe implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Cloudpipes.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Cloudpipes.java index 3a3f13e01..6d785de12 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Cloudpipes.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Cloudpipes.java @@ -3,7 +3,7 @@ import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Cloudpipes implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Extension.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Extension.java index 20892b78b..0d7176f75 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Extension.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Extension.java @@ -4,7 +4,7 @@ import java.util.Calendar; import java.util.List; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("extension") public class Extension implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Extensions.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Extensions.java index 5d049d997..b8c3bed5f 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Extensions.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Extensions.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Extensions implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Flavor.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Flavor.java index b04472bf6..bdc2dd873 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Flavor.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Flavor.java @@ -3,8 +3,8 @@ import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("flavor") public class Flavor implements Serializable { @@ -13,11 +13,11 @@ public class Flavor implements Serializable { private String name; - private String vcpus; + private Integer vcpus; private Integer ram; - private String disk; + private Integer disk; @JsonProperty("OS-FLV-EXT-DATA:ephemeral") private Integer ephemeral; @@ -72,14 +72,14 @@ public void setName(String name) { /** * @return the vcpus */ - public String getVcpus() { + public Integer getVcpus() { return vcpus; } /** * @param vcpus the vcpus to set */ - public void setVcpus(String vcpus) { + public void setVcpus(Integer vcpus) { this.vcpus = vcpus; } @@ -100,14 +100,14 @@ public void setRam(Integer ram) { /** * @return the disk */ - public String getDisk() { + public Integer getDisk() { return disk; } /** * @param disk the disk to set */ - public void setDisk(String disk) { + public void setDisk(Integer disk) { this.disk = disk; } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/FlavorForCreate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/FlavorForCreate.java index 295096d2a..36d5d5223 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/FlavorForCreate.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/FlavorForCreate.java @@ -3,8 +3,8 @@ import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("flavor") public class FlavorForCreate implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Flavors.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Flavors.java index 0337a3bb5..e95706506 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Flavors.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Flavors.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Flavors implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIp.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIp.java index 3eda923f0..b2e96caa6 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIp.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIp.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("floating_ip") public class FloatingIp implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpDomain.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpDomain.java index 4a6a280e6..806fde611 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpDomain.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpDomain.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("floating-ip-pool") public class FloatingIpDomain implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpDomains.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpDomains.java index 292b59fb4..cd3d544d8 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpDomains.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpDomains.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class FloatingIpDomains implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpPools.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpPools.java index db1c0e3e2..2fc642b63 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpPools.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIpPools.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; import com.woorea.openstack.nova.model.FloatingIpPools.FloatingIpPool; diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIps.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIps.java index 776c4ca8e..93c19a09b 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIps.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/FloatingIps.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class FloatingIps implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Host.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Host.java index 40509642f..2982bbabc 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Host.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Host.java @@ -3,7 +3,7 @@ import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Host implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/HostAggregate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/HostAggregate.java index ec2d1a6f9..4f90e71e4 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/HostAggregate.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/HostAggregate.java @@ -4,10 +4,10 @@ import java.util.List; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; -@JsonRootName("aggreagate") +@JsonRootName("aggregate") public class HostAggregate implements Serializable { private String id; @@ -28,7 +28,7 @@ public class HostAggregate implements Serializable { private Boolean deleted; - private List hosts; + private List hosts; private Map metadata; @@ -84,7 +84,7 @@ public Boolean getDeleted() { /** * @return the hosts */ - public List getHosts() { + public List getHosts() { return hosts; } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/HostAggregates.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/HostAggregates.java index 6810e832e..2d61d4d13 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/HostAggregates.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/HostAggregates.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class HostAggregates implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Hosts.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Hosts.java index 325a73580..35d0b3806 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Hosts.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Hosts.java @@ -4,12 +4,14 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Hosts implements Iterable, Serializable { public static final class Host { + private String zone; + @JsonProperty("host_name") private String hostName; @@ -28,6 +30,14 @@ public String getHostName() { public String getService() { return service; } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } /* (non-Javadoc) * @see java.lang.Object#toString() diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Hypervisor.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Hypervisor.java new file mode 100644 index 000000000..8a60de7d3 --- /dev/null +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Hypervisor.java @@ -0,0 +1,37 @@ +package com.woorea.openstack.nova.model; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +/** + * Model for Hypervisor + * + */ +@JsonRootName("hypervisor") +public class Hypervisor implements Serializable { + + private String id; + private String hypervisor_hostname; + + public String getId() { + return id; + } + + public void setHypervisor_hostname(String hypervisor_hostname) { + this.hypervisor_hostname = hypervisor_hostname; + } + + public String getHypervisor_hostname() { + return hypervisor_hostname; + } + + @Override + public String toString() { + return "Hypervisor {" + + "hypervisor_hostname='" + hypervisor_hostname + + ", id='" + id + + '}'; + } + +} diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Hypervisors.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Hypervisors.java new file mode 100644 index 000000000..8732790e3 --- /dev/null +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Hypervisors.java @@ -0,0 +1,33 @@ +package com.woorea.openstack.nova.model; + +import java.util.Iterator; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model for List of Hypervisors + * + */ +public class Hypervisors implements Iterable { + + @JsonProperty("hypervisors") + private List list; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + + @Override + public String toString() { + return "Hypervisors [list=" + list + "]"; + } +} diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Image.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Image.java index 212169617..a42d6771d 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Image.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Image.java @@ -5,11 +5,38 @@ import java.util.List; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("image") public class Image implements Serializable { + + public static final class Server implements Serializable { + + private String id; + + private List links; + + /** + * @return the id + */ + public String getId() { + return id; + } + + /** + * @return the links + */ + public List getLinks() { + return links; + } + + @Override + public String toString() { + return "Server [id=" + id + ", links=" + links + "]"; + } + + } private String id; @@ -31,6 +58,8 @@ public class Image implements Serializable { private Long size; private Map metadata; + + private Server server; private List links; @@ -166,6 +195,13 @@ public Long getSize() { public void setMetadata(Map metadata) { this.metadata = metadata; } + + /** + * @return the server + */ + public Server getServer() { + return server; + } /** * @return the links @@ -190,7 +226,7 @@ public String toString() { + ", progress=" + progress + ", minRam=" + minRam + ", minDisk=" + minDisk + ", created=" + (created != null ? created.getTime() : null) + ", updated=" + (updated != null ? updated.getTime() : null) + ", size=" + size + ", metadata=" - + metadata + ", links=" + links + "]"; + + metadata + ", server="+server+", links=" + links + "]"; } } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/ImageFromVolume.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/ImageFromVolume.java new file mode 100644 index 000000000..3cd993c8e --- /dev/null +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/ImageFromVolume.java @@ -0,0 +1,112 @@ +package com.woorea.openstack.nova.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("os-volume_upload_image") +public class ImageFromVolume implements Serializable { + + @JsonProperty("id") + String id; + @JsonProperty("updates_at") + String updates_at; + @JsonProperty("status") + String status; + @JsonProperty("display_description") + String display_description; + @JsonProperty("size") + String size; + @JsonProperty("volume_type") + String volume_type; + @JsonProperty("image_id") + String image_id; + @JsonProperty("container_format") + String container_format; + @JsonProperty("disk_format") + String disk_format; + @JsonProperty("image_name") + String image_name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getUpdates_at() { + return updates_at; + } + + public void setUpdates_at(String updates_at) { + this.updates_at = updates_at; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getDisplay_description() { + return display_description; + } + + public void setDisplay_description(String display_description) { + this.display_description = display_description; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + public String getVolume_type() { + return volume_type; + } + + public void setVolume_type(String volume_type) { + this.volume_type = volume_type; + } + + public String getImage_id() { + return image_id; + } + + public void setImage_id(String image_id) { + this.image_id = image_id; + } + + public String getContainer_format() { + return container_format; + } + + public void setContainer_format(String container_format) { + this.container_format = container_format; + } + + public String getDisk_format() { + return disk_format; + } + + public void setDisk_format(String disk_format) { + this.disk_format = disk_format; + } + + public String getImage_name() { + return image_name; + } + + public void setImage_name(String image_name) { + this.image_name = image_name; + } + +} diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Images.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Images.java index e678e9782..e45505272 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Images.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Images.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Images implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/KeyPair.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/KeyPair.java index b2fdb3464..23fa2088e 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/KeyPair.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/KeyPair.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("keypair") public class KeyPair implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/KeyPairs.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/KeyPairs.java index 62f158f73..d7f8730cc 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/KeyPairs.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/KeyPairs.java @@ -5,7 +5,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class KeyPairs implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Limits.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Limits.java index 881115354..5d4e75864 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Limits.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Limits.java @@ -4,27 +4,29 @@ import java.util.Calendar; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("limits") public class Limits implements Serializable { - + public static final class RateLimit implements Serializable { - + public static final class LimitEntry implements Serializable { - + @JsonProperty("next-available") private Calendar nextAvailable; - + private String unit; - + private String verb; - + private Integer remaining; - + private Integer available; + private Integer value; + /** * @return the nextAvailable */ @@ -60,24 +62,31 @@ public Integer getAvailable() { return available; } - /* (non-Javadoc) + /** + * @return the value + */ + public Integer getValue() { + return value; + } + + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override public String toString() { return "LimitEntry [nextAvailable=" + nextAvailable + ", unit=" + unit + ", verb=" + verb + ", remaining=" + remaining - + ", available=" + available + "]"; + + ", available=" + available + ", value=" + value + "]"; } - - - + } - + private String regex; - + private String uri; - + private List limit; /** @@ -101,7 +110,9 @@ public List getLimit() { return limit; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override @@ -109,24 +120,49 @@ public String toString() { return "RateLimit [regex=" + regex + ", uri=" + uri + ", limit=" + limit + "]"; } - + } - - private static final class AbsoluteLimit { - + + public static final class AbsoluteLimit { + private Integer maxServerMeta; - + private Integer serverMetaUsed; + private Integer maxPersonality; - + private Integer personalityUsed; + private Integer maxImageMeta; - + private Integer imageMetaUsed; + private Integer maxPersonalitySize; - + private Integer personalitySizeUsed; + private Integer maxTotalCores; - + private Integer totalCoresUsed; + private Integer maxTotalInstances; - + private Integer totalInstancesUsed; + private Integer maxTotalRAMSize; + private Integer totalRAMUsed; + + private Integer maxSecurityGroupRules; + private Integer securityGroupRulesUsed; + + private Integer maxTotalKeypairs; + private Integer totalKeyPairsUsed; + + private Integer maxTotalVolumes; + private Integer totalVolumesUsed; + + private Integer maxSecurityGroups; + private Integer totalSecurityGroupsUsed; + + private Integer maxTotalFloatingIps; + private Integer totalFloatingIpsUsed; + + private Integer maxTotalVolumeGigabytes; + private Integer totalVolumeGigabytesUsed; /** * @return the maxServerMeta @@ -177,7 +213,142 @@ public Integer getMaxTotalRAMSize() { return maxTotalRAMSize; } - /* (non-Javadoc) + /** + * @return the totalVolumesUsed + */ + public Integer getTotalVolumesUsed() { + return totalVolumesUsed; + } + + /** + * @return the maxSecurityGroupRules + */ + public Integer getMaxSecurityGroupRules() { + return maxSecurityGroupRules; + } + + /** + * @return the maxTotalKeypairs + */ + public Integer getMaxTotalKeypairs() { + return maxTotalKeypairs; + } + + /** + * @return the totalCoresUsed + */ + public Integer getTotalCoresUsed() { + return totalCoresUsed; + } + + /** + * @return the maxTotalVolumes + */ + public Integer getMaxTotalVolumes() { + return maxTotalVolumes; + } + + /** + * @return the totalRAMUsed + */ + public Integer getTotalRAMUsed() { + return totalRAMUsed; + } + + /** + * @return the totalInstancesUsed + */ + public Integer getTotalInstancesUsed() { + return totalInstancesUsed; + } + + /** + * @return the maxSecurityGroups + */ + public Integer getMaxSecurityGroups() { + return maxSecurityGroups; + } + + /** + * @return the totalVolumeGigabytesUsed + */ + public Integer getTotalVolumeGigabytesUsed() { + return totalVolumeGigabytesUsed; + } + + /** + * @return the totalSecurityGroupsUsed + */ + public Integer getTotalSecurityGroupsUsed() { + return totalSecurityGroupsUsed; + } + + /** + * @return the maxTotalFloatingIps + */ + public Integer getMaxTotalFloatingIps() { + return maxTotalFloatingIps; + } + + /** + * @return the totalKeyPairsUsed + */ + public Integer getTotalKeyPairsUsed() { + return totalKeyPairsUsed; + } + + /** + * @return the maxTotalVolumeGigabytes + */ + public Integer getMaxTotalVolumeGigabytes() { + return maxTotalVolumeGigabytes; + } + + /** + * @return the serverMetaUsed + */ + public Integer getServerMetaUsed() { + return serverMetaUsed; + } + + /** + * @return the personalityUsed + */ + public Integer getPersonalityUsed() { + return personalityUsed; + } + + /** + * @return the imageMetaUsed + */ + public Integer getImageMetaUsed() { + return imageMetaUsed; + } + + /** + * @return the personalitySizeUsed + */ + public Integer getPersonalitySizeUsed() { + return personalitySizeUsed; + } + + /** + * @return the securityGroupRulesUsed + */ + public Integer getSecurityGroupRulesUsed() { + return securityGroupRulesUsed; + } + + /** + * @return the totalFloatingIpsUsed + */ + public Integer getTotalFloatingIpsUsed() { + return totalFloatingIpsUsed; + } + + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override @@ -189,11 +360,11 @@ public String toString() { + ", maxTotalInstances=" + maxTotalInstances + ", maxTotalRAMSize=" + maxTotalRAMSize + "]"; } - + } - + private List rate; - + private AbsoluteLimit absolute; /** @@ -210,7 +381,9 @@ public AbsoluteLimit getAbsolute() { return absolute; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Metadata.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Metadata.java index dda327b3a..a3dbffb77 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Metadata.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Metadata.java @@ -12,5 +12,15 @@ public class Metadata { public Map getMetadata() { return metadata; } + + /** + * Set the metadata + * @param metadata + */ + public void setMetadata(Map metadata) { + this.metadata = metadata; + } + + } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Network.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Network.java index 6e82c1d64..e842e3d88 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Network.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Network.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("network") public class Network implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/NetworkForCreate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/NetworkForCreate.java new file mode 100644 index 000000000..d9ce4660a --- /dev/null +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/NetworkForCreate.java @@ -0,0 +1,29 @@ +package com.woorea.openstack.nova.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +public class NetworkForCreate { + + @JsonProperty("uuid") + private String id; + @JsonProperty("fixed_ip") + private String fixedIp; + + public String getId() { + return id; + } + + public String getFixedIp() { + return fixedIp; + } + + public void setId(String id) { + this.id = id; + } + + public void setFixedIp(String fixedIp) { + this.fixedIp = fixedIp; + } + +} diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Networks.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Networks.java index 6e8a94150..3ac070abe 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Networks.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Networks.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Networks implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/QuotaSet.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/QuotaSet.java index d9fe704f4..3f142d66b 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/QuotaSet.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/QuotaSet.java @@ -1,7 +1,7 @@ package com.woorea.openstack.nova.model; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("quota_set") public class QuotaSet { @@ -36,6 +36,12 @@ public class QuotaSet { @JsonProperty("security_group_rules") private Integer securityGroupRules; + @JsonProperty("injected_file_path_bytes") + private Integer injectedFilePathBytes; + + @JsonProperty("key_pairs") + private Integer keyPairs; + public String getId() { return id; } @@ -131,5 +137,20 @@ public Integer getSecurityGroupRules() { public void setSecurityGroupRules(Integer securityGroupRules) { this.securityGroupRules = securityGroupRules; } - -} + + public Integer getKeyPairs() { + return keyPairs; + } + + public void setKeyPairs(Integer keyPairs) { + this.keyPairs = keyPairs; + } + + public Integer getInjectedFilePathBytes() { + return injectedFilePathBytes; + } + + public void setInjectedFilePathBytes(Integer injectedFilePathBytes) { + this.injectedFilePathBytes = injectedFilePathBytes; + } +} \ No newline at end of file diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroup.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroup.java index b065e8e4d..2b7c31747 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroup.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroup.java @@ -3,8 +3,8 @@ import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("security_group") public class SecurityGroup implements Serializable { @@ -49,12 +49,12 @@ public String toString() { } - private Integer id; + private String id; private String name; @JsonProperty("parent_group_id") - private Integer parentGroupId; + private String parentGroupId; @JsonProperty("from_port") private Integer fromPort; @@ -73,7 +73,7 @@ public String toString() { /** * @return the id */ - public Integer getId() { + public String getId() { return id; } @@ -87,7 +87,7 @@ public String getName() { /** * @return the parentGroupId */ - public Integer getParentGroupId() { + public String getParentGroupId() { return parentGroupId; } @@ -139,7 +139,7 @@ public String toString() { } - private Integer id; + private String id; private String name; @@ -155,7 +155,7 @@ public String toString() { /** * @return the id */ - public Integer getId() { + public String getId() { return id; } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupForCreate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupForCreate.java index c3993bbec..17376f6b9 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupForCreate.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupForCreate.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("security_group") public class SecurityGroupForCreate implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupRuleForCreate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupRuleForCreate.java index e8bab735d..12c9851b3 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupRuleForCreate.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroupRuleForCreate.java @@ -4,14 +4,14 @@ import javax.xml.bind.annotation.XmlElement; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("security_group_rule") public class SecurityGroupRuleForCreate implements Serializable { @JsonProperty("parent_group_id") - private Integer parentGroupId; + private String parentGroupId; @JsonProperty("ip_protocol") private String ipProtocol; @@ -26,15 +26,48 @@ public class SecurityGroupRuleForCreate implements Serializable { private String cidr; @JsonProperty("group_id") - private Integer groupId; + private String groupId; public SecurityGroupRuleForCreate() { } - - + /** + * + * @param parentSecurityGroupId + * @param ipProtocol + * @param fromPort + * @param toPort + * @param cidr + * @deprecated Ids in some installs have shown to use strings .Use {@link #SecurityGroupRuleForCreate(String, String, Integer, Integer, String)} + */ + @Deprecated public SecurityGroupRuleForCreate(Integer parentSecurityGroupId, String ipProtocol, Integer fromPort,Integer toPort, String cidr) { + this.parentGroupId = String.valueOf(parentSecurityGroupId); + this.ipProtocol = ipProtocol; + this.fromPort = fromPort; + this.toPort = toPort; + this.cidr = cidr; + } + /** + * + * @param parentGroupId + * @param ipProtocol + * @param fromPort + * @param toPort + * @param sourceGroupId + * @deprecated Ids in some installs have shown to use strings .Use {@link #SecurityGroupRuleForCreate(String, String, String, Integer, Integer)} + */ + @Deprecated + public SecurityGroupRuleForCreate(Integer parentGroupId, String ipProtocol, Integer fromPort,Integer toPort, Integer sourceGroupId) { + this.parentGroupId = String.valueOf(parentGroupId); + this.ipProtocol = ipProtocol; + this.fromPort = fromPort; + this.toPort = toPort; + this.groupId = String.valueOf(sourceGroupId); + } + + public SecurityGroupRuleForCreate(String parentSecurityGroupId, String ipProtocol, Integer fromPort,Integer toPort, String cidr) { this.parentGroupId = parentSecurityGroupId; this.ipProtocol = ipProtocol; this.fromPort = fromPort; @@ -42,7 +75,7 @@ public SecurityGroupRuleForCreate(Integer parentSecurityGroupId, String ipProtoc this.cidr = cidr; } - public SecurityGroupRuleForCreate(Integer parentGroupId, String ipProtocol, Integer fromPort,Integer toPort, Integer sourceGroupId) { + public SecurityGroupRuleForCreate(String parentGroupId, String sourceGroupId, String ipProtocol, Integer fromPort,Integer toPort) { this.parentGroupId = parentGroupId; this.ipProtocol = ipProtocol; this.fromPort = fromPort; @@ -53,14 +86,23 @@ public SecurityGroupRuleForCreate(Integer parentGroupId, String ipProtocol, Inte /** * @return the parentGroupId */ - public Integer getParentGroupId() { + public String getParentGroupId() { return parentGroupId; } - + + /** * @param parentGroupId the parentGroupId to set + * @deprecated Use {@link #setParentGroupId(String)} */ public void setParentGroupId(Integer parentGroupId) { + this.parentGroupId = String.valueOf(parentGroupId); + } + + /** + * @param parentGroupId the parentGroupId to set + */ + public void setParentGroupId(String parentGroupId) { this.parentGroupId = parentGroupId; } @@ -123,14 +165,22 @@ public void setCidr(String cidr) { /** * @return the groupId */ - public Integer getGroupId() { + public String getGroupId() { return groupId; } /** * @param groupId the groupId to set + * @deprecated Use {@link #setGroupId(String)} */ public void setGroupId(Integer groupId) { + this.groupId = String.valueOf(groupId); + } + + /** + * @param groupId the groupId to set + */ + public void setGroupId(String groupId) { this.groupId = groupId; } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroups.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroups.java index 1c8cc5533..84a0096fe 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroups.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/SecurityGroups.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class SecurityGroups implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Server.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Server.java index 48f56052a..229b3329e 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Server.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Server.java @@ -6,9 +6,10 @@ import java.util.List; import java.util.Map; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("server") public class Server implements Serializable { @@ -227,6 +228,15 @@ public String toString() { @JsonProperty("OS-EXT-AZ:availability_zone") private String availabilityZone; + + @JsonProperty("OS-SRV-USG:launched_at") + private String launchedAt; + + @JsonProperty("OS-SRV-USG:terminated_at") + private String terminatedAt; + + @JsonProperty("os-extended-volumes:volumes_attached") + private List osExtendedVolumesAttached; private String uuid; @@ -442,7 +452,28 @@ public String getAvailabilityZone() { return availabilityZone; } - /** + /** + * @return the launchedAt + */ + public String getLaunchedAt() { + return launchedAt; + } + + /** + * @return the terminatedAt + */ + public String getTerminatedAt() { + return terminatedAt; + } + + /** + * @return the osExtendedVolumesAttached + */ + public List getOsExtendedVolumesAttached() { + return osExtendedVolumesAttached; + } + + /** * @return the uuid */ public String getUuid() { @@ -474,7 +505,9 @@ public String toString() { + vmState + ", host=" + host + ", instanceName=" + instanceName + ", hypervisorHostname=" + hypervisorHostname + ", diskConfig=" + diskConfig + ", availabilityZone=" - + availabilityZone + ", uuid=" + uuid + ", adminPass=" + + availabilityZone + ", launchedAt=" + launchedAt + ", terminatedAt=" + + ", " + "osExtendedVolumesAttached=" + osExtendedVolumesAttached + + ", uuid=" + uuid + ", adminPass=" + adminPass + "]"; } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/ServerAction.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/ServerAction.java index 26fa5a4a6..161eb6a76 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/ServerAction.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/ServerAction.java @@ -6,8 +6,8 @@ import java.util.List; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; public interface ServerAction extends Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/ServerForCreate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/ServerForCreate.java index accba8e9d..8b50774a0 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/ServerForCreate.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/ServerForCreate.java @@ -6,19 +6,19 @@ import java.util.List; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("server") public class ServerForCreate implements Serializable { - + public static final class SecurityGroup implements Serializable { - + private String name; public SecurityGroup() { } - + public SecurityGroup(String name) { this.name = name; } @@ -31,51 +31,55 @@ public String getName() { } /** - * @param name the name to set + * @param name + * the name to set */ public void setName(String name) { this.name = name; } - + } - + private String name; - + private String adminPass; - + private String imageRef; - + private String flavorRef; - + private String accessIPv4; - + private String accessIPv6; - + private Integer min; - + private Integer max; - + private String diskConfig; - + @JsonProperty("key_name") private String keyName; - + private List personality = new ArrayList(); - + private Map metadata = new HashMap(); - + @JsonProperty("security_groups") private List securityGroups; - + @JsonProperty("user_data") private String userData; - + @JsonProperty("availability_zone") private String availabilityZone; @JsonProperty("config_drive") private boolean configDrive; + @JsonProperty("networks") + private List networks = new ArrayList(); + /** * @return the name */ @@ -84,7 +88,8 @@ public String getName() { } /** - * @param name the name to set + * @param name + * the name to set */ public void setName(String name) { this.name = name; @@ -98,7 +103,8 @@ public String getAdminPass() { } /** - * @param adminPass the adminPass to set + * @param adminPass + * the adminPass to set */ public void setAdminPass(String adminPass) { this.adminPass = adminPass; @@ -112,7 +118,8 @@ public String getImageRef() { } /** - * @param imageRef the imageRef to set + * @param imageRef + * the imageRef to set */ public void setImageRef(String imageRef) { this.imageRef = imageRef; @@ -126,7 +133,8 @@ public String getFlavorRef() { } /** - * @param flavorRef the flavorRef to set + * @param flavorRef + * the flavorRef to set */ public void setFlavorRef(String flavorRef) { this.flavorRef = flavorRef; @@ -140,7 +148,8 @@ public String getAccessIPv4() { } /** - * @param accessIPv4 the accessIPv4 to set + * @param accessIPv4 + * the accessIPv4 to set */ public void setAccessIPv4(String accessIPv4) { this.accessIPv4 = accessIPv4; @@ -154,7 +163,8 @@ public String getAccessIPv6() { } /** - * @param accessIPv6 the accessIPv6 to set + * @param accessIPv6 + * the accessIPv6 to set */ public void setAccessIPv6(String accessIPv6) { this.accessIPv6 = accessIPv6; @@ -168,7 +178,8 @@ public Integer getMin() { } /** - * @param min the min to set + * @param min + * the min to set */ public void setMin(Integer min) { this.min = min; @@ -182,7 +193,8 @@ public Integer getMax() { } /** - * @param max the max to set + * @param max + * the max to set */ public void setMax(Integer max) { this.max = max; @@ -196,7 +208,8 @@ public String getDiskConfig() { } /** - * @param diskConfig the diskConfig to set + * @param diskConfig + * the diskConfig to set */ public void setDiskConfig(String diskConfig) { this.diskConfig = diskConfig; @@ -210,7 +223,8 @@ public String getKeyName() { } /** - * @param keyName the keyName to set + * @param keyName + * the keyName to set */ public void setKeyName(String keyName) { this.keyName = keyName; @@ -224,7 +238,8 @@ public List getPersonality() { } /** - * @param personality the personality to set + * @param personality + * the personality to set */ public void setPersonality(List personality) { this.personality = personality; @@ -238,7 +253,8 @@ public Map getMetadata() { } /** - * @param metadata the metadata to set + * @param metadata + * the metadata to set */ public void setMetadata(Map metadata) { this.metadata = metadata; @@ -248,12 +264,12 @@ public void setMetadata(Map metadata) { * @return the securityGroups */ public List getSecurityGroups() { - if(securityGroups == null) { + if (securityGroups == null) { securityGroups = new ArrayList(); } return securityGroups; } - + /** * @return the userData */ @@ -262,7 +278,8 @@ public String getUserData() { } /** - * @param userData the userData to set + * @param userData + * the userData to set */ public void setUserData(String userData) { this.userData = userData; @@ -276,7 +293,8 @@ public String getAvailabilityZone() { } /** - * @param availabilityZone the availabilityZone to set + * @param availabilityZone + * the availabilityZone to set */ public void setAvailabilityZone(String availabilityZone) { this.availabilityZone = availabilityZone; @@ -289,4 +307,20 @@ public boolean isConfigDrive() { public void setConfigDrive(boolean configDrive) { this.configDrive = configDrive; } + + public List getNetworks() { + return networks; + } + + public void setNetworks(List networks) { + this.networks = networks; + } + + public void addNetworks(String id, String fixedIp) { + NetworkForCreate net = new NetworkForCreate(); + net.setId(id); + net.setFixedIp(fixedIp); + this.networks.add(net); + } + } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Servers.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Servers.java index a144250dc..e6a5907d1 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Servers.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Servers.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Servers implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Service.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Service.java new file mode 100644 index 000000000..7a673e78e --- /dev/null +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Service.java @@ -0,0 +1,95 @@ +package com.woorea.openstack.nova.model; + +import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +/** + * Model for Service + * + */ +@JsonRootName("service") +public class Service implements Serializable { + + private String status; + private String binary; + private String zone; + private String state; + private String host; + + @JsonProperty("updated_at") + private String updatedAt; + + @JsonProperty("disabled_reason") + private String disabledReason; + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getBinary() { + return binary; + } + + public void setBinary(String binary) { + this.binary = binary; + } + + public String getZone() { + return zone; + } + + public void setZone(String zone) { + this.zone = zone; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(String updatedAt) { + this.updatedAt = updatedAt; + } + + public String getDisabledReason() { + return disabledReason; + } + + public void setDisabledReason(String disabledReason) { + this.disabledReason = disabledReason; + } + + @Override + public String toString() { + return "Service {" + + "host='" + host + + ", state='" + state + + ", status='" + status + + ", zone='" + zone + + ", binary='" + binary + + ", updated_at='" + updatedAt + + ", disabled_reason='" + disabledReason + + '}'; + } + +} diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Services.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Services.java new file mode 100644 index 000000000..797a5fb70 --- /dev/null +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Services.java @@ -0,0 +1,33 @@ +package com.woorea.openstack.nova.model; + +import java.util.Iterator; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Model for List of Services + * + */ +public class Services implements Iterable { + + @JsonProperty("services") + private List list; + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + + @Override + public String toString() { + return "Services [list=" + list + "]"; + } +} diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsage.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsage.java index 1c4423170..31b49a0a9 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsage.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsage.java @@ -2,9 +2,10 @@ import java.io.Serializable; import java.math.BigDecimal; +import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("tenant_usage") public class SimpleTenantUsage implements Serializable { @@ -28,6 +29,9 @@ public class SimpleTenantUsage implements Serializable { @JsonProperty("total_hours") private String totalHours; + @JsonProperty("server_usages") + private List serverUsages; + /** * @return the totalMemoryMbUsage */ @@ -126,6 +130,14 @@ public void setTotalHours(String totalHours) { this.totalHours = totalHours; } + public List getServerUsages() { + return serverUsages; + } + + public void setServerUsages(List serverUsages) { + this.serverUsages = serverUsages; + } + /* (non-Javadoc) * @see java.lang.Object#toString() */ @@ -138,5 +150,83 @@ public String toString() { + ", totalHours=" + totalHours + "]"; } + public static final class ServerUsage implements Serializable { + @JsonProperty("instance_id") + private String instanceId; + + private Integer uptime; + + @JsonProperty("started_at") + private String startedAt; + @JsonProperty("ended_at") + private String endedAt; + + @JsonProperty("memory_mb") + private Integer memoryMb; + + @JsonProperty("tenant_id") + private String tenantId; + + private String state; + + private Double hours; + + private Integer vcpus; + + private String flavor; + + @JsonProperty("local_gb") + private Integer localDiskSize; + + private String name; + + public String getInstanceId() { + return instanceId; + } + + public Integer getUptime() { + return uptime; + } + + public String getStartedAt() { + return startedAt; + } + + public String getEndedAt() { + return endedAt; + } + + public Integer getMemoryMb() { + return memoryMb; + } + + public String getTenantId() { + return tenantId; + } + + public String getState() { + return state; + } + + public Double getHours() { + return hours; + } + + public Integer getVcpus() { + return vcpus; + } + + public String getFlavor() { + return flavor; + } + + public Integer getLocalDiskSize() { + return localDiskSize; + } + + public String getName() { + return name; + } + } } diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsages.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsages.java index 33c46254d..d5b9e9c66 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsages.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/SimpleTenantUsages.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class SimpleTenantUsages implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Snapshot.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Snapshot.java index 06b9c4d76..fb84a1755 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Snapshot.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Snapshot.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("snapshot") public class Snapshot implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/SnapshotForCreate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/SnapshotForCreate.java index 5db392e49..9f90d6bfb 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/SnapshotForCreate.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/SnapshotForCreate.java @@ -2,8 +2,8 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("snapshot") public class SnapshotForCreate implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Snapshots.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Snapshots.java index 006d30cb4..00f45f1e6 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Snapshots.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Snapshots.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Snapshots implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Volume.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Volume.java index d4b7e6e68..7498dcf3b 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Volume.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Volume.java @@ -4,8 +4,8 @@ import java.util.List; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("volume") public class Volume implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeAttachment.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeAttachment.java index 54abc9e82..6db93bbb4 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeAttachment.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeAttachment.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("volumeAttachment") public class VolumeAttachment implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeAttachments.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeAttachments.java new file mode 100644 index 000000000..20f248d85 --- /dev/null +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeAttachments.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.nova.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class VolumeAttachments implements Iterable, Serializable { + + @JsonProperty("volumeAttachments") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "VolumeAttachments [list=" + list + "]"; + } + +} diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeForCreate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeForCreate.java index c4a09a334..1f8f26708 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeForCreate.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeForCreate.java @@ -3,8 +3,8 @@ import java.io.Serializable; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("volume") public class VolumeForCreate implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeForImageCreate.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeForImageCreate.java new file mode 100644 index 000000000..d4ee00646 --- /dev/null +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeForImageCreate.java @@ -0,0 +1,71 @@ +package com.woorea.openstack.nova.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("os-volume_upload_image") +public class VolumeForImageCreate implements Serializable { + String volumeId; + String tenantId; + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + @JsonProperty("force") + private Boolean force; + + public Boolean getForce() { + return force; + } + + public void setForce(Boolean force) { + this.force = force; + } + + @JsonProperty("container_format") + String container_format; + @JsonProperty("disk_format") + String disk_format; + @JsonProperty("image_name") + String image_name; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public String getContainer_format() { + return container_format; + } + + public void setContainer_format(String container_format) { + this.container_format = container_format; + } + + public String getDisk_format() { + return disk_format; + } + + public void setDisk_format(String disk_format) { + this.disk_format = disk_format; + } + + public String getImage_name() { + return image_name; + } + + public void setImage_name(String image_name) { + this.image_name = image_name; + } + +} diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeType.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeType.java index 4c25e4b81..bd1b30efd 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeType.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeType.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; @JsonRootName("volume-type") public class VolumeType implements Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeTypes.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeTypes.java index 42d8162d2..3c51d75c5 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeTypes.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/VolumeTypes.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class VolumeTypes implements Iterable, Serializable { diff --git a/nova-model/src/main/java/com/woorea/openstack/nova/model/Volumes.java b/nova-model/src/main/java/com/woorea/openstack/nova/model/Volumes.java index 349ef874a..de662355c 100644 --- a/nova-model/src/main/java/com/woorea/openstack/nova/model/Volumes.java +++ b/nova-model/src/main/java/com/woorea/openstack/nova/model/Volumes.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Volumes implements Iterable, Serializable { diff --git a/openstack-client-connectors/jersey-connector/pom.xml b/openstack-client-connectors/jersey-connector/pom.xml index aec6a52da..1b2ee1960 100644 --- a/openstack-client-connectors/jersey-connector/pom.xml +++ b/openstack-client-connectors/jersey-connector/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-client-connectors - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT jersey-connector OpenStack Jersey Connector @@ -15,9 +15,9 @@ 1.17.1 - org.codehaus.jackson - jackson-jaxrs - 1.9.12 + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + 2.9.8 diff --git a/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java b/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java index c3615942b..117f64340 100644 --- a/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java +++ b/openstack-client-connectors/jersey-connector/src/main/java/com/woorea/openstack/connector/JerseyConnector.java @@ -7,12 +7,12 @@ import javax.ws.rs.ext.ContextResolver; import javax.ws.rs.ext.Provider; -import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig; -import org.codehaus.jackson.map.annotate.JsonRootName; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.annotation.JsonRootName; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; @@ -78,15 +78,20 @@ public static class OpenStackObjectMapper implements ContextResolver T getEntity(Class returnType) { + if(response.getStatus() >= 400) { + throw new OpenStackResponseException(response.getClientResponseStatus().getReasonPhrase(), + response.getStatus()); + } if(response.hasEntity() && returnType != null && Void.class != returnType) { return response.getEntity(returnType); } else { diff --git a/openstack-client-connectors/jersey2-connector/pom.xml b/openstack-client-connectors/jersey2-connector/pom.xml index 5d89acc0a..e2c45a753 100644 --- a/openstack-client-connectors/jersey2-connector/pom.xml +++ b/openstack-client-connectors/jersey2-connector/pom.xml @@ -4,7 +4,7 @@ com.woorea openstack-client-connectors - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT jersey2-connector OpenStack Jersey2 Connector @@ -17,17 +17,17 @@ org.glassfish.jersey.core jersey-client - 2.0 + 2.6 org.glassfish.jersey.media jersey-media-json-jackson - 2.0 + 2.6 com.woorea openstack-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT diff --git a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Response.java b/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Response.java index 12169042f..ebddd0771 100644 --- a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Response.java +++ b/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/JaxRs20Response.java @@ -7,6 +7,7 @@ import javax.ws.rs.core.Response; import com.woorea.openstack.base.client.OpenStackResponse; +import com.woorea.openstack.base.client.OpenStackResponseException; public class JaxRs20Response implements OpenStackResponse { @@ -18,6 +19,10 @@ public JaxRs20Response(Response response) { @Override public T getEntity(Class returnType) { + if(response.getStatus() >= 400) { + throw new OpenStackResponseException(response.getStatusInfo().getReasonPhrase(), + response.getStatusInfo().getStatusCode()); + } return response.readEntity(returnType); } diff --git a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/OpenStack.java b/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/OpenStack.java index 54d8b5d2f..bb321bfc4 100644 --- a/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/OpenStack.java +++ b/openstack-client-connectors/jersey2-connector/src/main/java/com/woorea/openstack/connector/OpenStack.java @@ -9,13 +9,13 @@ import javax.ws.rs.client.ClientRequestFilter; import javax.ws.rs.ext.ContextResolver; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig; -import org.codehaus.jackson.map.annotate.JsonRootName; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.annotation.JsonRootName; +import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; import org.glassfish.jersey.SslConfigurator; -import org.glassfish.jersey.client.ClientProperties; import org.glassfish.jersey.jackson.JacksonFeature; public class OpenStack { @@ -70,17 +70,21 @@ private static void initialize() { DEFAULT_MAPPER = new ObjectMapper(); - DEFAULT_MAPPER.setSerializationInclusion(Inclusion.NON_NULL); - DEFAULT_MAPPER.enable(SerializationConfig.Feature.INDENT_OUTPUT); - DEFAULT_MAPPER.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + DEFAULT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); + DEFAULT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT); + DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + DEFAULT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); WRAPPED_MAPPER = new ObjectMapper(); - WRAPPED_MAPPER.setSerializationInclusion(Inclusion.NON_NULL); - WRAPPED_MAPPER.enable(SerializationConfig.Feature.INDENT_OUTPUT); - WRAPPED_MAPPER.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); - WRAPPED_MAPPER.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); - WRAPPED_MAPPER.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + WRAPPED_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); + WRAPPED_MAPPER.enable(SerializationFeature.INDENT_OUTPUT); + WRAPPED_MAPPER.enable(SerializationFeature.WRAP_ROOT_VALUE); + WRAPPED_MAPPER.enable(DeserializationFeature.UNWRAP_ROOT_VALUE); + WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + WRAPPED_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); CLIENT.register(new JacksonFeature()).register(new ContextResolver() { diff --git a/openstack-client-connectors/pom.xml b/openstack-client-connectors/pom.xml index de4bb170f..eeb26fb02 100644 --- a/openstack-client-connectors/pom.xml +++ b/openstack-client-connectors/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT openstack-client-connectors OpenStack Client Connectors @@ -42,7 +42,7 @@ com.woorea openstack-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT \ No newline at end of file diff --git a/openstack-client-connectors/resteasy-connector/pom.xml b/openstack-client-connectors/resteasy-connector/pom.xml index 52f2b3bff..be0b2acb5 100644 --- a/openstack-client-connectors/resteasy-connector/pom.xml +++ b/openstack-client-connectors/resteasy-connector/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-client-connectors - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT resteasy-connector OpenStack RESTEasy Connector @@ -12,12 +12,17 @@ org.jboss.resteasy resteasy-jaxrs - 2.3.2.Final + 3.0.26.Final - org.codehaus.jackson - jackson-jaxrs - 1.9.4 + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + 2.9.8 + + org.apache.httpcomponents + httpclient + 4.5.5 + - \ No newline at end of file + diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java index 040f6106d..5e078a344 100644 --- a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java +++ b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyConnector.java @@ -4,18 +4,21 @@ import java.util.Map; import java.util.Map.Entry; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import javax.ws.rs.ext.ContextResolver; - -import org.apache.commons.httpclient.HttpStatus; -import org.codehaus.jackson.jaxrs.JacksonJsonProvider; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.map.SerializationConfig; -import org.codehaus.jackson.map.annotate.JsonRootName; -import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion; +import javax.ws.rs.ext.Provider; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.apache.http.HttpStatus; +import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.annotation.JsonRootName; +import org.jboss.resteasy.client.ClientExecutor; import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientRequestFactory; import org.jboss.resteasy.client.ClientResponse; import org.jboss.resteasy.plugins.providers.InputStreamProvider; import org.jboss.resteasy.spi.ResteasyProviderFactory; @@ -31,42 +34,52 @@ public class RESTEasyConnector implements OpenStackClientConnector { public static ObjectMapper WRAPPED_MAPPER; + @Provider + @Produces(MediaType.APPLICATION_JSON) + static class ObjectMapperContextResolver implements ContextResolver { + public ObjectMapper getContext(Class type) { + return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER; + } + } + private static ResteasyProviderFactory providerFactory; static { DEFAULT_MAPPER = new ObjectMapper(); - DEFAULT_MAPPER.setSerializationInclusion(Inclusion.NON_NULL); - DEFAULT_MAPPER.enable(SerializationConfig.Feature.INDENT_OUTPUT); - DEFAULT_MAPPER.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + DEFAULT_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); + DEFAULT_MAPPER.enable(SerializationFeature.INDENT_OUTPUT); + DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + DEFAULT_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + DEFAULT_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); WRAPPED_MAPPER = new ObjectMapper(); - WRAPPED_MAPPER.setSerializationInclusion(Inclusion.NON_NULL); - WRAPPED_MAPPER.enable(SerializationConfig.Feature.INDENT_OUTPUT); - WRAPPED_MAPPER.enable(SerializationConfig.Feature.WRAP_ROOT_VALUE); - WRAPPED_MAPPER.enable(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); - WRAPPED_MAPPER.enable(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + WRAPPED_MAPPER.setSerializationInclusion(JsonInclude.Include.NON_NULL); + WRAPPED_MAPPER.enable(SerializationFeature.INDENT_OUTPUT); + WRAPPED_MAPPER.enable(SerializationFeature.WRAP_ROOT_VALUE); + WRAPPED_MAPPER.enable(DeserializationFeature.UNWRAP_ROOT_VALUE); + WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + WRAPPED_MAPPER.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); + WRAPPED_MAPPER.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); providerFactory = new ResteasyProviderFactory(); - providerFactory.addContextResolver(new ContextResolver() { - public ObjectMapper getContext(Class type) { - return type.getAnnotation(JsonRootName.class) == null ? DEFAULT_MAPPER : WRAPPED_MAPPER; - } - }); - - JacksonJsonProvider jsonProvider = new JacksonJsonProvider(); - providerFactory.addMessageBodyReader(jsonProvider); - providerFactory.addMessageBodyWriter(jsonProvider); + providerFactory.registerProviderInstance(new JacksonJsonProvider()); + providerFactory.registerProviderInstance(new ObjectMapperContextResolver()); + providerFactory.registerProviderInstance(new InputStreamProvider()); + } - InputStreamProvider streamProvider = new InputStreamProvider(); - providerFactory.addMessageBodyReader(streamProvider); - providerFactory.addMessageBodyWriter(streamProvider); + protected ClientExecutor createClientExecutor() { + return ClientRequest.getDefaultExecutor(); } public OpenStackResponse request(OpenStackRequest request) { - ClientRequest client = new ClientRequest(UriBuilder.fromUri(request.endpoint() + "/" + request.path()), - ClientRequest.getDefaultExecutor(), providerFactory); + String requestPath = request.path(); + if (requestPath != null && requestPath.isEmpty()) { + requestPath = "/"; + } + ClientRequest client = new ClientRequest(UriBuilder.fromUri(request.endpoint() + requestPath), + createClientExecutor(), providerFactory); for(Map.Entry > entry : request.queryParams().entrySet()) { for (Object o : entry.getValue()) { @@ -96,8 +109,9 @@ public OpenStackResponse request(OpenStackRequest request) { if (response.getStatus() == HttpStatus.SC_OK || response.getStatus() == HttpStatus.SC_CREATED - || response.getStatus() == HttpStatus.SC_NO_CONTENT) { - return new RESTEasyResponse(response); + || response.getStatus() == HttpStatus.SC_NO_CONTENT + || response.getStatus() == HttpStatus.SC_ACCEPTED) { + return new RESTEasyResponse(client, response); } response.releaseConnection(); diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java new file mode 100644 index 000000000..913a5000d --- /dev/null +++ b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyInputStream.java @@ -0,0 +1,37 @@ +package com.woorea.openstack.connector; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.SocketException; + +import org.jboss.resteasy.client.ClientExecutor; + + +public class RESTEasyInputStream extends FilterInputStream { + + protected ClientExecutor clientExecutor; + + public RESTEasyInputStream(InputStream inputStream, ClientExecutor clientExecutor) { + super(inputStream); + this.clientExecutor = clientExecutor; + } + + @Override + public void close() throws IOException { + try { + clientExecutor.close(); + } catch (Exception e) { + // Silently skip errors in the socket close errors + } + + try { + super.close(); + } catch (SocketException e) { + // We expect this exception because the socket is closed + } catch (IllegalStateException e) { + // We expect this exception because the socket is closed (httpclient 4.2) + } + } + +} diff --git a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java index 9b7b41e98..269ae13c9 100644 --- a/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java +++ b/openstack-client-connectors/resteasy-connector/src/main/java/com/woorea/openstack/connector/RESTEasyResponse.java @@ -1,5 +1,6 @@ package com.woorea.openstack.connector; +import org.jboss.resteasy.client.ClientRequest; import org.jboss.resteasy.client.ClientResponse; import com.woorea.openstack.base.client.OpenStackResponse; @@ -10,9 +11,12 @@ public class RESTEasyResponse implements OpenStackResponse { + private ClientRequest client; + private ClientResponse response; - public RESTEasyResponse(ClientResponse response) { + public RESTEasyResponse(ClientRequest client, ClientResponse response) { + this.client = client; this.response = response; } @@ -23,24 +27,21 @@ public T getEntity(Class returnType) { @Override public InputStream getInputStream() { - return (InputStream) response.getEntity(InputStream.class); + return new RESTEasyInputStream((InputStream) response.getEntity(InputStream.class), client.getExecutor()); } @Override public String header(String name) { - @SuppressWarnings("unchecked") - MultivaluedMap responseHeaders = response.getHeaders(); - return responseHeaders.getFirst(name); + return response.getHeaders().getFirst(name).toString(); } @Override public Map headers() { Map headers = new HashMap(); + MultivaluedMap responseHeaders = response.getHeaders(); - @SuppressWarnings("unchecked") - MultivaluedMap responseHeaders = response.getHeaders(); for (String key : responseHeaders.keySet()) { - headers.put(key, responseHeaders.getFirst(key)); + headers.put(key, responseHeaders.getFirst(key).toString()); } return headers; diff --git a/openstack-client/pom.xml b/openstack-client/pom.xml index 3ae61cd28..58e160b63 100644 --- a/openstack-client/pom.xml +++ b/openstack-client/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT openstack-client OpenStack Client diff --git a/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackClient.java b/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackClient.java index e0a180d3f..3c8b6cac3 100644 --- a/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackClient.java +++ b/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackClient.java @@ -79,4 +79,8 @@ public void token(String token) { setTokenProvider(new OpenStackSimpleTokenProvider(token)); } + public OpenStackRequest get(String path, Class returnType) { + return new OpenStackRequest(this, HttpMethod.GET, path, null, returnType); + } + } diff --git a/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackRequest.java b/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackRequest.java index 156f55537..5da28bef8 100644 --- a/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackRequest.java +++ b/openstack-client/src/main/java/com/woorea/openstack/base/client/OpenStackRequest.java @@ -8,12 +8,16 @@ import java.util.Map; public class OpenStackRequest { - + private OpenStackClient client; public OpenStackRequest() { } + + public OpenStackRequest(OpenStackClient client, HttpMethod method, String path, Entity entity, Class returnType) { + this(client, method, (CharSequence)path, entity, returnType); + } public OpenStackRequest(OpenStackClient client, HttpMethod method, CharSequence path, Entity entity, Class returnType) { this.client = client; @@ -97,6 +101,10 @@ public Class returnType() { public R execute() { return client.execute(this); } + + public OpenStackResponse request() { + return client.request(this); + } /* (non-Javadoc) * @see java.lang.Object#toString() @@ -129,7 +137,9 @@ public OpenStackRequest queryParam(String key, Object value) { protected static String buildPath(String ... elements) { StringBuilder stringBuilder = new StringBuilder(); + final String PATH_SEPARATOR = "/"; for (String element : elements) { + stringBuilder.append(PATH_SEPARATOR); stringBuilder.append(element); } diff --git a/openstack-console/pom.xml b/openstack-console/pom.xml index c6b9ea5bb..46d735c3e 100644 --- a/openstack-console/pom.xml +++ b/openstack-console/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT openstack-console OpenStack Console @@ -22,12 +22,12 @@ com.woorea keystone-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT com.woorea nova-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT diff --git a/openstack-console/src/main/java/com/woorea/openstack/console/Console.java b/openstack-console/src/main/java/com/woorea/openstack/console/Console.java index 13b7fbfde..0f7ad8446 100644 --- a/openstack-console/src/main/java/com/woorea/openstack/console/Console.java +++ b/openstack-console/src/main/java/com/woorea/openstack/console/Console.java @@ -87,7 +87,8 @@ public String getProperty(String name) { } /** - * @return the properties + * @param name + * @param value */ public void setProperty(String name, Object value) { properties.put(name, value); diff --git a/openstack-examples/pom.xml b/openstack-examples/pom.xml index 238649063..b9bb31134 100644 --- a/openstack-examples/pom.xml +++ b/openstack-examples/pom.xml @@ -3,8 +3,12 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT + + UTF-8 + 3.2.8 + openstack-examples OpenStack Examples OpenStack Examples @@ -12,32 +16,37 @@ com.woorea keystone-client - 3.1.0-SNAPSHOT + ${openstack-sdk.version} com.woorea nova-client - 3.1.0-SNAPSHOT + ${openstack-sdk.version} + + com.woorea + heat-client + ${openstack-sdk.version} + com.woorea swift-client - 3.1.0-SNAPSHOT + ${openstack-sdk.version} com.woorea quantum-client - 3.1.0-SNAPSHOT + ${openstack-sdk.version} com.woorea ceilometer-client - 3.1.0-SNAPSHOT + ${openstack-sdk.version} com.woorea glance-client - 3.1.0-SNAPSHOT + ${openstack-sdk.version} @@ -47,7 +56,7 @@ com.woorea jersey-connector - 3.0.0-SNAPSHOT + ${openstack-sdk.version} @@ -60,7 +69,7 @@ com.woorea jersey2-connector - 3.1.0-SNAPSHOT + ${openstack-sdk.version} @@ -70,9 +79,9 @@ com.woorea resteasy-connector - 3.1.0-SNAPSHOT + ${openstack-sdk.version} - \ No newline at end of file + diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/ExamplesConfiguration.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/ExamplesConfiguration.java index 621c4aadb..056eae52b 100644 --- a/openstack-examples/src/main/java/com/woorea/openstack/examples/ExamplesConfiguration.java +++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/ExamplesConfiguration.java @@ -7,13 +7,13 @@ public class ExamplesConfiguration { - public static final String KEYSTONE_AUTH_URL = "http://identity/v2.0"; + public static final String KEYSTONE_AUTH_URL = "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v3"; public static final String KEYSTONE_USERNAME = ""; public static final String KEYSTONE_PASSWORD = ""; - public static final String KEYSTONE_ENDPOINT = "http://keystone/v2.0"; + public static final String KEYSTONE_ENDPOINT = "https://region-a.geo-1.identity.hpcloudsvc.com:35357/v3"; public static final String TENANT_NAME = "admin"; diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java new file mode 100644 index 000000000..df4d44b7c --- /dev/null +++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/compute/NovaStopStartServer.java @@ -0,0 +1,40 @@ +package com.woorea.openstack.examples.compute; + +import com.woorea.openstack.examples.ExamplesConfiguration; +import com.woorea.openstack.keystone.Keystone; +import com.woorea.openstack.keystone.model.Access; +import com.woorea.openstack.keystone.model.authentication.UsernamePassword; +import com.woorea.openstack.nova.Nova; +import com.woorea.openstack.nova.api.ServersResource; +import com.woorea.openstack.nova.model.Servers; + +public class NovaStopStartServer { + public static void main(String[] args) throws InterruptedException { + Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); + Access access = keystone.tokens().authenticate(new UsernamePassword(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)) + .withTenantName(ExamplesConfiguration.TENANT_NAME) + .execute(); + + //use the token in the following requests + keystone.token(access.getToken().getId()); + + Nova novaClient = new Nova(ExamplesConfiguration.NOVA_ENDPOINT.concat("/").concat(access.getToken().getTenant().getId())); + novaClient.token(access.getToken().getId()); + + Servers servers = novaClient.servers().list(true).execute(); + if(servers.getList().size() > 0) { + + // Server has to be in activated state. + ServersResource.StopServer stopServer = novaClient.servers().stop(servers.getList().get(0).getId()); + stopServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT); + stopServer.execute(); + + // Wait until server shutdown. Or 400 error occurs. + Thread.sleep(5000); + + ServersResource.StartServer startServer = novaClient.servers().start(servers.getList().get(0).getId()); + startServer.endpoint(ExamplesConfiguration.NOVA_ENDPOINT); + startServer.execute(); + } + } +} diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/heat/HeatListStacks.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/heat/HeatListStacks.java new file mode 100644 index 000000000..75178c886 --- /dev/null +++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/heat/HeatListStacks.java @@ -0,0 +1,72 @@ +package com.woorea.openstack.examples.heat; + +import com.woorea.openstack.examples.ExamplesConfiguration; +import com.woorea.openstack.heat.Heat; +import com.woorea.openstack.heat.model.CreateStackParam; +import com.woorea.openstack.heat.model.Stack; +import com.woorea.openstack.keystone.model.Access; +import com.woorea.openstack.keystone.utils.KeystoneTokenProvider; +import com.woorea.openstack.keystone.utils.KeystoneUtils; + +import java.util.Collections; + +public class HeatListStacks { + + private static String TEMPLATE = "{\n" + + " \"HeatTemplateFormatVersion\": \"2012-12-12\",\n" + + " \"Parameters\": {},\n" + + " \"Mappings\": {},\n" + + " \"Resources\": {\n" + + " \"my-test-server\": {\n" + + " \"Type\": \"OS::Nova::Server\",\n" + + " \"Properties\": {\n" + + " \"flavor\": \"m1.small\",\n" + + " \"image\": \"centos:latest\"\n" + + " }\n" + + " }\n" + + " }\n" + + "}"; + + /** + * @param args + */ + public static void main(String[] args) throws InterruptedException { + KeystoneTokenProvider keystone = new KeystoneTokenProvider( + ExamplesConfiguration.KEYSTONE_ENDPOINT, + ExamplesConfiguration.KEYSTONE_USERNAME, + ExamplesConfiguration.KEYSTONE_PASSWORD + ); + + Access access = keystone.getAccessByTenant(ExamplesConfiguration.TENANT_NAME); + + String endpointURL = KeystoneUtils.findEndpointURL(access.getServiceCatalog(), "orchestration", null, "public"); + + + Heat heat = new Heat(endpointURL); + heat.setTokenProvider(keystone + .getProviderByTenant(ExamplesConfiguration.TENANT_NAME)); + + CreateStackParam param = new CreateStackParam(); + param.setStackName("helloWorld"); + param.setTimeoutMinutes(1); + param.setParameters(Collections.emptyMap()); + param.setTemplate(TEMPLATE); + + System.out.printf("Create: " + heat.getStacks().create(param).execute()); + Thread.sleep(3000); + + for (Stack s : heat.getStacks().list().execute()) { + System.out.println(s.getDescription()); + System.out.println(s.getId()); + System.out.println(s.getStackName()); + System.out.println(s.getStackStatus()); + System.out.println(s.getCreationTime()); + System.out.println(s.getUpdatedTime()); + System.out.println(s.getLinks()); + + System.out.println(heat.getStacks().byName(s.getStackName()).execute()); + + + } + } +} diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/Keystone3Authentication.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/Keystone3Authentication.java new file mode 100644 index 000000000..5481a154a --- /dev/null +++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/hpcloud/Keystone3Authentication.java @@ -0,0 +1,34 @@ +package com.woorea.openstack.examples.hpcloud; + + +import com.woorea.openstack.base.client.OpenStackResponse; +import com.woorea.openstack.examples.ExamplesConfiguration; +import com.woorea.openstack.keystone.v3.model.Authentication; +import com.woorea.openstack.keystone.v3.model.Authentication.Identity; +import com.woorea.openstack.keystone.v3.Keystone; +import com.woorea.openstack.keystone.v3.model.Token; + +public class Keystone3Authentication { + + /** + * @param args + */ + public static void main(String[] args) { + Keystone keystone = new Keystone(ExamplesConfiguration.KEYSTONE_AUTH_URL); + + Authentication auth = new Authentication(); + auth.setIdentity(Identity.password(ExamplesConfiguration.KEYSTONE_USERNAME, ExamplesConfiguration.KEYSTONE_PASSWORD)); + + OpenStackResponse response = keystone.tokens().authenticate(auth).request(); + + String tokenId = response.header("X-Subject-Token"); + + Token token = response.getEntity(Token.class); + + System.out.println(tokenId); + + System.out.println(token); + + } + +} diff --git a/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumNetworkCreate.java b/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumNetworkCreate.java new file mode 100644 index 000000000..7f4dff08c --- /dev/null +++ b/openstack-examples/src/main/java/com/woorea/openstack/examples/network/QuantumNetworkCreate.java @@ -0,0 +1,108 @@ +package com.woorea.openstack.examples.network; + +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +import com.woorea.openstack.keystone.utils.KeystoneUtils; + +import com.woorea.openstack.base.client.OpenStackSimpleTokenProvider; +import com.woorea.openstack.examples.ExamplesConfiguration; +import com.woorea.openstack.keystone.Keystone; +import com.woorea.openstack.keystone.model.Access; +import com.woorea.openstack.keystone.model.Tenant; +import com.woorea.openstack.keystone.model.Tenants; +import com.woorea.openstack.keystone.model.authentication.TokenAuthentication; +import com.woorea.openstack.keystone.model.authentication.UsernamePassword; +import com.woorea.openstack.quantum.Quantum; +import com.woorea.openstack.quantum.api.NetworksResource; +import com.woorea.openstack.quantum.api.NetworksResource.Create; +import com.woorea.openstack.quantum.model.Network; +import com.woorea.openstack.quantum.model.NetworkForCreate; +import com.woorea.openstack.quantum.model.Networks; +import com.woorea.openstack.quantum.model.Port; +import com.woorea.openstack.quantum.model.PortForCreate; +import com.woorea.openstack.quantum.model.Router; +import com.woorea.openstack.quantum.model.RouterForAddInterface; +import com.woorea.openstack.quantum.model.RouterForCreate; +import com.woorea.openstack.quantum.model.Subnet; +import com.woorea.openstack.quantum.model.SubnetForCreate; +import com.woorea.openstack.quantum.model.Subnets; + +public class QuantumNetworkCreate { + + /** + * @param args + */ + public static void main(String[] args) { + Keystone keystone = new Keystone( + ExamplesConfiguration.KEYSTONE_AUTH_URL); + // access with unscoped token + Access access = keystone + .tokens() + .authenticate( + new UsernamePassword( + ExamplesConfiguration.KEYSTONE_USERNAME, + ExamplesConfiguration.KEYSTONE_PASSWORD)) + .execute(); + // use the token in the following requests + keystone.setTokenProvider(new OpenStackSimpleTokenProvider(access + .getToken().getId())); + keystone.token(access.getToken().getId()); + Tenants tenants = keystone.tenants().list().execute(); + // try to exchange token using the first tenant + + if (tenants.getList().size() > 0) { + // access with tenant + Network network = new Network(); + access = keystone + .tokens() + .authenticate( + new TokenAuthentication(access.getToken().getId())) + .withTenantId("tenantId").execute(); + Quantum quantum = new Quantum(KeystoneUtils.findEndpointURL( + access.getServiceCatalog(), "network", null, "public")); + quantum.setTokenProvider(new OpenStackSimpleTokenProvider(access + .getToken().getId())); + NetworkForCreate netcreate = new NetworkForCreate(); + netcreate.setTenantId("tenantId"); + netcreate.setName("net2"); + netcreate.setAdminStateUp(true); + + network = quantum.networks().create(netcreate).execute(); + + // Creating Subnet + try { + Subnet sub = new Subnet(); + SubnetForCreate subnet = new SubnetForCreate(); + subnet.setCidr(""); + subnet.setName(""); + subnet.setNetworkId(network.getId()); + subnet.setIpVersion(4); + sub = quantum.subnets().create(subnet).execute(); + RouterForCreate routerForCreate = new RouterForCreate(); + routerForCreate.setName("routerName"); + routerForCreate.setTenantId("tenantId"); + Router router = quantum.routers().create(routerForCreate) + .execute(); + RouterForAddInterface routerForAdd = new RouterForAddInterface(); + routerForAdd.setSubnetId(sub.getId()); + routerForAdd.setRouterId(router.getId()); + quantum.routers().addInterface(routerForAdd).execute(); + + // System.out.println(sub); + } catch (Exception e) { + System.out.println(e.getMessage()); + } + + Networks networks = quantum.networks().list().execute(); + + for (Network network1 : networks) { + System.out.println(network1); + } + } else { + System.out.println("No tenants found!"); + } + + } +} diff --git a/pom.xml b/pom.xml index 352528050..f25f715d4 100644 --- a/pom.xml +++ b/pom.xml @@ -2,15 +2,11 @@ 4.0.0 com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT pom OpenStack Java SDK OpenStack Java SDK - - false - - org.sonatype.oss oss-parent @@ -21,18 +17,22 @@ nova-client glance-client + cinder-client keystone-client swift-client quantum-client openstack-client + heat-client nova-model glance-model + cinder-model keystone-model swift-model quantum-model ceilometer-model ceilometer-client openstack-client-connectors + heat-model @@ -82,9 +82,9 @@ - org.codehaus.jackson - jackson-mapper-asl - 1.9.4 + com.fasterxml.jackson.core + jackson-databind + 2.9.8 @@ -93,30 +93,13 @@ org.apache.maven.plugins maven-compiler-plugin - 3.0 + 3.1 - 1.6 - 1.6 + 1.7 + 1.7 UTF-8 - - org.apache.maven.plugins - maven-gpg-plugin - 1.4 - - ${skip.sign} - - - - sign-artifacts - verify - - sign - - - - org.apache.maven.plugins maven-eclipse-plugin diff --git a/quantum-client/pom.xml b/quantum-client/pom.xml index e0c60ba55..ae3968959 100644 --- a/quantum-client/pom.xml +++ b/quantum-client/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT quantum-client OpenStack Quantum Client @@ -12,12 +12,12 @@ com.woorea openstack-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT com.woorea quantum-model - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java index 0b466a524..ec9c40f97 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java @@ -5,8 +5,10 @@ import com.woorea.openstack.base.client.OpenStackClientConnector; import com.woorea.openstack.quantum.api.NetworksResource; import com.woorea.openstack.quantum.api.PortsResource; +import com.woorea.openstack.quantum.api.RoutersResource; import com.woorea.openstack.quantum.api.SubnetsResource; + public class Quantum extends OpenStackClient { private final NetworksResource NETWORKS; @@ -14,12 +16,15 @@ public class Quantum extends OpenStackClient { private final PortsResource PORTS; private final SubnetsResource SUBNETS; + private final RoutersResource ROUTERS; public Quantum(String endpoint, OpenStackClientConnector connector) { super(endpoint, connector); NETWORKS = new NetworksResource(this); PORTS = new PortsResource(this); SUBNETS = new SubnetsResource(this); + ROUTERS=new RoutersResource(this); + } public Quantum(String endpoint) { @@ -37,5 +42,10 @@ public PortsResource ports() { public SubnetsResource subnets() { return SUBNETS; } + public RoutersResource routers() + { + return ROUTERS; + } + } diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java index 3c79eb026..8b8edeec9 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java @@ -6,7 +6,6 @@ import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.quantum.model.Network; -import com.woorea.openstack.quantum.model.NetworkForCreate; import com.woorea.openstack.quantum.model.Networks; public class NetworksResource { @@ -21,10 +20,14 @@ public List list() { return new List(); } - public Create create(NetworkForCreate net){ + public Create create(Network net) { return new Create(net); } + public Update update(Network net) { + return new Update(net); + } + public Delete delete(String netId){ return new Delete(netId); } @@ -36,7 +39,7 @@ public Show show(String netId){ public class List extends OpenStackRequest { public List() { - super(CLIENT, HttpMethod.GET, "networks", null, Networks.class); + super(CLIENT, HttpMethod.GET, buildPath("networks"), null, Networks.class); } } @@ -53,22 +56,29 @@ public Query(Network network) { public class Create extends OpenStackRequest { - public Create(NetworkForCreate net){ - super(CLIENT, HttpMethod.POST, "networks", Entity.json(net), Network.class); + public Create(Network net) { + super(CLIENT, HttpMethod.POST, buildPath("networks"), Entity.json(net), Network.class); } } + public class Update extends OpenStackRequest { + + public Update(Network net) { + super(CLIENT, HttpMethod.PUT, buildPath("networks", net.getId()), Entity.json(net), Network.class); + } + } + public class Show extends OpenStackRequest { public Show(String id) { - super(CLIENT, HttpMethod.GET, buildPath("networks/", id), null, Network.class); + super(CLIENT, HttpMethod.GET, buildPath("networks", id), null, Network.class); } } public class Delete extends OpenStackRequest { public Delete(String id){ - super(CLIENT, HttpMethod.DELETE, buildPath("networks/", id), null, Void.class); + super(CLIENT, HttpMethod.DELETE, buildPath("networks", id), null, Void.class); } } } diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java index 4e38195b4..b1cac3cc9 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java @@ -6,7 +6,6 @@ import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.quantum.model.Port; -import com.woorea.openstack.quantum.model.PortForCreate; import com.woorea.openstack.quantum.model.Ports; public class PortsResource { @@ -21,22 +20,26 @@ public List list() { return new List(); } - public Create create(PortForCreate net){ - return new Create(net); + public Create create(Port port){ + return new Create(port); } - public Delete delete(String netId){ - return new Delete(netId); + public Update update(Port port){ + return new Update(port); } - public Show show(String netId){ - return new Show(netId); + public Delete delete(String portId){ + return new Delete(portId); + } + + public Show show(String portId){ + return new Show(portId); } public class List extends OpenStackRequest { public List() { - super(CLIENT, HttpMethod.GET, "ports", null, Ports.class); + super(CLIENT, HttpMethod.GET, buildPath("ports"), null, Ports.class); } } @@ -54,22 +57,29 @@ public Query(Port port) { public class Create extends OpenStackRequest { - public Create(PortForCreate port){ - super(CLIENT, HttpMethod.POST, "ports", Entity.json(port), Port.class); + public Create(Port port){ + super(CLIENT, HttpMethod.POST, buildPath("ports"), Entity.json(port), Port.class); } } + public class Update extends OpenStackRequest { + + public Update(Port port){ + super(CLIENT, HttpMethod.PUT, buildPath("ports", port.getId()), Entity.json(port), Port.class); + } + } + public class Show extends OpenStackRequest { public Show(String id) { - super(CLIENT, HttpMethod.GET, buildPath("ports/", id), null, Port.class); + super(CLIENT, HttpMethod.GET, buildPath("ports", id), null, Port.class); } } public class Delete extends OpenStackRequest { public Delete(String id){ - super(CLIENT, HttpMethod.DELETE, buildPath("ports/", id), null, Void.class); + super(CLIENT, HttpMethod.DELETE, buildPath("ports", id), null, Void.class); } } } diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java new file mode 100644 index 000000000..71357097e --- /dev/null +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java @@ -0,0 +1,102 @@ +package com.woorea.openstack.quantum.api; + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.quantum.model.Router; +import com.woorea.openstack.quantum.model.RouterForAddInterface; +import com.woorea.openstack.quantum.model.RouterForCreate; +import com.woorea.openstack.quantum.model.RouterInterface; +import com.woorea.openstack.quantum.model.Routers; + +public class RoutersResource { + + private final OpenStackClient CLIENT; + + public RoutersResource(OpenStackClient client) { + CLIENT = client; + } + + public List list() { + return new List(); + } + + public Create create(RouterForCreate router){ + return new Create(router); + } + + public Delete delete(String netId){ + return new Delete(netId); + } + + public Show show(String netId){ + return new Show(netId); + } + + public class List extends OpenStackRequest { + + public List() { + super(CLIENT, HttpMethod.GET, buildPath("routers"), null, Routers.class); + } + } + + public class Query extends OpenStackRequest { + + public Query(Router router) { + //super(network); +// target = target.path("v2.0").path("networks"); +// target = queryParam(target); +// return target.request(MediaType.APPLICATION_JSON).get(Networks.class); + } + } + public class Create extends OpenStackRequest { + + public Create(RouterForCreate router){ + super(CLIENT, HttpMethod.POST, buildPath("routers"), Entity.json(router), Router.class); + } + } + + + + public class Show extends OpenStackRequest { + + public Show(String id) { + super(CLIENT, HttpMethod.GET, buildPath("routers", id), null, Router.class); + } + } + + public class Delete extends OpenStackRequest { + + public Delete(String id){ + super(CLIENT, HttpMethod.DELETE, buildPath("routers", id), null, Void.class); + } + } + public Attach addInterface(RouterForAddInterface interfaceToAdd){ + return new Attach(interfaceToAdd); + } + public class Attach extends OpenStackRequest { + + public Attach(RouterForAddInterface interfaceToAdd){ + super(CLIENT, HttpMethod.PUT, buildPath("routers",interfaceToAdd.getRouterId(),"add_router_interface"), Entity.json(interfaceToAdd),RouterInterface.class); + } + + } + public Detach deleteInterface(RouterForAddInterface interfaceRouter) { + return new Detach(interfaceRouter); + } + + public class Detach extends OpenStackRequest { + + public Detach(RouterForAddInterface interfaceToAdd) { + super(CLIENT, HttpMethod.PUT, buildPath("routers", + interfaceToAdd.getRouterId(), "remove_router_interface"), + Entity.json(interfaceToAdd), RouterInterface.class); + } + + } + + + + +} diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java index d2d3e157f..3f6f5e5c8 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java @@ -6,7 +6,6 @@ import com.woorea.openstack.base.client.OpenStackClient; import com.woorea.openstack.base.client.OpenStackRequest; import com.woorea.openstack.quantum.model.Subnet; -import com.woorea.openstack.quantum.model.SubnetForCreate; import com.woorea.openstack.quantum.model.Subnets; public class SubnetsResource { @@ -21,10 +20,14 @@ public List list() { return new List(); } - public Create create(SubnetForCreate net){ + public Create create(Subnet net) { return new Create(net); } + public Update update(Subnet net) { + return new Update(net); + } + public Delete delete(String netId){ return new Delete(netId); } @@ -36,7 +39,7 @@ public Show show(String netId){ public class List extends OpenStackRequest { public List() { - super(CLIENT, HttpMethod.GET, "subnets", null, Subnets.class); + super(CLIENT, HttpMethod.GET, buildPath("subnets"), null, Subnets.class); } } @@ -53,22 +56,29 @@ public Query(Subnet subnet) { public class Create extends OpenStackRequest { - public Create(SubnetForCreate subnet){ - super(CLIENT, HttpMethod.POST, "subnets", Entity.json(subnet), Subnet.class); + public Create(Subnet subnet) { + super(CLIENT, HttpMethod.POST, buildPath("subnets"), Entity.json(subnet), Subnet.class); } } + public class Update extends OpenStackRequest { + + public Update(Subnet subnet) { + super(CLIENT, HttpMethod.PUT, buildPath("subnets", subnet.getId()), Entity.json(subnet), Subnet.class); + } + } + public class Show extends OpenStackRequest { public Show(String id) { - super(CLIENT, HttpMethod.GET, buildPath("subnets/", id), null, Subnet.class); + super(CLIENT, HttpMethod.GET, buildPath("subnets", id), null, Subnet.class); } } public class Delete extends OpenStackRequest { public Delete(String id){ - super(CLIENT, HttpMethod.DELETE, buildPath("subnets/", id), null, Void.class); + super(CLIENT, HttpMethod.DELETE, buildPath("subnets", id), null, Void.class); } } } diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java index 8de5abf48..342d9c3f8 100644 --- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java +++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.Map; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; import com.woorea.openstack.base.client.OpenStackRequest; diff --git a/quantum-model/pom.xml b/quantum-model/pom.xml index d8bb39337..a441743df 100644 --- a/quantum-model/pom.xml +++ b/quantum-model/pom.xml @@ -3,9 +3,17 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT quantum-model OpenStack Quantum Model OpenStack Quantum Model + + + junit + junit + 4.11 + test + + diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java new file mode 100644 index 000000000..eddfc3326 --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/GatewayInfo.java @@ -0,0 +1,24 @@ +package com.woorea.openstack.quantum.model; + +import java.util.List; +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class GatewayInfo implements Serializable { + + @JsonProperty("network_id") + private String networkId; + + public String getNetworkId() { + return networkId; + } + + public void setNetworkId(String id) { + this.networkId = id; + } + + @Override public String toString() { + return "[networkId=" + networkId + "]"; + } +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/HostRoute.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/HostRoute.java new file mode 100644 index 000000000..979add34b --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/HostRoute.java @@ -0,0 +1,27 @@ +package com.woorea.openstack.quantum.model; + +import java.io.Serializable; + +public class HostRoute implements Serializable { + + private String destination; + private String nexthop; + + public String getDestination() { + return destination; + } + public void setDestination(String destination) { + this.destination = destination; + } + + public String getNexthop() { + return nexthop; + } + public void setNexthop(String nexthop) { + this.nexthop = nexthop; + } + + @Override public String toString() { + return "[destination=" + destination + ", nexthop=" + nexthop + "]"; + } +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java index b89ecc33c..c79766857 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Network.java @@ -3,241 +3,314 @@ import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +@SuppressWarnings("serial") @JsonRootName("network") @JsonIgnoreProperties(ignoreUnknown = true) -public class Network implements Serializable{ - - private String status; - private List subnets; - private String name; - @JsonProperty("provider:physical_network") - private String providerPhyNet; - @JsonProperty("admin_state_up") - private boolean adminStateUp; - @JsonProperty("tenant_id") - private String tenantId; - @JsonProperty("provider:network_type") - private String netType; - @JsonProperty("router:external") - private String routerExternal; - private String id; - private String shared; - @JsonProperty("provider:segmentation_id") - private String providerSegID; - - - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - - - /** - * @param status the status to set - */ - public void setStatus(String status) { - this.status = status; - } - - - - /** - * @return the subnets - */ - public List getSubnets() { - return subnets; - } - - - - /** - * @param subnets the subnets to set - */ - public void setSubnets(List subnets) { - this.subnets = subnets; - } - - - - /** - * @return the name - */ - public String getName() { - return name; - } - - - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - - - /** - * @return the providerPhyNet - */ - public String getProviderPhyNet() { - return providerPhyNet; - } - - - - /** - * @param providerPhyNet the providerPhyNet to set - */ - public void setProviderPhyNet(String providerPhyNet) { - this.providerPhyNet = providerPhyNet; - } - - - - /** - * @return the adminStateUp - */ - public boolean isAdminStateUp() { - return adminStateUp; - } - - - - /** - * @param adminStateUp the adminStateUp to set - */ - public void setAdminStateUp(boolean adminStateUp) { - this.adminStateUp = adminStateUp; - } - - - - /** - * @return the tenantId - */ - public String getTenantId() { - return tenantId; - } - - - - /** - * @param tenantId the tenantId to set - */ - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - - - /** - * @return the netType - */ - public String getNetType() { - return netType; - } - - - - /** - * @param netType the netType to set - */ - public void setNetType(String netType) { - this.netType = netType; - } - - - - /** - * @return the routerExternal - */ - public String getRouterExternal() { - return routerExternal; - } - - - - /** - * @param routerExternal the routerExternal to set - */ - public void setRouterExternal(String routerExternal) { - this.routerExternal = routerExternal; - } - - - - /** - * @return the id - */ - public String getId() { - return id; - } - - - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - - - /** - * @return the shared - */ - public String getShared() { - return shared; - } - - - - /** - * @param shared the shared to set - */ - public void setShared(String shared) { - this.shared = shared; - } - - - - /** - * @return the providerSegID - */ - public String getProviderSegID() { - return providerSegID; - } - - - - /** - * @param providerSegID the providerSegID to set - */ - public void setProviderSegID(String providerSegID) { - this.providerSegID = providerSegID; - } - - - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Network [id=" + id + ", name=" + name + ", subnets=" - + subnets + ", status=" + status + ", admin_state_up=" + adminStateUp + ", tenant_id=" + - tenantId + ", shared=" + shared + ", provider:physical_network=" + providerPhyNet + - ", provider:network_type=" + netType + ", router:external=" + routerExternal + - ", provider:segmentation_id=" + providerSegID + "]"; - } +public class Network implements Serializable { + + private String status; + + private List subnets; + + private String name; + + @JsonProperty("admin_state_up") + private Boolean adminStateUp; + + @JsonProperty("tenant_id") + private String tenantId; + + @JsonProperty("provider:physical_network") + private String providerPhysicalNetwork; + + @JsonProperty("provider:network_type") + private String providerNetworkType; + + @JsonProperty("provider:segmentation_id") + private Integer providerSegmentationId; + + @JsonProperty("router:external") + private String routerExternal; + + private String id; + + private String shared; + + private Integer mtu; + + @JsonProperty("port_security_enabled") + private Boolean portSecurityEnabled; + + /** + * @return the status + */ + @JsonIgnore + public String getStatus() { + return status; + } + + /** + * @param status + * the status to set + */ + @JsonProperty + public void setStatus(String status) { + this.status = status; + } + + /** + * @return the subnets + */ + @JsonIgnore + public List getSubnets() { + return subnets; + } + + /** + * @param subnets + * the subnets to set + */ + @JsonProperty + public void setSubnets(List subnets) { + this.subnets = subnets; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the providerPhyNet + * @deprecated + */ + @Deprecated + @JsonIgnore + public String getProviderPhyNet() { + return getProviderPhysicalNetwork(); + } + + /** + * @param providerPhyNet + * the providerPhyNet to set + * @deprecated + */ + @Deprecated + @JsonIgnore + public void setProviderPhyNet(String providerPhyNet) { + setProviderPhysicalNetwork(providerPhyNet); + } + + /** + * @return the adminStateUp + */ + @JsonIgnore + public boolean isAdminStateUp() { + return adminStateUp; + } + + public Boolean getAdminStateUp() { + return adminStateUp; + } + + /** + * @param adminStateUp + * the adminStateUp to set + */ + public void setAdminStateUp(Boolean adminStateUp) { + this.adminStateUp = adminStateUp; + } + + /** + * @return the tenantId + */ + public String getTenantId() { + return tenantId; + } + + /** + * @param tenantId + * the tenantId to set + */ + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + /** + * @return the netType + * @deprecated + */ + @Deprecated + @JsonIgnore + public String getNetType() { + return getProviderNetworkType(); + } + + /** + * @param netType + * the netType to set + * @deprecated + */ + @Deprecated + @JsonIgnore + public void setNetType(String netType) { + setProviderNetworkType(netType); + } + + /** + * @return the routerExternal + */ + public String getRouterExternal() { + return routerExternal; + } + + /** + * @param routerExternal + * the routerExternal to set + */ + public void setRouterExternal(String routerExternal) { + this.routerExternal = routerExternal; + } + + /** + * @return the id + */ + @JsonIgnore + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + @JsonProperty + public void setId(String id) { + this.id = id; + } + + /** + * @return the shared + */ + public String getShared() { + return shared; + } + + /** + * @param shared + * the shared to set + */ + public void setShared(String shared) { + this.shared = shared; + } + + /** + * @return the providerSegID + * @deprecated + */ + @Deprecated + @JsonIgnore + public String getProviderSegID() { + return getProviderSegmentationId() == null ? null : Integer.toString(getProviderSegmentationId()); + } + + /** + * @param providerSegID + * the providerSegID to set + * @deprecated + */ + @Deprecated + @JsonIgnore + public void setProviderSegID(String providerSegID) { + setProviderSegmentationId(providerSegID == null ? null : Integer.parseInt(providerSegID)); + } + + public String getProviderNetworkType() { + return providerNetworkType; + } + + public void setProviderNetworkType(String providerNetworkType) { + this.providerNetworkType = providerNetworkType; + } + + public String getProviderPhysicalNetwork() { + return providerPhysicalNetwork; + } + + public void setProviderPhysicalNetwork(String providerPhysicalNetwork) { + this.providerPhysicalNetwork = providerPhysicalNetwork; + } + + public Integer getProviderSegmentationId() { + return providerSegmentationId; + } + + public void setProviderSegmentationId(Integer providerSegmentationId) { + this.providerSegmentationId = providerSegmentationId; + } + + /** + * @return the MTU + */ + public Integer getMtu() { + return mtu; + } + + /** + * @param mtu + * the MTU to set + */ + public void setMtu(Integer mtu) { + this.mtu = mtu; + } + + /** + * @return the portSecurityEnabled + */ + @JsonIgnore + public boolean isPortSecurityEnabled() { + return portSecurityEnabled; + } + + public Boolean getPortSecurityEnabled() { + return portSecurityEnabled; + } + + /** + * + * @param portSecurityEnabled enable / disable the default portSecurityEnabled for all future ports in this network + */ + public void setPortSecurityEnabled(Boolean portSecurityEnabled) { + this.portSecurityEnabled = portSecurityEnabled; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Network [id=" + id + ", name=" + name + ", subnets=" + + subnets + ", status=" + status + ", admin_state_up=" + adminStateUp + ", tenant_id=" + + tenantId + ", shared=" + shared + ", mtu=" + mtu + ", provider:physical_network=" + + providerPhysicalNetwork + ", provider:network_type=" + providerNetworkType + ", router:external=" + + routerExternal + ", provider:segmentation_id=" + providerSegmentationId + + ", port_security_enabled=" + portSecurityEnabled + "]"; + } } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java index a06d9d7f2..1d4d5cb69 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/NetworkForCreate.java @@ -1,83 +1,9 @@ package com.woorea.openstack.quantum.model; -import java.io.Serializable; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; +@SuppressWarnings("serial") @JsonRootName("network") -public class NetworkForCreate implements Serializable{ - - private String name; - @JsonProperty("admin_state_up") - private boolean adminStateUp; - - @JsonProperty("provider:network_type") - private String providerNetworkType; - - @JsonProperty("provider:physical_network") - private String providerPhysicalNetwork; - - @JsonProperty("provider:segmentation_id") - private Integer providerSegmentationId; - - @JsonProperty("tenant_id") - private String tenantId; - - /** - * @return the name - */ - public String getName() { - return name; - } - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - /** - * @return the adminStateUp - */ - public boolean isAdminStateUp() { - return adminStateUp; - } - /** - * @param adminStateUp the adminStateUp to set - */ - public void setAdminStateUp(boolean adminStateUp) { - this.adminStateUp = adminStateUp; - } - - public String getProviderNetworkType() { - return providerNetworkType; - } - - public void setProviderNetworkType(String providerNetworkType) { - this.providerNetworkType = providerNetworkType; - } - - public String getProviderPhysicalNetwork() { - return providerPhysicalNetwork; - } - - public void setProviderPhysicalNetwork(String providerPhysicalNetwork) { - this.providerPhysicalNetwork = providerPhysicalNetwork; - } - - public Integer getProviderSegmentationId() { - return providerSegmentationId; - } - - public void setProviderSegmentationId(Integer providerSegmentationId) { - this.providerSegmentationId = providerSegmentationId; - } - - public String getTenantId() { - return tenantId; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } +@Deprecated +public class NetworkForCreate extends Network { } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Networks.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Networks.java index a4fd330de..f5b251ceb 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Networks.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Networks.java @@ -3,7 +3,7 @@ import java.io.Serializable; import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Networks implements Iterable, Serializable{ diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java index aff9cff81..169809899 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Port.java @@ -2,267 +2,373 @@ import java.io.Serializable; import java.util.List; +import java.util.Map; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonUnwrapped; +import com.fasterxml.jackson.annotation.JsonRootName; + +@SuppressWarnings("serial") @JsonRootName("port") @JsonIgnoreProperties(ignoreUnknown = true) public class Port implements Serializable { - - public static final class Ip implements Serializable { - - @JsonProperty("ip_address") - private String address; - @JsonProperty("subnet_id") - private String subnetId; - - /** - * @return the address - */ - public String getAddress() { - return address; - } - - /** - * @param address the address to set - */ - public void setAddress(String address) { - this.address = address; - } - - /** - * @return the subnetId - */ - public String getSubnetId() { - return subnetId; - } - - /** - * @param subnetId the subnetId to set - */ - public void setSubnetId(String subnetId) { - this.subnetId = subnetId; - } - - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "ip_addresses [ip_address=" + address + ", subnet_id=" + subnetId + "]"; - } - - } - - @JsonProperty("admin_state_up") - private String adminStateUp; - @JsonProperty("device_id") - private String deviceId; - @JsonProperty("device_owner") - private String deviceOwner; - @JsonProperty("fixed_ips") - private List list; - private String id; - @JsonProperty("mac_address") - private String macAddress; - private String name; - @JsonProperty("network_id") - private String networkId; - private String status; - @JsonProperty("tenant_id") - private String tenantId; - - - - /** - * @return the adminStateUp - */ - public String getAdminStateUp() { - return adminStateUp; - } - - - - /** - * @param adminStateUp the adminStateUp to set - */ - public void setAdminStateUp(String adminStateUp) { - this.adminStateUp = adminStateUp; - } - - - - /** - * @return the deviceId - */ - public String getDeviceId() { - return deviceId; - } - - - - /** - * @param deviceId the deviceId to set - */ - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - - - /** - * @return the deviceOwner - */ - public String getDeviceOwner() { - return deviceOwner; - } - - - - /** - * @param deviceOwner the deviceOwner to set - */ - public void setDeviceOwner(String deviceOwner) { - this.deviceOwner = deviceOwner; - } - - - - /** - * @return the list - */ - public List getList() { - return list; - } - - - - /** - * @param list the list to set - */ - public void setList(List list) { - this.list = list; - } - - - - /** - * @return the id - */ - public String getId() { - return id; - } - - - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - - - /** - * @return the macAddress - */ - public String getMacAddress() { - return macAddress; - } - - - - /** - * @param macAddress the macAddress to set - */ - public void setMacAddress(String macAddress) { - this.macAddress = macAddress; - } - - - - /** - * @return the name - */ - public String getName() { - return name; - } - - - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - - - /** - * @return the networkId - */ - public String getNetworkId() { - return networkId; - } - - - - /** - * @param networkId the networkId to set - */ - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - - - /** - * @return the status - */ - public String getStatus() { - return status; - } - - - - /** - * @param status the status to set - */ - public void setStatus(String status) { - this.status = status; - } - - - - /** - * @return the tenantId - */ - public String getTenantId() { - return tenantId; - } - - - - /** - * @param tenantId the tenantId to set - */ - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - - @Override - public String toString() { - return "Port [id=" + id + ", name=" + name + ", mac_address=" - + macAddress + ", admin_state_up=" + adminStateUp + ", device_id=" + deviceId - + ", device_owner=" + deviceOwner + ", fixed_ips=" + list - + ", network_id=" + networkId + ", status=" + status - + ", tenant_id=" + tenantId + "]"; - } + public static final class Ip implements Serializable { + + @JsonProperty("ip_address") + private String address; + + @JsonProperty("subnet_id") + private String subnetId; + + /** + * @return the address + */ + public String getAddress() { + return address; + } + + /** + * @param address + * the address to set + */ + public void setAddress(String address) { + this.address = address; + } + + /** + * @return the subnetId + */ + public String getSubnetId() { + return subnetId; + } + + /** + * @param subnetId + * the subnetId to set + */ + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + @Override + public String toString() { + return "ip_addresses [ip_address=" + address + ", subnet_id=" + subnetId + "]"; + } + + } + + public static final class Binding { + + /** + * The host on which the port will be allocated. + */ + @JsonProperty("binding:host_id") + private String hostId; + + /** + * The vif type for the specific port. + */ + @JsonProperty("binding:vif_type") + private String vifType; + + /** + * The type of vnic that this port should be attached to + */ + @JsonProperty("binding:vnic_type") + private String vnicType; + + /** + * A map containing additional information needed by the interface driver + */ + @JsonProperty("binding:vif_details") + private Map vifDetails; + + /** + * A map to enable applications running on the specific host to pass and receive vif port specific information + * to the plugin. + */ + @JsonProperty("binding:profile") + private Map profile; + + public String getHostId() { + return hostId; + } + + public void setHostId(String hostId) { + this.hostId = hostId; + } + + public String getVifType() { + return vifType; + } + + public void setVifType(String vifType) { + this.vifType = vifType; + } + + public String getVnicType() { + return vnicType; + } + + public void setVnicType(String vnicType) { + this.vnicType = vnicType; + } + + public Map getVifDetails() { + return vifDetails; + } + + public void setVifDetails(Map vifDetails) { + this.vifDetails = vifDetails; + } + + public Map getProfile() { + return profile; + } + + public void setProfile(Map profile) { + this.profile = profile; + } + + @Override + public String toString() { + return "Binding [hostId=" + hostId + + ", vifType=" + vifType + + ", vnicType=" + vnicType + + ", vifDetails=" + vifDetails + + ", profile=" + profile + "]"; + } + } + + @JsonProperty("admin_state_up") + private Boolean adminStateUp; + + @JsonProperty("device_id") + private String deviceId; + + @JsonProperty("device_owner") + private String deviceOwner; + + @JsonProperty("fixed_ips") + private List list; + + private String id; + + @JsonProperty("mac_address") + private String macAddress; + + private String name; + + @JsonProperty("network_id") + private String networkId; + + private String status; + + @JsonProperty("tenant_id") + private String tenantId; + + @JsonProperty("security_groups") + private List securityGroups; + + @JsonUnwrapped + private Binding binding; + + /** + * @return the adminStateUp + */ + public Boolean getAdminStateUp() { + return adminStateUp; + } + + /** + * @param adminStateUp + * the adminStateUp to set + */ + public void setAdminStateUp(Boolean adminStateUp) { + this.adminStateUp = adminStateUp; + } + + /** + * @return the deviceId + */ + public String getDeviceId() { + return deviceId; + } + + /** + * @param deviceId + * the deviceId to set + */ + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + /** + * @return the deviceOwner + */ + public String getDeviceOwner() { + return deviceOwner; + } + + /** + * @param deviceOwner + * the deviceOwner to set + */ + public void setDeviceOwner(String deviceOwner) { + this.deviceOwner = deviceOwner; + } + + /** + * @return the list + */ + public List getList() { + return list; + } + + /** + * @param list + * the list to set + */ + public void setList(List list) { + this.list = list; + } + + /** + * @return the id + */ + @JsonIgnore + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + @JsonProperty + public void setId(String id) { + this.id = id; + } + + /** + * @return the macAddress + */ + public String getMacAddress() { + return macAddress; + } + + /** + * @param macAddress + * the macAddress to set + */ + public void setMacAddress(String macAddress) { + this.macAddress = macAddress; + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the networkId + */ + public String getNetworkId() { + return networkId; + } + + /** + * @param networkId + * the networkId to set + */ + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + /** + * @return the status + */ + @JsonIgnore + public String getStatus() { + return status; + } + + /** + * @param status + * the status to set + */ + @JsonProperty + public void setStatus(String status) { + this.status = status; + } + + /** + * @return the tenantId + */ + public String getTenantId() { + return tenantId; + } + + /** + * @param tenantId + * the tenantId to set + */ + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + /** + * @return the associated security group IDs + */ + public List getSecurityGroups() { + return securityGroups; + } + + /** + * @param securityGroups + * IDs of security groups to associate to the port + */ + public void setSecurityGroups(List securityGroups) { + this.securityGroups = securityGroups; + } + + /** + * @return the binding of the port + */ + public Binding getBinding() { + return binding; + } + + /** + * @param binding + * The port bindings by which the port is bind to network on host + */ + public void setBinding(Binding binding) { + this.binding = binding; + } + + @Override + public String toString() { + return "Port [id=" + id + ", name=" + name + ", mac_address=" + + macAddress + ", admin_state_up=" + adminStateUp + ", device_id=" + deviceId + + ", device_owner=" + deviceOwner + ", fixed_ips=" + list + + ", network_id=" + networkId + ", status=" + status + + ", tenant_id=" + tenantId + + ", securityGroups=" + securityGroups + + ", binding=" + binding + "]"; + } } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/PortForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/PortForCreate.java index 7b4eadde2..f7df76f53 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/PortForCreate.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/PortForCreate.java @@ -1,105 +1,12 @@ package com.woorea.openstack.quantum.model; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonRootName; +/** + * @deprecated Please use {@link Port} directly. + */ +@SuppressWarnings("serial") @JsonRootName("port") -public class PortForCreate { - - @JsonProperty("admin_state_up") - private boolean adminStateUp; - @JsonProperty("device_id") - private String deviceId; - private String name; - @JsonProperty("network_id") - private String networkId; - - @JsonProperty("mac_address") - private String macAddress; - - @JsonProperty("device_owner") - private String deviceOwner; - - @JsonProperty("tenant_id") - private String tenantId; - - /** - * @return the adminStateUp - */ - public boolean isAdminStateUp() { - return adminStateUp; - } - - /** - * @param adminStateUp the adminStateUp to set - */ - public void setAdminStateUp(boolean adminStateUp) { - this.adminStateUp = adminStateUp; - } - - /** - * @return the deviceId - */ - public String getDeviceId() { - return deviceId; - } - - /** - * @param deviceId the deviceId to set - */ - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the networkId - */ - public String getNetworkId() { - return networkId; - } - - /** - * @param networkId the networkId to set - */ - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - public String getMacAddress() { - return macAddress; - } - - public void setMacAddress(String macAddress) { - this.macAddress = macAddress; - } - - public String getDeviceOwner() { - return deviceOwner; - } - - public void setDeviceOwner(String deviceOwner) { - this.deviceOwner = deviceOwner; - } - - public String getTenantId() { - return tenantId; - } - - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } +@Deprecated +public class PortForCreate extends Port { } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java index d6d5f2764..5d0ed3a2e 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Ports.java @@ -4,33 +4,37 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; +@SuppressWarnings("serial") public class Ports implements Iterable, Serializable { - - @JsonProperty("ports") - private List list; - - /** - * @return the list - */ - public List getList() { - return list; - } - - /** - * @param list the list to set - */ - public void setList(List list) { - this.list = list; - } - - public Iterator iterator() { - return list.iterator(); - } - @Override - public String toString() { - return "Ports [list=" + list + "]"; - } + + @JsonProperty("ports") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + /** + * @param list + * the list to set + */ + public void setList(List list) { + this.list = list; + } + + @Override + public Iterator iterator() { + return list.iterator(); + } + + @Override + public String toString() { + return "Ports [list=" + list + "]"; + } } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java new file mode 100644 index 000000000..c1acb433e --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Router.java @@ -0,0 +1,77 @@ +package com.woorea.openstack.quantum.model; + +import java.util.List; +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("router") +public class Router implements Serializable { + + @JsonProperty("status") + private String status; + + @JsonProperty("external_gateway_info") + private GatewayInfo externalGatewayInfo; + + @JsonProperty("name") + private String name; + + @JsonProperty("admin_state_up") + private String admin_state_up; + + @JsonProperty("tenant_id") + private String tenantId; + + @JsonProperty("id") + private String id; + + @JsonProperty("routes") + private List routes; + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public List getRoutes() { + return routes; + } + public void setRoutes(List routes) { + this.routes = routes; + } + public String getAdmin_state_up() { + return admin_state_up; + } + public void setAdmin_state_up(String admin_state_up) { + this.admin_state_up = admin_state_up; + } + public String getStatus() { + return status; + } + public void setStatus(String status) { + this.status = status; + } + public GatewayInfo getExternalGatewayInfo() { + return externalGatewayInfo; + } + public void setExternalGatewayInfo(GatewayInfo externalGatewayInfo) { + this.externalGatewayInfo = externalGatewayInfo; + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + + +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForAddInterface.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForAddInterface.java new file mode 100644 index 000000000..24ca72d51 --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForAddInterface.java @@ -0,0 +1,28 @@ +package com.woorea.openstack.quantum.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class RouterForAddInterface implements Serializable { + + @JsonProperty("subnet_id") + String subnetId; + String routerId; + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public String getRouterId() { + return routerId; + } + + public void setRouterId(String routerId) { + this.routerId = routerId; + } + } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java new file mode 100644 index 000000000..26ca202ec --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterForCreate.java @@ -0,0 +1,75 @@ +package com.woorea.openstack.quantum.model; + +import java.util.List; +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName("router") +public class RouterForCreate implements Serializable { + + @JsonProperty("name") + private String name; + + private List routes; + + @JsonProperty("admin_state_up") + private String admin_state_up; + + @JsonProperty("status") + private String status; + + @JsonProperty("external_gateway_info") + private GatewayInfo externalGatewayInfo; + + @JsonProperty("tenant_id") + private String tenantId; + + @JsonProperty("id") + private String id; + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public List getRoutes() { + return routes; + } + public void setRoutes(List routes) { + this.routes = routes; + } + public String getAdmin_state_up() { + return admin_state_up; + } + public void setAdmin_state_up(String admin_state_up) { + this.admin_state_up = admin_state_up; + } + public String getStatus() { + return status; + } + public void setStatus(String status) { + this.status = status; + } + public GatewayInfo getExternalGatewayInfo() { + return externalGatewayInfo; + } + public void setExternalGatewayInfo(GatewayInfo externalGatewayInfo) { + this.externalGatewayInfo = externalGatewayInfo; + } + public String getTenantId() { + return tenantId; + } + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterInterface.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterInterface.java new file mode 100644 index 000000000..824779e03 --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/RouterInterface.java @@ -0,0 +1,19 @@ +package com.woorea.openstack.quantum.model; + +import java.io.Serializable; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +public class RouterInterface implements Serializable { + + @JsonProperty("subnet_id") + String subnetId; + @JsonProperty("port_id") + String portId; + @JsonProperty("tenant_id") + String tenantId; + @JsonProperty("id") + String id; + +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Routers.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Routers.java new file mode 100644 index 000000000..f180cdb6b --- /dev/null +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Routers.java @@ -0,0 +1,38 @@ +package com.woorea.openstack.quantum.model; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Routers implements Iterable, Serializable{ + + @JsonProperty("routers") + private List list; + + /** + * @return the list + */ + public List getList() { + return list; + } + + + /** + * @param list the list to set + */ + public void setList(List list) { + this.list = list; + } + + + public String toString() { + return "Routers [list=" + list + "]"; + } + + + public Iterator iterator() { + return list.iterator(); + } + +} diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java index a4df31694..b300f71e8 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnet.java @@ -3,252 +3,263 @@ import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonCreator; -import org.codehaus.jackson.annotate.JsonIgnoreProperties; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.annotate.JsonValue; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import com.fasterxml.jackson.annotation.JsonRootName; + +@SuppressWarnings("serial") @JsonRootName("subnet") @JsonIgnoreProperties(ignoreUnknown = true) -public class Subnet implements Serializable{ - - private String name; - @JsonProperty("enable_dhcp") - private boolean enableDHCP; - @JsonProperty("network_id") - private String networkId; - @JsonProperty("tenant_id") - private String tenantId; - @JsonProperty("dns_nameservers") - private List dnsNames; - @JsonProperty("allocation_pools") - private List list; - @JsonProperty("host_routes") - private List hostRoutes; - @JsonProperty("ip_version") - private IpVersion ipversion; - @JsonProperty("gateway_ip") - private String gw; - private String cidr; - private String id; - - public static enum IpVersion implements Serializable { - IPV4(4), IPV6(6); - private int code; - - IpVersion(int code) { - this.code = code; - } - - @JsonValue - public int code() { - return code; - } - - @JsonCreator - public static IpVersion valueOf(int value) { - for (IpVersion ipVersion : IpVersion.values()) { - if (ipVersion.code() == value) { - return ipVersion; - } - } - return IPV4; - } - - @Override - public String toString() { - return String.valueOf(code); - } - } - - - /** - * @return the name - */ - public String getName() { - return name; - } - - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - - /** - * @return the enableDHCP - */ - public boolean isEnableDHCP() { - return enableDHCP; - } - - - /** - * @param enableDHCP the enableDHCP to set - */ - public void setEnableDHCP(boolean enableDHCP) { - this.enableDHCP = enableDHCP; - } - - - /** - * @return the networkId - */ - public String getNetworkId() { - return networkId; - } - - - /** - * @param networkId the networkId to set - */ - public void setNetworkId(String networkId) { - this.networkId = networkId; - } - - - /** - * @return the tenantId - */ - public String getTenantId() { - return tenantId; - } - - - /** - * @param tenantId the tenantId to set - */ - public void setTenantId(String tenantId) { - this.tenantId = tenantId; - } - - - /** - * @return the dnsNames - */ - public List getDnsNames() { - return dnsNames; - } - - - /** - * @param dnsNames the dnsNames to set - */ - public void setDnsNames(List dnsNames) { - this.dnsNames = dnsNames; - } - - - /** - * @return the list - */ - public List getList() { - return list; - } - - - /** - * @param list the list to set - */ - public void setList(List list) { - this.list = list; - } - - - /** - * @return the hostRoutes - */ - public List getHostRoutes() { - return hostRoutes; - } - - - /** - * @param hostRoutes the hostRoutes to set - */ - public void setHostRoutes(List hostRoutes) { - this.hostRoutes = hostRoutes; - } - - - /** - * @return the ipversion - */ - public IpVersion getIpversion() { - return ipversion; - } - - - /** - * @param ipversion the ipversion to set - */ - public void setIpversion(IpVersion ipversion) { - this.ipversion = ipversion; - } - - - /** - * @return the gw - */ - public String getGw() { - return gw; - } - - - /** - * @param gw the gw to set - */ - public void setGw(String gw) { - this.gw = gw; - } - - - /** - * @return the cidr - */ - public String getCidr() { - return cidr; - } - - - /** - * @param cidr the cidr to set - */ - public void setCidr(String cidr) { - this.cidr = cidr; - } - - - /** - * @return the id - */ - public String getId() { - return id; - } - - - /** - * @param id the id to set - */ - public void setId(String id) { - this.id = id; - } - - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - return "Subnet [id=" + id + ", name=" + name + ", network_id=" - + networkId + ", tenant_id=" + tenantId + ", allocation_pools=" + list - + ", gateway_ip=" + gw + ", ip_version=" + ipversion - + ", cidr=" + cidr + ", enable_dhcp=" + enableDHCP + ", dns_nameservers=" - + dnsNames + ", host_routes=" + hostRoutes + "]"; - } +public class Subnet implements Serializable { + + private String name; + + @JsonProperty("enable_dhcp") + private Boolean enableDHCP; + + @JsonProperty("network_id") + private String networkId; + + @JsonProperty("tenant_id") + private String tenantId; + + @JsonProperty("dns_nameservers") + private List dnsNames; + + @JsonProperty("allocation_pools") + private List list; + + @JsonProperty("host_routes") + private List hostRoutes; + + @JsonProperty("ip_version") + private IpVersion ipversion; + + @JsonProperty("gateway_ip") + private String gw; + + private String cidr; + + private String id; + + public static enum IpVersion implements Serializable { + IPV4(4), + IPV6(6); + private int code; + + IpVersion(int code) { + this.code = code; + } + + @JsonValue + public int code() { + return code; + } + + @JsonCreator + public static IpVersion valueOf(int value) { + for (IpVersion ipVersion : IpVersion.values()) { + if (ipVersion.code() == value) { + return ipVersion; + } + } + return IPV4; + } + + @Override + public String toString() { + return String.valueOf(code); + } + } + + /** + * @return the name + */ + public String getName() { + return name; + } + + /** + * @param name + * the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * @return the enableDHCP + */ + @JsonIgnore + public boolean isEnableDHCP() { + return enableDHCP; + } + + public Boolean getEnableDHCP() { + return enableDHCP; + } + + /** + * @param enableDHCP + * the enableDHCP to set + */ + public void setEnableDHCP(Boolean enableDHCP) { + this.enableDHCP = enableDHCP; + } + + /** + * @return the networkId + */ + public String getNetworkId() { + return networkId; + } + + /** + * @param networkId + * the networkId to set + */ + public void setNetworkId(String networkId) { + this.networkId = networkId; + } + + /** + * @return the tenantId + */ + public String getTenantId() { + return tenantId; + } + + /** + * @param tenantId + * the tenantId to set + */ + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + /** + * @return the dnsNames + */ + public List getDnsNames() { + return dnsNames; + } + + /** + * @param dnsNames + * the dnsNames to set + */ + public void setDnsNames(List dnsNames) { + this.dnsNames = dnsNames; + } + + /** + * @return the list + */ + public List getList() { + return list; + } + + /** + * @param list + * the list to set + */ + public void setList(List list) { + this.list = list; + } + + /** + * @return the hostRoutes + */ + public List getHostRoutes() { + return hostRoutes; + } + + /** + * @param hostRoutes + * the hostRoutes to set + */ + public void setHostRoutes(List hostRoutes) { + this.hostRoutes = hostRoutes; + } + + /** + * @return the ipversion + */ + public IpVersion getIpversion() { + return ipversion; + } + + /** + * @param ipversion + * the ipversion to set + */ + public void setIpversion(IpVersion ipversion) { + this.ipversion = ipversion; + } + + /** + * @return the gw + */ + public String getGw() { + return gw; + } + + /** + * @param gw + * the gw to set + */ + public void setGw(String gw) { + this.gw = gw; + } + + /** + * @return the cidr + */ + public String getCidr() { + return cidr; + } + + /** + * @param cidr + * the cidr to set + */ + public void setCidr(String cidr) { + this.cidr = cidr; + } + + /** + * @return the id + */ + @JsonIgnore + public String getId() { + return id; + } + + /** + * @param id + * the id to set + */ + @JsonProperty + public void setId(String id) { + this.id = id; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Subnet [id=" + id + ", name=" + name + ", network_id=" + + networkId + ", tenant_id=" + tenantId + ", allocation_pools=" + list + + ", gateway_ip=" + gw + ", ip_version=" + ipversion + + ", cidr=" + cidr + ", enable_dhcp=" + enableDHCP + ", dns_nameservers=" + + dnsNames + ", host_routes=" + hostRoutes + "]"; + } } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java index 4182d7463..fe0b19e2a 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/SubnetForCreate.java @@ -1,95 +1,34 @@ package com.woorea.openstack.quantum.model; -import java.io.Serializable; -import java.util.List; - -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonRootName; +/** + * Please use {@link Subnet} directly. + */ +@SuppressWarnings("serial") @JsonRootName("subnet") - -public class SubnetForCreate implements Serializable{ - - private String name; - @JsonProperty("network_id") - private String networkid; - @JsonProperty("ip_version") - private int ipVersion; - private String cidr; - @JsonProperty("allocation_pools") - private List list; - - /** - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return the name - */ - public String getName() { - return name; - } - /** - * @return the id - */ - public String getNetworkId() { - return networkid; - } - - /** - * @param id the id to set - */ - public void setNetworkId(String id) { - this.networkid = id; - } - - - /** - * @return the ipVersion - */ - public int getIpVersion() { - return ipVersion; - } - - /** - * @param ipVersion the ipVersion to set - */ - public void setIpVersion(int ipVersion) { - this.ipVersion = ipVersion; - } - - /** - * @return the cidr - */ - public String getCidr() { - return cidr; - } - - /** - * @param cidr the cidr to set - */ - public void setCidr(String cidr) { - this.cidr = cidr; - } - - /** - * @return the list - */ - public List getList() { - return list; - } - - /** - * @param list the list to set - */ - public void setList(List list) { - this.list = list; - } - - - - +@Deprecated +public class SubnetForCreate extends Subnet { + + /** + * @return the ipVersion + * @deprecated + */ + @Deprecated + @JsonIgnore + public int getIpVersion() { + return getIpversion().code(); + } + + /** + * @param ipVersion + * the ipVersion to set + * @deprecated + */ + @Deprecated + @JsonIgnore + public void setIpVersion(int ipVersion) { + setIpversion(IpVersion.valueOf(ipVersion)); + } } diff --git a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnets.java b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnets.java index e9b21f47e..b520e5a91 100644 --- a/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnets.java +++ b/quantum-model/src/main/java/com/woorea/openstack/quantum/model/Subnets.java @@ -4,7 +4,7 @@ import java.util.Iterator; import java.util.List; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Subnets implements Serializable, Iterable { diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworkTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworkTest.java new file mode 100644 index 000000000..a54326873 --- /dev/null +++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/NetworkTest.java @@ -0,0 +1,124 @@ +package com.woorea.openstack.quantum.model; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +import java.util.Arrays; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.junit.Before; +import org.junit.Test; + +public class NetworkTest { + + private static final String ID = "testId"; + + private static final boolean ADMIN_STATE_UP = true; + + private static final String NAME = "name"; + + private static final String TENANT_ID = "tenantId"; + + private static final String SHARED = "shared"; + + private static final String STATUS = "status"; + + private static final String SUBNET = "subnet"; + + private static final String PROVIDER_NETWORK_TYPE = "vlan"; + + private static final String PROVIDER_PHYSICAL_NETWORK = "physicalNetwork"; + + private static final int PROVIDER_SEGMENTATION_ID = 100; + + private static final String ROUTER_EXTERNAL = "routerExternal"; + + private static final Boolean PORT_SECURITY_ENABLED = Boolean.FALSE; + + /** + * JSON with read only attributes. + */ + private static final String NETWORK_JSON = "{" + + " \"network\" : {" + + " \"id\" : \"" + ID + "\"," + + " \"status\" : \"" + STATUS + "\"," + + " \"subnets\" : [ \"" + SUBNET + "\" ]" + + " }" + + "}"; + + private ObjectMapper objectMapper; + + private String serializedNetwork; + + @Before + public void setUp() throws Exception { + objectMapper = PortTest.initializeObjectMapper(); + } + + @Test + public void testSerialization() throws Exception { + Network network = new Network(); + network.setId(ID); + network.setProviderNetworkType(PROVIDER_NETWORK_TYPE); + network.setProviderPhysicalNetwork(PROVIDER_PHYSICAL_NETWORK); + network.setProviderSegmentationId(PROVIDER_SEGMENTATION_ID); + network.setAdminStateUp(ADMIN_STATE_UP); + network.setSubnets(Arrays.asList(SUBNET)); + network.setRouterExternal(ROUTER_EXTERNAL); + network.setName(NAME); + network.setShared(SHARED); + network.setTenantId(TENANT_ID); + network.setPortSecurityEnabled(PORT_SECURITY_ENABLED); + + serializedNetwork = objectMapper.writeValueAsString(network); + assertThat(serializedNetwork, not(containsString(ID))); + assertThat(serializedNetwork, not(containsString(STATUS))); + assertThat(serializedNetwork, not(containsString(SUBNET))); + assertThat(serializedNetwork, containsString("\"admin_state_up\" : " + ADMIN_STATE_UP)); + assertThat(serializedNetwork, containsString(NAME)); + assertThat(serializedNetwork, containsString(SHARED)); + assertThat(serializedNetwork, containsString(TENANT_ID)); + assertThat(serializedNetwork, containsString(ROUTER_EXTERNAL)); + assertThat(serializedNetwork, containsString(PROVIDER_NETWORK_TYPE)); + assertThat(serializedNetwork, containsString(PROVIDER_PHYSICAL_NETWORK)); + assertThat(serializedNetwork, containsString(Integer.toString(PROVIDER_SEGMENTATION_ID))); + assertThat(serializedNetwork, containsString("\"port_security_enabled\" : " + PORT_SECURITY_ENABLED)); + } + + @Test + public void testSerializationEmpty() throws Exception { + Network network = new Network(); + serializedNetwork = objectMapper.writeValueAsString(network); + + assertThat(serializedNetwork, containsString("\"network\" : { }")); + } + + @Test + public void testDeserializationReadOnlyFields() throws Exception { + Network network = objectMapper.readValue(NETWORK_JSON, Network.class); + + assertThat(network.getId(), is(equalTo(ID))); + assertThat(network.getSubnets(), hasItem(equalTo(SUBNET))); + assertThat(network.getStatus(), is(equalTo(STATUS))); + } + + @Test + public void testDeserialization() throws Exception { + testSerialization(); + Network network = objectMapper.readValue(serializedNetwork, Network.class); + + assertThat(network.getName(), is(equalTo(NAME))); + assertThat(network.isAdminStateUp(), is(equalTo(ADMIN_STATE_UP))); + assertThat(network.getShared(), is(equalTo(SHARED))); + assertThat(network.getTenantId(), is(equalTo(TENANT_ID))); + assertThat(network.getRouterExternal(), is(equalTo(ROUTER_EXTERNAL))); + assertThat(network.getProviderNetworkType(), is(equalTo(PROVIDER_NETWORK_TYPE))); + assertThat(network.getProviderPhysicalNetwork(), is(equalTo(PROVIDER_PHYSICAL_NETWORK))); + assertThat(network.getProviderSegmentationId(), is(equalTo(PROVIDER_SEGMENTATION_ID))); + assertThat(network.getPortSecurityEnabled(), is(equalTo(PORT_SECURITY_ENABLED))); + } +} diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortTest.java new file mode 100644 index 000000000..e63efbd3b --- /dev/null +++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/PortTest.java @@ -0,0 +1,156 @@ +package com.woorea.openstack.quantum.model; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion; +import org.hamcrest.CustomMatcher; +import org.junit.Before; +import org.junit.Test; + +import com.woorea.openstack.quantum.model.Port.Ip; + +public class PortTest { + + private static final String TENANT_ID = "tenantId"; + + private static final String STATUS = "status"; + + private static final String NETWORK_ID = "networkId"; + + private static final String NAME = "name"; + + private static final String MAC_ADDRESS = "macAddress"; + + private static final String DEVICE_OWNER = "deviceOwner"; + + private static final String DEVICE_ID = "deviceId"; + + private static final String IP_SUBNET_ID = "ipSubnetId"; + + private static final String IP_ADDRESS = "10.0.0.1"; + + private static final boolean ADMIN_STATE_UP = true; + + private static final String SEC_GROUP = "secGroup"; + + private static final String ID = "testId"; + + /** + * JSON with read only attributes. + */ + private static final String PORT_JSON = "{" + + " \"port\" : {" + + " \"id\" : \"" + ID + "\"," + + " \"status\" : \"" + STATUS + "\"" + + " }" + + "}"; + + private ObjectMapper objectMapper; + + private String serializedPort; + + @Before + public void setUp() throws Exception { + objectMapper = initializeObjectMapper(); + } + + public static ObjectMapper initializeObjectMapper() { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL) + .enable(SerializationFeature.INDENT_OUTPUT) + .enable(SerializationFeature.WRAP_ROOT_VALUE) + .enable(DeserializationFeature.UNWRAP_ROOT_VALUE) + .enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY); + return objectMapper; + } + + @Test + public void testSerialization() throws Exception { + Port port = new Port(); + port.setId(ID); + port.setAdminStateUp(ADMIN_STATE_UP); + port.setSecurityGroups(Arrays.asList(SEC_GROUP)); + port.setDeviceId(DEVICE_ID); + port.setDeviceOwner(DEVICE_OWNER); + port.setMacAddress(MAC_ADDRESS); + port.setName(NAME); + port.setNetworkId(NETWORK_ID); + port.setStatus(STATUS); + port.setTenantId(TENANT_ID); + + List ips = new ArrayList(); + Ip ip = new Ip(); + ip.setAddress(IP_ADDRESS); + ip.setSubnetId(IP_SUBNET_ID); + ips.add(ip); + port.setList(ips); + + serializedPort = objectMapper.writeValueAsString(port); + assertThat(serializedPort, not(containsString(ID))); + assertThat(serializedPort, not(containsString(STATUS))); + assertThat(serializedPort, containsString("\"admin_state_up\" : " + ADMIN_STATE_UP)); + assertThat(serializedPort, containsString(SEC_GROUP)); + assertThat(serializedPort, containsString(IP_ADDRESS)); + assertThat(serializedPort, containsString(DEVICE_ID)); + assertThat(serializedPort, containsString(DEVICE_OWNER)); + assertThat(serializedPort, containsString(MAC_ADDRESS)); + assertThat(serializedPort, containsString(NAME)); + assertThat(serializedPort, containsString(NETWORK_ID)); + assertThat(serializedPort, containsString(TENANT_ID)); + } + + @Test + public void testSerializationEmpty() throws Exception { + Port port = new Port(); + serializedPort = objectMapper.writeValueAsString(port); + + assertThat(serializedPort, containsString("\"port\" : { }")); + } + + @Test + public void testDeserializationReadOnlyFields() throws Exception { + Port port = objectMapper.readValue(PORT_JSON, Port.class); + + assertThat(port.getId(), is(equalTo(ID))); + assertThat(port.getStatus(), is(equalTo(STATUS))); + } + + @Test + public void testDeserializationAfterSerialization() throws Exception { + testSerialization(); + Port port = objectMapper.readValue(serializedPort, Port.class); + + assertThat(port.getAdminStateUp(), is(equalTo(ADMIN_STATE_UP))); + assertThat(port.getDeviceId(), is(equalTo(DEVICE_ID))); + assertThat(port.getDeviceOwner(), is(equalTo(DEVICE_OWNER))); + assertThat(port.getMacAddress(), is(equalTo(MAC_ADDRESS))); + assertThat(port.getName(), is(equalTo(NAME))); + assertThat(port.getNetworkId(), is(equalTo(NETWORK_ID))); + assertThat(port.getTenantId(), is(equalTo(TENANT_ID))); + + assertThat(port.getSecurityGroups(), hasItem(equalTo(SEC_GROUP))); + assertThat(port.getList(), hasItem(new CustomMatcher( + "an Ip object with address " + IP_ADDRESS + " and subnet id " + IP_SUBNET_ID) { + + @Override + public boolean matches(Object ip) { + return ip instanceof Ip + && IP_ADDRESS.equals(((Ip) ip).getAddress()) + && IP_SUBNET_ID.equals(((Ip) ip).getSubnetId()); + } + })); + } +} diff --git a/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java new file mode 100644 index 000000000..013ca3028 --- /dev/null +++ b/quantum-model/src/test/java/com/woorea/openstack/quantum/model/SubnetTest.java @@ -0,0 +1,137 @@ +package com.woorea.openstack.quantum.model; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.CoreMatchers.hasItem; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +import java.util.Arrays; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.hamcrest.CustomMatcher; +import org.junit.Before; +import org.junit.Test; + +import com.woorea.openstack.quantum.model.Subnet.IpVersion; + +public class SubnetTest { + + private static final String POOL_END = "poolEnd"; + + private static final String POOL_START = "poolStart"; + + private static final String TENANT_ID = "tenantId"; + + private static final String NETWORK_ID = "networkId"; + + private static final String NAME = "name"; + + private static final String HOST_ROUTE = "hostRoute"; + + private static final String GATEWAY = "gw"; + + private static final boolean ENABLE_DHCP = true; + + private static final String ID = "testId"; + + private static final String CIDR = "10.0.0.0/8"; + + private static final String DNS_SERVER = "dnsServer"; + + private static final IpVersion IP_VERSION = IpVersion.IPV4; + + /** + * JSON with read only attributes. + */ + private static final String SUBNET_JSON = "{" + + " \"subnet\" : {" + + " \"id\" : \"" + ID + "\"" + + " }" + + "}"; + + private ObjectMapper objectMapper; + + private String serializedSubnet; + + @Before + public void setUp() throws Exception { + objectMapper = PortTest.initializeObjectMapper(); + } + + @Test + public void testSerialization() throws Exception { + Subnet subnet = new Subnet(); + subnet.setId(ID); + subnet.setCidr(CIDR); + subnet.setDnsNames(Arrays.asList(DNS_SERVER)); + subnet.setEnableDHCP(ENABLE_DHCP); + subnet.setIpversion(IP_VERSION); + subnet.setGw(GATEWAY); + subnet.setHostRoutes(Arrays.asList(HOST_ROUTE)); + subnet.setName(NAME); + subnet.setNetworkId(NETWORK_ID); + subnet.setTenantId(TENANT_ID); + + Pool pool = new Pool(); + pool.setStart(POOL_START); + pool.setEnd(POOL_END); + subnet.setList(Arrays.asList(pool)); + + serializedSubnet = objectMapper.writeValueAsString(subnet); + assertThat(serializedSubnet, not(containsString(ID))); + assertThat(serializedSubnet, containsString(CIDR)); + assertThat(serializedSubnet, containsString(DNS_SERVER)); + assertThat(serializedSubnet, containsString("\"enable_dhcp\" : " + ENABLE_DHCP)); + assertThat(serializedSubnet, containsString(Integer.toString(IP_VERSION.code()))); + assertThat(serializedSubnet, containsString(GATEWAY)); + assertThat(serializedSubnet, containsString(HOST_ROUTE)); + assertThat(serializedSubnet, containsString(NAME)); + assertThat(serializedSubnet, containsString(NETWORK_ID)); + assertThat(serializedSubnet, containsString(TENANT_ID)); + assertThat(serializedSubnet, containsString(POOL_START)); + assertThat(serializedSubnet, containsString(POOL_END)); + } + + @Test + public void testSerializationEmpty() throws Exception { + Subnet subnet = new Subnet(); + serializedSubnet = objectMapper.writeValueAsString(subnet); + + assertThat(serializedSubnet, containsString("\"subnet\" : { }")); + } + + @Test + public void testDeserializationReadOnlyFields() throws Exception { + Subnet subnet = objectMapper.readValue(SUBNET_JSON, Subnet.class); + + assertThat(subnet.getId(), is(equalTo(ID))); + } + + @Test + public void testDeserializationAfterSerialization() throws Exception { + testSerialization(); + Subnet subnet = objectMapper.readValue(serializedSubnet, Subnet.class); + + assertThat(subnet.getCidr(), is(equalTo(CIDR))); + assertThat(subnet.getDnsNames(), hasItem(equalTo(DNS_SERVER))); + assertThat(subnet.isEnableDHCP(), is(equalTo(ENABLE_DHCP))); + assertThat(subnet.getIpversion(), is(equalTo(IP_VERSION))); + assertThat(subnet.getGw(), is(equalTo(GATEWAY))); + assertThat(subnet.getHostRoutes(), hasItem(equalTo(HOST_ROUTE))); + assertThat(subnet.getName(), is(equalTo(NAME))); + assertThat(subnet.getNetworkId(), is(equalTo(NETWORK_ID))); + assertThat(subnet.getTenantId(), is(equalTo(TENANT_ID))); + assertThat(subnet.getList(), hasItem(new CustomMatcher( + "a Pool object with start " + POOL_START + " and end " + POOL_END) { + + @Override + public boolean matches(Object pool) { + return pool instanceof Pool + && POOL_START.equals(((Pool) pool).getStart()) + && POOL_END.equals(((Pool) pool).getEnd()); + } + })); + } +} diff --git a/swift-client/pom.xml b/swift-client/pom.xml index 89440bd33..2f30057a8 100644 --- a/swift-client/pom.xml +++ b/swift-client/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT swift-client OpenStack Swift Client @@ -12,12 +12,12 @@ com.woorea openstack-client - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT com.woorea swift-model - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT \ No newline at end of file diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java b/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java index 70c5a10f6..f98fbf923 100644 --- a/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java +++ b/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java @@ -11,7 +11,7 @@ public AccountResource(OpenStackClient client) { CLIENT = client; } - public class ShowAccount extends OpenStackRequest { + public class ShowAccount extends OpenStackRequest { public ShowAccount() { // return target.request(MediaType.APPLICATION_JSON).head(); diff --git a/swift-model/pom.xml b/swift-model/pom.xml index 796bed074..da007e95e 100644 --- a/swift-model/pom.xml +++ b/swift-model/pom.xml @@ -3,7 +3,7 @@ com.woorea openstack-java-sdk - 3.1.0-SNAPSHOT + 3.2.10-SNAPSHOT swift-model OpenStack Swift Model diff --git a/swift-model/src/main/java/com/woorea/openstack/swift/model/Container.java b/swift-model/src/main/java/com/woorea/openstack/swift/model/Container.java index 62a002ade..f61c435b2 100644 --- a/swift-model/src/main/java/com/woorea/openstack/swift/model/Container.java +++ b/swift-model/src/main/java/com/woorea/openstack/swift/model/Container.java @@ -2,7 +2,7 @@ import java.io.Serializable; -import org.codehaus.jackson.annotate.JsonProperty; +import com.fasterxml.jackson.annotation.JsonProperty; public class Container implements Serializable { diff --git a/swift-model/src/main/java/com/woorea/openstack/swift/model/Object.java b/swift-model/src/main/java/com/woorea/openstack/swift/model/Object.java index d53ee65d6..1ba18e1f3 100644 --- a/swift-model/src/main/java/com/woorea/openstack/swift/model/Object.java +++ b/swift-model/src/main/java/com/woorea/openstack/swift/model/Object.java @@ -3,8 +3,7 @@ import java.io.Serializable; import java.util.Calendar; -import org.codehaus.jackson.annotate.JsonProperty; - +import com.fasterxml.jackson.annotation.JsonProperty; public class Object implements Serializable {