Skip to content

Commit 7652a44

Browse files
committed
add datastore configurator, for each hypervisor and each protocol, needs to have its own configurator
1 parent ae59bf6 commit 7652a44

31 files changed

Lines changed: 993 additions & 2 deletions

engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/PrimaryDataStoreLifeCycle.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ public interface PrimaryDataStoreLifeCycle {
3434
public boolean cancelMaintain();
3535

3636
public boolean deleteDataStore();
37+
38+
/**
39+
* @param dataStore
40+
*/
41+
void setDataStore(PrimaryDataStoreInfo dataStore);
3742
}

engine/storage/volume/src/org/apache/cloudstack/storage/datastore/DefaultPrimaryDataStore.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ private DefaultPrimaryDataStore(PrimaryDataStoreVO pdsv) {
4949
}
5050

5151
public void setDriver(PrimaryDataStoreDriver driver) {
52+
driver.setDataStore(this);
5253
this.driver = driver;
5354
}
5455

5556
public void setLifeCycle(PrimaryDataStoreLifeCycle lifeCycle) {
57+
lifeCycle.setDataStore(this);
5658
this.lifeCycle = lifeCycle;
5759
}
5860

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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.datastore.configurator;
20+
21+
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
22+
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
23+
24+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
25+
import com.cloud.storage.Storage.StoragePoolType;
26+
27+
public interface PrimaryDataStoreConfigurator {
28+
public HypervisorType getSupportedHypervisor();
29+
public StoragePoolType getSupportedDataStoreType();
30+
public PrimaryDataStore getDataStore(long dataStoreId);
31+
public ProtocolValidator getValidator();
32+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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.datastore.configurator.kvm;
20+
21+
import javax.inject.Inject;
22+
23+
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
24+
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
25+
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
26+
import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
27+
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
28+
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
29+
import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
30+
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
31+
import org.apache.cloudstack.storage.datastore.lifecycle.DefaultKvmPrimaryDataStoreLifeCycle;
32+
33+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
34+
import com.cloud.utils.exception.CloudRuntimeException;
35+
36+
public abstract class AbstractKvmConfigurator implements PrimaryDataStoreConfigurator {
37+
@Inject
38+
PrimaryDataStoreDao dataStoreDao;
39+
@Override
40+
public HypervisorType getSupportedHypervisor() {
41+
return HypervisorType.KVM;
42+
}
43+
44+
protected PrimaryDataStoreLifeCycle getLifeCycle() {
45+
return new DefaultKvmPrimaryDataStoreLifeCycle(dataStoreDao);
46+
}
47+
48+
protected PrimaryDataStoreDriver getDriver() {
49+
return new DefaultPrimaryDataStoreDriverImpl();
50+
}
51+
52+
@Override
53+
public PrimaryDataStore getDataStore(long dataStoreId) {
54+
PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
55+
if (dataStoreVO == null) {
56+
throw new CloudRuntimeException("Can't find primary data store: " + dataStoreId);
57+
}
58+
59+
DefaultPrimaryDataStore dataStore = DefaultPrimaryDataStore.createDataStore(dataStoreVO);
60+
dataStore.setDriver(this.getDriver());
61+
dataStore.setLifeCycle(getLifeCycle());
62+
return dataStore;
63+
}
64+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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.datastore.configurator.kvm;
20+
21+
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
22+
import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
23+
import org.apache.cloudstack.storage.datastore.configurator.validator.CLVMValidator;
24+
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
25+
import org.springframework.beans.factory.annotation.Qualifier;
26+
import org.springframework.stereotype.Component;
27+
28+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
29+
import com.cloud.storage.Storage.StoragePoolType;
30+
31+
@Component
32+
@Qualifier("defaultProvider")
33+
public class KvmCLVMConfigurator extends AbstractKvmConfigurator {
34+
35+
@Override
36+
public StoragePoolType getSupportedDataStoreType() {
37+
return StoragePoolType.CLVM;
38+
}
39+
40+
@Override
41+
public ProtocolValidator getValidator() {
42+
return new CLVMValidator();
43+
}
44+
45+
46+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.datastore.configurator.kvm;
20+
21+
import org.apache.cloudstack.storage.datastore.configurator.validator.NfsValidator;
22+
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
23+
import org.springframework.beans.factory.annotation.Qualifier;
24+
import org.springframework.stereotype.Component;
25+
26+
import com.cloud.storage.Storage.StoragePoolType;
27+
28+
@Component
29+
@Qualifier("defaultProvider")
30+
public class KvmNfsConfigurator extends AbstractKvmConfigurator {
31+
32+
@Override
33+
public StoragePoolType getSupportedDataStoreType() {
34+
return StoragePoolType.NetworkFilesystem;
35+
}
36+
37+
@Override
38+
public ProtocolValidator getValidator() {
39+
return new NfsValidator();
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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.datastore.configurator.kvm;
20+
21+
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
22+
import org.apache.cloudstack.storage.datastore.configurator.validator.RBDValidator;
23+
import org.springframework.beans.factory.annotation.Qualifier;
24+
import org.springframework.stereotype.Component;
25+
26+
import com.cloud.storage.Storage.StoragePoolType;
27+
28+
@Component
29+
@Qualifier("defaultProvider")
30+
public class KvmRBDConfigurator extends AbstractKvmConfigurator {
31+
32+
@Override
33+
public StoragePoolType getSupportedDataStoreType() {
34+
return StoragePoolType.RBD;
35+
}
36+
37+
@Override
38+
public ProtocolValidator getValidator() {
39+
return new RBDValidator();
40+
}
41+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.datastore.configurator.validator;
20+
21+
import java.util.List;
22+
import java.util.Map;
23+
24+
public class CLVMValidator implements ProtocolValidator {
25+
26+
@Override
27+
public boolean validate(Map<String, String> params) {
28+
// TODO Auto-generated method stub
29+
return false;
30+
}
31+
32+
@Override
33+
public List<String> getInputParamNames() {
34+
// TODO Auto-generated method stub
35+
return null;
36+
}
37+
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.datastore.configurator.validator;
20+
21+
import java.util.List;
22+
import java.util.Map;
23+
24+
public class FileSystemValidator implements ProtocolValidator {
25+
26+
@Override
27+
public boolean validate(Map<String, String> params) {
28+
// TODO Auto-generated method stub
29+
return false;
30+
}
31+
32+
@Override
33+
public List<String> getInputParamNames() {
34+
// TODO Auto-generated method stub
35+
return null;
36+
}
37+
38+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.datastore.configurator.validator;
20+
21+
import java.util.List;
22+
import java.util.Map;
23+
24+
public class ISCSIValiator implements ProtocolValidator {
25+
26+
@Override
27+
public boolean validate(Map<String, String> params) {
28+
// TODO Auto-generated method stub
29+
return false;
30+
}
31+
32+
@Override
33+
public List<String> getInputParamNames() {
34+
// TODO Auto-generated method stub
35+
return null;
36+
}
37+
38+
}

0 commit comments

Comments
 (0)