mirror of https://github.com/apache/cloudstack.git
Added Storage policy id to VO
This commit is contained in:
parent
037fcfd032
commit
a4ec86a652
|
|
@ -16,6 +16,7 @@
|
|||
// under the License.
|
||||
package com.cloud.hypervisor.vmware;
|
||||
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
import javax.persistence.Column;
|
||||
|
|
@ -66,6 +67,15 @@ public class VsphereStoragePolicyVO implements VsphereStoragePolicy {
|
|||
this.policyId = policyId;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.updateTime = DateUtil.currentGMTTime();
|
||||
}
|
||||
|
||||
public VsphereStoragePolicyVO() {
|
||||
uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
public VsphereStoragePolicyVO(long id) {
|
||||
this.id = id;
|
||||
uuid = UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1429,7 +1429,7 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
|
|||
}
|
||||
|
||||
for (PbmProfile storageProfile : storageProfiles) {
|
||||
VsphereStoragePolicyVO StoragePolicyVO = new VsphereStoragePolicyVO(zoneId, storageProfile.getProfileId().toString(), storageProfile.getName(), storageProfile.getDescription());
|
||||
VsphereStoragePolicyVO StoragePolicyVO = new VsphereStoragePolicyVO(zoneId, storageProfile.getProfileId().getUniqueId(), storageProfile.getName(), storageProfile.getDescription());
|
||||
vsphereStoragePolicyDao.persist(StoragePolicyVO);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.cloudstack.api.command.admin.zone;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
|
|
@ -29,6 +30,7 @@ import com.cloud.hypervisor.vmware.VsphereStoragePolicy;
|
|||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
|
|
@ -72,15 +74,23 @@ public class ImportVsphereStoragePoliciesCmd extends BaseAsyncCmd {
|
|||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
|
||||
final DataCenter dataCenter = _resourceService.getZone(getZoneId());
|
||||
if (dataCenter == null) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Unable to find zone by ID: " + getZoneId());
|
||||
}
|
||||
|
||||
List<? extends VsphereStoragePolicy> storagePolicies = _vmwareDatacenterService.importVsphereStoragePolicies(this);
|
||||
final ListResponse<ImportVsphereStoragePoliciesResponse> responseList = new ListResponse<>();
|
||||
final List<ImportVsphereStoragePoliciesResponse> storagePoliciesResponseList = new ArrayList<>();
|
||||
for (VsphereStoragePolicy storagePolicy : storagePolicies) {
|
||||
final ImportVsphereStoragePoliciesResponse storagePoliciesResponse = new ImportVsphereStoragePoliciesResponse();
|
||||
storagePoliciesResponse.setZoneId(dataCenter.getUuid());
|
||||
storagePoliciesResponse.setId(storagePolicy.getUuid());
|
||||
storagePoliciesResponse.setName(storagePolicy.getName());
|
||||
storagePoliciesResponse.setPolicyId(storagePolicy.getPolicyId());
|
||||
storagePoliciesResponse.setDescription(storagePolicy.getDescription());
|
||||
storagePoliciesResponse.setObjectName("StoragePolicy");
|
||||
|
||||
storagePoliciesResponseList.add(storagePoliciesResponse);
|
||||
}
|
||||
responseList.setResponses(storagePoliciesResponseList);
|
||||
|
|
|
|||
Loading…
Reference in New Issue