Examples of NicVO


Examples of com.cloud.vm.NicVO

        to.setNetworkRateMbps(profile.getNetworkRate());
        to.setName(profile.getName());
        to.setSecurityGroupEnabled(profile.isSecurityGroupEnabled());

        // Workaround to make sure the TO has the UUID we need for Niciri integration
        NicVO nicVO = _nicDao.findById(profile.getId());
        if(nicVO != null){
            to.setUuid(nicVO.getUuid());
            //check whether the this nic has secondary ip addresses set
            //set nic secondary ip address in NicTO which are used for security group
            // configuration. Use full when vm stop/start
            List <String> secIps = null;
            if (nicVO.getSecondaryIp()) {
                secIps = _nicSecIpDao.getSecondaryIpAddressesForNic(nicVO.getId());
            }
            to.setNicSecIps(secIps);
        } else {
            //Workaround for dynamically created nics
            //FixMe: uuid and secondary IPs can be made part of nic profile
View Full Code Here

Examples of com.cloud.vm.NicVO

        VMInstanceVO vo = _vmDao.findById(vm.getId());
        if (vo.getLastHostId() == null) {
            Transaction txn = Transaction.currentTxn();
            txn.start();
            nic.setMacAddress(dest.getHost().getPrivateMacAddress());
            NicVO nicVo = _nicDao.findById(nic.getId());
            assert vo != null : "Where ths nic " + nic.getId() + " going???";
            nicVo.setMacAddress(nic.getMacAddress());
            _nicDao.update(nicVo.getId(), nicVo);
            txn.commit();
           
          /*This vm is just being created */
          if (!_pxeMgr.prepare(vm, nic, dest, context)) {
              throw new CloudRuntimeException("Cannot prepare pxe server");
View Full Code Here

Examples of com.cloud.vm.NicVO

        if (network.getBroadcastUri() == null) {
            s_logger.error("Nic has no broadcast Uri with the LSwitch Uuid");
            return false;
        }

        NicVO nicVO = _nicDao.findById(nic.getId());

        List<NiciraNvpDeviceVO> devices = _niciraNvpDao
                .listByPhysicalNetwork(network.getPhysicalNetworkId());
        if (devices.isEmpty()) {
            s_logger.error("No NiciraNvp Controller on physical network "
                    + network.getPhysicalNetworkId());
            return false;
        }
        NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
        HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());

        NiciraNvpNicMappingVO existingNicMap = _niciraNvpNicMappingDao
                .findByNicUuid(nicVO.getUuid());
        if (existingNicMap != null) {
            FindLogicalSwitchPortCommand findCmd = new FindLogicalSwitchPortCommand(
                    existingNicMap.getLogicalSwitchUuid(),
                    existingNicMap.getLogicalSwitchPortUuid());
            FindLogicalSwitchPortAnswer answer = (FindLogicalSwitchPortAnswer) _agentMgr
                    .easySend(niciraNvpHost.getId(), findCmd);

            if (answer.getResult()) {
                s_logger.warn("Existing Logical Switchport found for nic "
                        + nic.getName() + " with uuid "
                        + existingNicMap.getLogicalSwitchPortUuid());
                UpdateLogicalSwitchPortCommand cmd = new UpdateLogicalSwitchPortCommand(
                        existingNicMap.getLogicalSwitchPortUuid(), network
                        .getBroadcastUri().getSchemeSpecificPart(),
                        nicVO.getUuid(), context.getDomain().getName() + "-"
                                + context.getAccount().getAccountName(),
                                nic.getName());
                _agentMgr.easySend(niciraNvpHost.getId(), cmd);
                return true;
            } else {
                s_logger.error("Stale entry found for nic " + nic.getName()
                        + " with logical switchport uuid "
                        + existingNicMap.getLogicalSwitchPortUuid());
                _niciraNvpNicMappingDao.remove(existingNicMap.getId());
            }
        }

        CreateLogicalSwitchPortCommand cmd = new CreateLogicalSwitchPortCommand(
                network.getBroadcastUri().getSchemeSpecificPart(),
                nicVO.getUuid(), context.getDomain().getName() + "-"
                        + context.getAccount().getAccountName(), nic.getName());
        CreateLogicalSwitchPortAnswer answer = (CreateLogicalSwitchPortAnswer) _agentMgr
                .easySend(niciraNvpHost.getId(), cmd);

        if (answer == null || !answer.getResult()) {
            s_logger.error("CreateLogicalSwitchPortCommand failed");
            return false;
        }

        NiciraNvpNicMappingVO nicMap = new NiciraNvpNicMappingVO(network
                .getBroadcastUri().getSchemeSpecificPart(),
                answer.getLogicalSwitchPortUuid(), nicVO.getUuid());
        _niciraNvpNicMappingDao.persist(nicMap);

        return true;
    }
View Full Code Here

Examples of com.cloud.vm.NicVO

        if (network.getBroadcastUri() == null) {
            s_logger.error("Nic has no broadcast Uri with the LSwitch Uuid");
            return false;
        }

        NicVO nicVO = _nicDao.findById(nic.getId());

        List<NiciraNvpDeviceVO> devices = _niciraNvpDao
                .listByPhysicalNetwork(network.getPhysicalNetworkId());
        if (devices.isEmpty()) {
            s_logger.error("No NiciraNvp Controller on physical network "
                    + network.getPhysicalNetworkId());
            return false;
        }
        NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
        HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());

        NiciraNvpNicMappingVO nicMap = _niciraNvpNicMappingDao
                .findByNicUuid(nicVO.getUuid());
        if (nicMap == null) {
            s_logger.error("No mapping for nic " + nic.getName());
            return false;
        }
View Full Code Here

Examples of com.cloud.vm.NicVO

                s_logger.warn("Ssp api tenant port deletion failed "+nic.toString());
            }
            _sspUuidDao.removeUuid(tenantPortUuid);
        }
        if(remainingTarget != null){
            NicVO nicVo = _nicDao.findById(nic.getId());
            nicVo.setReservationId(remainingTarget.getReservationId());
            _nicDao.persist(nicVo); // persist the new reservationId
        }
        return true;
    }
View Full Code Here

Examples of com.cloud.vm.NicVO

       
        /* use last host id when VM stopped */
        Long hostId = (vm.getHostId() == null ? vm.getLastHostId() : vm.getHostId());
        HostVO host = _hostDao.findById(hostId);
        DataCenterVO dc = _dcDao.findById(host.getDataCenterId());
        NicVO nic = nics.get(0);
        String mask = nic.getNetmask();
        String mac = nic.getMacAddress();
        String ip = nic.getIp4Address();
        String gateway = nic.getGateway();
        String dns = dc.getDns1();
        if (dns == null) {
            dns = dc.getDns2();
        }
       
View Full Code Here

Examples of com.cloud.vm.NicVO

        UserVmVO vm = (UserVmVO) profile.getVirtualMachine();
        _vmDao.loadDetails(vm);
       
        String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getServiceOfferingId()).getDisplayText();
        String zoneName = _dcDao.findById(vm.getDataCenterId()).getName();
        NicVO nvo = _nicDao.findById(nic.getId());
        VmDataCommand cmd = new VmDataCommand(nvo.getIp4Address(), vm.getInstanceName(), _ntwkModel.getExecuteInSeqNtwkElmtCmd());
        cmd.addVmData("userdata", "user-data", vm.getUserData());
        cmd.addVmData("metadata", "service-offering", StringUtils.unicodeEscape(serviceOffering));
        cmd.addVmData("metadata", "availability-zone", StringUtils.unicodeEscape(zoneName));
        cmd.addVmData("metadata", "local-ipv4", nic.getIp4Address());
        cmd.addVmData("metadata", "local-hostname", StringUtils.unicodeEscape(vm.getInstanceName()));
View Full Code Here

Examples of com.cloud.vm.NicVO

        return null;
    }

    private UUID getNicUUID(NicProfile nic){
        NicVO nicvo = _nicDao.findById(nic.getId());
        return UUID.fromString(nicvo.getUuid());
    }
View Full Code Here

Examples of com.cloud.vm.NicVO

                false, 0,false,null,false,false,
                VirtualMachine.Type.InternalLoadBalancerVm, null);
        vm.setRole(Role.INTERNAL_LB_VM);
        vm = setId(vm, 1);
        vm.setPrivateIpAddress("10.2.2.2");
        NicVO nic = new NicVO("somereserver", 1L, 1L, VirtualMachine.Type.InternalLoadBalancerVm);
        nic.setIp4Address(requestedIp);
       
        List<DomainRouterVO> emptyList = new ArrayList<DomainRouterVO>();
        List<DomainRouterVO> nonEmptyList = new ArrayList<DomainRouterVO>();
        nonEmptyList.add(vm);
       
View Full Code Here

Examples of com.cloud.vm.NicVO

    };

    private MappingNic getLoadBalancingIpNic(DataCenterVO zone, Network network, long sourceIpId, boolean revoked, String existedGuestIp) throws ResourceUnavailableException {
        String srcIp = _networkModel.getIp(sourceIpId).getAddress().addr();
        InlineLoadBalancerNicMapVO mapping = _inlineLoadBalancerNicMapDao.findByPublicIpAddress(srcIp);
        NicVO loadBalancingIpNic = null;
        MappingNic nic = new MappingNic();
        nic.setState(MappingState.Unchanged);
        if (!revoked) {
            if (mapping == null) {
                // Acquire a new guest IP address and save it as the load balancing IP address
                String loadBalancingIpAddress = existedGuestIp;
               
                if (loadBalancingIpAddress == null) {
                    loadBalancingIpAddress = _networkMgr.acquireGuestIpAddress(network, null);
                }

                if (loadBalancingIpAddress == null) {
                    String msg = "Ran out of guest IP addresses.";
                s_logger.error(msg);
                    throw new ResourceUnavailableException(msg, DataCenter.class, network.getDataCenterId());
                }

                // If a NIC doesn't exist for the load balancing IP address, create one
                loadBalancingIpNic = _nicDao.findByIp4AddressAndNetworkId(loadBalancingIpAddress, network.getId());
                if (loadBalancingIpNic == null) {
                    loadBalancingIpNic = _networkMgr.savePlaceholderNic(network, loadBalancingIpAddress, null, null);
                }

                // Save a mapping between the source IP address and the load balancing IP address NIC
                mapping = new InlineLoadBalancerNicMapVO(srcIp, loadBalancingIpNic.getId());
                _inlineLoadBalancerNicMapDao.persist(mapping);

                // On the firewall provider for the network, create a static NAT rule between the source IP
                // address and the load balancing IP address
                try {
                    applyStaticNatRuleForInlineLBRule(zone, network, revoked, srcIp, loadBalancingIpNic.getIp4Address());
                } catch (ResourceUnavailableException ex) {
                    // Rollback db operation
                    _inlineLoadBalancerNicMapDao.expunge(mapping.getId());
                    _nicDao.expunge(loadBalancingIpNic.getId());
                    throw ex;
                }

                s_logger.debug("Created static nat rule for inline load balancer");
                nic.setState(MappingState.Create);
            } else {
                loadBalancingIpNic = _nicDao.findById(mapping.getNicId());
            }
        } else {
            if (mapping != null) {
                // Find the NIC that the mapping refers to
                loadBalancingIpNic = _nicDao.findById(mapping.getNicId());

                int count = _networkMgr.getRuleCountForIp(sourceIpId, Purpose.LoadBalancing, FirewallRule.State.Active);
                if (count == 0) {
                    // On the firewall provider for the network, delete the static NAT rule between the source IP
                    // address and the load balancing IP address
                    applyStaticNatRuleForInlineLBRule(zone, network, revoked, srcIp, loadBalancingIpNic.getIp4Address());

                    // Delete the mapping between the source IP address and the load balancing IP address
                    _inlineLoadBalancerNicMapDao.expunge(mapping.getId());

                    // Delete the NIC
                    _nicDao.expunge(loadBalancingIpNic.getId());

                    s_logger.debug("Revoked static nat rule for inline load balancer");
                    nic.setState(MappingState.Remove);
                }
            } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.