You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/01/15 03:04:54 UTC
[25/44] Revert "Merge remote-tracking branch 'origin/javelin' into
javelin"
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIProtocolTransformer.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIProtocolTransformer.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIProtocolTransformer.java
new file mode 100644
index 0000000..44bdba9
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/ISCSIProtocolTransformer.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class ISCSIProtocolTransformer implements StorageProtocolTransformer {
+
+ @Override
+ public List<String> getInputParamNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean normalizeUserInput(Map<String, String> params) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VolumeTO getVolumeTO(VolumeInfo volume) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
new file mode 100644
index 0000000..67ec5e8
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/NfsProtocolTransformer.java
@@ -0,0 +1,96 @@
+/*
+ * 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.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
+import org.apache.cloudstack.storage.to.NfsPrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class NfsProtocolTransformer implements StorageProtocolTransformer {
+ private final PrimaryDataStoreDao dataStoreDao;
+
+ public NfsProtocolTransformer(PrimaryDataStoreDao dao) {
+ this.dataStoreDao = dao;
+ }
+
+ @Override
+ public boolean normalizeUserInput(Map<String, String> params) {
+ String url = params.get("url");
+
+ try {
+ URI uri = new URI(url);
+ if (!"nfs".equalsIgnoreCase(uri.getScheme())) {
+ throw new CloudRuntimeException("invalid protocol, must starting with nfs");
+ }
+ String storageHost = uri.getHost();
+ String hostPath = uri.getPath();
+ String userInfo = uri.getUserInfo();
+ int port = uri.getPort();
+ if (port == -1) {
+ port = 2049;
+ }
+ params.put("server", storageHost);
+ params.put("path", hostPath);
+ params.put("user", userInfo);
+ params.put("port", String.valueOf(port));
+ params.put("uuid", UUID.nameUUIDFromBytes((storageHost + hostPath).getBytes()).toString());
+ } catch (URISyntaxException e) {
+ throw new CloudRuntimeException("invalid url: " + e.toString());
+ }
+ return true;
+ }
+
+ @Override
+ public List<String> getInputParamNames() {
+ List<String> paramNames = new ArrayList<String>();
+ paramNames.add("server");
+ paramNames.add("path");
+ return paramNames;
+ }
+
+ @Override
+ public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+ NfsPrimaryDataStoreTO dataStoreTO = new NfsPrimaryDataStoreTO(dataStore);
+ PrimaryDataStoreVO dataStoreVO = dataStoreDao.findById(dataStore.getId());
+ dataStoreTO.setServer(dataStoreVO.getHostAddress());
+ dataStoreTO.setPath(dataStoreVO.getPath());
+ return dataStoreTO;
+ }
+
+ @Override
+ public VolumeTO getVolumeTO(VolumeInfo volume) {
+ VolumeTO vol = new VolumeTO(volume);
+ vol.setDataStore(this.getDataStoreTO(volume.getDataStore()));
+ return vol;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java
new file mode 100644
index 0000000..e18c861
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/RBDValidator.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class RBDValidator implements StorageProtocolTransformer {
+
+ @Override
+ public boolean normalizeUserInput(Map<String, String> params) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public List<String> getInputParamNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VolumeTO getVolumeTO(VolumeInfo volume) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/StorageProtocolTransformer.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/StorageProtocolTransformer.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/StorageProtocolTransformer.java
new file mode 100644
index 0000000..ab9a613
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/StorageProtocolTransformer.java
@@ -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.configurator.validator;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public interface StorageProtocolTransformer {
+ public boolean normalizeUserInput(Map<String, String> params);
+ public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore);
+ public VolumeTO getVolumeTO(VolumeInfo volume);
+ public List<String> getInputParamNames();
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java
new file mode 100644
index 0000000..a0ae1f8
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/validator/VMFSValidator.java
@@ -0,0 +1,55 @@
+/*
+ * 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;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+
+public class VMFSValidator implements StorageProtocolTransformer {
+
+ @Override
+ public boolean normalizeUserInput(Map<String, String> params) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public List<String> getInputParamNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PrimaryDataStoreTO getDataStoreTO(PrimaryDataStoreInfo dataStore) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public VolumeTO getVolumeTO(VolumeInfo volume) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/AbstractVmwareConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/AbstractVmwareConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/AbstractVmwareConfigurator.java
new file mode 100644
index 0000000..c688bd6
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/AbstractVmwareConfigurator.java
@@ -0,0 +1,49 @@
+/*
+ * 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.configurator.AbstractPrimaryDataStoreConfigurator;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+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;
+
+public abstract class AbstractVmwareConfigurator extends AbstractPrimaryDataStoreConfigurator {
+
+ @Inject
+ PrimaryDataStoreDao dataStoreDao;
+ @Override
+ public HypervisorType getSupportedHypervisor() {
+ return HypervisorType.VMware;
+ }
+
+ @Override
+ protected PrimaryDataStoreLifeCycle getLifeCycle() {
+ return new DefaultVmwarePrimaryDataStoreLifeCycle(dataStoreDao);
+ }
+
+ @Override
+ protected PrimaryDataStoreDriver getDriver() {
+ return new DefaultPrimaryDataStoreDriverImpl();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
new file mode 100644
index 0000000..4e59656
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareIsciConfigurator.java
@@ -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.datastore.configurator.vmware;
+
+import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+@Component
+@Qualifier("defaultProvider")
+public class VmwareIsciConfigurator extends AbstractVmwareConfigurator {
+
+ public String getSupportedDataStoreType() {
+ return "iscsi";
+ }
+
+ @Override
+ public StorageProtocolTransformer getProtocolTransformer() {
+ return new ISCSIProtocolTransformer();
+ }
+
+ @Override
+ protected boolean isLocalStorageSupported() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java
new file mode 100644
index 0000000..afd8d21
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareNfsConfigurator.java
@@ -0,0 +1,49 @@
+/*
+ * 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.storage.datastore.configurator.validator.NfsProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+@Component
+@Qualifier("defaultProvider")
+public class VmwareNfsConfigurator extends AbstractVmwareConfigurator {
+ @Inject
+ PrimaryDataStoreDao dataStoreDao;
+ @Override
+ public String getSupportedDataStoreType() {
+ return "nfs";
+ }
+
+ @Override
+ public StorageProtocolTransformer getProtocolTransformer() {
+ return new NfsProtocolTransformer(dataStoreDao);
+ }
+
+ @Override
+ protected boolean isLocalStorageSupported() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java
new file mode 100644
index 0000000..fc8738c
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/vmware/VmwareVMFSConfigurator.java
@@ -0,0 +1,47 @@
+/*
+ * 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.StorageProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.configurator.validator.VMFSValidator;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+import com.cloud.storage.Storage.StoragePoolType;
+
+@Component
+@Qualifier("defaultProvider")
+public class VmwareVMFSConfigurator extends AbstractVmwareConfigurator {
+
+ @Override
+ public String getSupportedDataStoreType() {
+ return "vmfs";
+ }
+
+ @Override
+ public StorageProtocolTransformer getProtocolTransformer() {
+ return new VMFSValidator();
+ }
+
+ @Override
+ protected boolean isLocalStorageSupported() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java
new file mode 100644
index 0000000..1181dea
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/AbstractXenConfigurator.java
@@ -0,0 +1,40 @@
+// 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.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
+import org.apache.cloudstack.storage.datastore.configurator.AbstractPrimaryDataStoreConfigurator;
+import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.driver.PrimaryDataStoreDriver;
+import org.apache.cloudstack.storage.datastore.lifecycle.DefaultXenPrimaryDataStoreLifeCycle;
+
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+
+public abstract class AbstractXenConfigurator extends AbstractPrimaryDataStoreConfigurator {
+ @Override
+ public HypervisorType getSupportedHypervisor() {
+ return HypervisorType.XenServer;
+ }
+
+ protected PrimaryDataStoreLifeCycle getLifeCycle() {
+ return new DefaultXenPrimaryDataStoreLifeCycle(dataStoreDao);
+ }
+
+ protected PrimaryDataStoreDriver getDriver() {
+ return new DefaultPrimaryDataStoreDriverImpl();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
new file mode 100644
index 0000000..1120ec2
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenIscsiConfigurator.java
@@ -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.datastore.configurator.xen;
+
+import org.apache.cloudstack.storage.datastore.configurator.validator.ISCSIProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+@Component
+@Qualifier("defaultProvider")
+public class XenIscsiConfigurator extends AbstractXenConfigurator {
+
+ @Override
+ public String getSupportedDataStoreType() {
+ return "iscsi";
+ }
+
+ @Override
+ public StorageProtocolTransformer getProtocolTransformer() {
+ return new ISCSIProtocolTransformer();
+ }
+
+ protected boolean isLocalStorageSupported() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java
new file mode 100644
index 0000000..0cb24a8
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/configurator/xen/XenNfsConfigurator.java
@@ -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.datastore.configurator.xen;
+
+import org.apache.cloudstack.storage.datastore.configurator.validator.NfsProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.configurator.validator.StorageProtocolTransformer;
+import org.apache.cloudstack.storage.datastore.protocol.DataStoreProtocol;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+@Component
+@Qualifier("defaultProvider")
+public class XenNfsConfigurator extends AbstractXenConfigurator {
+ @Override
+ public String getSupportedDataStoreType() {
+ return DataStoreProtocol.NFS.toString();
+ }
+
+ @Override
+ public StorageProtocolTransformer getProtocolTransformer() {
+ return new NfsProtocolTransformer(dataStoreDao);
+ }
+
+ @Override
+ protected boolean isLocalStorageSupported() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
new file mode 100644
index 0000000..24a5c79
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
@@ -0,0 +1,116 @@
+/*
+ * 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.db;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.cloudstack.storage.datastore.DataStoreStatus;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface PrimaryDataStoreDao extends GenericDao<PrimaryDataStoreVO, Long> {
+
+ /**
+ * @param datacenterId
+ * -- the id of the datacenter (availability zone)
+ */
+ List<PrimaryDataStoreVO> listByDataCenterId(long datacenterId);
+
+ /**
+ * @param datacenterId
+ * -- the id of the datacenter (availability zone)
+ */
+ List<PrimaryDataStoreVO> listBy(long datacenterId, long podId, Long clusterId);
+
+ /**
+ * Set capacity of storage pool in bytes
+ *
+ * @param id
+ * pool id.
+ * @param capacity
+ * capacity in bytes
+ */
+ void updateCapacity(long id, long capacity);
+
+ /**
+ * Set available bytes of storage pool in bytes
+ *
+ * @param id
+ * pool id.
+ * @param available
+ * available capacity in bytes
+ */
+ void updateAvailable(long id, long available);
+
+ PrimaryDataStoreVO persist(PrimaryDataStoreVO pool, Map<String, String> details);
+
+ /**
+ * Find pool by name.
+ *
+ * @param name
+ * name of pool.
+ * @return the single StoragePoolVO
+ */
+ List<PrimaryDataStoreVO> findPoolByName(String name);
+
+ /**
+ * Find pools by the pod that matches the details.
+ *
+ * @param podId
+ * pod id to find the pools in.
+ * @param details
+ * details to match. All must match for the pool to be returned.
+ * @return List of StoragePoolVO
+ */
+ List<PrimaryDataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details);
+
+ List<PrimaryDataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared);
+
+ /**
+ * Find pool by UUID.
+ *
+ * @param uuid
+ * uuid of pool.
+ * @return the single StoragePoolVO
+ */
+ PrimaryDataStoreVO findPoolByUUID(String uuid);
+
+ List<PrimaryDataStoreVO> listByStorageHost(String hostFqdnOrIp);
+
+ PrimaryDataStoreVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid);
+
+ List<PrimaryDataStoreVO> listPoolByHostPath(String host, String path);
+
+ void updateDetails(long poolId, Map<String, String> details);
+
+ Map<String, String> getDetails(long poolId);
+
+ List<String> searchForStoragePoolDetails(long poolId, String value);
+
+ List<PrimaryDataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid);
+
+ List<PrimaryDataStoreVO> listByStatus(DataStoreStatus status);
+
+ long countPoolsByStatus(DataStoreStatus... statuses);
+
+ List<PrimaryDataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status);
+
+ List<PrimaryDataStoreVO> listPoolsByCluster(long clusterId);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
new file mode 100644
index 0000000..ef42208
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -0,0 +1,360 @@
+/*
+ * 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.db;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+
+import org.apache.cloudstack.storage.datastore.DataStoreStatus;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.GenericSearchBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.SearchCriteria.Func;
+import com.cloud.utils.db.SearchCriteria.Op;
+import com.cloud.utils.db.Transaction;
+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;
+ protected final SearchBuilder<PrimaryDataStoreVO> DcPodAnyClusterSearch;
+ protected final SearchBuilder<PrimaryDataStoreVO> DeleteLvmSearch;
+ protected final GenericSearchBuilder<PrimaryDataStoreVO, Long> StatusCountSearch;
+
+ @Inject protected PrimaryDataStoreDetailsDao _detailsDao;
+
+ private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed is null and storage_pool.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and (";
+ private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING COUNT(storage_pool_details.name) >= ?";
+ private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details WHERE pool_id = ? and value = ?";
+
+ public PrimaryDataStoreDaoImpl() {
+ AllFieldSearch = createSearchBuilder();
+ AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("status", AllFieldSearch.entity().getStatus(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
+ AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
+ AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ);
+ AllFieldSearch.done();
+
+ DcPodSearch = createSearchBuilder();
+ DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
+ DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
+ DcPodSearch.cp();
+ DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
+ DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
+ DcPodSearch.cp();
+ DcPodSearch.done();
+
+ DcPodAnyClusterSearch = createSearchBuilder();
+ DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+ DcPodAnyClusterSearch.and().op("nullpod", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.NULL);
+ DcPodAnyClusterSearch.or("podId", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.EQ);
+ DcPodAnyClusterSearch.cp();
+ DcPodAnyClusterSearch.done();
+
+ DeleteLvmSearch = createSearchBuilder();
+ DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN);
+ DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
+ DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
+ DeleteLvmSearch.cp();
+ DeleteLvmSearch.done();
+
+ StatusCountSearch = createSearchBuilder(Long.class);
+ StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
+ StatusCountSearch.select(null, Func.COUNT, null);
+ StatusCountSearch.done();
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> findPoolByName(String name) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("name", name);
+ return listIncludingRemovedBy(sc);
+ }
+
+ @Override
+ public PrimaryDataStoreVO findPoolByUUID(String uuid) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("uuid", uuid);
+ return findOneIncludingRemovedBy(sc);
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> findIfDuplicatePoolsExistByUUID(String uuid) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("uuid", uuid);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> listByDataCenterId(long datacenterId) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("datacenterId", datacenterId);
+ return listBy(sc);
+ }
+
+ @Override
+ public void updateAvailable(long id, long available) {
+ PrimaryDataStoreVO pool = createForUpdate(id);
+ pool.setAvailableBytes(available);
+ update(id, pool);
+ }
+
+ @Override
+ public void updateCapacity(long id, long capacity) {
+ PrimaryDataStoreVO pool = createForUpdate(id);
+ pool.setCapacityBytes(capacity);
+ update(id, pool);
+
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> listByStorageHost(String hostFqdnOrIp) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("hostAddress", hostFqdnOrIp);
+ return listIncludingRemovedBy(sc);
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> listByStatus(DataStoreStatus status) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("status", status);
+ return listBy(sc);
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> listByStatusInZone(long dcId, DataStoreStatus status) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("status", status);
+ sc.setParameters("datacenterId", dcId);
+ return listBy(sc);
+ }
+
+ @Override
+ public PrimaryDataStoreVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("hostAddress", host);
+ sc.setParameters("path", path);
+ sc.setParameters("datacenterId", datacenterId);
+ sc.setParameters("podId", podId);
+ sc.setParameters("uuid", uuid);
+
+ return findOneBy(sc);
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> listBy(long datacenterId, long podId, Long clusterId) {
+ if (clusterId != null) {
+ SearchCriteria<PrimaryDataStoreVO> sc = DcPodSearch.create();
+ sc.setParameters("datacenterId", datacenterId);
+ sc.setParameters("podId", podId);
+
+ sc.setParameters("cluster", clusterId);
+ return listBy(sc);
+ } else {
+ SearchCriteria<PrimaryDataStoreVO> sc = DcPodAnyClusterSearch.create();
+ sc.setParameters("datacenterId", datacenterId);
+ sc.setParameters("podId", podId);
+ return listBy(sc);
+ }
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> listPoolByHostPath(String host, String path) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("hostAddress", host);
+ sc.setParameters("path", path);
+
+ return listBy(sc);
+ }
+
+ public PrimaryDataStoreVO listById(Integer id) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("id", id);
+
+ return findOneIncludingRemovedBy(sc);
+ }
+
+ @Override
+ @DB
+ public PrimaryDataStoreVO persist(PrimaryDataStoreVO pool, Map<String, String> details) {
+ Transaction txn = Transaction.currentTxn();
+ txn.start();
+ pool = super.persist(pool);
+ if (details != null) {
+ for (Map.Entry<String, String> detail : details.entrySet()) {
+ PrimaryDataStoreDetailVO vo = new PrimaryDataStoreDetailVO(pool.getId(), detail.getKey(), detail.getValue());
+ _detailsDao.persist(vo);
+ }
+ }
+ txn.commit();
+ return pool;
+ }
+
+ @DB
+ @Override
+ public List<PrimaryDataStoreVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String, String> details) {
+ StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
+ if (clusterId != null) {
+ sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND (");
+ }
+ for (Map.Entry<String, String> detail : details.entrySet()) {
+ sql.append("((storage_pool_details.name='").append(detail.getKey()).append("') AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
+ }
+ sql.delete(sql.length() - 4, sql.length());
+ sql.append(DetailsSqlSuffix);
+ Transaction txn = Transaction.currentTxn();
+ PreparedStatement pstmt = null;
+ try {
+ pstmt = txn.prepareAutoCloseStatement(sql.toString());
+ int i = 1;
+ pstmt.setLong(i++, dcId);
+ pstmt.setLong(i++, podId);
+ if (clusterId != null) {
+ pstmt.setLong(i++, clusterId);
+ }
+ pstmt.setInt(i++, details.size());
+ ResultSet rs = pstmt.executeQuery();
+ List<PrimaryDataStoreVO> pools = new ArrayList<PrimaryDataStoreVO>();
+ while (rs.next()) {
+ pools.add(toEntityBean(rs, false));
+ }
+ return pools;
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to execute " + pstmt, e);
+ }
+ }
+
+ protected Map<String, String> tagsToDetails(String[] tags) {
+ Map<String, String> details = new HashMap<String, String>(tags.length);
+ for (String tag : tags) {
+ details.put(tag, "true");
+ }
+ return details;
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[] tags, Boolean shared) {
+ List<PrimaryDataStoreVO> storagePools = null;
+ if (tags == null || tags.length == 0) {
+ storagePools = listBy(dcId, podId, clusterId);
+ } else {
+ Map<String, String> details = tagsToDetails(tags);
+ storagePools = findPoolsByDetails(dcId, podId, clusterId, details);
+ }
+
+ if (shared == null) {
+ return storagePools;
+ } else {
+ List<PrimaryDataStoreVO> filteredStoragePools = new ArrayList<PrimaryDataStoreVO>(storagePools);
+ for (PrimaryDataStoreVO pool : storagePools) {
+ /*
+ * if (shared != pool.isShared()) {
+ * filteredStoragePools.remove(pool); }
+ */
+ }
+
+ return filteredStoragePools;
+ }
+ }
+
+ @Override
+ @DB
+ public List<String> searchForStoragePoolDetails(long poolId, String value) {
+
+ StringBuilder sql = new StringBuilder(FindPoolTagDetails);
+
+ Transaction txn = Transaction.currentTxn();
+ PreparedStatement pstmt = null;
+ try {
+ pstmt = txn.prepareAutoCloseStatement(sql.toString());
+ pstmt.setLong(1, poolId);
+ pstmt.setString(2, value);
+
+ ResultSet rs = pstmt.executeQuery();
+ List<String> tags = new ArrayList<String>();
+
+ while (rs.next()) {
+ tags.add(rs.getString("name"));
+ }
+ return tags;
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
+ }
+
+ }
+
+ @Override
+ public void updateDetails(long poolId, Map<String, String> details) {
+ if (details != null) {
+ _detailsDao.update(poolId, details);
+ }
+ }
+
+ @Override
+ public Map<String, String> getDetails(long poolId) {
+ return _detailsDao.getDetails(poolId);
+ }
+
+ @Override
+ public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ super.configure(name, params);
+ _detailsDao.configure("DetailsDao", params);
+ return true;
+ }
+
+ @Override
+ public long countPoolsByStatus(DataStoreStatus... statuses) {
+ SearchCriteria<Long> sc = StatusCountSearch.create();
+
+ sc.setParameters("status", (Object[]) statuses);
+
+ List<Long> rs = customSearchIncludingRemoved(sc, null);
+ if (rs.size() == 0) {
+ return 0;
+ }
+
+ return rs.get(0);
+ }
+
+ @Override
+ public List<PrimaryDataStoreVO> listPoolsByCluster(long clusterId) {
+ SearchCriteria<PrimaryDataStoreVO> sc = AllFieldSearch.create();
+ sc.setParameters("clusterId", clusterId);
+
+ return listBy(sc);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
new file mode 100644
index 0000000..d1f802d
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
@@ -0,0 +1,79 @@
+// 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.db;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="storage_pool_details")
+public class PrimaryDataStoreDetailVO {
+ @Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id")
+ long id;
+
+ @Column(name="pool_id")
+ long poolId;
+
+ @Column(name="name")
+ String name;
+
+ @Column(name="value")
+ String value;
+
+ public PrimaryDataStoreDetailVO(long poolId, String name, String value) {
+ this.poolId = poolId;
+ this.name = name;
+ this.value = value;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public long getPoolId() {
+ return poolId;
+ }
+
+ public void setPoolId(long poolId) {
+ this.poolId = poolId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ protected PrimaryDataStoreDetailVO() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
new file mode 100644
index 0000000..906742b
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
@@ -0,0 +1,28 @@
+// 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.db;
+
+import java.util.Map;
+
+import com.cloud.storage.StoragePoolDetailVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface PrimaryDataStoreDetailsDao extends GenericDao<PrimaryDataStoreDetailVO, Long> {
+
+ void update(long poolId, Map<String, String> details);
+ Map<String, String> getDetails(long poolId);
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDaoImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDaoImpl.java
new file mode 100644
index 0000000..59c488c
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDaoImpl.java
@@ -0,0 +1,71 @@
+// 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.db;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+
+@Component
+public class PrimaryDataStoreDetailsDaoImpl extends GenericDaoBase<PrimaryDataStoreDetailVO, Long> implements PrimaryDataStoreDetailsDao {
+
+ protected final SearchBuilder<PrimaryDataStoreDetailVO> PoolSearch = null;
+
+ protected PrimaryDataStoreDetailsDaoImpl() {
+ /*
+ super();
+ PoolSearch = createSearchBuilder();
+ PoolSearch.and("pool", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
+ PoolSearch.done();
+ */
+ }
+
+ @Override
+ public void update(long poolId, Map<String, String> details) {
+ Transaction txn = Transaction.currentTxn();
+ SearchCriteria<PrimaryDataStoreDetailVO> sc = PoolSearch.create();
+ sc.setParameters("pool", poolId);
+
+ txn.start();
+ expunge(sc);
+ for (Map.Entry<String, String> entry : details.entrySet()) {
+ PrimaryDataStoreDetailVO detail = new PrimaryDataStoreDetailVO(poolId, entry.getKey(), entry.getValue());
+ persist(detail);
+ }
+ txn.commit();
+ }
+
+ @Override
+ public Map<String, String> getDetails(long poolId) {
+ SearchCriteria<PrimaryDataStoreDetailVO> sc = PoolSearch.create();
+ sc.setParameters("pool", poolId);
+
+ List<PrimaryDataStoreDetailVO> details = listBy(sc);
+ Map<String, String> detailsMap = new HashMap<String, String>();
+ for (PrimaryDataStoreDetailVO detail : details) {
+ detailsMap.put(detail.getName(), detail.getValue());
+ }
+
+ return detailsMap;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDao.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDao.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDao.java
new file mode 100644
index 0000000..ebba01c
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDao.java
@@ -0,0 +1,25 @@
+/*
+ * 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.db;
+
+import com.cloud.utils.db.GenericDao;
+
+public interface PrimaryDataStoreProviderDao extends GenericDao<PrimaryDataStoreProviderVO, Long> {
+ public PrimaryDataStoreProviderVO findByName(String name);
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDaoImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDaoImpl.java
new file mode 100644
index 0000000..0050c2f
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderDaoImpl.java
@@ -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.db;
+
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchCriteria2;
+import com.cloud.utils.db.SearchCriteriaService;
+import com.cloud.utils.db.SearchCriteria.Op;
+
+@Component
+class PrimaryDataStoreProviderDaoImpl extends GenericDaoBase<PrimaryDataStoreProviderVO, Long> implements PrimaryDataStoreProviderDao {
+
+ @Override
+ public PrimaryDataStoreProviderVO findByName(String name) {
+ SearchCriteriaService<PrimaryDataStoreProviderVO, PrimaryDataStoreProviderVO> sc = SearchCriteria2.create(PrimaryDataStoreProviderVO.class);
+ sc.addAnd(sc.getEntity().getName(), Op.EQ, name);
+ return sc.find();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderVO.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderVO.java
new file mode 100644
index 0000000..7e31d9c
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreProviderVO.java
@@ -0,0 +1,49 @@
+/*
+ * 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.db;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+
+@Entity
+@Table(name = "primary_data_store_provider")
+public class PrimaryDataStoreProviderVO {
+ @Id
+ @TableGenerator(name = "data_store_provider_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "data_store_provider_seq", allocationSize = 1)
+ @Column(name = "id", updatable = false, nullable = false)
+ private long id;
+
+ @Column(name = "name", nullable = false)
+ private String name;
+
+ public long getId() {
+ return id;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
new file mode 100644
index 0000000..c8265c7
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreVO.java
@@ -0,0 +1,265 @@
+/*
+ * 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.db;
+
+import java.util.Date;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.TableGenerator;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+
+import org.apache.cloudstack.api.Identity;
+import org.apache.cloudstack.storage.datastore.DataStoreStatus;
+
+import com.cloud.utils.db.GenericDao;
+
+@Entity
+@Table(name = "storage_pool")
+public class PrimaryDataStoreVO implements Identity {
+ @Id
+ @TableGenerator(name = "storage_pool_sq", table = "sequence", pkColumnName = "name", valueColumnName = "value", pkColumnValue = "storage_pool_seq", allocationSize = 1)
+ @Column(name = "id", updatable = false, nullable = false)
+ private long id;
+
+ @Column(name = "name", updatable = false, nullable = false, length = 255)
+ private String name = null;
+
+ @Column(name = "uuid", length = 255)
+ private String uuid = null;
+
+ @Column(name = "pool_type", updatable = false, nullable = false, length = 32)
+ private String poolType;
+
+ @Column(name = GenericDao.CREATED_COLUMN)
+ Date created;
+
+ @Column(name = GenericDao.REMOVED_COLUMN)
+ private Date removed;
+
+ @Column(name = "update_time", updatable = true)
+ @Temporal(value = TemporalType.TIMESTAMP)
+ private Date updateTime;
+
+ @Column(name = "data_center_id", updatable = true, nullable = false)
+ private long dataCenterId;
+
+ @Column(name = "pod_id", updatable = true)
+ private Long podId;
+
+ @Column(name = "available_bytes", updatable = true, nullable = true)
+ private long availableBytes;
+
+ @Column(name = "capacity_bytes", updatable = true, nullable = true)
+ private long capacityBytes;
+
+ @Column(name = "status", updatable = true, nullable = false)
+ @Enumerated(value = EnumType.STRING)
+ private DataStoreStatus status;
+
+ @Column(name = "storage_provider_id", updatable = true, nullable = false)
+ private Long storageProviderId;
+
+ @Column(name = "host_address")
+ private String hostAddress;
+
+ @Column(name = "path")
+ private String path;
+
+ @Column(name = "port")
+ private int port;
+
+ @Column(name = "user_info")
+ private String userInfo;
+
+ @Column(name = "cluster_id")
+ private Long clusterId;
+
+ @Column(name = "configurator_key")
+ private String key;
+
+ public long getId() {
+ return id;
+ }
+
+ public DataStoreStatus getStatus() {
+ return status;
+ }
+
+ public PrimaryDataStoreVO() {
+ this.status = DataStoreStatus.Initial;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+ public String getPoolType() {
+ return poolType;
+ }
+
+ public void setPoolType(String protocol) {
+ this.poolType = protocol;
+ }
+
+ public Date getCreated() {
+ return created;
+ }
+
+ public Date getRemoved() {
+ return removed;
+ }
+
+ public Date getUpdateTime() {
+ return updateTime;
+ }
+
+ public long getDataCenterId() {
+ return dataCenterId;
+ }
+
+ public long getAvailableBytes() {
+ return availableBytes;
+ }
+
+ public Long getStorageProviderId() {
+ return storageProviderId;
+ }
+
+ public void setStorageProviderId(Long provider) {
+ storageProviderId = provider;
+ }
+
+ public long getCapacityBytes() {
+ return capacityBytes;
+ }
+
+ public void setAvailableBytes(long available) {
+ availableBytes = available;
+ }
+
+ public void setCapacityBytes(long capacity) {
+ capacityBytes = capacity;
+ }
+
+ public Long getClusterId() {
+ return clusterId;
+ }
+
+ public void setClusterId(Long clusterId) {
+ this.clusterId = clusterId;
+ }
+
+ public String getHostAddress() {
+ return hostAddress;
+ }
+
+ public void setHostAddress(String host) {
+ this.hostAddress = host;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getUserInfo() {
+ return userInfo;
+ }
+
+ public void setStatus(DataStoreStatus status) {
+ this.status = status;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setDataCenterId(long dcId) {
+ this.dataCenterId = dcId;
+ }
+
+ public void setPodId(Long podId) {
+ this.podId = podId;
+ }
+
+ public void setUuid(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public void setUserInfo(String userInfo) {
+ this.userInfo = userInfo;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public Long getPodId() {
+ return podId;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public String getKey() {
+ return this.key;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof PrimaryDataStoreVO) || obj == null) {
+ return false;
+ }
+ PrimaryDataStoreVO that = (PrimaryDataStoreVO) obj;
+ return this.id == that.id;
+ }
+
+ @Override
+ public int hashCode() {
+ return new Long(id).hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder("Pool[").append(id).append("|").append(poolType).append("]").toString();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
index fd8a35c..2855d4e 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
@@ -1,27 +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.datastore.driver;
import java.util.List;
-import java.util.Set;
+import java.util.Map;
-import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
import org.apache.cloudstack.framework.async.AsyncRpcConext;
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.command.CommandResult;
import org.apache.cloudstack.storage.command.CreateVolumeAnswer;
import org.apache.cloudstack.storage.command.CreateVolumeCommand;
-import org.apache.cloudstack.storage.command.DeleteCommand;
+import org.apache.cloudstack.storage.command.CreateVolumeFromBaseImageCommand;
+import org.apache.cloudstack.storage.command.DeleteVolumeCommand;
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
-import org.apache.cloudstack.storage.volume.PrimaryDataStoreDriver;
+import org.apache.cloudstack.storage.to.ImageOnPrimayDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeTO;
+import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
+import org.apache.cloudstack.storage.volume.VolumeObject;
import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
import com.cloud.agent.api.Answer;
-
+import com.cloud.agent.api.Command;
+import com.cloud.utils.exception.CloudRuntimeException;
public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
@@ -34,28 +52,48 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
}
+ @Override
+ public void setDataStore(PrimaryDataStore dataStore) {
+ this.dataStore = dataStore;
+ }
+
private class CreateVolumeContext<T> extends AsyncRpcConext<T> {
- private final DataObject volume;
+ private final VolumeObject volume;
/**
* @param callback
*/
- public CreateVolumeContext(AsyncCompletionCallback<T> callback, DataObject volume) {
+ public CreateVolumeContext(AsyncCompletionCallback<T> callback, VolumeObject volume) {
super(callback);
this.volume = volume;
}
- public DataObject getVolume() {
+ public VolumeObject getVolume() {
return this.volume;
}
}
- public Void createAsyncCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, CreateVolumeContext<CommandResult> context) {
+ @Override
+ public void createVolumeAsync(VolumeObject vol, AsyncCompletionCallback<CommandResult> callback) {
+ List<EndPoint> endPoints = vol.getDataStore().getEndPoints();
+ EndPoint ep = endPoints.get(0);
+ VolumeInfo volInfo = vol;
+ CreateVolumeCommand createCmd = new CreateVolumeCommand(this.dataStore.getVolumeTO(volInfo));
+
+ CreateVolumeContext<CommandResult> context = new CreateVolumeContext<CommandResult>(callback, vol);
+ AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
+ caller.setContext(context)
+ .setCallback(caller.getTarget().createVolumeAsyncCallback(null, null));
+
+ ep.sendMessageAsync(createCmd, caller);
+ }
+
+ public Void createVolumeAsyncCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, CreateVolumeContext<CommandResult> context) {
CommandResult result = new CommandResult();
CreateVolumeAnswer volAnswer = (CreateVolumeAnswer) callback.getResult();
if (volAnswer.getResult()) {
- DataObject volume = context.getVolume();
- //volume.setPath(volAnswer.getVolumeUuid());
+ VolumeObject volume = context.getVolume();
+ volume.setPath(volAnswer.getVolumeUuid());
} else {
result.setResult(volAnswer.getDetails());
}
@@ -65,18 +103,18 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
}
@Override
- public void deleteAsync(DataObject vo, AsyncCompletionCallback<CommandResult> callback) {
- DeleteCommand cmd = new DeleteCommand(vo.getUri());
- List<EndPoint> endPoints = null;
+ public void deleteVolumeAsync(VolumeObject vo, AsyncCompletionCallback<CommandResult> callback) {
+ DeleteVolumeCommand cmd = new DeleteVolumeCommand(this.dataStore.getVolumeTO(vo));
+ List<EndPoint> endPoints = vo.getDataStore().getEndPoints();
EndPoint ep = endPoints.get(0);
AsyncRpcConext<CommandResult> context = new AsyncRpcConext<CommandResult>(callback);
AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
- caller.setCallback(caller.getTarget().deleteCallback(null, null))
+ caller.setCallback(caller.getTarget().deleteVolumeCallback(null, null))
.setContext(context);
ep.sendMessageAsync(cmd, caller);
}
- public Void deleteCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, AsyncRpcConext<CommandResult> context) {
+ public Void deleteVolumeCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, AsyncRpcConext<CommandResult> context) {
CommandResult result = new CommandResult();
Answer answer = callback.getResult();
if (!answer.getResult()) {
@@ -85,7 +123,19 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
context.getParentCallback().complete(result);
return null;
}
- /*
+
+ @Override
+ public String grantAccess(VolumeObject vol, EndPoint ep) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean revokeAccess(VolumeObject vol, EndPoint ep) {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
private class CreateVolumeFromBaseImageContext<T> extends AsyncRpcConext<T> {
private final VolumeObject volume;
@@ -99,14 +149,12 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
}
}
-
@Override
- public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateInfo template, AsyncCompletionCallback<CommandResult> callback) {
+ public void createVolumeFromBaseImageAsync(VolumeObject volume, String template, AsyncCompletionCallback<CommandResult> callback) {
VolumeTO vol = this.dataStore.getVolumeTO(volume);
+ CreateVolumeFromBaseImageCommand cmd = new CreateVolumeFromBaseImageCommand(vol, template);
List<EndPoint> endPoints = this.dataStore.getEndPoints();
EndPoint ep = endPoints.get(0);
- String templateUri = template.getDataStore().grantAccess(template, ep);
- CreateVolumeFromBaseImageCommand cmd = new CreateVolumeFromBaseImageCommand(vol, templateUri);
CreateVolumeFromBaseImageContext<CommandResult> context = new CreateVolumeFromBaseImageContext<CommandResult>(callback, volume);
AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
@@ -114,8 +162,10 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
.setCallback(caller.getTarget().createVolumeFromBaseImageAsyncCallback(null, null));
ep.sendMessageAsync(cmd, caller);
- }*/
- /*
+
+
+ }
+
public Object createVolumeFromBaseImageAsyncCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, CreateVolumeFromBaseImageContext<CommandResult> context) {
CreateVolumeAnswer answer = (CreateVolumeAnswer)callback.getResult();
CommandResult result = new CommandResult();
@@ -132,69 +182,37 @@ public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver
AsyncCompletionCallback<CommandResult> parentCall = context.getParentCallback();
parentCall.complete(result);
return null;
- }*/
-
- @Override
- public void createAsync(DataObject vol,
- AsyncCompletionCallback<CreateCmdResult> callback) {
- List<EndPoint> endPoints = null;
- EndPoint ep = endPoints.get(0);
- CreateVolumeCommand createCmd = new CreateVolumeCommand(vol.getUri());
-
- CreateVolumeContext<CommandResult> context = null;
- AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
- caller.setContext(context)
- .setCallback(caller.getTarget().createAsyncCallback(null, null));
-
- ep.sendMessageAsync(createCmd, caller);
-
- }
-
- @Override
- public String grantAccess(DataObject vol, EndPoint ep) {
- // TODO Auto-generated method stub
- return null;
}
@Override
- public boolean revokeAccess(DataObject vol, EndPoint ep) {
+ public long getCapacity() {
// TODO Auto-generated method stub
- return false;
+ return 0;
}
@Override
- public Set<DataObject> listObjects(DataStore store) {
+ public long getAvailableCapacity() {
// TODO Auto-generated method stub
- return null;
+ return 0;
}
@Override
- public void takeSnapshot(SnapshotInfo snapshot,
- AsyncCompletionCallback<CommandResult> callback) {
+ public boolean initialize(Map<String, String> params) {
// TODO Auto-generated method stub
-
+ return false;
}
@Override
- public void revertSnapshot(SnapshotInfo snapshot,
- AsyncCompletionCallback<CommandResult> callback) {
+ public boolean grantAccess(EndPoint ep) {
// TODO Auto-generated method stub
-
+ return false;
}
-
-
@Override
- public boolean canCopy(DataObject srcData, DataObject destData) {
+ public boolean revokeAccess(EndPoint ep) {
// TODO Auto-generated method stub
return false;
}
- @Override
- public void copyAsync(DataObject srcdata, DataObject destData,
- AsyncCompletionCallback<CopyCommandResult> callback) {
- // TODO Auto-generated method stub
-
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/110465b5/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
new file mode 100644
index 0000000..3a9b13d
--- /dev/null
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/PrimaryDataStoreDriver.java
@@ -0,0 +1,49 @@
+// 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.driver;
+
+import java.util.Map;
+
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.EndPoint;
+import org.apache.cloudstack.storage.command.CommandResult;
+import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
+import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
+import org.apache.cloudstack.storage.volume.VolumeObject;
+
+public interface PrimaryDataStoreDriver {
+ void createVolumeAsync(VolumeObject vol, AsyncCompletionCallback<CommandResult> callback);
+
+ void createVolumeFromBaseImageAsync(VolumeObject volume, String template, AsyncCompletionCallback<CommandResult> callback);
+
+ void deleteVolumeAsync(VolumeObject vo, AsyncCompletionCallback<CommandResult> callback);
+
+ String grantAccess(VolumeObject vol, EndPoint ep);
+
+ boolean revokeAccess(VolumeObject vol, EndPoint ep);
+
+ long getCapacity();
+
+ long getAvailableCapacity();
+
+
+ //Lifecycle API
+ boolean initialize(Map<String, String> params);
+ boolean grantAccess(EndPoint ep);
+ boolean revokeAccess(EndPoint ep);
+ void setDataStore(PrimaryDataStore dataStore);
+}