add datastore configurator, for each hypervisor and each protocol, needs to have its own configurator

This commit is contained in:
Edison Su 2012-12-07 18:22:54 -08:00
parent ae59bf6c3b
commit 7652a44be7
31 changed files with 993 additions and 2 deletions

View File

@ -34,4 +34,9 @@ public interface PrimaryDataStoreLifeCycle {
public boolean cancelMaintain();
public boolean deleteDataStore();
/**
* @param dataStore
*/
void setDataStore(PrimaryDataStoreInfo dataStore);
}

View File

@ -49,10 +49,12 @@ public class DefaultPrimaryDataStore implements PrimaryDataStore {
}
public void setDriver(PrimaryDataStoreDriver driver) {
driver.setDataStore(this);
this.driver = driver;
}
public void setLifeCycle(PrimaryDataStoreLifeCycle lifeCycle) {
lifeCycle.setDataStore(this);
this.lifeCycle = lifeCycle;
}

View File

@ -0,0 +1,32 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage.StoragePoolType;
public interface PrimaryDataStoreConfigurator {
public HypervisorType getSupportedHypervisor();
public StoragePoolType getSupportedDataStoreType();
public PrimaryDataStore getDataStore(long dataStoreId);
public ProtocolValidator getValidator();
}

View File

@ -0,0 +1,64 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.kvm;
import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
import org.apache.cloudstack.storage.datastore.lifecycle.DefaultKvmPrimaryDataStoreLifeCycle;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.exception.CloudRuntimeException;
public abstract class AbstractKvmConfigurator implements PrimaryDataStoreConfigurator {
@Inject
PrimaryDataStoreDao dataStoreDao;
@Override
public HypervisorType getSupportedHypervisor() {
return HypervisorType.KVM;
}
protected PrimaryDataStoreLifeCycle getLifeCycle() {
return new DefaultKvmPrimaryDataStoreLifeCycle(dataStoreDao);
}
protected PrimaryDataStoreDriver getDriver() {
return new DefaultPrimaryDataStoreDriverImpl();
}
@Override
public PrimaryDataStore getDataStore(long dataStoreId) {
PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
if (dataStoreVO == null) {
throw new CloudRuntimeException("Can't find primary data store: " + dataStoreId);
}
DefaultPrimaryDataStore dataStore = DefaultPrimaryDataStore.createDataStore(dataStoreVO);
dataStore.setDriver(this.getDriver());
dataStore.setLifeCycle(getLifeCycle());
return dataStore;
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.kvm;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
import org.apache.cloudstack.storage.datastore.configurator.validator.CLVMValidator;
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage.StoragePoolType;
@Component
@Qualifier("defaultProvider")
public class KvmCLVMConfigurator extends AbstractKvmConfigurator {
@Override
public StoragePoolType getSupportedDataStoreType() {
return StoragePoolType.CLVM;
}
@Override
public ProtocolValidator getValidator() {
return new CLVMValidator();
}
}

View File

@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.kvm;
import org.apache.cloudstack.storage.datastore.configurator.validator.NfsValidator;
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import com.cloud.storage.Storage.StoragePoolType;
@Component
@Qualifier("defaultProvider")
public class KvmNfsConfigurator extends AbstractKvmConfigurator {
@Override
public StoragePoolType getSupportedDataStoreType() {
return StoragePoolType.NetworkFilesystem;
}
@Override
public ProtocolValidator getValidator() {
return new NfsValidator();
}
}

View File

@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.kvm;
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
import org.apache.cloudstack.storage.datastore.configurator.validator.RBDValidator;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import com.cloud.storage.Storage.StoragePoolType;
@Component
@Qualifier("defaultProvider")
public class KvmRBDConfigurator extends AbstractKvmConfigurator {
@Override
public StoragePoolType getSupportedDataStoreType() {
return StoragePoolType.RBD;
}
@Override
public ProtocolValidator getValidator() {
return new RBDValidator();
}
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.validator;
import java.util.List;
import java.util.Map;
public class CLVMValidator implements ProtocolValidator {
@Override
public boolean validate(Map<String, String> params) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<String> getInputParamNames() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.validator;
import java.util.List;
import java.util.Map;
public class FileSystemValidator implements ProtocolValidator {
@Override
public boolean validate(Map<String, String> params) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<String> getInputParamNames() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.validator;
import java.util.List;
import java.util.Map;
public class ISCSIValiator implements ProtocolValidator {
@Override
public boolean validate(Map<String, String> params) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<String> getInputParamNames() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.validator;
import java.util.List;
import java.util.Map;
public class NfsValidator implements ProtocolValidator {
@Override
public boolean validate(Map<String, String> params) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<String> getInputParamNames() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,27 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.validator;
import java.util.List;
import java.util.Map;
public interface ProtocolValidator {
public boolean validate(Map<String, String> params);
public List<String> getInputParamNames();
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.validator;
import java.util.List;
import java.util.Map;
public class RBDValidator implements ProtocolValidator {
@Override
public boolean validate(Map<String, String> params) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<String> getInputParamNames() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.validator;
import java.util.List;
import java.util.Map;
public class VMFSValidator implements ProtocolValidator {
@Override
public boolean validate(Map<String, String> params) {
// TODO Auto-generated method stub
return false;
}
@Override
public List<String> getInputParamNames() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,66 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.vmware;
import javax.inject.Inject;
import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
import org.apache.cloudstack.storage.datastore.DefaultPrimaryDataStore;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
import org.apache.cloudstack.storage.datastore.lifecycle.DefaultVmwarePrimaryDataStoreLifeCycle;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.exception.CloudRuntimeException;
public abstract class AbstractVmwareConfigurator implements PrimaryDataStoreConfigurator {
@Inject
PrimaryDataStoreDao dataStoreDao;
@Override
public HypervisorType getSupportedHypervisor() {
return HypervisorType.VMware;
}
protected PrimaryDataStoreLifeCycle getLifeCycle() {
return new DefaultVmwarePrimaryDataStoreLifeCycle();
}
protected PrimaryDataStoreDriver getDriver() {
return new DefaultPrimaryDataStoreDriverImpl();
}
@Override
public PrimaryDataStore getDataStore(long dataStoreId) {
PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(dataStoreId);
if (dataStoreVO == null) {
throw new CloudRuntimeException("Can't find primary data store: " + dataStoreId);
}
DefaultPrimaryDataStore dataStore = DefaultPrimaryDataStore.createDataStore(dataStoreVO);
dataStore.setDriver(this.getDriver());
dataStore.setLifeCycle(getLifeCycle());
return dataStore;
}
}

View File

@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.vmware;
import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIValiator;
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import com.cloud.storage.Storage.StoragePoolType;
@Component
@Qualifier("defaultProvider")
public class VmwareIsciConfigurator extends AbstractVmwareConfigurator {
@Override
public StoragePoolType getSupportedDataStoreType() {
return StoragePoolType.Iscsi;
}
@Override
public ProtocolValidator getValidator() {
return new ISCSIValiator();
}
}

View File

@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.vmware;
import org.apache.cloudstack.storage.datastore.configurator.validator.NfsValidator;
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
import com.cloud.storage.Storage.StoragePoolType;
public class VmwareNfsConfigurator extends AbstractVmwareConfigurator {
@Override
public StoragePoolType getSupportedDataStoreType() {
return StoragePoolType.NetworkFilesystem;
}
@Override
public ProtocolValidator getValidator() {
return new NfsValidator();
}
}

View File

@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.vmware;
import org.apache.cloudstack.storage.datastore.configurator.validator.ProtocolValidator;
import org.apache.cloudstack.storage.datastore.configurator.validator.VMFSValidator;
import com.cloud.storage.Storage.StoragePoolType;
public class VmwareVMFSConfigurator extends AbstractVmwareConfigurator {
@Override
public StoragePoolType getSupportedDataStoreType() {
return StoragePoolType.VMFS;
}
@Override
public ProtocolValidator getValidator() {
return new VMFSValidator();
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.xen;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
public class XenIscsiConfigurator implements PrimaryDataStoreConfigurator {
@Override
public HypervisorType getSupportedHypervisor() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getSupportedDataStoreType() {
// TODO Auto-generated method stub
return null;
}
@Override
public PrimaryDataStore getDataStore() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -0,0 +1,46 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.configurator.xen;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
public class XenNfsConfigurator implements PrimaryDataStoreConfigurator {
@Override
public HypervisorType getSupportedHypervisor() {
// TODO Auto-generated method stub
return null;
}
@Override
public String getSupportedDataStoreType() {
// TODO Auto-generated method stub
return null;
}
@Override
public PrimaryDataStore getDataStore() {
// TODO Auto-generated method stub
return null;
}
}

View File

@ -46,6 +46,7 @@ import com.cloud.utils.db.SearchCriteria.Func;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.exception.CloudRuntimeException;
@Component
public class PrimaryDataStoreDaoImpl extends GenericDaoBase<PrimaryDataStoreVO, Long> implements PrimaryDataStoreDao {
protected final SearchBuilder<PrimaryDataStoreVO> AllFieldSearch;
protected final SearchBuilder<PrimaryDataStoreVO> DcPodSearch;

View File

@ -28,6 +28,15 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
this.dataStore = dataStore;
}
public DefaultPrimaryDataStoreDriverImpl() {
}
@Override
public void setDataStore(PrimaryDataStore dataStore) {
this.dataStore = dataStore;
}
@Override
public boolean createVolume(VolumeObject vol) {
// The default driver will send createvolume command to one of hosts

View File

@ -3,6 +3,7 @@ package org.apache.cloudstack.storage.datastore.driver;
import java.util.Map;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
import org.apache.cloudstack.storage.volume.VolumeObject;
@ -26,5 +27,5 @@ public interface PrimaryDataStoreDriver {
boolean initialize(Map<String, String> params);
boolean grantAccess(EndPoint ep);
boolean revokeAccess(EndPoint ep);
void setDataStore(PrimaryDataStore dataStore);
}

View File

@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.lifecycle;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
public class DefaultKvmPrimaryDataStoreLifeCycle extends DefaultPrimaryDataStoreLifeCycleImpl {
/**
* @param dataStoreDao
* @param dataStore
*/
public DefaultKvmPrimaryDataStoreLifeCycle(PrimaryDataStoreDao dataStoreDao) {
super(dataStoreDao);
// TODO Auto-generated constructor stub
}
}

View File

@ -39,8 +39,12 @@ import org.springframework.stereotype.Component;
public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLifeCycle {
protected PrimaryDataStoreInfo dataStore;
protected PrimaryDataStoreDao dataStoreDao;
public DefaultPrimaryDataStoreLifeCycleImpl(PrimaryDataStoreDao dataStoreDao, PrimaryDataStore dataStore) {
public DefaultPrimaryDataStoreLifeCycleImpl(PrimaryDataStoreDao dataStoreDao) {
this.dataStoreDao = dataStoreDao;
}
@Override
public void setDataStore(PrimaryDataStoreInfo dataStore) {
this.dataStore = dataStore;
}

View File

@ -0,0 +1,39 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.lifecycle;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
public class DefaultVmwarePrimaryDataStoreLifeCycle extends DefaultPrimaryDataStoreLifeCycleImpl {
/**
* @param dataStoreDao
* @param dataStore
*/
public DefaultVmwarePrimaryDataStoreLifeCycle(PrimaryDataStoreDao dataStoreDao, PrimaryDataStore dataStore) {
super(dataStoreDao, dataStore);
// TODO Auto-generated constructor stub
}
public DefaultVmwarePrimaryDataStoreLifeCycle() {
super(null, null);
}
}

View File

@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.datastore.lifecycle;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
public class DefaultXenPrimaryDataStoreLifeCycle extends DefaultPrimaryDataStoreLifeCycleImpl {
/**
* @param dataStoreDao
* @param dataStore
*/
public DefaultXenPrimaryDataStoreLifeCycle(PrimaryDataStoreDao dataStoreDao, PrimaryDataStore dataStore) {
super(dataStoreDao, dataStore);
// TODO Auto-generated constructor stub
}
}

View File

@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.volume.test;
import java.util.List;
import javax.inject.Inject;
import org.apache.cloudstack.storage.datastore.configurator.PrimaryDataStoreConfigurator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:/resource/testContext.xml")
public class ConfiguratorTest {
@Inject
@Qualifier("defaultProvider")
List<PrimaryDataStoreConfigurator> configurators;
@Test
public void testLoadConfigurator() {
for (PrimaryDataStoreConfigurator configurator : configurators) {
System.out.println(configurator.getClass().getName());
}
}
}

View File

@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cloudstack.storage.volume.test;
import org.apache.cloudstack.storage.image.motion.ImageMotionService;
import org.mockito.Mockito;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class TestConfiguration {
@Bean
public ImageMotionService imageMotion() {
return Mockito.mock(ImageMotionService.class);
}
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="org.apache.cloudstack.storage" />
<context:component-scan base-package="org.apache.cloudstack.engine.subsystem.api.storage" />
<context:component-scan base-package="com.cloud.utils.db" />
<context:component-scan base-package="com.cloud.utils.component" />
<context:component-scan base-package="com.cloud.host.dao" />
<context:component-scan base-package="com.cloud.dc.dao" />
<context:component-scan base-package=" com.cloud.upgrade.dao" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean class="org.cloudstack.storage.volume.test.TestConfiguration" />
</beans>

View File

@ -3,6 +3,7 @@ package org.apache.cloudstack.storage.datastore.driver;
import java.util.Map;
import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
import org.apache.cloudstack.storage.volume.VolumeObject;
@ -69,4 +70,10 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
return false;
}
@Override
public void setDataStore(PrimaryDataStore dataStore) {
// TODO Auto-generated method stub
}
}