Skip to content

Commit c3f0d14

Browse files
storage/object: Add support for Ceph RGW Object Store (#8389)
This feature adds support for Ceph's RADOS Gateway (RGW) support for the Object Store feature of CloudStack. The RGW of Ceph is Amazon S3 compliant and is therefor an easy and straigforward implementation of basic S3 features. Existing Ceph environments can have the RGW added as an additional feature to a cluster already providing RBD (Block Device) to a CloudStack environment. Introduce the BucketTO to pass to the drivers. This replaces just passing the bucket's name. Some upcoming drivers require more information then just the bucket name to perform their actions, for example they require the access and secret key which belong to the account of this bucket. This is leftover code from a long time ago and this validation test has nu influence on the end result on how a URL will be used afterwards. We should support hosts pointing to an IPv6(-only) address out of the box. For the code it does not matter if it's IPv4 or IPv6. This is the admin's choice. Signed-off-by: Rohit Yadav <[email protected]> Co-authored-by: Rohit Yadav <[email protected]>
1 parent 605534b commit c3f0d14

File tree

23 files changed

+1008
-82
lines changed

23 files changed

+1008
-82
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package com.cloud.agent.api.to;
18+
19+
import org.apache.cloudstack.storage.object.Bucket;
20+
21+
public final class BucketTO {
22+
23+
private String name;
24+
25+
private String accessKey;
26+
27+
private String secretKey;
28+
29+
public BucketTO(Bucket bucket) {
30+
this.name = bucket.getName();
31+
this.accessKey = bucket.getAccessKey();
32+
this.secretKey = bucket.getSecretKey();
33+
}
34+
35+
public BucketTO(String name) {
36+
this.name = name;
37+
}
38+
39+
public String getName() {
40+
return this.name;
41+
}
42+
43+
public String getAccessKey() {
44+
return this.accessKey;
45+
}
46+
47+
public String getSecretKey() {
48+
return this.secretKey;
49+
}
50+
}

client/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,11 @@
648648
<artifactId>cloud-plugin-storage-object-minio</artifactId>
649649
<version>${project.version}</version>
650650
</dependency>
651+
<dependency>
652+
<groupId>org.apache.cloudstack</groupId>
653+
<artifactId>cloud-plugin-storage-object-ceph</artifactId>
654+
<version>${project.version}</version>
655+
</dependency>
651656
<dependency>
652657
<groupId>org.apache.cloudstack</groupId>
653658
<artifactId>cloud-plugin-storage-object-simulator</artifactId>

engine/api/src/main/java/org/apache/cloudstack/storage/object/ObjectStoreEntity.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.cloudstack.storage.object;
2020

21+
import com.cloud.agent.api.to.BucketTO;
2122
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
2223

2324
import java.util.List;
@@ -30,19 +31,19 @@ public interface ObjectStoreEntity extends DataStore, ObjectStore {
3031

3132
boolean createUser(long accountId);
3233

33-
boolean deleteBucket(String name);
34+
boolean deleteBucket(BucketTO bucket);
3435

35-
boolean setBucketEncryption(String name);
36+
boolean setBucketEncryption(BucketTO bucket);
3637

37-
boolean deleteBucketEncryption(String name);
38+
boolean deleteBucketEncryption(BucketTO bucket);
3839

39-
boolean setBucketVersioning(String name);
40+
boolean setBucketVersioning(BucketTO bucket);
4041

41-
boolean deleteBucketVersioning(String name);
42+
boolean deleteBucketVersioning(BucketTO bucket);
4243

43-
void setBucketPolicy(String name, String policy);
44+
void setBucketPolicy(BucketTO bucket, String policy);
4445

45-
void setQuota(String name, int quota);
46+
void setQuota(BucketTO bucket, int quota);
4647

4748
Map<String, Long> getAllBucketsUsage();
4849
}

engine/schema/src/main/java/com/cloud/storage/BucketVO.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,23 @@ public class BucketVO implements Bucket {
9797
String uuid;
9898

9999
public BucketVO() {
100+
this.uuid = UUID.randomUUID().toString();
101+
}
102+
103+
public BucketVO(String name) {
104+
this.uuid = UUID.randomUUID().toString();
105+
this.name = name;
106+
this.state = State.Allocated;
100107
}
101108

102109
public BucketVO(long accountId, long domainId, long objectStoreId, String name, Integer quota, boolean versioning,
103-
boolean encryption, boolean objectLock, String policy)
104-
{
110+
boolean encryption, boolean objectLock, String policy) {
105111
this.accountId = accountId;
106112
this.domainId = domainId;
107113
this.objectStoreId = objectStoreId;
108114
this.name = name;
109-
state = State.Allocated;
110-
uuid = UUID.randomUUID().toString();
115+
this.state = State.Allocated;
116+
this.uuid = UUID.randomUUID().toString();
111117
this.quota = quota;
112118
this.versioning = versioning;
113119
this.encryption = encryption;

engine/storage/object/src/main/java/org/apache/cloudstack/storage/object/store/ObjectStoreImpl.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919
package org.apache.cloudstack.storage.object.store;
2020

21+
import com.cloud.agent.api.to.BucketTO;
2122
import com.cloud.agent.api.to.DataStoreTO;
2223
import org.apache.cloudstack.storage.object.Bucket;
2324
import com.cloud.storage.DataStoreRole;
@@ -107,38 +108,38 @@ public Bucket createBucket(Bucket bucket, boolean objectLock) {
107108
}
108109

109110
@Override
110-
public boolean deleteBucket(String bucketName) {
111-
return driver.deleteBucket(bucketName, objectStoreVO.getId());
111+
public boolean deleteBucket(BucketTO bucket) {
112+
return driver.deleteBucket(bucket, objectStoreVO.getId());
112113
}
113114

114115
@Override
115-
public boolean setBucketEncryption(String bucketName) {
116-
return driver.setBucketEncryption(bucketName, objectStoreVO.getId());
116+
public boolean setBucketEncryption(BucketTO bucket) {
117+
return driver.setBucketEncryption(bucket, objectStoreVO.getId());
117118
}
118119

119120
@Override
120-
public boolean deleteBucketEncryption(String bucketName) {
121-
return driver.deleteBucketEncryption(bucketName, objectStoreVO.getId());
121+
public boolean deleteBucketEncryption(BucketTO bucket) {
122+
return driver.deleteBucketEncryption(bucket, objectStoreVO.getId());
122123
}
123124

124125
@Override
125-
public boolean setBucketVersioning(String bucketName) {
126-
return driver.setBucketVersioning(bucketName, objectStoreVO.getId());
126+
public boolean setBucketVersioning(BucketTO bucket) {
127+
return driver.setBucketVersioning(bucket, objectStoreVO.getId());
127128
}
128129

129130
@Override
130-
public boolean deleteBucketVersioning(String bucketName) {
131-
return driver.deleteBucketVersioning(bucketName, objectStoreVO.getId());
131+
public boolean deleteBucketVersioning(BucketTO bucket) {
132+
return driver.deleteBucketVersioning(bucket, objectStoreVO.getId());
132133
}
133134

134135
@Override
135-
public void setBucketPolicy(String bucketName, String policy) {
136-
driver.setBucketPolicy(bucketName, policy, objectStoreVO.getId());
136+
public void setBucketPolicy(BucketTO bucket, String policy) {
137+
driver.setBucketPolicy(bucket, policy, objectStoreVO.getId());
137138
}
138139

139140
@Override
140-
public void setQuota(String bucketName, int quota) {
141-
driver.setBucketQuota(bucketName, objectStoreVO.getId(), quota);
141+
public void setQuota(BucketTO bucket, int quota) {
142+
driver.setBucketQuota(bucket, objectStoreVO.getId(), quota);
142143
}
143144

144145
@Override

engine/storage/src/main/java/org/apache/cloudstack/storage/object/ObjectStoreDriver.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import com.amazonaws.services.s3.model.AccessControlList;
2222
import com.amazonaws.services.s3.model.BucketPolicy;
23+
import com.cloud.agent.api.to.BucketTO;
2324
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
2425

2526
import java.util.List;
@@ -30,30 +31,30 @@ public interface ObjectStoreDriver extends DataStoreDriver {
3031

3132
List<Bucket> listBuckets(long storeId);
3233

33-
boolean deleteBucket(String bucketName, long storeId);
34+
boolean deleteBucket(BucketTO bucket, long storeId);
3435

35-
AccessControlList getBucketAcl(String bucketName, long storeId);
36+
AccessControlList getBucketAcl(BucketTO bucket, long storeId);
3637

37-
void setBucketAcl(String bucketName, AccessControlList acl, long storeId);
38+
void setBucketAcl(BucketTO bucket, AccessControlList acl, long storeId);
3839

39-
void setBucketPolicy(String bucketName, String policyType, long storeId);
40+
void setBucketPolicy(BucketTO bucket, String policyType, long storeId);
4041

41-
BucketPolicy getBucketPolicy(String bucketName, long storeId);
42+
BucketPolicy getBucketPolicy(BucketTO bucket, long storeId);
4243

43-
void deleteBucketPolicy(String bucketName, long storeId);
44+
void deleteBucketPolicy(BucketTO bucket, long storeId);
4445

4546
boolean createUser(long accountId, long storeId);
4647

47-
boolean setBucketEncryption(String bucketName, long storeId);
48+
boolean setBucketEncryption(BucketTO bucket, long storeId);
4849

49-
boolean deleteBucketEncryption(String bucketName, long storeId);
50+
boolean deleteBucketEncryption(BucketTO bucket, long storeId);
5051

5152

52-
boolean setBucketVersioning(String bucketName, long storeId);
53+
boolean setBucketVersioning(BucketTO bucket, long storeId);
5354

54-
boolean deleteBucketVersioning(String bucketName, long storeId);
55+
boolean deleteBucketVersioning(BucketTO bucket, long storeId);
5556

56-
void setBucketQuota(String bucketName, long storeId, long size);
57+
void setBucketQuota(BucketTO bucket, long storeId, long size);
5758

5859
Map<String, Long> getAllBucketsUsage(long storeId);
5960
}

plugins/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
<module>storage/volume/flasharray</module>
139139
<module>storage/volume/primera</module>
140140
<module>storage/object/minio</module>
141+
<module>storage/object/ceph</module>
141142
<module>storage/object/simulator</module>
142143

143144

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<artifactId>cloud-plugin-storage-object-ceph</artifactId>
23+
<name>Apache CloudStack Plugin - Ceph RGW object storage provider</name>
24+
<parent>
25+
<groupId>org.apache.cloudstack</groupId>
26+
<artifactId>cloudstack-plugins</artifactId>
27+
<version>4.20.0.0-SNAPSHOT</version>
28+
<relativePath>../../../pom.xml</relativePath>
29+
</parent>
30+
<dependencies>
31+
<dependency>
32+
<groupId>org.apache.cloudstack</groupId>
33+
<artifactId>cloud-engine-storage</artifactId>
34+
<version>${project.version}</version>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.apache.cloudstack</groupId>
38+
<artifactId>cloud-engine-storage-object</artifactId>
39+
<version>${project.version}</version>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.apache.cloudstack</groupId>
43+
<artifactId>cloud-engine-schema</artifactId>
44+
<version>${project.version}</version>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.github.twonote</groupId>
48+
<artifactId>radosgw-admin4j</artifactId>
49+
<version>2.0.9</version>
50+
</dependency>
51+
</dependencies>
52+
</project>

0 commit comments

Comments
 (0)