当前位置: 首页>>代码示例>>Java>>正文


Java Answer.getDetails方法代码示例

本文整理汇总了Java中com.cloud.agent.api.Answer.getDetails方法的典型用法代码示例。如果您正苦于以下问题:Java Answer.getDetails方法的具体用法?Java Answer.getDetails怎么用?Java Answer.getDetails使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloud.agent.api.Answer的用法示例。


在下文中一共展示了Answer.getDetails方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyAsync

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public Void copyAsync(final DataObject srcData, final DataObject destData, final Host destHost, final AsyncCompletionCallback<CopyCommandResult> callback) {
    Answer answer = null;
    String errMsg = null;
    try {
        s_logger.debug("copyAsync inspecting src type " + srcData.getType().toString() + " copyAsync inspecting dest type " + destData.getType().toString());

        if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.VOLUME) {
            answer = copyVolumeFromSnapshot(srcData, destData);
        } else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.TEMPLATE) {
            answer = createTemplateFromSnapshot(srcData, destData);
        } else if (srcData.getType() == DataObjectType.TEMPLATE && destData.getType() == DataObjectType.VOLUME) {
            answer = cloneVolume(srcData, destData);
        } else if (destData.getType() == DataObjectType.VOLUME && srcData.getType() == DataObjectType.VOLUME &&
                srcData.getDataStore().getRole() == DataStoreRole.Primary && destData.getDataStore().getRole() == DataStoreRole.Primary) {
            if (srcData.getId() == destData.getId()) {
                // The volume has to be migrated across storage pools.
                answer = migrateVolumeToPool(srcData, destData);
            } else {
                answer = copyVolumeBetweenPools(srcData, destData);
            }
        } else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) {
            answer = copySnapshot(srcData, destData);
        } else {
            answer = copyObject(srcData, destData, destHost);
        }

        if (answer != null && !answer.getResult()) {
            errMsg = answer.getDetails();
        }
    } catch (final Exception e) {
        s_logger.debug("copy failed", e);
        errMsg = e.toString();
    }
    final CopyCommandResult result = new CopyCommandResult(null, answer);
    result.setResult(errMsg);
    callback.complete(result);
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:40,代码来源:AncientDataMotionStrategy.java

示例2: resizeVolumeOnHypervisor

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public void resizeVolumeOnHypervisor(final long volumeId, final long newSize, final long destHostId, final String instanceName) {
    final String errMsg = "Resize command failed";

    try {
        Answer answer = null;
        final Host destHost = _hostDao.findById(destHostId);
        final EndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(destHost);

        if (ep != null) {
            final VolumeVO volume = volDao.findById(volumeId);
            final PrimaryDataStore primaryDataStore = this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
            final ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(volume.getPath(), new StorageFilerTO(primaryDataStore), volume.getSize(), newSize, true,
                    instanceName);

            answer = ep.sendMessage(resizeCmd);
        } else {
            throw new CloudRuntimeException("Could not find a remote endpoint to send command to. Check if host or SSVM is down.");
        }

        if (answer == null || !answer.getResult()) {
            throw new CloudRuntimeException(answer != null ? answer.getDetails() : errMsg);
        }
    } catch (final Exception e) {
        throw new CloudRuntimeException(errMsg, e);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:28,代码来源:VolumeServiceImpl.java

示例3: createStoragePool

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
protected boolean createStoragePool(final long hostId, final StoragePool pool) {
    s_logger.debug("creating pool " + pool.getName() + " on  host " + hostId);

    if (pool.getPoolType() != StoragePoolType.NetworkFilesystem && pool.getPoolType() != StoragePoolType.Filesystem &&
            pool.getPoolType() != StoragePoolType.IscsiLUN && pool.getPoolType() != StoragePoolType.Iscsi &&
            pool.getPoolType() != StoragePoolType.SharedMountPoint && pool.getPoolType() != StoragePoolType.PreSetup && pool.getPoolType() != StoragePoolType.OCFS2 &&
            pool.getPoolType() != StoragePoolType.RBD && pool.getPoolType() != StoragePoolType.CLVM && pool.getPoolType() != StoragePoolType.SMB &&
            pool.getPoolType() != StoragePoolType.Gluster) {
        s_logger.warn(" Doesn't support storage pool type " + pool.getPoolType());
        return false;
    }
    final CreateStoragePoolCommand cmd = new CreateStoragePoolCommand(true, pool);
    final Answer answer = agentMgr.easySend(hostId, cmd);
    if (answer != null && answer.getResult()) {
        return true;
    } else {
        primaryDataStoreDao.expunge(pool.getId());
        String msg = "";
        if (answer != null) {
            msg = "Can not create storage pool through host " + hostId + " due to " + answer.getDetails();
            s_logger.warn(msg);
        } else {
            msg = "Can not create storage pool through host " + hostId + " due to CreateStoragePoolCommand returns null";
            s_logger.warn(msg);
        }
        throw new CloudRuntimeException(msg);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:29,代码来源:CloudStackPrimaryDataStoreLifeCycleImpl.java

示例4: handleManagedStorage

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
private void handleManagedStorage(final UserVmVO vm, final VolumeVO root) {
    if (Volume.State.Allocated.equals(root.getState())) {
        return;
    }
    final StoragePoolVO storagePool = _storagePoolDao.findById(root.getPoolId());

    if (storagePool != null && storagePool.isManaged()) {
        final Long hostId = vm.getHostId() != null ? vm.getHostId() : vm.getLastHostId();

        if (hostId != null) {
            final VolumeInfo volumeInfo = volFactory.getVolume(root.getId());
            final Host host = _hostDao.findById(hostId);

            final Command cmd;

            if (host.getHypervisorType() == HypervisorType.XenServer) {
                final DiskTO disk = new DiskTO(volumeInfo.getTO(), root.getDeviceId(), root.getPath(), root.getVolumeType());

                // it's OK in this case to send a detach command to the host for a root volume as this
                // will simply lead to the SR that supports the root volume being removed
                cmd = new DettachCommand(disk, vm.getInstanceName());

                final DettachCommand detachCommand = (DettachCommand) cmd;

                detachCommand.setManaged(true);

                detachCommand.setStorageHost(storagePool.getHostAddress());
                detachCommand.setStoragePort(storagePool.getPort());

                detachCommand.set_iScsiName(root.get_iScsiName());
            } else {
                throw new CloudRuntimeException("This hypervisor type is not supported on managed storage for this command.");
            }

            final Commands cmds = new Commands(Command.OnError.Stop);

            cmds.addCommand(cmd);

            try {
                _agentMgr.send(hostId, cmds);
            } catch (final Exception ex) {
                throw new CloudRuntimeException(ex.getMessage());
            }

            if (!cmds.isSuccessful()) {
                for (final Answer answer : cmds.getAnswers()) {
                    if (!answer.getResult()) {
                        s_logger.warn("Failed to reset vm due to: " + answer.getDetails());

                        throw new CloudRuntimeException("Unable to reset " + vm + " due to " + answer.getDetails());
                    }
                }
            }

            // root.getPoolId() should be null if the VM we are detaching the disk from has never been started before
            final DataStore dataStore = root.getPoolId() != null ? _dataStoreMgr.getDataStore(root.getPoolId(), DataStoreRole.Primary) : null;
            volumeMgr.revokeAccess(volFactory.getVolume(root.getId()), host, dataStore);
        }
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:61,代码来源:UserVmManagerImpl.java

示例5: finalizeStart

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public boolean finalizeStart(final VirtualMachineProfile profile, final long hostId, final Commands cmds, final ReservationContext context) {
    final DomainRouterVO router = _routerDao.findById(profile.getId());

    // process all the answers
    for (final Answer answer : cmds.getAnswers()) {
        // handle any command failures
        if (!answer.getResult()) {
            final String cmdClassName = answer.getClass().getCanonicalName().replace("Answer", "Command");
            final String errorMessage = "Command: " + cmdClassName + " failed while starting virtual router";
            final String errorDetails = "Details: " + answer.getDetails() + " " + answer.toString();
            // add alerts for the failed commands
            _alertMgr.sendAlert(AlertService.AlertType.ALERT_TYPE_DOMAIN_ROUTER, router.getDataCenterId(), router.getPodIdToDeployIn(), errorMessage, errorDetails);
            s_logger.error(answer.getDetails());
            s_logger.warn(errorMessage);
            // Stop the router if any of the commands failed
            return false;
        }
    }

    // at this point, all the router command are successful.
    boolean result = true;
    // Get guest networks info
    final List<Network> guestNetworks = new ArrayList<>();

    final List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
    for (final Nic nic : routerNics) {
        final Network network = _networkModel.getNetwork(nic.getNetworkId());

        final Zone zone = zoneRepository.findOne(network.getDataCenterId());

        if (network.getTrafficType() == TrafficType.Guest) {
            guestNetworks.add(network);
            if (nic.getBroadcastUri().getScheme().equals("pvlan")) {
                final NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic");

                final NetworkTopology networkTopology = _networkTopologyContext.retrieveNetworkTopology(zone);
                try {
                    result = networkTopology.setupDhcpForPvlan(true, router, router.getHostId(), nicProfile);
                } catch (final ResourceUnavailableException e) {
                    s_logger.debug("ERROR in finalizeStart: ", e);
                }
            }
        }
    }
    if (result) {
        final GetDomRVersionAnswer versionAnswer = (GetDomRVersionAnswer) cmds.getAnswer("getDomRVersion");
        router.setTemplateVersion(versionAnswer.getTemplateVersion());
        router.setScriptsVersion(versionAnswer.getScriptsVersion());
        _routerDao.persist(router, guestNetworks);
    }

    return result;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:55,代码来源:VirtualNetworkApplianceManagerImpl.java

示例6: orchestrateDetachVolumeFromVM

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
private Volume orchestrateDetachVolumeFromVM(final long vmId, final long volumeId) {

        final Volume volume = _volsDao.findById(volumeId);
        final VMInstanceVO vm = _vmInstanceDao.findById(vmId);

        String errorMsg = "Failed to detach volume " + volume.getName() + " from VM " + vm.getHostName();
        boolean sendCommand = vm.getState() == State.Running;

        final Long hostId = vm.getHostId();

        HostVO host = null;
        final StoragePoolVO volumePool = _storagePoolDao.findByIdIncludingRemoved(volume.getPoolId());

        if (hostId != null) {
            host = _hostDao.findById(hostId);

            if (host != null && host.getHypervisorType() == HypervisorType.XenServer && volumePool != null && volumePool.isManaged()) {
                sendCommand = true;
            }
        }

        Answer answer = null;

        if (sendCommand) {
            final DataTO volTO = volFactory.getVolume(volume.getId()).getTO();
            final DiskTO disk = new DiskTO(volTO, volume.getDeviceId(), volume.getPath(), volume.getVolumeType());

            final DettachCommand cmd = new DettachCommand(disk, vm.getInstanceName());

            cmd.setManaged(volumePool.isManaged());

            cmd.setStorageHost(volumePool.getHostAddress());
            cmd.setStoragePort(volumePool.getPort());

            cmd.set_iScsiName(volume.get_iScsiName());

            try {
                answer = _agentMgr.send(hostId, cmd);
            } catch (final Exception e) {
                throw new CloudRuntimeException(errorMsg + " due to: " + e.getMessage());
            }
        }

        if (!sendCommand || answer != null && answer.getResult()) {
            // Mark the volume as detached
            _volsDao.detachVolume(volume.getId());

            // volume.getPoolId() should be null if the VM we are detaching the disk from has never been started before
            final DataStore dataStore = volume.getPoolId() != null ? dataStoreMgr.getDataStore(volume.getPoolId(), DataStoreRole.Primary) : null;

            volService.revokeAccess(volFactory.getVolume(volume.getId()), host, dataStore);

            return _volsDao.findById(volumeId);
        } else {

            if (answer != null) {
                final String details = answer.getDetails();
                if (details != null && !details.isEmpty()) {
                    errorMsg += "; " + details;
                }
            }

            throw new CloudRuntimeException(errorMsg);
        }
    }
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:66,代码来源:VolumeApiServiceImpl.java


注:本文中的com.cloud.agent.api.Answer.getDetails方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。