Repository: cloudstack Updated Branches: refs/heads/master 21ff99b0a -> 30fbff868
Changes/additions related to SolidFire automation tests Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/30fbff86 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/30fbff86 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/30fbff86 Branch: refs/heads/master Commit: 30fbff86877cbd88e46d4d5e003a60c06fa33e8a Parents: 21ff99b Author: Vania Xu <vania...@solidfire.com> Authored: Wed Aug 27 14:57:07 2014 -0600 Committer: Mike Tutkowski <mike.tutkow...@solidfire.com> Committed: Wed Aug 27 16:02:29 2014 -0600 ---------------------------------------------------------------------- client/tomcatconf/commands.properties.in | 6 ++ .../GetSolidFireVolumeAccessGroupIdCmd.java | 84 ++++++++++++++++++++ .../GetSolidFireVolumeIscsiNameCmd.java | 78 ++++++++++++++++++ .../solidfire/GetSolidFireVolumeSizeCmd.java | 84 ++++++++++++++++++++ ...ApiSolidFireVolumeAccessGroupIdResponse.java | 37 +++++++++ .../ApiSolidFireVolumeIscsiNameResponse.java | 37 +++++++++ .../ApiSolidFireVolumeSizeResponse.java | 37 +++++++++ .../solidfire/ApiSolidFireService.java | 8 ++ .../solidfire/ApiSolidFireServiceImpl.java | 57 ++++++++++++- 9 files changed, 427 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/client/tomcatconf/commands.properties.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 18ac2bf..006a4ff 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -655,6 +655,12 @@ listApis=15 getApiLimit=15 resetApiLimit=1 +#### API SolidFire Service Command +getSolidFireAccountId=15 +getSolidFireVolumeSize=15 +getSolidFireVolumeAccessGroupId=15 +getSolidFireVolumeIscsiName=15 + #### Region commands addRegion=1 updateRegion=1 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeAccessGroupIdCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeAccessGroupIdCmd.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeAccessGroupIdCmd.java new file mode 100644 index 0000000..c432fb1 --- /dev/null +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeAccessGroupIdCmd.java @@ -0,0 +1,84 @@ +// 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.api.command.user.solidfire; + +import com.cloud.user.Account; +import com.cloud.org.Cluster; +import com.cloud.storage.StoragePool; +import com.cloud.dc.dao.ClusterDao; + +import javax.inject.Inject; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeAccessGroupIdResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.solidfire.ApiSolidFireService; +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; + +@APICommand(name = "getSolidFireVolumeAccessGroupId", responseObject = ApiSolidFireVolumeAccessGroupIdResponse.class, description = "Get the SF Volume Access Group ID", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class GetSolidFireVolumeAccessGroupIdCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(GetSolidFireVolumeAccessGroupIdCmd.class.getName()); + private static final String s_name = "getsolidfirevolumeaccessgroupidresponse"; + + @Parameter(name = ApiConstants.CLUSTER_ID, type = CommandType.STRING, description = "Cluster UUID", required = true) + private String clusterUuid; + @Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.STRING, description = "Storage Pool UUID", required = true) + private String storagePoolUuid; + + @Inject private ApiSolidFireService _apiSolidFireService; + @Inject private ClusterDao _clusterDao; + @Inject private PrimaryDataStoreDao _storagePoolDao; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + Account account = CallContext.current().getCallingAccount(); + + if (account != null) { + return account.getId(); + } + + return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked + } + + @Override + public void execute() { + Cluster cluster = _clusterDao.findByUuid(clusterUuid); + StoragePool storagePool = _storagePoolDao.findByUuid(storagePoolUuid); + + ApiSolidFireVolumeAccessGroupIdResponse response = _apiSolidFireService.getSolidFireVolumeAccessGroupId(cluster.getId(), storagePool.getId()); + + response.setResponseName(getCommandName()); + response.setObjectName("apisolidfirevolumeaccessgroupid"); + + this.setResponseObject(response); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeIscsiNameCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeIscsiNameCmd.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeIscsiNameCmd.java new file mode 100644 index 0000000..7afa301 --- /dev/null +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeIscsiNameCmd.java @@ -0,0 +1,78 @@ +// 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.api.command.user.solidfire; + +import com.cloud.storage.dao.VolumeDao; +import com.cloud.storage.Volume; +import com.cloud.user.Account; + +import javax.inject.Inject; + +import org.apache.log4j.Logger; +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeIscsiNameResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.solidfire.ApiSolidFireService; + +@APICommand(name = "getSolidFireVolumeIscsiName", responseObject = ApiSolidFireVolumeIscsiNameResponse.class, description = "Get SolidFire Volume's Iscsi Name", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) + +public class GetSolidFireVolumeIscsiNameCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(GetSolidFireVolumeIscsiNameCmd.class.getName()); + private static final String s_name = "getsolidfirevolumeiscsinameresponse"; + + @Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.STRING, description = "CloudStack Volume UUID", required = true) + private String volumeUuid; + + @Inject private ApiSolidFireService _apiSolidFireService; + @Inject private VolumeDao _volumeDao; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + Account account = CallContext.current().getCallingAccount(); + + if (account != null) { + return account.getId(); + } + + return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked + } + + @Override + public void execute() { + Volume volume = _volumeDao.findByUuid(volumeUuid); + + ApiSolidFireVolumeIscsiNameResponse response = _apiSolidFireService.getSolidFireVolumeIscsiName(volume); + + response.setResponseName(getCommandName()); + response.setObjectName("apisolidfirevolumeiscsiname"); + + this.setResponseObject(response); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeSizeCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeSizeCmd.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeSizeCmd.java new file mode 100644 index 0000000..3a27a66 --- /dev/null +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireVolumeSizeCmd.java @@ -0,0 +1,84 @@ +// 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.api.command.user.solidfire; + +import com.cloud.storage.Volume; +import com.cloud.user.Account; +import com.cloud.storage.dao.VolumeDao; +import com.cloud.storage.StoragePool; + +import javax.inject.Inject; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.ApiConstants; +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeSizeResponse; +import org.apache.cloudstack.context.CallContext; +import org.apache.cloudstack.solidfire.ApiSolidFireService; +import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; + +@APICommand(name = "getSolidFireVolumeSize", responseObject = ApiSolidFireVolumeSizeResponse.class, description = "Get the SF volume size including Hypervisor Snapshot Reserve", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class GetSolidFireVolumeSizeCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(GetSolidFireVolumeSizeCmd.class.getName()); + private static final String s_name = "getsolidfirevolumesizeresponse"; + + @Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.STRING, description = "Volume UUID", required = true) + private String volumeUuid; + @Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.STRING, description = "Storage Pool UUID", required = true) + private String storagePoolUuid; + + @Inject private ApiSolidFireService _apiSolidFireService; + @Inject private VolumeDao _volumeDao; + @Inject private PrimaryDataStoreDao _storagePoolDao; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + Account account = CallContext.current().getCallingAccount(); + + if (account != null) { + return account.getId(); + } + + return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked + } + + @Override + public void execute() { + Volume volume = _volumeDao.findByUuid(volumeUuid); + StoragePool storagePool = _storagePoolDao.findByUuid(storagePoolUuid); + + ApiSolidFireVolumeSizeResponse response = _apiSolidFireService.getSolidFireVolumeSize(volume, storagePool); + + response.setResponseName(getCommandName()); + response.setObjectName("apisolidfirevolumesize"); + + this.setResponseObject(response); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeAccessGroupIdResponse.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeAccessGroupIdResponse.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeAccessGroupIdResponse.java new file mode 100644 index 0000000..8b63192 --- /dev/null +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeAccessGroupIdResponse.java @@ -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.api.response; + +import com.cloud.serializer.Param; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.BaseResponse; + +public class ApiSolidFireVolumeAccessGroupIdResponse extends BaseResponse { + @SerializedName("solidFireVolumeAccessGroupId") + @Param(description = "SolidFire Volume Access Group Id") + private long solidFireVolumeAccessGroupId; + + public ApiSolidFireVolumeAccessGroupIdResponse(long sfVolumeAccessGroupId) { + solidFireVolumeAccessGroupId = sfVolumeAccessGroupId; + } + + public long getSolidFireAccessGroupId() { + return solidFireVolumeAccessGroupId; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeIscsiNameResponse.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeIscsiNameResponse.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeIscsiNameResponse.java new file mode 100644 index 0000000..517cba9 --- /dev/null +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeIscsiNameResponse.java @@ -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.api.response; + +import com.cloud.serializer.Param; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.BaseResponse; + +public class ApiSolidFireVolumeIscsiNameResponse extends BaseResponse { + @SerializedName("solidFireVolumeIscsiName") + @Param(description = "SolidFire Volume Iscsi Name") + private String solidFireVolumeIscsiName; + + public ApiSolidFireVolumeIscsiNameResponse(String sfVolumeIscsiName) { + solidFireVolumeIscsiName = sfVolumeIscsiName; + } + + public String getSolidFireVolumeIscsiName() { + return solidFireVolumeIscsiName; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeSizeResponse.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeSizeResponse.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeSizeResponse.java new file mode 100644 index 0000000..b320ada --- /dev/null +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/response/ApiSolidFireVolumeSizeResponse.java @@ -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.api.response; + +import com.cloud.serializer.Param; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.BaseResponse; + +public class ApiSolidFireVolumeSizeResponse extends BaseResponse { + @SerializedName("solidFireVolumeSize") + @Param(description = "SolidFire Volume Size Including Hypervisor Snapshot Reserve") + private long solidFireVolumeSize; + + public ApiSolidFireVolumeSizeResponse(long sfVolumeSize) { + solidFireVolumeSize = sfVolumeSize; + } + + public long getSolidFireVolumeSize() { + return solidFireVolumeSize; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java index 2f01cfd..92828d4 100644 --- a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java @@ -17,8 +17,13 @@ package org.apache.cloudstack.solidfire; import com.cloud.utils.component.PluggableService; +import com.cloud.storage.Volume; +import com.cloud.storage.StoragePool; import org.apache.cloudstack.api.response.ApiSolidFireAccountIdResponse; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeSizeResponse; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeAccessGroupIdResponse; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeIscsiNameResponse; /** * Provide API for SolidFire integration tests @@ -26,4 +31,7 @@ import org.apache.cloudstack.api.response.ApiSolidFireAccountIdResponse; */ public interface ApiSolidFireService extends PluggableService { public ApiSolidFireAccountIdResponse getSolidFireAccountId(Long csAccountId, Long storagePoolId); + public ApiSolidFireVolumeSizeResponse getSolidFireVolumeSize(Volume volume, StoragePool storagePool); + public ApiSolidFireVolumeAccessGroupIdResponse getSolidFireVolumeAccessGroupId(Long csClusterId, Long storagePoolId); + public ApiSolidFireVolumeIscsiNameResponse getSolidFireVolumeIscsiName(Volume volume); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/30fbff86/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java index bbb485c..85e195c 100644 --- a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java @@ -27,11 +27,26 @@ import javax.naming.ConfigurationException; import org.apache.log4j.Logger; import org.apache.cloudstack.acl.APIChecker; import org.apache.cloudstack.storage.datastore.util.SolidFireUtil; -import org.apache.cloudstack.api.response.ApiSolidFireAccountIdResponse; import org.apache.cloudstack.api.command.user.solidfire.GetSolidFireAccountIdCmd; +import org.apache.cloudstack.api.command.user.solidfire.GetSolidFireVolumeAccessGroupIdCmd; +import org.apache.cloudstack.api.command.user.solidfire.GetSolidFireVolumeIscsiNameCmd; +import org.apache.cloudstack.api.command.user.solidfire.GetSolidFireVolumeSizeCmd; +import org.apache.cloudstack.api.response.ApiSolidFireAccountIdResponse; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeAccessGroupIdResponse; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeIscsiNameResponse; +import org.apache.cloudstack.api.response.ApiSolidFireVolumeSizeResponse; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider; +import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager; +import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver; import org.springframework.stereotype.Component; +import com.cloud.dc.ClusterDetailsDao; +import com.cloud.dc.ClusterDetailsVO; +import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.PermissionDeniedException; +import com.cloud.storage.StoragePool; +import com.cloud.storage.Volume; import com.cloud.user.AccountDetailsDao; import com.cloud.user.AccountDetailVO; import com.cloud.user.User; @@ -44,6 +59,10 @@ public class ApiSolidFireServiceImpl extends AdapterBase implements APIChecker, @Inject private AccountDetailsDao _accountDetailsDao; + @Inject + private DataStoreProviderManager _dataStoreProviderMgr; + @Inject + private ClusterDetailsDao _clusterDetailsDao; @Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { @@ -61,6 +80,39 @@ public class ApiSolidFireServiceImpl extends AdapterBase implements APIChecker, } @Override + public ApiSolidFireVolumeSizeResponse getSolidFireVolumeSize(Volume volume, StoragePool storagePool) { + PrimaryDataStoreDriver primaryStoreDriver = null; + + try { + DataStoreProvider storeProvider = _dataStoreProviderMgr.getDataStoreProvider(storagePool.getStorageProviderName()); + DataStoreDriver storeDriver = storeProvider.getDataStoreDriver(); + + if (storeDriver instanceof PrimaryDataStoreDriver) { + primaryStoreDriver = (PrimaryDataStoreDriver)storeDriver; + } + } + catch(InvalidParameterValueException e) { + throw new InvalidParameterValueException("Invalid Storage Driver Type"); + } + + return new ApiSolidFireVolumeSizeResponse(primaryStoreDriver.getVolumeSizeIncludingHypervisorSnapshotReserve(volume, storagePool)); + } + + @Override + public ApiSolidFireVolumeAccessGroupIdResponse getSolidFireVolumeAccessGroupId(Long csClusterId, Long storagePoolId) { + ClusterDetailsVO clusterDetails = _clusterDetailsDao.findDetail(csClusterId, SolidFireUtil.getVagKey(storagePoolId)); + String sfVagId = clusterDetails.getValue(); + + return new ApiSolidFireVolumeAccessGroupIdResponse(Long.parseLong(sfVagId)); + } + + @Override + public ApiSolidFireVolumeIscsiNameResponse getSolidFireVolumeIscsiName(Volume volume) { + return new ApiSolidFireVolumeIscsiNameResponse(volume.get_iScsiName()); + } + + + @Override public boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException { return true; } @@ -70,6 +122,9 @@ public class ApiSolidFireServiceImpl extends AdapterBase implements APIChecker, List<Class<?>> cmdList = new ArrayList<Class<?>>(); cmdList.add(GetSolidFireAccountIdCmd.class); + cmdList.add(GetSolidFireVolumeSizeCmd.class); + cmdList.add(GetSolidFireVolumeAccessGroupIdCmd.class); + cmdList.add(GetSolidFireVolumeIscsiNameCmd.class); return cmdList; }