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


Java Answer.getResult方法代码示例

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


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

示例1: checkVmOnHost

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
protected boolean checkVmOnHost(final VirtualMachine vm, final long hostId) throws AgentUnavailableException, OperationTimedoutException {
    final Answer answer = _agentMgr.send(hostId, new CheckVirtualMachineCommand(vm.getInstanceName()));
    if (answer == null || !answer.getResult()) {
        return false;
    }
    if (answer instanceof CheckVirtualMachineAnswer) {
        final CheckVirtualMachineAnswer vmAnswer = (CheckVirtualMachineAnswer) answer;
        if (vmAnswer.getState() == PowerState.PowerOff) {
            return false;
        }
    }

    UserVmVO userVm = _userVmDao.findById(vm.getId());
    if (userVm != null) {
        List<VMSnapshotVO> vmSnapshots = _vmSnapshotDao.findByVm(vm.getId());
        RestoreVMSnapshotCommand command = _vmSnapshotMgr.createRestoreCommand(userVm, vmSnapshots);
        if (command != null) {
            RestoreVMSnapshotAnswer restoreVMSnapshotAnswer = (RestoreVMSnapshotAnswer) _agentMgr.send(hostId, command);
            if (restoreVMSnapshotAnswer == null || !restoreVMSnapshotAnswer.getResult()) {
                s_logger.warn("Unable to restore the vm snapshot from image file after live migration of vm with vmsnapshots: " + restoreVMSnapshotAnswer.getDetails());
            }
        }
    }

    return true;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:27,代码来源:VirtualMachineManagerImpl.java

示例2: isSuccessful

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
/**
 * @return For Commands with handler OnError.Continue, one command succeeding is successful.  If not, all commands must succeed to be successful.
 */
public boolean isSuccessful() {
    if (_answers == null) {
        return false;
    }
    if (_handler == OnError.Continue) {
        return true;
    }
    for (final Answer answer : _answers) {
        if (_handler == OnError.Continue && answer.getResult()) {
            return true;
        } else if (_handler != OnError.Continue && !answer.getResult()) {
            return false;
        }
    }

    return _handler != OnError.Continue;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:21,代码来源:Commands.java

示例3: isAgentAlive

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public Status isAgentAlive(final Host agent) {
    if (agent.getHypervisorType() != HypervisorType.XenServer) {
        return null;
    }

    final CheckOnHostCommand cmd = new CheckOnHostCommand(agent);
    final List<HostVO> neighbors = _resourceMgr.listAllHostsInCluster(agent.getClusterId());
    for (final HostVO neighbor : neighbors) {
        if (neighbor.getId() == agent.getId() || neighbor.getHypervisorType() != HypervisorType.XenServer) {
            continue;
        }
        final Answer answer = _agentMgr.easySend(neighbor.getId(), cmd);
        if (answer != null && answer.getResult()) {
            final CheckOnHostAnswer ans = (CheckOnHostAnswer) answer;
            if (!ans.isDetermined()) {
                s_logger.debug("Host " + neighbor + " couldn't determine the status of " + agent);
                continue;
            }
            // even it returns true, that means host is up, but XAPI may not work
            return ans.isAlive() ? null : Status.Down;
        }
    }

    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:27,代码来源:XenServerInvestigator.java

示例4: getHostStatistics

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public HostStats getHostStatistics(final long hostId) {
    final Answer answer = _agentMgr.easySend(hostId, new GetHostStatsCommand(_hostDao.findById(hostId).getGuid(), _hostDao.findById(hostId).getName(), hostId));

    if (answer != null && answer instanceof UnsupportedAnswer) {
        return null;
    }

    if (answer == null || !answer.getResult()) {
        final String msg = "Unable to obtain host " + hostId + " statistics. ";
        s_logger.warn(msg);
        return null;
    } else {

        // now construct the result object
        if (answer instanceof GetHostStatsAnswer) {
            return ((GetHostStatsAnswer) answer).getHostStats();
        }
    }
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:22,代码来源:ResourceManagerImpl.java

示例5: getGPUStatistics

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public HashMap<String, HashMap<String, VgpuTypesInfo>> getGPUStatistics(final HostVO host) {
    final Answer answer = _agentMgr.easySend(host.getId(), new GetGPUStatsCommand(host.getGuid(), host.getName()));
    if (answer != null && answer instanceof UnsupportedAnswer) {
        return null;
    }
    if (answer == null || !answer.getResult()) {
        final String msg = "Unable to obtain GPU stats for host " + host.getName();
        s_logger.warn(msg);
        return null;
    } else {
        // now construct the result object
        if (answer instanceof GetGPUStatsAnswer) {
            return ((GetGPUStatsAnswer) answer).getGroupDetails();
        }
    }
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:19,代码来源:ResourceManagerImpl.java

示例6: doUpdateHostPassword

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
private boolean doUpdateHostPassword(final long hostId) {
    if (!_agentMgr.isAgentAttached(hostId)) {
        return false;
    }

    DetailVO nv = _hostDetailsDao.findDetail(hostId, ApiConstants.USERNAME);
    final String username = nv.getValue();
    nv = _hostDetailsDao.findDetail(hostId, ApiConstants.PASSWORD);
    final String password = nv.getValue();

    final HostVO host = _hostDao.findById(hostId);
    final String hostIpAddress = host.getPrivateIpAddress();

    final UpdateHostPasswordCommand cmd = new UpdateHostPasswordCommand(username, password, hostIpAddress);
    final Answer answer = _agentMgr.easySend(hostId, cmd);

    s_logger.info("Result returned from update host password ==> " + answer.getDetails());
    return answer.getResult();
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:20,代码来源:ResourceManagerImpl.java

示例7: rebootProxy

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public boolean rebootProxy(final long proxyVmId) {
    final ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);

    if (proxy == null || proxy.getState() == State.Destroyed) {
        return false;
    }

    if (proxy.getState() == State.Running && proxy.getHostId() != null) {
        final RebootCommand cmd = new RebootCommand(proxy.getInstanceName(), _itMgr.getExecuteInSequence(proxy.getHypervisorType()));
        final Answer answer = _agentMgr.easySend(proxy.getHostId(), cmd);

        if (answer != null && answer.getResult()) {
            logger.debug("Successfully reboot console proxy " + proxy.getHostName());

            SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT, this,
                    new ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_REBOOTED, proxy.getDataCenterId(), proxy.getId(), proxy, null));

            return true;
        } else {
            logger.debug("failed to reboot console proxy : " + proxy.getHostName());

            return false;
        }
    } else {
        return startProxy(proxyVmId, false) != null;
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:29,代码来源:ConsoleProxyManagerImpl.java

示例8: 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

示例9: 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

示例10: cleanupStorage

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
public void cleanupStorage() {

        final int EXTRACT_URL_LIFE_LIMIT_IN_SECONDS = _urlExpirationInterval;
        final List<UploadVO> extractJobs = _uploadDao.listByModeAndStatus(Mode.HTTP_DOWNLOAD, Status.DOWNLOAD_URL_CREATED);

        for (final UploadVO extractJob : extractJobs) {
            if (getTimeDiff(extractJob.getLastUpdated()) > EXTRACT_URL_LIFE_LIMIT_IN_SECONDS) {
                final String path = extractJob.getInstallPath();
                final DataStore secStore = storeMgr.getDataStore(extractJob.getDataStoreId(), DataStoreRole.Image);

                // Would delete the symlink for the Type and if Type == VOLUME then also the volume
                final DeleteEntityDownloadURLCommand cmd =
                        new DeleteEntityDownloadURLCommand(path, extractJob.getType(), extractJob.getUploadUrl(), ((ImageStoreVO) secStore).getParent());
                final EndPoint ep = _epSelector.select(secStore);
                if (ep == null) {
                    s_logger.warn("UploadMonitor cleanup: There is no secondary storage VM for secondary storage host " + extractJob.getDataStoreId());
                    continue; //TODO: why continue? why not break?
                }
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("UploadMonitor cleanup: Sending deletion of extract URL " + extractJob.getUploadUrl() + " to ssvm " + ep.getHostAddr());
                }
                final Answer ans = ep.sendMessage(cmd);
                if (ans != null && ans.getResult()) {
                    _uploadDao.remove(extractJob.getId());
                } else {
                    s_logger.warn("UploadMonitor cleanup: Unable to delete the link for " + extractJob.getType() + " id=" + extractJob.getTypeId() + " url=" +
                            extractJob.getUploadUrl() + " on ssvm " + ep.getHostAddr());
                }
            }
        }
    }
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:32,代码来源:UploadMonitorImpl.java

示例11: getVmDiskStatistics

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public HashMap<Long, List<VmDiskStatsEntry>> getVmDiskStatistics(final long hostId, final String hostName, final List<Long> vmIds) throws CloudRuntimeException {
    final HashMap<Long, List<VmDiskStatsEntry>> vmDiskStatsById = new HashMap<>();

    if (vmIds.isEmpty()) {
        return vmDiskStatsById;
    }

    final List<String> vmNames = new ArrayList<>();

    for (final Long vmId : vmIds) {
        final UserVmVO vm = _vmDao.findById(vmId);
        vmNames.add(vm.getInstanceName());
    }

    final Answer answer = _agentMgr.easySend(hostId, new GetVmDiskStatsCommand(vmNames, _hostDao.findById(hostId).getGuid(), hostName));
    if (answer == null || !answer.getResult()) {
        s_logger.warn("Unable to obtain VM disk statistics.");
        return null;
    } else {
        final HashMap<String, List<VmDiskStatsEntry>> vmDiskStatsByName = ((GetVmDiskStatsAnswer) answer).getVmDiskStatsMap();

        if (vmDiskStatsByName == null) {
            s_logger.warn("Unable to obtain VM disk statistics.");
            return null;
        }

        for (final Map.Entry<String, List<VmDiskStatsEntry>> entry : vmDiskStatsByName.entrySet()) {
            vmDiskStatsById.put(vmIds.get(vmNames.indexOf(entry.getKey())), entry.getValue());
        }
    }

    return vmDiskStatsById;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:35,代码来源:UserVmManagerImpl.java

示例12: processAnswers

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public boolean processAnswers(final long agentId, final long seq, final Answer[] answers) {
    final List<Long> affectedVms = new ArrayList<>();
    int commandNum = 0;
    for (final Answer ans : answers) {
        if (ans instanceof SecurityGroupRuleAnswer) {
            final SecurityGroupRuleAnswer ruleAnswer = (SecurityGroupRuleAnswer) ans;
            if (ans.getResult()) {
                s_logger.debug("Successfully programmed rule " + ruleAnswer.toString() + " into host " + agentId);
                _workDao.updateStep(ruleAnswer.getVmId(), ruleAnswer.getLogSequenceNumber(), Step.Done);
                recordSuccess(ruleAnswer.getVmId());
            } else {
                _workDao.updateStep(ruleAnswer.getVmId(), ruleAnswer.getLogSequenceNumber(), Step.Error);
                s_logger.debug("Failed to program rule " + ruleAnswer.toString() + " into host " + agentId + " due to " + ruleAnswer.getDetails() +
                        " and updated  jobs");
                if (ruleAnswer.getReason() == FailureReason.CANNOT_BRIDGE_FIREWALL) {
                    s_logger.debug("Not retrying security group rules for vm " + ruleAnswer.getVmId() + " on failure since host " + agentId +
                            " cannot do bridge firewalling");
                } else if (ruleAnswer.getReason() == FailureReason.PROGRAMMING_FAILED) {
                    if (checkShouldRetryOnFailure(ruleAnswer.getVmId())) {
                        s_logger.debug("Retrying security group rules on failure for vm " + ruleAnswer.getVmId());
                        affectedVms.add(ruleAnswer.getVmId());
                    } else {
                        s_logger.debug("Not retrying security group rules for vm " + ruleAnswer.getVmId() + " on failure: too many retries");
                    }
                }
            }
            commandNum++;
            if (_workTracker != null) {
                _workTracker.processAnswers(agentId, seq, answers);
            }
        }
    }

    if (affectedVms.size() > 0) {
        _securityGroupManager.scheduleRulesetUpdateToHosts(affectedVms, false, new Long(10 * 1000l));
    }

    return true;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:41,代码来源:SecurityGroupListener.java

示例13: sendCommandsToRouter

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public boolean sendCommandsToRouter(final VirtualRouter router, final Commands cmds) throws AgentUnavailableException, ResourceUnavailableException {
    if (!checkRouterVersion(router)) {
        logger.debug("Router requires upgrade. Unable to send command to router:" + router.getId() + ", router template version : " + router.getTemplateVersion()
                + ", minimal required version : " + NetworkOrchestrationService.MinVRVersion.valueIn(router.getDataCenterId()));
        throw new ResourceUnavailableException("Unable to send command. Router requires upgrade", VirtualRouter.class, router.getId());
    }
    Answer[] answers = null;
    try {
        answers = _agentMgr.send(router.getHostId(), cmds);
    } catch (final OperationTimedoutException e) {
        logger.warn("Timed Out", e);
        throw new AgentUnavailableException("Unable to send commands to virtual router ", router.getHostId(), e);
    }

    if (answers == null || answers.length != cmds.size()) {
        return false;
    }

    // FIXME: Have to return state for individual command in the future
    boolean result = true;
    for (final Answer answer : answers) {
        if (!answer.getResult()) {
            result = false;
            break;
        }
    }
    return result;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:30,代码来源:NetworkHelperImpl.java

示例14: deleteAsync

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
@Override
public void deleteAsync(final DataStore dataStore, final DataObject data, final AsyncCompletionCallback<CommandResult> callback) {
    final DeleteCommand cmd = new DeleteCommand(data.getTO());

    final CommandResult result = new CommandResult();
    try {
        EndPoint ep = null;
        if (data.getType() == DataObjectType.VOLUME) {
            ep = epSelector.select(data, StorageAction.DELETEVOLUME);
        } else {
            ep = epSelector.select(data);
        }
        if (ep == null) {
            final String errMsg = "No remote endpoint to send DeleteCommand, check if host or ssvm is down?";
            s_logger.error(errMsg);
            result.setResult(errMsg);
        } else {
            final Answer answer = ep.sendMessage(cmd);
            if (answer != null && !answer.getResult()) {
                result.setResult(answer.getDetails());
            }
        }
    } catch (final Exception ex) {
        s_logger.debug("Unable to destoy volume" + data.getId(), ex);
        result.setResult(ex.toString());
    }
    callback.complete(result);
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:29,代码来源:CloudStackPrimaryDataStoreDriverImpl.java

示例15: testUserVM

import com.cloud.agent.api.Answer; //导入方法依赖的package包/类
private Boolean testUserVM(final VirtualMachine vm, final Nic nic, final VirtualRouter router) {
    final String privateIp = nic.getIPv4Address();
    final String routerPrivateIp = router.getPrivateIpAddress();

    List<Long> otherHosts = new ArrayList<>();
    if (vm.getHypervisorType() == HypervisorType.XenServer || vm.getHypervisorType() == HypervisorType.KVM) {
        otherHosts.add(router.getHostId());
    } else {
        otherHosts = findHostByPod(router.getPodIdToDeployIn(), null);
    }
    for (final Long hostId : otherHosts) {
        try {
            final Answer pingTestAnswer = _agentMgr.easySend(hostId, new PingTestCommand(routerPrivateIp, privateIp));
            if (pingTestAnswer != null && pingTestAnswer.getResult()) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("user vm's " + vm.getHostName() + " ip address " + privateIp + "  has been successfully pinged from the Virtual Router " +
                            router.getHostName() + ", returning that vm is alive");
                }
                return Boolean.TRUE;
            }
        } catch (final Exception e) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Couldn't reach due to", e);
            }
            continue;
        }
    }
    if (s_logger.isDebugEnabled()) {
        s_logger.debug(vm + " could not be pinged, returning that it is unknown");
    }
    return null;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:33,代码来源:UserVmDomRInvestigator.java


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