Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2579318EF5 for ; Wed, 14 Oct 2015 18:09:56 +0000 (UTC) Received: (qmail 69391 invoked by uid 500); 14 Oct 2015 18:09:43 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 69242 invoked by uid 500); 14 Oct 2015 18:09:43 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 68923 invoked by uid 99); 14 Oct 2015 18:09:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Oct 2015 18:09:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4E947E060C; Wed, 14 Oct 2015 18:09:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mtutkowski@apache.org To: commits@cloudstack.apache.org Date: Wed, 14 Oct 2015 18:09:47 -0000 Message-Id: <6564f57893b4489eb4b961f5a1a71888@git.apache.org> In-Reply-To: <661f7193f4344fd4bef7f77433b49e5c@git.apache.org> References: <661f7193f4344fd4bef7f77433b49e5c@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [7/7] git commit: updated refs/heads/sf-plugins-a to 49ca3b4 SolidFire API and GUI plug-ins Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/49ca3b40 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/49ca3b40 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/49ca3b40 Branch: refs/heads/sf-plugins-a Commit: 49ca3b40af707495874a2d1d9fd2db02136814e7 Parents: 59f337d Author: Mike Tutkowski Authored: Thu May 7 12:21:35 2015 -0600 Committer: Mike Tutkowski Committed: Wed Oct 14 12:06:49 2015 -0600 ---------------------------------------------------------------------- client/pom.xml | 5 + client/tomcatconf/commands.properties.in | 14 + .../spring-solidfire-intg-test-context.xml | 2 +- .../solidfire/GetSolidFireAccountIdCmd.java | 8 +- .../GetSolidFireVolumeAccessGroupIdCmd.java | 8 +- .../GetSolidFireVolumeIscsiNameCmd.java | 8 +- .../solidfire/GetSolidFireVolumeSizeCmd.java | 8 +- .../solidfire/ApiSolidFireIntgTestService.java | 37 + .../ApiSolidFireIntgTestServiceImpl.java | 128 +++ .../solidfire/ApiSolidFireService.java | 37 - .../solidfire/ApiSolidFireServiceImpl.java | 128 --- plugins/api/solidfire/pom.xml | 50 + .../cloudstack/solidfire/module.properties | 18 + .../solidfire/spring-solidfire-context.xml | 37 + .../CreateReferenceToSolidFireClusterCmd.java | 106 ++ .../CreateSolidFireVirtualNetworkCmd.java | 104 ++ .../DeleteReferenceToSolidFireClusterCmd.java | 82 ++ .../DeleteSolidFireVirtualNetworkCmd.java | 90 ++ .../solidfire/ListSolidFireClustersCmd.java | 95 ++ .../UpdateReferenceToSolidFireClusterCmd.java | 95 ++ .../UpdateSolidFireVirtualNetworkCmd.java | 103 ++ .../solidfire/CreateSolidFireVolumeCmd.java | 105 ++ .../solidfire/DeleteSolidFireVolumeCmd.java | 97 ++ .../ListSolidFireVirtualNetworksCmd.java | 114 +++ .../user/solidfire/ListSolidFireVolumesCmd.java | 99 ++ .../solidfire/UpdateSolidFireVolumeCmd.java | 108 ++ .../solidfire/ApiSolidFireClusterResponse.java | 161 +++ .../ApiSolidFireVirtualNetworkResponse.java | 209 ++++ .../solidfire/ApiSolidFireVolumeResponse.java | 320 ++++++ .../api/solidfire/ApiSolidFireService.java | 6 + .../api/solidfire/ApiSolidFireServiceImpl.java | 45 + .../api/solidfire/SfApiConstants.java | 44 + .../dataaccess/dao/solidfire/SfClusterDao.java | 29 + .../dao/solidfire/SfClusterDaoImpl.java | 62 ++ .../dao/solidfire/SfVirtualNetworkDao.java | 29 + .../dao/solidfire/SfVirtualNetworkDaoImpl.java | 67 ++ .../dataaccess/dao/solidfire/SfVolumeDao.java | 27 + .../dao/solidfire/SfVolumeDaoImpl.java | 50 + .../dataaccess/vo/solidfire/SfClusterVO.java | 173 ++++ .../vo/solidfire/SfVirtualNetworkVO.java | 180 ++++ .../dataaccess/vo/solidfire/SfVolumeVO.java | 168 ++++ .../apache/cloudstack/solidfire/SfCluster.java | 40 + .../cloudstack/solidfire/SfVirtualNetwork.java | 40 + .../apache/cloudstack/solidfire/SfVolume.java | 42 + .../cloudstack/solidfire/SolidFireManager.java | 66 ++ .../solidfire/SolidFireManagerImpl.java | 977 +++++++++++++++++++ .../cloudstack/util/solidfire/SfUtil.java | 221 +++++ .../util/solidfire/SolidFireConnection.java | 950 ++++++++++++++++++ plugins/pom.xml | 1 + .../driver/SolidFirePrimaryDataStoreDriver.java | 6 +- .../SolidFireSharedPrimaryDataStoreDriver.java | 45 - ui/plugins/plugins.js | 4 +- ui/plugins/sfAdministration/config.js | 9 + ui/plugins/sfAdministration/icon.png | Bin 0 -> 7943 bytes ui/plugins/sfAdministration/sfAdministration.js | 566 +++++++++++ ui/plugins/sfSharedVolume/config.js | 9 + ui/plugins/sfSharedVolume/icon.png | Bin 0 -> 7943 bytes ui/plugins/sfSharedVolume/sfSharedVolume.js | 377 +++++++ 58 files changed, 6383 insertions(+), 226 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/client/pom.xml ---------------------------------------------------------------------- diff --git a/client/pom.xml b/client/pom.xml index bcb1391..633319e 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -348,6 +348,11 @@ org.apache.cloudstack + cloud-plugin-api-solidfire + ${project.version} + + + org.apache.cloudstack cloud-plugin-api-solidfire-intg-test ${project.version} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/client/tomcatconf/commands.properties.in ---------------------------------------------------------------------- diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index a69605c..a1e9b8e 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -663,6 +663,20 @@ getApiLimit=15 resetApiLimit=1 #### API SolidFire Service Command +createReferenceToSolidFireCluster=1 +createSolidFireVirtualNetwork=1 +deleteReferenceToSolidFireCluster=1 +deleteSolidFireVirtualNetwork=1 +listSolidFireClusters=1 +updateReferenceToSolidFireCluster=1 +updateSolidFireVirtualNetwork=1 +createSolidFireVolume=15 +deleteSolidFireVolume=15 +listSolidFireVirtualNetworks=15 +listSolidFireVolumes=15 +updateSolidFireVolume=15 + +#### API SolidFire Integration-Testing Service Command getSolidFireAccountId=15 getSolidFireVolumeSize=15 getSolidFireVolumeAccessGroupId=15 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml b/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml index 1bab734..f9bc021 100644 --- a/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml +++ b/plugins/api/solidfire-intg-test/resources/META-INF/cloudstack/solidfire-intg-test/spring-solidfire-intg-test-context.xml @@ -27,6 +27,6 @@ http://www.springframework.org/schema/context/spring-context-3.0.xsd" > - + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.java index f4c0076..f54a3d2 100644 --- a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.java +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/api/command/user/solidfire/GetSolidFireAccountIdCmd.java @@ -29,7 +29,7 @@ import org.apache.cloudstack.api.BaseCmd; import org.apache.cloudstack.api.Parameter; import org.apache.cloudstack.api.response.ApiSolidFireAccountIdResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.cloudstack.solidfire.ApiSolidFireService; +import org.apache.cloudstack.solidfire.ApiSolidFireIntgTestService; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; @@ -44,7 +44,7 @@ public class GetSolidFireAccountIdCmd extends BaseCmd { @Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.STRING, description = "Storage Pool UUID", required = true) private String storagePoolUuid; - @Inject private ApiSolidFireService _apiSolidFireService; + @Inject private ApiSolidFireIntgTestService _apiSolidFireIntgTestService; @Inject private AccountDao _accountDao; @Inject private PrimaryDataStoreDao _storagePoolDao; @@ -70,10 +70,12 @@ public class GetSolidFireAccountIdCmd extends BaseCmd { @Override public void execute() { + s_logger.info(GetSolidFireAccountIdCmd.class.getName() + ".execute invoked"); + Account account = _accountDao.findByUuid(accountUuid); StoragePoolVO storagePool = _storagePoolDao.findByUuid(storagePoolUuid); - ApiSolidFireAccountIdResponse response = _apiSolidFireService.getSolidFireAccountId(account.getId(), storagePool.getId()); + ApiSolidFireAccountIdResponse response = _apiSolidFireIntgTestService.getSolidFireAccountId(account.getId(), storagePool.getId()); response.setResponseName(getCommandName()); response.setObjectName("apisolidfireaccountid"); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/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 index c432fb1..df03685 100644 --- 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 @@ -31,7 +31,7 @@ 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.solidfire.ApiSolidFireIntgTestService; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; @APICommand(name = "getSolidFireVolumeAccessGroupId", responseObject = ApiSolidFireVolumeAccessGroupIdResponse.class, description = "Get the SF Volume Access Group ID", @@ -45,7 +45,7 @@ public class GetSolidFireVolumeAccessGroupIdCmd extends BaseCmd { @Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.STRING, description = "Storage Pool UUID", required = true) private String storagePoolUuid; - @Inject private ApiSolidFireService _apiSolidFireService; + @Inject private ApiSolidFireIntgTestService _apiSolidFireIntgTestService; @Inject private ClusterDao _clusterDao; @Inject private PrimaryDataStoreDao _storagePoolDao; @@ -71,10 +71,12 @@ public class GetSolidFireVolumeAccessGroupIdCmd extends BaseCmd { @Override public void execute() { + s_logger.info(GetSolidFireVolumeAccessGroupIdCmd.class.getName() + ".execute invoked"); + Cluster cluster = _clusterDao.findByUuid(clusterUuid); StoragePool storagePool = _storagePoolDao.findByUuid(storagePoolUuid); - ApiSolidFireVolumeAccessGroupIdResponse response = _apiSolidFireService.getSolidFireVolumeAccessGroupId(cluster.getId(), storagePool.getId()); + ApiSolidFireVolumeAccessGroupIdResponse response = _apiSolidFireIntgTestService.getSolidFireVolumeAccessGroupId(cluster.getId(), storagePool.getId()); response.setResponseName(getCommandName()); response.setObjectName("apisolidfirevolumeaccessgroupid"); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/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 index 7afa301..49a384d 100644 --- 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 @@ -29,7 +29,7 @@ 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; +import org.apache.cloudstack.solidfire.ApiSolidFireIntgTestService; @APICommand(name = "getSolidFireVolumeIscsiName", responseObject = ApiSolidFireVolumeIscsiNameResponse.class, description = "Get SolidFire Volume's Iscsi Name", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) @@ -41,7 +41,7 @@ public class GetSolidFireVolumeIscsiNameCmd extends BaseCmd { @Parameter(name = ApiConstants.VOLUME_ID, type = CommandType.STRING, description = "CloudStack Volume UUID", required = true) private String volumeUuid; - @Inject private ApiSolidFireService _apiSolidFireService; + @Inject private ApiSolidFireIntgTestService _apiSolidFireIntgTestService; @Inject private VolumeDao _volumeDao; ///////////////////////////////////////////////////// @@ -66,9 +66,11 @@ public class GetSolidFireVolumeIscsiNameCmd extends BaseCmd { @Override public void execute() { + s_logger.info(GetSolidFireVolumeIscsiNameCmd.class.getName() + ".execute invoked"); + Volume volume = _volumeDao.findByUuid(volumeUuid); - ApiSolidFireVolumeIscsiNameResponse response = _apiSolidFireService.getSolidFireVolumeIscsiName(volume); + ApiSolidFireVolumeIscsiNameResponse response = _apiSolidFireIntgTestService.getSolidFireVolumeIscsiName(volume); response.setResponseName(getCommandName()); response.setObjectName("apisolidfirevolumeiscsiname"); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/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 index 3a27a66..55b6d1f 100644 --- 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 @@ -31,7 +31,7 @@ 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.solidfire.ApiSolidFireIntgTestService; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; @APICommand(name = "getSolidFireVolumeSize", responseObject = ApiSolidFireVolumeSizeResponse.class, description = "Get the SF volume size including Hypervisor Snapshot Reserve", @@ -45,7 +45,7 @@ public class GetSolidFireVolumeSizeCmd extends BaseCmd { @Parameter(name = ApiConstants.STORAGE_ID, type = CommandType.STRING, description = "Storage Pool UUID", required = true) private String storagePoolUuid; - @Inject private ApiSolidFireService _apiSolidFireService; + @Inject private ApiSolidFireIntgTestService _apiSolidFireIntgTestService; @Inject private VolumeDao _volumeDao; @Inject private PrimaryDataStoreDao _storagePoolDao; @@ -71,10 +71,12 @@ public class GetSolidFireVolumeSizeCmd extends BaseCmd { @Override public void execute() { + s_logger.info(GetSolidFireVolumeSizeCmd.class.getName() + ".execute invoked"); + Volume volume = _volumeDao.findByUuid(volumeUuid); StoragePool storagePool = _storagePoolDao.findByUuid(storagePoolUuid); - ApiSolidFireVolumeSizeResponse response = _apiSolidFireService.getSolidFireVolumeSize(volume, storagePool); + ApiSolidFireVolumeSizeResponse response = _apiSolidFireIntgTestService.getSolidFireVolumeSize(volume, storagePool); response.setResponseName(getCommandName()); response.setObjectName("apisolidfirevolumesize"); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireIntgTestService.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireIntgTestService.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireIntgTestService.java new file mode 100644 index 0000000..b6a54f6 --- /dev/null +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireIntgTestService.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.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 + * + */ +public interface ApiSolidFireIntgTestService 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/49ca3b40/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireIntgTestServiceImpl.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireIntgTestServiceImpl.java b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireIntgTestServiceImpl.java new file mode 100644 index 0000000..1ea33a6 --- /dev/null +++ b/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireIntgTestServiceImpl.java @@ -0,0 +1,128 @@ +// 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.solidfire; + +import java.util.Map; +import java.util.List; +import java.util.ArrayList; + +import javax.ejb.Local; +import javax.inject.Inject; +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.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; +import com.cloud.utils.component.AdapterBase; + +@Component +@Local(value = APIChecker.class) +public class ApiSolidFireIntgTestServiceImpl extends AdapterBase implements APIChecker, ApiSolidFireIntgTestService { + // private static final Logger s_logger = Logger.getLogger(ApiSolidFireServiceImpl.class); + + @Inject private AccountDetailsDao _accountDetailsDao; + @Inject private DataStoreProviderManager _dataStoreProviderMgr; + @Inject private ClusterDetailsDao _clusterDetailsDao; + + @Override + public boolean configure(String name, Map params) throws ConfigurationException { + super.configure(name, params); + + return true; + } + + @Override + public ApiSolidFireAccountIdResponse getSolidFireAccountId(Long csAccountId, Long storagePoolId) { + AccountDetailVO accountDetail = _accountDetailsDao.findDetail(csAccountId, SolidFireUtil.getAccountKey(storagePoolId)); + String sfAccountId = accountDetail.getValue(); + + return new ApiSolidFireAccountIdResponse(Long.parseLong(sfAccountId)); + } + + @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; + } + + @Override + public List> getCommands() { + List> cmdList = new ArrayList>(); + + cmdList.add(GetSolidFireAccountIdCmd.class); + cmdList.add(GetSolidFireVolumeSizeCmd.class); + cmdList.add(GetSolidFireVolumeAccessGroupIdCmd.class); + cmdList.add(GetSolidFireVolumeIscsiNameCmd.class); + + return cmdList; + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/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 deleted file mode 100644 index 92828d4..0000000 --- a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireService.java +++ /dev/null @@ -1,37 +0,0 @@ -// 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.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 - * - */ -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/49ca3b40/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 deleted file mode 100644 index a95272a..0000000 --- a/plugins/api/solidfire-intg-test/src/org/apache/cloudstack/solidfire/ApiSolidFireServiceImpl.java +++ /dev/null @@ -1,128 +0,0 @@ -// 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.solidfire; - -import java.util.Map; -import java.util.List; -import java.util.ArrayList; - -import javax.ejb.Local; -import javax.inject.Inject; -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.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; -import com.cloud.utils.component.AdapterBase; - -@Component -@Local(value = APIChecker.class) -public class ApiSolidFireServiceImpl extends AdapterBase implements APIChecker, ApiSolidFireService { - // private static final Logger s_logger = Logger.getLogger(ApiSolidFireServiceImpl.class); - - @Inject private AccountDetailsDao _accountDetailsDao; - @Inject private DataStoreProviderManager _dataStoreProviderMgr; - @Inject private ClusterDetailsDao _clusterDetailsDao; - - @Override - public boolean configure(String name, Map params) throws ConfigurationException { - super.configure(name, params); - - return true; - } - - @Override - public ApiSolidFireAccountIdResponse getSolidFireAccountId(Long csAccountId, Long storagePoolId) { - AccountDetailVO accountDetail = _accountDetailsDao.findDetail(csAccountId, SolidFireUtil.getAccountKey(storagePoolId)); - String sfAccountId = accountDetail.getValue(); - - return new ApiSolidFireAccountIdResponse(Long.parseLong(sfAccountId)); - } - - @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; - } - - @Override - public List> getCommands() { - List> cmdList = new ArrayList>(); - - cmdList.add(GetSolidFireAccountIdCmd.class); - cmdList.add(GetSolidFireVolumeSizeCmd.class); - cmdList.add(GetSolidFireVolumeAccessGroupIdCmd.class); - cmdList.add(GetSolidFireVolumeIscsiNameCmd.class); - - return cmdList; - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/pom.xml ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/pom.xml b/plugins/api/solidfire/pom.xml new file mode 100644 index 0000000..35ee222 --- /dev/null +++ b/plugins/api/solidfire/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + cloud-plugin-api-solidfire + SolidFire API Plugin + + org.apache.cloudstack + cloudstack-plugins + 4.5.3-SNAPSHOT + ../../pom.xml + + + + org.apache.cloudstack + cloud-plugin-storage-volume-solidfire + ${project.version} + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + -Xmx1024m + + org/apache/cloudstack/solidfire/integration/* + + + + + + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/resources/META-INF/cloudstack/solidfire/module.properties ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/resources/META-INF/cloudstack/solidfire/module.properties b/plugins/api/solidfire/resources/META-INF/cloudstack/solidfire/module.properties new file mode 100644 index 0000000..00c290d --- /dev/null +++ b/plugins/api/solidfire/resources/META-INF/cloudstack/solidfire/module.properties @@ -0,0 +1,18 @@ +# 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. +name=solidfire +parent=api \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/resources/META-INF/cloudstack/solidfire/spring-solidfire-context.xml ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/resources/META-INF/cloudstack/solidfire/spring-solidfire-context.xml b/plugins/api/solidfire/resources/META-INF/cloudstack/solidfire/spring-solidfire-context.xml new file mode 100644 index 0000000..f9a5037 --- /dev/null +++ b/plugins/api/solidfire/resources/META-INF/cloudstack/solidfire/spring-solidfire-context.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/CreateReferenceToSolidFireClusterCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/CreateReferenceToSolidFireClusterCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/CreateReferenceToSolidFireClusterCmd.java new file mode 100644 index 0000000..0741399 --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/CreateReferenceToSolidFireClusterCmd.java @@ -0,0 +1,106 @@ +// 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.admin.solidfire; + +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.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.ZoneResponse; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireClusterResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfCluster; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "createReferenceToSolidFireCluster", responseObject = ApiSolidFireClusterResponse.class, description = "Create Reference to SolidFire Cluster", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class CreateReferenceToSolidFireClusterCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(CreateReferenceToSolidFireClusterCmd.class.getName()); + private static final String s_name = "createreferencetosolidfireclusterresponse"; + + @Parameter(name = SfApiConstants.MVIP, type = CommandType.STRING, description = SfApiConstants.SOLIDFIRE_MVIP_DESC, required = true) + private String _mvip; + + @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, description = SfApiConstants.SOLIDFIRE_USERNAME_DESC, required = true) + private String _username; + + @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, description = SfApiConstants.SOLIDFIRE_PASSWORD_DESC, required = true) + private String _password; + + @Parameter(name = SfApiConstants.TOTAL_CAPACITY, type = CommandType.LONG, description = SfApiConstants.TOTAL_CAPACITY_DESC, required = true) + private long _totalCapacity; + + @Parameter(name = SfApiConstants.TOTAL_MIN_IOPS, type = CommandType.LONG, description = SfApiConstants.TOTAL_MIN_IOPS_DESC, required = true) + private long _totalMinIops; + + @Parameter(name = SfApiConstants.TOTAL_MAX_IOPS, type = CommandType.LONG, description = SfApiConstants.TOTAL_MAX_IOPS_DESC, required = true) + private long _totalMaxIops; + + @Parameter(name = SfApiConstants.TOTAL_BURST_IOPS, type = CommandType.LONG, description = SfApiConstants.TOTAL_BURST_IOPS_DESC, required = true) + private long _totalBurstIops; + + @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = SfApiConstants.ZONE_ID_DESC, required = true) + private long _zoneId; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() { + try { + s_logger.info(CreateReferenceToSolidFireClusterCmd.class.getName() + ".execute invoked"); + + SfCluster sfCluster = _solidFireManager.createReferenceToSolidFireCluster(_mvip, _username, _password, _totalCapacity, + _totalMinIops, _totalMaxIops, _totalBurstIops, _zoneId); + + ApiSolidFireClusterResponse response = _sfUtil.getApiSolidFireClusterResponse(sfCluster); + + response.setResponseName(getCommandName()); + response.setObjectName("apicreatereferencetosolidfirecluster"); + + setResponseObject(response); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/CreateSolidFireVirtualNetworkCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/CreateSolidFireVirtualNetworkCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/CreateSolidFireVirtualNetworkCmd.java new file mode 100644 index 0000000..f78baac --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/CreateSolidFireVirtualNetworkCmd.java @@ -0,0 +1,104 @@ +// 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.admin.solidfire; + +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.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.AccountResponse; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireVirtualNetworkResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfVirtualNetwork; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "createSolidFireVirtualNetwork", responseObject = ApiSolidFireVirtualNetworkResponse.class, description = "Create SolidFire Virtual Network", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class CreateSolidFireVirtualNetworkCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(CreateSolidFireVirtualNetworkCmd.class.getName()); + private static final String s_name = "createsolidfirevirtualnetworkresponse"; + + @Parameter(name = SfApiConstants.CLUSTER_NAME, type = CommandType.STRING, description = SfApiConstants.SOLIDFIRE_CLUSTER_NAME_DESC, required = true) + private String _clusterName; + + @Parameter(name = SfApiConstants.NAME, type = CommandType.STRING, description = SfApiConstants.VIRTUAL_NETWORK_NAME_DESC, required = true) + private String _name; + + @Parameter(name = SfApiConstants.TAG, type = CommandType.STRING, description = SfApiConstants.VIRTUAL_NETWORK_TAG_DESC, required = true) + private String _tag; + + @Parameter(name = SfApiConstants.START_IP, type = CommandType.STRING, description = SfApiConstants.START_IP_ADDRESS_DESC, required = true) + private String _startIp; + + @Parameter(name = SfApiConstants.SIZE, type = CommandType.INTEGER, description = SfApiConstants.NUMBER_OF_IP_ADDRESSES_DESC, required = true) + private int _size; + + @Parameter(name = SfApiConstants.NETMASK, type = CommandType.STRING, description = SfApiConstants.NETMASK_DESC, required = true) + private String _netmask; + + @Parameter(name = SfApiConstants.SVIP, type = CommandType.STRING, description = SfApiConstants.SOLIDFIRE_SVIP_DESC, required = true) + private String _svip; + + @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = SfApiConstants.ACCOUNT_ID_DESC, required = true) + private long _accountId; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return _accountId; + } + + @Override + public void execute() { + try { + s_logger.info(CreateSolidFireVirtualNetworkCmd.class.getName() + ".execute invoked"); + + SfVirtualNetwork sfVirtualNetwork = _solidFireManager.createSolidFireVirtualNetwork(_clusterName, _name, _tag, _startIp, _size, _netmask, _svip, _accountId); + + ApiSolidFireVirtualNetworkResponse response = _sfUtil.getApiSolidFireVirtualNetworkResponse(sfVirtualNetwork, ResponseView.Full); + + response.setResponseName(getCommandName()); + response.setObjectName("apicreatesolidfirevirtualnetwork"); + + setResponseObject(response); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/DeleteReferenceToSolidFireClusterCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/DeleteReferenceToSolidFireClusterCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/DeleteReferenceToSolidFireClusterCmd.java new file mode 100644 index 0000000..7ee063c --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/DeleteReferenceToSolidFireClusterCmd.java @@ -0,0 +1,82 @@ +// 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.admin.solidfire; + +import com.cloud.user.Account; + +import javax.inject.Inject; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireClusterResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfCluster; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "deleteReferenceToSolidFireCluster", responseObject = ApiSolidFireClusterResponse.class, description = "Delete Reference to SolidFire Cluster", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class DeleteReferenceToSolidFireClusterCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(DeleteReferenceToSolidFireClusterCmd.class.getName()); + private static final String s_name = "deletereferencetosolidfireclusterresponse"; + + @Parameter(name = SfApiConstants.NAME, type = CommandType.STRING, description = SfApiConstants.SOLIDFIRE_CLUSTER_NAME_DESC, required = true) + private String _name; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() { + try { + s_logger.info(DeleteReferenceToSolidFireClusterCmd.class.getName() + ".execute invoked"); + + SfCluster sfCluster = _solidFireManager.deleteReferenceToSolidFireCluster(_name); + + ApiSolidFireClusterResponse response = _sfUtil.getApiSolidFireClusterResponse(sfCluster); + + response.setResponseName(getCommandName()); + response.setObjectName("apideletereferencetosolidfirecluster"); + + setResponseObject(response); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/DeleteSolidFireVirtualNetworkCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/DeleteSolidFireVirtualNetworkCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/DeleteSolidFireVirtualNetworkCmd.java new file mode 100644 index 0000000..56b57b2 --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/DeleteSolidFireVirtualNetworkCmd.java @@ -0,0 +1,90 @@ +// 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.admin.solidfire; + +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.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireVirtualNetworkResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfVirtualNetwork; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "deleteSolidFireVirtualNetwork", responseObject = ApiSolidFireVirtualNetworkResponse.class, description = "Delete SolidFire Virtual Network", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class DeleteSolidFireVirtualNetworkCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(DeleteSolidFireVirtualNetworkCmd.class.getName()); + private static final String s_name = "deletesolidfirevirtualnetworkresponse"; + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ApiSolidFireVirtualNetworkResponse.class, description = SfApiConstants.VIRTUAL_NETWORK_ID_DESC, required = true) + private long _id; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + SfVirtualNetwork sfVirtualNetwork = _entityMgr.findById(SfVirtualNetwork.class, _id); + + if (sfVirtualNetwork != null) { + sfVirtualNetwork.getAccountId(); + } + + return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked + } + + @Override + public void execute() { + try { + s_logger.info(DeleteSolidFireVirtualNetworkCmd.class.getName() + ".execute invoked"); + + SfVirtualNetwork sfVirtualNetwork = _solidFireManager.deleteSolidFireVirtualNetwork(_id); + + ApiSolidFireVirtualNetworkResponse response = _sfUtil.getApiSolidFireVirtualNetworkResponse(sfVirtualNetwork, ResponseView.Full); + + response.setResponseName(getCommandName()); + response.setObjectName("apideletesolidfirevirtualnetwork"); + + setResponseObject(response); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/ListSolidFireClustersCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/ListSolidFireClustersCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/ListSolidFireClustersCmd.java new file mode 100644 index 0000000..e2e168c --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/ListSolidFireClustersCmd.java @@ -0,0 +1,95 @@ +// 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.admin.solidfire; + +import java.util.ArrayList; +import java.util.List; + +import javax.inject.Inject; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseListCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.ListResponse; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireClusterResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfCluster; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "listSolidFireClusters", responseObject = ApiSolidFireClusterResponse.class, description = "List SolidFire Clusters", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class ListSolidFireClustersCmd extends BaseListCmd { + private static final Logger s_logger = Logger.getLogger(ListSolidFireClustersCmd.class.getName()); + private static final String s_name = "listsolidfireclustersresponse"; + + @Parameter(name = SfApiConstants.NAME, type = CommandType.STRING, description = SfApiConstants.SOLIDFIRE_CLUSTER_NAME_DESC) + private String _name; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public void execute() { + try { + s_logger.info(ListSolidFireClustersCmd.class.getName() + ".execute invoked"); + + final List sfClusters; + + if (_name != null) { + sfClusters = new ArrayList<>(); + + SfCluster sfCluster = _solidFireManager.listSolidFireCluster(_name); + + if (sfCluster != null) { + sfClusters.add(sfCluster); + } + } + else { + sfClusters = _solidFireManager.listSolidFireClusters(); + } + + List responses = _sfUtil.getApiSolidFireClusterResponse(sfClusters); + + ListResponse listReponse = new ListResponse<>(); + + listReponse.setResponses(responses); + listReponse.setResponseName(getCommandName()); + listReponse.setObjectName("apilistsolidfireclusters"); + + setResponseObject(listReponse); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/UpdateReferenceToSolidFireClusterCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/UpdateReferenceToSolidFireClusterCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/UpdateReferenceToSolidFireClusterCmd.java new file mode 100644 index 0000000..6f102a4 --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/UpdateReferenceToSolidFireClusterCmd.java @@ -0,0 +1,95 @@ +// 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.admin.solidfire; + +import com.cloud.user.Account; + +import javax.inject.Inject; + +import org.apache.log4j.Logger; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireClusterResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfCluster; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "updateReferenceToSolidFireCluster", responseObject = ApiSolidFireClusterResponse.class, description = "Update Reference to SolidFire Cluster", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateReferenceToSolidFireClusterCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(UpdateReferenceToSolidFireClusterCmd.class.getName()); + private static final String s_name = "updatereferencetosolidfireclusterresponse"; + + @Parameter(name = SfApiConstants.NAME, type = CommandType.STRING, description = SfApiConstants.SOLIDFIRE_CLUSTER_NAME_DESC, required = true) + private String _name; + + @Parameter(name = SfApiConstants.TOTAL_CAPACITY, type = CommandType.LONG, description = SfApiConstants.TOTAL_CAPACITY_DESC, required = true) + private long _totalCapacity; + + @Parameter(name = SfApiConstants.TOTAL_MIN_IOPS, type = CommandType.LONG, description = SfApiConstants.TOTAL_MIN_IOPS_DESC, required = true) + private long _totalMinIops; + + @Parameter(name = SfApiConstants.TOTAL_MAX_IOPS, type = CommandType.LONG, description = SfApiConstants.TOTAL_MAX_IOPS_DESC, required = true) + private long _totalMaxIops; + + @Parameter(name = SfApiConstants.TOTAL_BURST_IOPS, type = CommandType.LONG, description = SfApiConstants.TOTAL_BURST_IOPS_DESC, required = true) + private long _totalBurstIops; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + + @Override + public void execute() { + try { + s_logger.info(UpdateReferenceToSolidFireClusterCmd.class.getName() + ".execute invoked"); + + SfCluster sfCluster = _solidFireManager.updateReferenceToSolidFireCluster(_name, _totalCapacity, + _totalMinIops, _totalMaxIops, _totalBurstIops); + + ApiSolidFireClusterResponse response = _sfUtil.getApiSolidFireClusterResponse(sfCluster); + + response.setResponseName(getCommandName()); + response.setObjectName("apiupdatereferencetosolidfirecluster"); + + setResponseObject(response); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/UpdateSolidFireVirtualNetworkCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/UpdateSolidFireVirtualNetworkCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/UpdateSolidFireVirtualNetworkCmd.java new file mode 100644 index 0000000..26c717c --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/admin/solidfire/UpdateSolidFireVirtualNetworkCmd.java @@ -0,0 +1,103 @@ +// 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.admin.solidfire; + +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.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireVirtualNetworkResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfVirtualNetwork; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "updateSolidFireVirtualNetwork", responseObject = ApiSolidFireVirtualNetworkResponse.class, description = "Update SolidFire Virtual Network", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class UpdateSolidFireVirtualNetworkCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(UpdateSolidFireVirtualNetworkCmd.class.getName()); + private static final String s_name = "updatesolidfirevirtualnetworkresponse"; + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ApiSolidFireVirtualNetworkResponse.class, description = SfApiConstants.VIRTUAL_NETWORK_ID_DESC, + required = true) + private long _id; + + @Parameter(name = SfApiConstants.NAME, type = CommandType.STRING, description = SfApiConstants.VIRTUAL_NETWORK_NAME_DESC, required = true) + private String _name; + + @Parameter(name = SfApiConstants.START_IP, type = CommandType.STRING, description = SfApiConstants.START_IP_ADDRESS_DESC, required = true) + private String _startIp; + + @Parameter(name = SfApiConstants.SIZE, type = CommandType.INTEGER, description = SfApiConstants.NUMBER_OF_IP_ADDRESSES_DESC, required = true) + private int _size; + + @Parameter(name = SfApiConstants.NETMASK, type = CommandType.STRING, description = SfApiConstants.NETMASK, required = true) + private String _netmask; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + SfVirtualNetwork sfVirtualNetwork = _entityMgr.findById(SfVirtualNetwork.class, _id); + + if (sfVirtualNetwork != null) { + sfVirtualNetwork.getAccountId(); + } + + return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked + } + + @Override + public void execute() { + try { + s_logger.info(UpdateSolidFireVirtualNetworkCmd.class.getName() + ".execute invoked"); + + SfVirtualNetwork sfVirtualNetwork = _solidFireManager.updateSolidFireVirtualNetwork(_id, _name, _startIp, _size, _netmask); + + ApiSolidFireVirtualNetworkResponse response = _sfUtil.getApiSolidFireVirtualNetworkResponse(sfVirtualNetwork, ResponseView.Full); + + response.setResponseName(getCommandName()); + response.setObjectName("apiupdatesolidfirevirtualnetwork"); + + setResponseObject(response); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/CreateSolidFireVolumeCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/CreateSolidFireVolumeCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/CreateSolidFireVolumeCmd.java new file mode 100644 index 0000000..ffb59a3 --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/CreateSolidFireVolumeCmd.java @@ -0,0 +1,105 @@ +// 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 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.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.response.AccountResponse; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireVirtualNetworkResponse; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireVolumeResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfVolume; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "createSolidFireVolume", responseObject = ApiSolidFireVolumeResponse.class, description = "Create SolidFire Volume", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class CreateSolidFireVolumeCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(CreateSolidFireVolumeCmd.class.getName()); + private static final String s_name = "createsolidfirevolumeresponse"; + + @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, description = SfApiConstants.VOLUME_NAME_DESC, required = true) + private String _name; + + @Parameter(name = ApiConstants.SIZE, type = CommandType.LONG, description = SfApiConstants.SIZE_DESC, required = true) + private long _size; + + @Parameter(name = ApiConstants.MIN_IOPS, type = CommandType.LONG, description = SfApiConstants.MIN_IOPS_DESC, required = true) + private long _minIops; + + @Parameter(name = ApiConstants.MAX_IOPS, type = CommandType.LONG, description = SfApiConstants.MAX_IOPS_DESC, required = true) + private long _maxIops; + + @Parameter(name = SfApiConstants.BURST_IOPS, type = CommandType.LONG, description = SfApiConstants.BURST_IOPS_DESC, required = true) + private long _burstIops; + + @Parameter(name = ApiConstants.ACCOUNT_ID, type = CommandType.UUID, entityType = AccountResponse.class, description = SfApiConstants.ACCOUNT_ID_DESC, required = true) + private long _accountId; + + @Parameter(name = SfApiConstants.SF_VIRTUAL_NETWORK_ID, type = CommandType.UUID, entityType = ApiSolidFireVirtualNetworkResponse.class, + description = SfApiConstants.VIRTUAL_NETWORK_ID_DESC, required = true) + private long _sfVirtualNetworkId; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + return _accountId; + } + + @Override + public void execute() { + try { + s_logger.info(CreateSolidFireVolumeCmd.class.getName() + ".execute invoked"); + + SfVolume sfVolume = _solidFireManager.createSolidFireVolume(_name, _size, _minIops, _maxIops, _burstIops, _accountId, _sfVirtualNetworkId); + + ResponseView responseView = _sfUtil.isRootAdmin() ? ResponseView.Full : ResponseView.Restricted; + + ApiSolidFireVolumeResponse response = _sfUtil.getApiSolidFireVolumeResponse(sfVolume, responseView); + + response.setResponseName(getCommandName()); + response.setObjectName("apicreatesolidfirevolume"); + + setResponseObject(response); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/49ca3b40/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/DeleteSolidFireVolumeCmd.java ---------------------------------------------------------------------- diff --git a/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/DeleteSolidFireVolumeCmd.java b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/DeleteSolidFireVolumeCmd.java new file mode 100644 index 0000000..6185db1 --- /dev/null +++ b/plugins/api/solidfire/src/org/apache/cloudstack/api/command/user/solidfire/DeleteSolidFireVolumeCmd.java @@ -0,0 +1,97 @@ +// 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 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.ApiErrorCode; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.Parameter; +import org.apache.cloudstack.api.ServerApiException; +import org.apache.cloudstack.api.ResponseObject.ResponseView; +import org.apache.cloudstack.api.response.solidfire.ApiSolidFireVolumeResponse; +import org.apache.cloudstack.api.solidfire.SfApiConstants; +import org.apache.cloudstack.solidfire.SfVirtualNetwork; +import org.apache.cloudstack.solidfire.SfVolume; +import org.apache.cloudstack.solidfire.SolidFireManager; +import org.apache.cloudstack.util.solidfire.SfUtil; + +@APICommand(name = "deleteSolidFireVolume", responseObject = ApiSolidFireVolumeResponse.class, description = "Delete SolidFire Volume", + requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class DeleteSolidFireVolumeCmd extends BaseCmd { + private static final Logger s_logger = Logger.getLogger(DeleteSolidFireVolumeCmd.class.getName()); + private static final String s_name = "deletesolidfirevolumeresponse"; + + @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ApiSolidFireVolumeResponse.class, description = SfApiConstants.VOLUME_ID_DESC, required = true) + private long _id; + + @Inject private SolidFireManager _solidFireManager; + @Inject private SfUtil _sfUtil; + + ///////////////////////////////////////////////////// + /////////////// API Implementation/////////////////// + ///////////////////////////////////////////////////// + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public long getEntityOwnerId() { + SfVolume sfVolume = _entityMgr.findById(SfVolume.class, _id); + + if (sfVolume != null) { + SfVirtualNetwork sfVirtualNetwork = _entityMgr.findById(SfVirtualNetwork.class, sfVolume.getSfVirtualNetworkId()); + + if (sfVirtualNetwork != null) { + sfVirtualNetwork.getAccountId(); + } + } + + return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked + } + + @Override + public void execute() { + try { + s_logger.info(DeleteSolidFireVolumeCmd.class.getName() + ".execute invoked"); + + SfVolume sfVolume = _solidFireManager.deleteSolidFireVolume(_id); + + ResponseView responseView = _sfUtil.isRootAdmin() ? ResponseView.Full : ResponseView.Restricted; + + ApiSolidFireVolumeResponse response = _sfUtil.getApiSolidFireVolumeResponse(sfVolume, responseView); + + response.setResponseName(getCommandName()); + response.setObjectName("apideletesolidfirevolume"); + + setResponseObject(response); + } + catch (Throwable t) { + s_logger.error(t.getMessage()); + + throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, t.getMessage()); + } + } +}