Skip to content

Commit 8af85b0

Browse files
author
Edison Su
committed
refactor api, based on suggestion from community
1 parent 8ba00f7 commit 8af85b0

164 files changed

Lines changed: 3675 additions & 3162 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

engine/api/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
<artifactId>cloud-api</artifactId>
3131
<version>${project.version}</version>
3232
</dependency>
33+
<dependency>
34+
<groupId>org.apache.cloudstack</groupId>
35+
<artifactId>cloud-framework-ipc</artifactId>
36+
<version>${project.version}</version>
37+
</dependency>
3338
<dependency>
3439
<groupId>org.apache.cxf</groupId>
3540
<artifactId>cxf-bundle-jaxrs</artifactId>

engine/api/src/org/apache/cloudstack/engine/cloud/entity/api/VolumeEntity.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import org.apache.cloudstack.engine.datacenter.entity.api.StorageEntity;
2222
import org.apache.cloudstack.engine.entity.api.CloudStackEntity;
23-
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VolumeDiskType;
23+
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
2424
import org.apache.cloudstack.engine.subsystem.api.storage.type.VolumeType;
2525

2626

@@ -76,12 +76,9 @@ public interface VolumeEntity extends CloudStackEntity {
7676

7777
long getSize();
7878

79-
VolumeDiskType getDiskType();
79+
DiskFormat getDiskType();
8080

8181
VolumeType getType();
8282

8383
StorageEntity getDataStore();
84-
85-
boolean createVolumeFromTemplate(long dataStoreId, VolumeDiskType diskType, TemplateEntity template);
86-
boolean createVolume(long dataStoreId, VolumeDiskType diskType);
8784
}

engine/storage/src/org/apache/cloudstack/storage/command/CommandResult.java renamed to engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CommandResult.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,24 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.cloudstack.storage.command;
19+
package org.apache.cloudstack.engine.subsystem.api.storage;
2020

2121
public class CommandResult {
2222
private boolean success;
2323
private String result;
24-
2524
public CommandResult() {
2625
this.success = true;
2726
this.result = "";
2827
}
29-
28+
3029
public boolean isSuccess() {
3130
return this.success;
3231
}
3332

33+
public boolean isFailed() {
34+
return !this.success;
35+
}
36+
3437
public void setSucess(boolean success) {
3538
this.success = success;
3639
}

engine/storage/image/src/org/apache/cloudstack/storage/image/store/ImageDataStore.java renamed to engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/CopyCommandResult.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.apache.cloudstack.storage.image.store;
19+
package org.apache.cloudstack.engine.subsystem.api.storage;
2020

21-
import org.apache.cloudstack.storage.datastore.DataStore;
22-
import org.apache.cloudstack.storage.image.TemplateObject;
23-
24-
public interface ImageDataStore extends ImageDataStoreInfo {
25-
TemplateObject registerTemplate(long templateId);
26-
boolean deleteTemplate(long templateId);
27-
28-
boolean needDownloadToCacheStorage();
21+
public class CopyCommandResult extends CommandResult {
22+
private final String path;
23+
public CopyCommandResult(String path) {
24+
super();
25+
this.path = path;
26+
}
2927

30-
TemplateObject getTemplate(long templateId);
28+
public String getPath() {
29+
return this.path;
30+
}
3131
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
package org.apache.cloudstack.engine.subsystem.api.storage;
20+
21+
public class CreateCmdResult extends CommandResult {
22+
private String path;
23+
public CreateCmdResult(String path) {
24+
super();
25+
this.path = path;
26+
}
27+
28+
public String getPath() {
29+
return this.path;
30+
}
31+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
package org.apache.cloudstack.engine.subsystem.api.storage;
20+
21+
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
22+
23+
public interface DataObject {
24+
public long getId();
25+
public String getUri();
26+
public DataStore getDataStore();
27+
public long getSize();
28+
public DataObjectType getType();
29+
public DiskFormat getFormat();
30+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
package org.apache.cloudstack.engine.subsystem.api.storage;
20+
21+
public enum DataObjectType {
22+
VOLUME,
23+
SNAPSHOT,
24+
TEMPLATE
25+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.apache.cloudstack.engine.subsystem.api.storage;
2+
3+
public interface DataStore {
4+
DataStoreDriver getDriver();
5+
DataStoreRole getRole();
6+
long getId();
7+
String getUri();
8+
Scope getScope();
9+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
package org.apache.cloudstack.engine.subsystem.api.storage;
20+
21+
import java.util.Set;
22+
23+
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
24+
25+
public interface DataStoreDriver {
26+
public String grantAccess(DataObject data, EndPoint ep);
27+
public boolean revokeAccess(DataObject data, EndPoint ep);
28+
public Set<DataObject> listObjects(DataStore store);
29+
public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback);
30+
public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback);
31+
public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback);
32+
public boolean canCopy(DataObject srcData, DataObject destData);
33+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
package org.apache.cloudstack.engine.subsystem.api.storage;
20+
21+
import java.util.Map;
22+
23+
24+
public interface DataStoreLifeCycle {
25+
public boolean initialize(DataStore store, Map<String, String> dsInfos);
26+
27+
public boolean attachCluster(DataStore store, ClusterScope scope);
28+
29+
boolean attachZone(DataStore dataStore, ZoneScope scope);
30+
31+
public boolean dettach();
32+
33+
public boolean unmanaged();
34+
35+
public boolean maintain();
36+
37+
public boolean cancelMaintain();
38+
39+
public boolean deleteDataStore();
40+
41+
42+
}

0 commit comments

Comments
 (0)