Changes/additions related to SolidFire automation tests

This commit is contained in:
Vania Xu 2014-08-27 14:57:07 -06:00 committed by Mike Tutkowski
parent 21ff99b0ae
commit 30fbff8687
9 changed files with 427 additions and 1 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,37 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.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;
}
}

View File

@ -0,0 +1,37 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.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;
}
}

View File

@ -0,0 +1,37 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.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;
}
}

View File

@ -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);
}

View File

@ -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 {
@ -60,6 +79,39 @@ public class ApiSolidFireServiceImpl extends AdapterBase implements APIChecker,
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;
@ -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;
}