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


Java NicVO.getNetworkId方法代码示例

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


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

示例1: prepare

import com.cloud.vm.NicVO; //导入方法依赖的package包/类
@Override
public void prepare(final VirtualMachineProfile vmProfile, final DeployDestination dest, final ReservationContext context) throws InsufficientCapacityException,
        ConcurrentOperationException,
        ResourceUnavailableException {
    final List<NicVO> nics = _nicDao.listByVmId(vmProfile.getId());

    // we have to implement default nics first - to ensure that default network elements start up first in multiple
    //nics case
    // (need for setting DNS on Dhcp to domR's Ip4 address)
    Collections.sort(nics, new Comparator<NicVO>() {

        @Override
        public int compare(final NicVO nic1, final NicVO nic2) {
            final boolean isDefault1 = nic1.isDefaultNic();
            final boolean isDefault2 = nic2.isDefaultNic();

            return isDefault1 ^ isDefault2 ? isDefault1 ^ true ? 1 : -1 : 0;
        }
    });

    for (final NicVO nic : nics) {
        final Pair<NetworkGuru, NetworkVO> implemented = implementNetwork(nic.getNetworkId(), dest, context, vmProfile.getVirtualMachine().getType() == Type.DomainRouter);
        if (implemented == null || implemented.first() == null) {
            s_logger.warn("Failed to implement network id=" + nic.getNetworkId() + " as a part of preparing nic id=" + nic.getId());
            throw new CloudRuntimeException("Failed to implement network id=" + nic.getNetworkId() + " as a part preparing nic id=" + nic.getId());
        }

        final NetworkVO network = implemented.second();
        final NicProfile profile = prepareNic(vmProfile, dest, context, nic.getId(), network);
        vmProfile.addNic(profile);
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:33,代码来源:NetworkOrchestrator.java

示例2: sendRulesetUpdates

import com.cloud.vm.NicVO; //导入方法依赖的package包/类
public void sendRulesetUpdates(final SecurityGroupWork work) {
    final Long userVmId = work.getInstanceId();
    final UserVm vm = _userVMDao.findById(userVmId);

    if (vm != null && vm.getState() == State.Running) {
        if (s_logger.isTraceEnabled()) {
            s_logger.trace("SecurityGroupManager v2: found vm, " + userVmId + " state=" + vm.getState());
        }
        final Map<PortAndProto, Set<String>> ingressRules = generateRulesForVM(userVmId, SecurityRuleType.IngressRule);
        final Map<PortAndProto, Set<String>> egressRules = generateRulesForVM(userVmId, SecurityRuleType.EgressRule);
        final Long agentId = vm.getHostId();
        if (agentId != null) {
            final String privateIp = vm.getPrivateIpAddress();
            final NicVO nic = _nicDao.findByIp4AddressAndVmId(privateIp, vm.getId());
            List<String> nicSecIps = null;
            if (nic != null) {
                if (nic.getSecondaryIp()) {
                    //get secondary ips of the vm
                    final long networkId = nic.getNetworkId();
                    nicSecIps = _nicSecIpDao.getSecondaryIpAddressesForNic(nic.getId());
                }
            }
            final SecurityGroupRulesCmd cmd =
                    generateRulesetCmd(vm.getInstanceName(), vm.getPrivateIpAddress(), vm.getPrivateMacAddress(), vm.getId(), null, work.getLogsequenceNumber(),
                            ingressRules, egressRules, nicSecIps);
            cmd.setMsId(_serverId);
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("SecurityGroupManager v2: sending ruleset update for vm " + vm.getInstanceName() + ":ingress num rules=" +
                        cmd.getIngressRuleSet().length + ":egress num rules=" + cmd.getEgressRuleSet().length + " num cidrs=" + cmd.getTotalNumCidrs() + " sig=" +
                        cmd.getSignature());
            }
            final Commands cmds = new Commands(cmd);
            try {
                _agentMgr.send(agentId, cmds, _answerListener);
                if (s_logger.isTraceEnabled()) {
                    s_logger.trace("SecurityGroupManager v2: sent ruleset updates for " + vm.getInstanceName() + " curr queue size=" + _workQueue.size());
                }
            } catch (final AgentUnavailableException e) {
                s_logger.debug("Unable to send updates for vm: " + userVmId + "(agentid=" + agentId + ")");
                _workTracker.handleException(agentId);
            }
        }
    } else {
        if (s_logger.isDebugEnabled()) {
            if (vm != null) {
                s_logger.debug("No rules sent to vm " + vm + "state=" + vm.getState());
            } else {
                s_logger.debug("Could not find vm: No rules sent to vm " + userVmId);
            }
        }
    }
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:53,代码来源:SecurityGroupManagerImpl2.java

示例3: startRouter

import com.cloud.vm.NicVO; //导入方法依赖的package包/类
@Override
public VirtualRouter startRouter(final long routerId, final boolean reprogramNetwork) throws ResourceUnavailableException, InsufficientCapacityException,
        ConcurrentOperationException {
    final Account caller = CallContext.current().getCallingAccount();
    final User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());

    // verify parameters
    DomainRouterVO router = _routerDao.findById(routerId);
    if (router == null) {
        throw new InvalidParameterValueException("Unable to find router by id " + routerId + ".");
    }
    _accountMgr.checkAccess(caller, null, true, router);

    final Account owner = _accountMgr.getAccount(router.getAccountId());

    // Check if all networks are implemented for the domR; if not -
    // implement them
    final Zone zone = zoneRepository.findOne(router.getDataCenterId());
    HostPodVO pod = null;
    if (router.getPodIdToDeployIn() != null) {
        pod = _podDao.findById(router.getPodIdToDeployIn());
    }
    final DeployDestination dest = new DeployDestination(zone, pod, null, null);

    final ReservationContext context = new ReservationContextImpl(null, null, callerUser, owner);

    final List<NicVO> nics = _nicDao.listByVmId(routerId);

    for (final NicVO nic : nics) {
        if (!_networkMgr.startNetwork(nic.getNetworkId(), dest, context)) {
            s_logger.warn("Failed to start network id=" + nic.getNetworkId() + " as a part of domR start");
            throw new CloudRuntimeException("Failed to start network id=" + nic.getNetworkId() + " as a part of domR start");
        }
    }

    // After start network, check if it's already running
    router = _routerDao.findById(routerId);
    if (router.getState() == VirtualMachine.State.Running) {
        return router;
    }

    final UserVO user = _userDao.findById(CallContext.current().getCallingUserId());
    final Map<Param, Object> params = new HashMap<>();
    if (reprogramNetwork) {
        params.put(Param.ReProgramGuestNetworks, true);
    } else {
        params.put(Param.ReProgramGuestNetworks, false);
    }
    final VirtualRouter virtualRouter = _nwHelper.startVirtualRouter(router, user, caller, params);
    if (virtualRouter == null) {
        throw new CloudRuntimeException("Failed to start router with id " + routerId);
    }
    return virtualRouter;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:55,代码来源:VirtualNetworkApplianceManagerImpl.java


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