Skip to content

Commit ae59bf6

Browse files
committed
add lifecycle on primarydatastore
1 parent 57c9b4c commit ae59bf6

27 files changed

Lines changed: 384 additions & 128 deletions

‎engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreLifeCycle.java‎

Lines changed: 0 additions & 13 deletions
This file was deleted.

‎engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreInfo.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ public interface PrimaryDataStoreInfo {
3838
public State getManagedState();
3939
public String getName();
4040
public String getType();
41+
public PrimaryDataStoreLifeCycle getLifeCycle();
42+
PrimaryDataStoreProvider getProvider();
4143
}

engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/PrimaryDataStoreLifeCycle.java renamed to engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java

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

2121
import java.util.Map;
2222

23-
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
24-
2523
public interface PrimaryDataStoreLifeCycle {
26-
public PrimaryDataStoreInfo registerDataStore(Map<String, String> dsInfos);
24+
public boolean initialize(Map<String, String> dsInfos);
2725

28-
public boolean attach(long scope);
26+
public boolean attach(Scope scope);
2927

30-
public boolean dettach(long dataStoreId);
28+
public boolean dettach();
3129

32-
public boolean unmanaged(long dataStoreId);
30+
public boolean unmanaged();
3331

34-
public boolean maintain(long dataStoreId);
32+
public boolean maintain();
3533

36-
public boolean cancelMaintain(long dataStoreId);
34+
public boolean cancelMaintain();
3735

38-
public boolean deleteDataStore(long dataStoreId);
36+
public boolean deleteDataStore();
3937
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.apache.cloudstack.engine.subsystem.api.storage;
2+
3+
import java.util.Map;
4+
5+
public interface PrimaryDataStoreProvider {
6+
public PrimaryDataStoreInfo getDataStore(long dataStoreId);
7+
public long getId();
8+
public String getName();
9+
10+
/**
11+
* @param dsInfos
12+
* @return
13+
*/
14+
PrimaryDataStoreInfo registerDataStore(Map<String, String> dsInfos);
15+
16+
//LifeCycle of provider
17+
public boolean configure();
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 interface Scope {
22+
public ScopeType getScopeType();
23+
public long getScopeId();
24+
}
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 ScopeType {
22+
HOST,
23+
CLUSTER,
24+
ZONE;
25+
}

‎engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
3636
import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity;
3737
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
38+
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
39+
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
3840
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.QCOW2;
3941
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VHD;
4042
import org.apache.cloudstack.engine.subsystem.api.storage.disktype.VMDK;
@@ -47,9 +49,7 @@
4749
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
4850
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
4951
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
50-
import org.apache.cloudstack.storage.datastore.lifecycle.PrimaryDataStoreLifeCycle;
5152
import org.apache.cloudstack.storage.datastore.provider.DefaultPrimaryDatastoreProviderImpl;
52-
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProvider;
5353
import org.apache.cloudstack.storage.datastore.provider.PrimaryDataStoreProviderManager;
5454
import org.apache.cloudstack.storage.image.ImageService;
5555
import org.apache.cloudstack.storage.image.db.ImageDataDao;

‎engine/storage/src/org/apache/cloudstack/storage/datastore/PrimaryDataStore.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,4 @@ public interface PrimaryDataStore extends PrimaryDataStoreInfo {
4949
boolean installTemplate(TemplateOnPrimaryDataStoreInfo template);
5050

5151
VolumeDiskType getDefaultDiskType();
52-
5352
}
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.storage.scope;
20+
21+
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
22+
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
23+
24+
public class ClusterScope implements Scope {
25+
private ScopeType type = ScopeType.CLUSTER;
26+
private long clusterId;
27+
28+
public ClusterScope(long clusterId) {
29+
this.clusterId = clusterId;
30+
}
31+
32+
@Override
33+
public ScopeType getScopeType() {
34+
return this.type;
35+
}
36+
37+
@Override
38+
public long getScopeId() {
39+
return this.clusterId;
40+
}
41+
42+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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.storage.scope;
20+
21+
import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
22+
import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
23+
24+
public class HostScope implements Scope {
25+
private ScopeType type = ScopeType.HOST;
26+
private long hostId;
27+
public HostScope(long hostId) {
28+
this.hostId = hostId;
29+
}
30+
@Override
31+
public ScopeType getScopeType() {
32+
return this.type;
33+
}
34+
35+
@Override
36+
public long getScopeId() {
37+
return this.hostId;
38+
}
39+
}

0 commit comments

Comments
 (0)