summaryrefslogtreecommitdiffstats
path: root/cinder-client
diff options
context:
space:
mode:
authorSmokowski, Steve (ss835w) <ss835w@us.att.com>2019-05-02 09:42:55 -0400
committerSmokowski, Steve (ss835w) <ss835w@us.att.com>2019-05-02 12:15:48 -0400
commite153f0adfbed711ce1e215748594a4d04fd1edaf (patch)
tree15a1f4d7b8af126e2061633c1547881992cfbb6f /cinder-client
parentf9b78e1d7ca2b64badd8529aa4600250387ddae7 (diff)
Enhance Openstack Client
Update Openstack Client to support Cinder, and drop null query params Issue-ID: SO-1844 Change-Id: If58717656e0468ec0ce5d53055c381fe7d1c03f5 Signed-off-by: Smokowski, Steve (ss835w) <ss835w@us.att.com>
Diffstat (limited to 'cinder-client')
-rwxr-xr-xcinder-client/pom.xml26
-rwxr-xr-xcinder-client/src/main/java/com/woorea/openstack/cinder/Cinder.java65
-rwxr-xr-xcinder-client/src/main/java/com/woorea/openstack/cinder/LimitsExtension.java42
-rwxr-xr-xcinder-client/src/main/java/com/woorea/openstack/cinder/SchedulerStatsExtension.java44
-rwxr-xr-xcinder-client/src/main/java/com/woorea/openstack/cinder/SnapshotsExtension.java125
-rwxr-xr-xcinder-client/src/main/java/com/woorea/openstack/cinder/VolumeTypesExtension.java84
-rwxr-xr-xcinder-client/src/main/java/com/woorea/openstack/cinder/VolumesExtension.java178
7 files changed, 564 insertions, 0 deletions
diff --git a/cinder-client/pom.xml b/cinder-client/pom.xml
new file mode 100755
index 0000000..47978ac
--- /dev/null
+++ b/cinder-client/pom.xml
@@ -0,0 +1,26 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.so.libs</groupId>
+ <artifactId>openstack-java-sdk</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>cinder-client</artifactId>
+ <name>OpenStack Cinder Client</name>
+ <description>OpenStack Cinder Client</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+ <artifactId>openstack-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+ <artifactId>cinder-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <groupId>org.onap.so.libs.openstack-java-sdk</groupId>
+</project> \ 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 100755
index 0000000..ca65d3f
--- /dev/null
+++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/Cinder.java
@@ -0,0 +1,65 @@
+/* ============LICENSE_START=======================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+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 100755
index 0000000..32c05d7
--- /dev/null
+++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/LimitsExtension.java
@@ -0,0 +1,42 @@
+/* ============LICENSE_START=======================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+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<Limits> {
+
+ 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 100755
index 0000000..09ad3ac
--- /dev/null
+++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/SchedulerStatsExtension.java
@@ -0,0 +1,44 @@
+/* ============LICENSE_START=======================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+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<Pools> {
+
+ 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 100755
index 0000000..d01bdc9
--- /dev/null
+++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/SnapshotsExtension.java
@@ -0,0 +1,125 @@
+/* ============LICENSE_START=======================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+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<Snapshots> {
+
+ public List(boolean detail) {
+ super(CLIENT, HttpMethod.GET, detail ? "/snapshots/detail" : "/snapshots", null, Snapshots.class);
+ }
+
+ }
+
+ public class Create extends OpenStackRequest<Snapshot> {
+
+ public Create(SnapshotForCreate snapshotForCreate) {
+ super(CLIENT, HttpMethod.POST, "/snapshots", Entity.json(snapshotForCreate), Snapshot.class);
+ }
+
+ }
+
+ public class Show extends OpenStackRequest<Snapshot> {
+
+ public Show(String id) {
+ super(CLIENT, HttpMethod.GET, new StringBuilder("/snapshots/").append(id).toString(), null, Snapshot.class);
+ }
+
+ }
+
+ public class Delete extends OpenStackRequest<Void> {
+
+ public Delete(String id) {
+ super(CLIENT, HttpMethod.DELETE, new StringBuilder("/snapshots/").append(id).toString(), null, Void.class);
+ }
+
+ }
+
+ public class Update extends OpenStackRequest<Void> {
+
+ 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<Metadata> {
+
+ public ShowMetadata(String id) {
+ super(CLIENT,
+ HttpMethod.GET,
+ new StringBuilder("/snapshots/").append(id).append("/metadata").toString(),
+ null,
+ Metadata.class);
+ }
+
+ }
+
+ public class UpdateMetadata extends OpenStackRequest<Void> {
+
+ 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 100755
index 0000000..ded5768
--- /dev/null
+++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/VolumeTypesExtension.java
@@ -0,0 +1,84 @@
+/* ============LICENSE_START=======================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+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<VolumeTypes> {
+
+ public List() {
+ super(CLIENT, HttpMethod.GET, "/types", null, VolumeTypes.class);
+ }
+
+ }
+
+ public class Create extends OpenStackRequest<VolumeType> {
+
+ 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<VolumeType> {
+
+ public Show(String id) {
+ super(CLIENT, HttpMethod.GET, new StringBuilder("/types/").append(id).toString(), null, VolumeType.class);
+ }
+
+ }
+
+ public class Delete extends OpenStackRequest<Void> {
+
+ 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 100755
index 0000000..3e6bf97
--- /dev/null
+++ b/cinder-client/src/main/java/com/woorea/openstack/cinder/VolumesExtension.java
@@ -0,0 +1,178 @@
+/* ============LICENSE_START=======================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+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<Volumes> {
+
+ public List(boolean detail) {
+ super(CLIENT, HttpMethod.GET, detail ? "/volumes/detail"
+ : "/volumes", null, Volumes.class);
+ }
+
+ }
+
+ public class Create extends OpenStackRequest<Volume> {
+
+ 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<Void> {
+
+ 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<Volume> {
+
+ public Show(String id) {
+ super(CLIENT, HttpMethod.GET, new StringBuilder("/volumes/")
+ .append(id).toString(), null, Volume.class);
+ }
+
+ }
+
+ public class ShowMetadata extends OpenStackRequest<Metadata> {
+
+ public ShowMetadata(String id) {
+ super(CLIENT, HttpMethod.GET, new StringBuilder("/volumes/")
+ .append(id).append("/metadata").toString(), null,
+ Metadata.class);
+ }
+
+ }
+
+ public class Delete extends OpenStackRequest<Void> {
+
+ public Delete(String id) {
+ super(CLIENT, HttpMethod.DELETE, new StringBuilder("/volumes/")
+ .append(id).toString(), null, Void.class);
+ }
+
+ }
+
+ public class Update extends OpenStackRequest<Void> {
+
+ 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<Void> {
+
+ 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<ConnectionInfo> {
+
+ 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<Void> {
+
+ public TerminateConnection(String id, ConnectionForTerminate connectionForTerminate) {
+ super(CLIENT, HttpMethod.POST, new StringBuilder("/volumes/")
+ .append(id).append("/action").toString(),
+ Entity.json(connectionForTerminate), Void.class);
+ }
+
+ }
+
+}