Search in sources :

Example 86 with Pair

use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method searchForStorageTagsInternal.

private Pair<List<StorageTagVO>, Integer> searchForStorageTagsInternal(final ListStorageTagsCmd cmd) {
    final Filter searchFilter = new Filter(StorageTagVO.class, "id", Boolean.TRUE, null, null);
    final SearchBuilder<StorageTagVO> sb = _storageTagDao.createSearchBuilder();
    // select distinct
    sb.select(null, Func.DISTINCT, sb.entity().getId());
    final SearchCriteria<StorageTagVO> sc = sb.create();
    // search storage tag details by ids
    final Pair<List<StorageTagVO>, Integer> uniqueTagPair = _storageTagDao.searchAndCount(sc, searchFilter);
    final Integer count = uniqueTagPair.second();
    if (count.intValue() == 0) {
        return uniqueTagPair;
    }
    final List<StorageTagVO> uniqueTags = uniqueTagPair.first();
    final Long[] vrIds = new Long[uniqueTags.size()];
    int i = 0;
    for (final StorageTagVO v : uniqueTags) {
        vrIds[i++] = v.getId();
    }
    final List<StorageTagVO> vrs = _storageTagDao.searchByIds(vrIds);
    return new Pair<>(vrs, count);
}
Also used : Filter(com.cloud.utils.db.Filter) TemplateFilter(com.cloud.legacymodel.storage.VirtualMachineTemplate.TemplateFilter) ArrayList(java.util.ArrayList) List(java.util.List) StorageTagVO(com.cloud.api.query.vo.StorageTagVO) Pair(com.cloud.legacymodel.utils.Pair)

Example 87 with Pair

use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.

the class QueryManagerImpl method searchForUserVMsInternal.

private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(final ListVMsCmd cmd) {
    final Account caller = CallContext.current().getCallingAccount();
    final List<Long> permittedAccounts = new ArrayList<>();
    final boolean listAll = cmd.listAll();
    final Long id = cmd.getId();
    final Long userId = cmd.getUserId();
    final Map<String, String> tags = cmd.getTags();
    final Boolean display = cmd.getDisplay();
    final Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<>(cmd.getDomainId(), cmd.isRecursive(), null);
    _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
    final Long domainId = domainIdRecursiveListProject.first();
    final Boolean isRecursive = domainIdRecursiveListProject.second();
    final ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    final Filter searchFilter = new Filter(UserVmJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
    final List<Long> ids;
    if (cmd.getId() != null) {
        if (cmd.getIds() != null && !cmd.getIds().isEmpty()) {
            throw new InvalidParameterValueException("Specify either id or ids but not both parameters");
        }
        ids = new ArrayList<>();
        ids.add(cmd.getId());
    } else {
        ids = cmd.getIds();
    }
    // first search distinct vm id by using query criteria and pagination
    final SearchBuilder<UserVmJoinVO> sb = _userVmJoinDao.createSearchBuilder();
    // select distinct ids
    sb.select(null, Func.DISTINCT, sb.entity().getId());
    _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    final String hypervisor = cmd.getHypervisor();
    final Object name = cmd.getName();
    final String state = cmd.getState();
    final Object zoneId = cmd.getZoneId();
    final Object keyword = cmd.getKeyword();
    boolean isAdmin = false;
    boolean isRootAdmin = false;
    if (_accountMgr.isAdmin(caller.getId())) {
        isAdmin = true;
    }
    if (_accountMgr.isRootAdmin(caller.getId())) {
        isRootAdmin = true;
    }
    final Object groupId = cmd.getGroupId();
    final Object networkId = cmd.getNetworkId();
    if (HypervisorType.getType(hypervisor) == HypervisorType.None && hypervisor != null) {
        // invalid hypervisor type input
        throw new InvalidParameterValueException("Invalid HypervisorType " + hypervisor);
    }
    final Object templateId = cmd.getTemplateId();
    final Object isoId = cmd.getIsoId();
    final Object vpcId = cmd.getVpcId();
    final Object affinityGroupId = cmd.getAffinityGroupId();
    final Object keyPairName = cmd.getKeyPairName();
    final Object serviceOffId = cmd.getServiceOfferingId();
    final String complianceStatus = cmd.getComplianceStatus();
    Object pod = null;
    Object hostId = null;
    Object storageId = null;
    if (cmd instanceof ListVMsCmdByAdmin) {
        final ListVMsCmdByAdmin adCmd = (ListVMsCmdByAdmin) cmd;
        pod = adCmd.getPodId();
        hostId = adCmd.getHostId();
        storageId = adCmd.getStorageId();
    }
    sb.and("displayName", sb.entity().getDisplayName(), SearchCriteria.Op.LIKE);
    sb.and("idIN", sb.entity().getId(), SearchCriteria.Op.IN);
    sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
    sb.and("stateEQ", sb.entity().getState(), SearchCriteria.Op.EQ);
    sb.and("stateNEQ", sb.entity().getState(), SearchCriteria.Op.NEQ);
    sb.and("stateNIN", sb.entity().getState(), SearchCriteria.Op.NIN);
    sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
    sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
    sb.and("hostIdEQ", sb.entity().getHostId(), SearchCriteria.Op.EQ);
    sb.and("templateId", sb.entity().getTemplateId(), SearchCriteria.Op.EQ);
    sb.and("isoId", sb.entity().getIsoId(), SearchCriteria.Op.EQ);
    sb.and("instanceGroupId", sb.entity().getInstanceGroupId(), SearchCriteria.Op.EQ);
    if (serviceOffId != null) {
        sb.and("serviceOfferingId", sb.entity().getServiceOfferingId(), SearchCriteria.Op.EQ);
    }
    if (display != null) {
        sb.and("display", sb.entity().isDisplayVm(), SearchCriteria.Op.EQ);
    }
    if (groupId != null && (Long) groupId != -1) {
        sb.and("instanceGroupId", sb.entity().getInstanceGroupId(), SearchCriteria.Op.EQ);
    }
    if (userId != null) {
        sb.and("userId", sb.entity().getUserId(), SearchCriteria.Op.EQ);
    }
    if (networkId != null) {
        sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
    }
    if (vpcId != null && networkId == null) {
        sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
    }
    if (storageId != null) {
        sb.and("poolId", sb.entity().getPoolId(), SearchCriteria.Op.EQ);
    }
    if (affinityGroupId != null) {
        sb.and("affinityGroupId", sb.entity().getAffinityGroupId(), SearchCriteria.Op.EQ);
    }
    if (keyPairName != null) {
        sb.and("keyPairName", sb.entity().getKeypairName(), SearchCriteria.Op.EQ);
    }
    if (complianceStatus != null) {
        sb.and("complianceStatus", sb.entity().getComplianceStatus(), SearchCriteria.Op.EQ);
    }
    if (!isRootAdmin) {
        sb.and("displayVm", sb.entity().isDisplayVm(), SearchCriteria.Op.EQ);
    }
    // populate the search criteria with the values passed in
    final SearchCriteria<UserVmJoinVO> sc = sb.create();
    // building ACL condition
    _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (tags != null && !tags.isEmpty()) {
        final SearchCriteria<UserVmJoinVO> tagSc = _userVmJoinDao.createSearchCriteria();
        for (final Map.Entry<String, String> entry : tags.entrySet()) {
            final SearchCriteria<UserVmJoinVO> tsc = _userVmJoinDao.createSearchCriteria();
            tsc.addAnd("tagKey", SearchCriteria.Op.EQ, entry.getKey());
            tsc.addAnd("tagValue", SearchCriteria.Op.EQ, entry.getValue());
            tagSc.addOr("tagKey", SearchCriteria.Op.SC, tsc);
        }
        sc.addAnd("tagKey", SearchCriteria.Op.SC, tagSc);
    }
    if (groupId != null && (Long) groupId != -1) {
        sc.setParameters("instanceGroupId", groupId);
    }
    if (keyword != null) {
        final SearchCriteria<UserVmJoinVO> ssc = _userVmJoinDao.createSearchCriteria();
        ssc.addOr("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("instanceName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("hostName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("state", SearchCriteria.Op.EQ, keyword);
        sc.addAnd("displayName", SearchCriteria.Op.SC, ssc);
    }
    if (serviceOffId != null) {
        sc.setParameters("serviceOfferingId", serviceOffId);
    }
    if (display != null) {
        sc.setParameters("display", display);
    }
    if (ids != null && !ids.isEmpty()) {
        sc.setParameters("idIN", ids.toArray());
    }
    if (templateId != null) {
        sc.setParameters("templateId", templateId);
    }
    if (isoId != null) {
        sc.setParameters("isoId", isoId);
    }
    if (userId != null) {
        sc.setParameters("userId", userId);
    }
    if (networkId != null) {
        sc.setParameters("networkId", networkId);
    }
    if (vpcId != null && networkId == null) {
        sc.setParameters("vpcId", vpcId);
    }
    if (name != null) {
        sc.setParameters("name", "%" + name + "%");
    }
    if (state != null) {
        if (state.equalsIgnoreCase("present")) {
            sc.setParameters("stateNIN", "Destroyed", "Expunging");
        } else {
            sc.setParameters("stateEQ", state);
        }
    }
    if (hypervisor != null) {
        sc.setParameters("hypervisorType", hypervisor);
    }
    // Don't show Destroyed and Expunging vms to the end user if the AllowUserViewDestroyedVM flag is not set.
    if (!isAdmin && !AllowUserViewDestroyedVM.valueIn(caller.getAccountId())) {
        sc.setParameters("stateNIN", "Destroyed", "Expunging");
    }
    if (zoneId != null) {
        sc.setParameters("dataCenterId", zoneId);
    }
    if (affinityGroupId != null) {
        sc.setParameters("affinityGroupId", affinityGroupId);
    }
    if (keyPairName != null) {
        sc.setParameters("keyPairName", keyPairName);
    }
    if (complianceStatus != null) {
        sc.setParameters("complianceStatus", complianceStatus);
    }
    if (cmd instanceof ListVMsCmdByAdmin) {
        final ListVMsCmdByAdmin aCmd = (ListVMsCmdByAdmin) cmd;
        if (aCmd.getPodId() != null) {
            sc.setParameters("podId", pod);
            if (state == null) {
                sc.setParameters("stateNEQ", "Destroyed");
            }
        }
        if (hostId != null) {
            sc.setParameters("hostIdEQ", hostId);
        }
        if (storageId != null) {
            sc.setParameters("poolId", storageId);
        }
    }
    if (!isRootAdmin) {
        sc.setParameters("displayVm", 1);
    }
    // search vm details by ids
    final Pair<List<UserVmJoinVO>, Integer> uniqueVmPair = _userVmJoinDao.searchAndDistinctCount(sc, searchFilter);
    final Integer count = uniqueVmPair.second();
    if (count.intValue() == 0) {
        // handle empty result cases
        return uniqueVmPair;
    }
    final List<UserVmJoinVO> uniqueVms = uniqueVmPair.first();
    final Long[] vmIds = new Long[uniqueVms.size()];
    int i = 0;
    for (final UserVmJoinVO v : uniqueVms) {
        vmIds[i++] = v.getId();
    }
    final List<UserVmJoinVO> vms = _userVmJoinDao.searchByIds(vmIds);
    return new Pair<>(vms, count);
}
Also used : Account(com.cloud.legacymodel.user.Account) ArrayList(java.util.ArrayList) InvalidParameterValueException(com.cloud.legacymodel.exceptions.InvalidParameterValueException) ArrayList(java.util.ArrayList) List(java.util.List) Pair(com.cloud.legacymodel.utils.Pair) Ternary(com.cloud.legacymodel.utils.Ternary) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) Filter(com.cloud.utils.db.Filter) TemplateFilter(com.cloud.legacymodel.storage.VirtualMachineTemplate.TemplateFilter) ListVMsCmdByAdmin(com.cloud.api.command.admin.vm.ListVMsCmdByAdmin) Map(java.util.Map)

Example 88 with Pair

use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.

the class VolumeOrchestrator method recreateVolume.

private Pair<VolumeVO, DataStore> recreateVolume(final VolumeVO vol, final VirtualMachineProfile vm, final DeployDestination dest) throws StorageUnavailableException {
    VolumeVO newVol;
    final boolean recreate = RecreatableSystemVmEnabled.value();
    DataStore destPool = null;
    if (recreate && (dest.getStorageForDisks() == null || dest.getStorageForDisks().get(vol) == null)) {
        destPool = this.dataStoreMgr.getDataStore(vol.getPoolId(), DataStoreRole.Primary);
        s_logger.debug("existing pool: " + destPool.getId());
    } else {
        final StoragePool pool = dest.getStorageForDisks().get(vol);
        destPool = this.dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
    }
    if (vol.getState() == Volume.State.Allocated || vol.getState() == Volume.State.Creating) {
        newVol = vol;
    } else {
        newVol = switchVolume(vol, vm);
        // changed
        if (dest.getStorageForDisks() != null && dest.getStorageForDisks().containsKey(vol)) {
            final StoragePool poolWithOldVol = dest.getStorageForDisks().get(vol);
            dest.getStorageForDisks().put(newVol, poolWithOldVol);
            dest.getStorageForDisks().remove(vol);
        }
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Created new volume " + newVol + " for old volume " + vol);
        }
    }
    VolumeInfo volume = this.volFactory.getVolume(newVol.getId(), destPool);
    final Long templateId = newVol.getTemplateId();
    for (int i = 0; i < 2; i++) {
        // retry one more time in case of template reload is required for Vmware case
        AsyncCallFuture<VolumeService.VolumeApiResult> future = null;
        if (templateId == null) {
            final DiskOffering diskOffering = this._entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId());
            final HypervisorType hyperType = vm.getVirtualMachine().getHypervisorType();
            // update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage)
            this.volService.updateHypervisorSnapshotReserveForVolume(diskOffering, volume.getId(), hyperType);
            volume = this.volFactory.getVolume(newVol.getId(), destPool);
            future = this.volService.createVolumeAsync(volume, destPool);
        } else {
            final TemplateInfo templ = this.tmplFactory.getReadyTemplateOnImageStore(templateId, dest.getZone().getId());
            if (templ == null) {
                s_logger.debug("can't find ready template: " + templateId + " for data center " + dest.getZone().getId());
                throw new CloudRuntimeException("can't find ready template: " + templateId + " for data center " + dest.getZone().getId());
            }
            final PrimaryDataStore primaryDataStore = (PrimaryDataStore) destPool;
            if (primaryDataStore.isManaged()) {
                final DiskOffering diskOffering = this._entityMgr.findById(DiskOffering.class, volume.getDiskOfferingId());
                final HypervisorType hyperType = vm.getVirtualMachine().getHypervisorType();
                // update the volume's hv_ss_reserve (hypervisor snapshot reserve) from a disk offering (used for managed storage)
                this.volService.updateHypervisorSnapshotReserveForVolume(diskOffering, volume.getId(), hyperType);
                final long hostId = vm.getVirtualMachine().getHostId();
                future = this.volService.createManagedStorageAndVolumeFromTemplateAsync(volume, destPool.getId(), templ, hostId);
            } else {
                future = this.volService.createVolumeFromTemplateAsync(volume, destPool.getId(), templ);
            }
        }
        VolumeService.VolumeApiResult result = null;
        try {
            result = future.get();
            if (result.isFailed()) {
                if (result.getResult().contains("request template reload") && (i == 0)) {
                    s_logger.debug("Retry template re-deploy for vmware");
                    continue;
                } else {
                    s_logger.debug("Unable to create " + newVol + ":" + result.getResult());
                    throw new StorageUnavailableException("Unable to create " + newVol + ":" + result.getResult(), destPool.getId());
                }
            }
            final StoragePoolVO storagePool = this._storagePoolDao.findById(destPool.getId());
            if (storagePool.isManaged()) {
                final long hostId = vm.getVirtualMachine().getHostId();
                final Host host = this._hostDao.findById(hostId);
                this.volService.grantAccess(this.volFactory.getVolume(newVol.getId()), host, destPool);
            }
            newVol = this._volsDao.findById(newVol.getId());
            // break out of template-redeploy retry loop
            break;
        } catch (final InterruptedException e) {
            s_logger.error("Unable to create " + newVol, e);
            throw new StorageUnavailableException("Unable to create " + newVol + ":" + e.toString(), destPool.getId());
        } catch (final ExecutionException e) {
            s_logger.error("Unable to create " + newVol, e);
            throw new StorageUnavailableException("Unable to create " + newVol + ":" + e.toString(), destPool.getId());
        }
    }
    return new Pair<>(newVol, destPool);
}
Also used : StoragePool(com.cloud.legacymodel.storage.StoragePool) DiskOffering(com.cloud.legacymodel.storage.DiskOffering) VolumeInfo(com.cloud.engine.subsystem.api.storage.VolumeInfo) Host(com.cloud.legacymodel.dc.Host) HypervisorType(com.cloud.model.enumeration.HypervisorType) TemplateInfo(com.cloud.engine.subsystem.api.storage.TemplateInfo) VolumeVO(com.cloud.storage.VolumeVO) StorageUnavailableException(com.cloud.legacymodel.exceptions.StorageUnavailableException) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) VolumeService(com.cloud.engine.subsystem.api.storage.VolumeService) DataStore(com.cloud.engine.subsystem.api.storage.DataStore) PrimaryDataStore(com.cloud.engine.subsystem.api.storage.PrimaryDataStore) StoragePoolVO(com.cloud.storage.datastore.db.StoragePoolVO) ExecutionException(java.util.concurrent.ExecutionException) PrimaryDataStore(com.cloud.engine.subsystem.api.storage.PrimaryDataStore) Pair(com.cloud.legacymodel.utils.Pair)

Example 89 with Pair

use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.

the class CitrixResourceBase method getControlDomain.

protected Pair<VM, VM.Record> getControlDomain(final Connection conn) throws XenAPIException, XmlRpcException {
    final Host host = Host.getByUuid(conn, this._host.getUuid());
    Set<VM> vms = null;
    vms = host.getResidentVMs(conn);
    for (final VM vm : vms) {
        if (vm.getIsControlDomain(conn)) {
            return new Pair<>(vm, vm.getRecord(conn));
        }
    }
    throw new CloudRuntimeException("Com'on no control domain?  What the crap?!#@!##$@");
}
Also used : CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) VM(com.xensource.xenapi.VM) Host(com.xensource.xenapi.Host) Pair(com.cloud.legacymodel.utils.Pair)

Example 90 with Pair

use of com.cloud.legacymodel.utils.Pair in project cosmic by MissionCriticalCloud.

the class XenServer610MigrateWithStorageCommandWrapper method execute.

@Override
public Answer execute(final MigrateWithStorageCommand command, final XenServer610Resource xenServer610Resource) {
    final Connection connection = xenServer610Resource.getConnection();
    final VirtualMachineTO vmSpec = command.getVirtualMachine();
    final List<Pair<VolumeTO, StorageFilerTO>> volumeToFiler = command.getVolumeToFilerAsList();
    final String vmName = vmSpec.getName();
    Task task = null;
    final XsHost xsHost = xenServer610Resource.getHost();
    final String uuid = xsHost.getUuid();
    try {
        xenServer610Resource.prepareISO(connection, vmName, null, null);
        // Get the list of networks and recreate VLAN, if required.
        for (final NicTO nicTo : vmSpec.getNics()) {
            xenServer610Resource.getNetwork(connection, nicTo);
        }
        final Map<String, String> other = new HashMap<>();
        other.put("live", "true");
        final XsLocalNetwork nativeNetworkForTraffic = xenServer610Resource.getNativeNetworkForTraffic(connection, TrafficType.Storage, null);
        final Network networkForSm = nativeNetworkForTraffic.getNetwork();
        // Create the vif map. The vm stays in the same cluster so we have to pass an empty vif map.
        final Map<VIF, Network> vifMap = new HashMap<>();
        final Map<VDI, SR> vdiMap = new HashMap<>();
        for (final Pair<VolumeTO, StorageFilerTO> entry : volumeToFiler) {
            final VolumeTO volume = entry.first();
            final StorageFilerTO sotrageFiler = entry.second();
            vdiMap.put(xenServer610Resource.getVDIbyUuid(connection, volume.getPath()), xenServer610Resource.getStorageRepository(connection, sotrageFiler.getUuid()));
        }
        // Get the vm to migrate.
        final Set<VM> vms = VM.getByNameLabel(connection, vmSpec.getName());
        final VM vmToMigrate = vms.iterator().next();
        // Check migration with storage is possible.
        final Host host = Host.getByUuid(connection, uuid);
        final Map<String, String> token = host.migrateReceive(connection, networkForSm, other);
        task = vmToMigrate.assertCanMigrateAsync(connection, token, true, vdiMap, vifMap, other);
        try {
            // poll every 1 seconds
            final long timeout = xenServer610Resource.getMigrateWait() * 1000L;
            xenServer610Resource.waitForTask(connection, task, 1000, timeout);
            xenServer610Resource.checkForSuccess(connection, task);
        } catch (final Types.HandleInvalid e) {
            s_logger.error("Error while checking if vm " + vmName + " can be migrated to the destination host " + host, e);
            throw new CloudRuntimeException("Error while checking if vm " + vmName + " can be migrated to the " + "destination host " + host, e);
        }
        // Migrate now.
        task = vmToMigrate.migrateSendAsync(connection, token, true, vdiMap, vifMap, other);
        try {
            // poll every 1 seconds.
            final long timeout = xenServer610Resource.getMigrateWait() * 1000L;
            xenServer610Resource.waitForTask(connection, task, 1000, timeout);
            xenServer610Resource.checkForSuccess(connection, task);
        } catch (final Types.HandleInvalid e) {
            s_logger.error("Error while migrating vm " + vmName + " to the destination host " + host, e);
            throw new CloudRuntimeException("Error while migrating vm " + vmName + " to the destination host " + host, e);
        }
        // Volume paths would have changed. Return that information.
        final List<VolumeObjectTO> volumeToList = xenServer610Resource.getUpdatedVolumePathsOfMigratedVm(connection, vmToMigrate, vmSpec.getDisks());
        vmToMigrate.setAffinity(connection, host);
        return new MigrateWithStorageAnswer(command, volumeToList);
    } catch (final Exception e) {
        s_logger.warn("Catch Exception " + e.getClass().getName() + ". Storage motion failed due to " + e.toString(), e);
        return new MigrateWithStorageAnswer(command, e);
    } finally {
        if (task != null) {
            try {
                task.destroy(connection);
            } catch (final Exception e) {
                s_logger.debug("Unable to destroy task " + task.toString() + " on host " + uuid + " due to " + e.toString());
            }
        }
    }
}
Also used : Types(com.xensource.xenapi.Types) Task(com.xensource.xenapi.Task) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) HashMap(java.util.HashMap) StorageFilerTO(com.cloud.legacymodel.to.StorageFilerTO) VirtualMachineTO(com.cloud.legacymodel.to.VirtualMachineTO) VolumeTO(com.cloud.legacymodel.to.VolumeTO) XsLocalNetwork(com.cloud.hypervisor.xenserver.resource.XsLocalNetwork) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) Network(com.xensource.xenapi.Network) XsLocalNetwork(com.cloud.hypervisor.xenserver.resource.XsLocalNetwork) VolumeObjectTO(com.cloud.legacymodel.to.VolumeObjectTO) VDI(com.xensource.xenapi.VDI) Pair(com.cloud.legacymodel.utils.Pair) NicTO(com.cloud.legacymodel.to.NicTO) SR(com.xensource.xenapi.SR) MigrateWithStorageAnswer(com.cloud.legacymodel.communication.answer.MigrateWithStorageAnswer) Connection(com.xensource.xenapi.Connection) Host(com.xensource.xenapi.Host) XsHost(com.cloud.hypervisor.xenserver.resource.XsHost) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) VIF(com.xensource.xenapi.VIF) VM(com.xensource.xenapi.VM)

Aggregations

Pair (com.cloud.legacymodel.utils.Pair)139 ArrayList (java.util.ArrayList)87 List (java.util.List)64 Account (com.cloud.legacymodel.user.Account)49 Filter (com.cloud.utils.db.Filter)48 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)38 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)27 HashMap (java.util.HashMap)27 Ternary (com.cloud.legacymodel.utils.Ternary)23 ListProjectResourcesCriteria (com.cloud.projects.Project.ListProjectResourcesCriteria)22 ExcludeList (com.cloud.deploy.DeploymentPlanner.ExcludeList)20 SSHKeyPair (com.cloud.legacymodel.user.SSHKeyPair)16 TemplateFilter (com.cloud.legacymodel.storage.VirtualMachineTemplate.TemplateFilter)13 Map (java.util.Map)13 DB (com.cloud.utils.db.DB)11 DomainVO (com.cloud.domain.DomainVO)10 VolumeVO (com.cloud.storage.VolumeVO)10 PermissionDeniedException (com.cloud.legacymodel.exceptions.PermissionDeniedException)9 Network (com.cloud.legacymodel.network.Network)9 ResourceTagVO (com.cloud.tags.ResourceTagVO)9