Skip to content

Commit 6075878

Browse files
committed
Add more storage code
1 parent 13542fd commit 6075878

22 files changed

Lines changed: 254 additions & 158 deletions

api/src/com/cloud/storage/StoragePool.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,14 @@ public interface StoragePool {
103103
int getPort();
104104

105105
Long getPodId();
106+
107+
/**
108+
* @return
109+
*/
110+
String getStorageProvider();
111+
112+
/**
113+
* @return
114+
*/
115+
String getStorageType();
106116
}

api/src/com/cloud/storage/StoragePoolStatus.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.cloud.storage;
1818

1919
public enum StoragePoolStatus {
20+
Creating,
2021
Up,
2122
PrepareForMaintenance,
2223
ErrorInMaintenance,

core/src/com/cloud/storage/StoragePoolVO.java

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class StoragePoolVO implements StoragePool, Identity {
5050

5151
@Column(name="pool_type", updatable=false, nullable=false, length=32)
5252
@Enumerated(value=EnumType.STRING)
53-
private StoragePoolType poolType;
53+
private StoragePoolType protocol;
5454

5555
@Column(name=GenericDao.CREATED_COLUMN)
5656
Date created;
@@ -78,6 +78,12 @@ public class StoragePoolVO implements StoragePool, Identity {
7878
@Enumerated(value=EnumType.STRING)
7979
private StoragePoolStatus status;
8080

81+
@Column(name="storage_provider", updatable=true, nullable=false)
82+
private String storageProvider;
83+
84+
@Column(name="storage_type", nullable=false)
85+
private String storageType;
86+
8187
@Override
8288
public long getId() {
8389
return id;
@@ -104,7 +110,7 @@ public String getUuid() {
104110

105111
@Override
106112
public StoragePoolType getPoolType() {
107-
return poolType;
113+
return protocol;
108114
}
109115

110116
@Override
@@ -130,6 +136,24 @@ public long getDataCenterId() {
130136
public long getAvailableBytes() {
131137
return availableBytes;
132138
}
139+
140+
@Override
141+
public String getStorageProvider() {
142+
return storageProvider;
143+
}
144+
145+
public void setStorageProvider(String provider) {
146+
storageProvider = provider;
147+
}
148+
149+
@Override
150+
public String getStorageType() {
151+
return storageType;
152+
}
153+
154+
public void setStorageType(String type) {
155+
storageType = type;
156+
}
133157

134158
@Override
135159
public long getCapacityBytes() {
@@ -189,37 +213,37 @@ public StoragePoolVO(long poolId, String name, String uuid, StoragePoolType type
189213
this.name = name;
190214
this.id = poolId;
191215
this.uuid = uuid;
192-
this.poolType = type;
216+
this.protocol = type;
193217
this.dataCenterId = dataCenterId;
194218
this.availableBytes = availableBytes;
195219
this.capacityBytes = capacityBytes;
196220
this.hostAddress = hostAddress;
197221
this.path = hostPath;
198222
this.port = port;
199223
this.podId = podId;
200-
this.setStatus(StoragePoolStatus.Up);
224+
this.setStatus(StoragePoolStatus.Creating);
201225
}
202226

203227
public StoragePoolVO(StoragePoolVO that) {
204-
this(that.id, that.name, that.uuid, that.poolType, that.dataCenterId, that.podId, that.availableBytes, that.capacityBytes, that.hostAddress, that.port, that.path);
228+
this(that.id, that.name, that.uuid, that.protocol, that.dataCenterId, that.podId, that.availableBytes, that.capacityBytes, that.hostAddress, that.port, that.path);
205229
}
206230

207231
public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path) {
208-
this.poolType = type;
232+
this.protocol = type;
209233
this.hostAddress = hostAddress;
210234
this.port = port;
211235
this.path = path;
212-
this.setStatus(StoragePoolStatus.Up);
236+
this.setStatus(StoragePoolStatus.Creating);
213237
this.uuid = UUID.randomUUID().toString();
214238
}
215239

216240
public StoragePoolVO(StoragePoolType type, String hostAddress, int port, String path, String userInfo) {
217-
this.poolType = type;
241+
this.protocol = type;
218242
this.hostAddress = hostAddress;
219243
this.port = port;
220244
this.path = path;
221245
this.userInfo = userInfo;
222-
this.setStatus(StoragePoolStatus.Up);
246+
this.setStatus(StoragePoolStatus.Creating);
223247
this.uuid = UUID.randomUUID().toString();
224248
}
225249

@@ -259,12 +283,12 @@ public int getPort() {
259283

260284
@Override
261285
public boolean isShared() {
262-
return poolType.isShared();
286+
return protocol.isShared();
263287
}
264288

265289
@Override
266290
public boolean isLocal() {
267-
return !poolType.isShared();
291+
return !protocol.isShared();
268292
}
269293

270294
@Transient
@@ -315,6 +339,6 @@ public int hashCode() {
315339

316340
@Override
317341
public String toString() {
318-
return new StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
342+
return new StringBuilder("Pool[").append(id).append("|").append(protocol).append("]").toString();
319343
}
320344
}

platform/api/.classpath

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="src" path="src"/>
4-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5-
<classpathentry combineaccessrules="false" kind="src" path="/api"/>
6-
<classpathentry combineaccessrules="false" kind="src" path="/server"/>
7-
<classpathentry kind="output" path="bin"/>
3+
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src"/>
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
5+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
6+
<classpathentry kind="output" path="target/classes"/>
87
</classpath>

platform/api/.project

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010
<arguments>
1111
</arguments>
1212
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
1318
</buildSpec>
1419
<natures>
20+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
1521
<nature>org.eclipse.jdt.core.javanature</nature>
1622
</natures>
1723
</projectDescription>

platform/api/pom.xml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
<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">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
3-
<groupId>cloudstack</groupId>
44
<artifactId>cloud-platform-api</artifactId>
5-
<version>0.0.1-SNAPSHOT</version>
5+
<name>Apache CloudStack platform API</name>
6+
<parent>
7+
<groupId>com.cloud</groupId>
8+
<artifactId>cloud-parent</artifactId>
9+
<version>4.0.0-SNAPSHOT</version>
10+
<relativePath>../../parent/pom.xml</relativePath>
11+
</parent>
612
<dependencies>
7-
<dependency>
8-
<groupId>com.cloud</groupId>
9-
<artifactId>cloud-api</artifactId>
10-
<version>4.0.0-SNAPSHOT</version>
11-
</dependency>
13+
<dependency>
14+
<groupId>com.cloud</groupId>
15+
<artifactId>cloud-api</artifactId>
16+
<version>${project.version}</version>
17+
</dependency>
1218
</dependencies>
19+
<build>
20+
<defaultGoal>install</defaultGoal>
21+
<sourceDirectory>src</sourceDirectory>
22+
<!-- <testSourceDirectory>test</testSourceDirectory> -->
23+
</build>
1324
</project>

platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStore.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ public class StoreScope {
3939

4040
String getURI();
4141
String getUUID();
42+
long getCluterId();
43+
long getPodId();
44+
long getZoneId();
4245
StoreType getType();
4346
StoreScope getScope();
4447
Long getId();
4548
DataStoreDriver getDataStoreDriver();
46-
void setEndPointSelector(DataStoreEndPointSelector selector);
49+
DataStoreEndPointSelector getEndPointSelector();
4750
FileSystem getFileSystem();
4851
VolumeStrategy getVolumeStrategy();
4952
SnapshotStrategy getSnapshotStrategy();

platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreDriver.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
*/
1919
package org.apache.cloudstack.platform.subsystem.api.storage;
2020

21+
import com.cloud.agent.api.Answer;
22+
import com.cloud.agent.api.Command;
23+
2124
public interface DataStoreDriver {
2225
String getDriverType();
2326
DataObject create(DataObject obj);
2427
DataObject copy(DataObject src, DataStore dest);
2528
DataObject copy(DataObject src, DataObject dest);
2629
DataObject move(DataObject src, DataObject dest);
30+
Answer sendMessage(DataStoreEndPoint dsep, Command cmd);
2731
boolean delete(DataObject obj);
2832
}
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
package org.apache.cloudstack.platform.subsystem.api.storage;
22

3-
public interface DataStoreEndPoint {
4-
3+
public class DataStoreEndPoint {
4+
protected long hostId;
5+
protected String privIp;
6+
7+
public DataStoreEndPoint(long host, String ip) {
8+
hostId = host;
9+
privIp = ip;
10+
}
11+
12+
public long getHostId() {
13+
return hostId;
14+
}
15+
16+
public String getPrivateIp() {
17+
return privIp;
18+
}
519
}

platform/api/src/org/apache/cloudstack/platform/subsystem/api/storage/DataStoreEndPointSelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
import java.util.List;
44

55
public interface DataStoreEndPointSelector {
6-
List<DataStoreEndPoint> getEndPoints(DataStore ds);
6+
List<DataStoreEndPoint> getEndPoints();
77
}

0 commit comments

Comments
 (0)