Package com.cloud.host

Examples of com.cloud.host.HostVO


    private String hostIdToUuid(Long hostId) {
        if (hostId == null) {
            return null;
        }
        HostVO vo = hostDao.findById(hostId);
        return vo.getUuid();
    }
View Full Code Here


            s_logger.error("No NiciraNvp Controller on physical network "
                    + network.getPhysicalNetworkId());
            return false;
        }
        NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
        HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
        _hostDao.loadDetails(niciraNvpHost);

        Account owner = context.getAccount();

        /**
         * Lock the network as we might need to do multiple operations that
         * should be done only once.
         */
//    Network lock = _networkDao.acquireInLockTable(network.getId(),
//        _networkModel.getNetworkLockTimeout());
//    if (lock == null) {
//      throw new ConcurrentOperationException("Unable to lock network "
//          + network.getId());
//    }

        // Implement SourceNat immediately as we have al the info already
        if (_networkModel.isProviderSupportServiceInNetwork(
                network.getId(), Service.SourceNat, Provider.NiciraNvp)) {
            s_logger.debug("Apparently we are supposed to provide SourceNat on this network");

            PublicIp sourceNatIp = _networkManager
                    .assignSourceNatIpAddressToGuestNetwork(owner, network);
            String publicCidr = sourceNatIp.getAddress().addr() + "/"
                    + NetUtils.getCidrSize(sourceNatIp.getVlanNetmask());
            String internalCidr = network.getGateway() + "/"
                    + network.getCidr().split("/")[1];
            long vlanid = (Vlan.UNTAGGED.equals(sourceNatIp.getVlanTag())) ? 0
                    : Long.parseLong(sourceNatIp.getVlanTag());

            CreateLogicalRouterCommand cmd = new CreateLogicalRouterCommand(
                    niciraNvpHost.getDetail("l3gatewayserviceuuid"), vlanid,
                    network.getBroadcastUri().getSchemeSpecificPart(),
                    "router-" + network.getDisplayText(), publicCidr,
                    sourceNatIp.getGateway(), internalCidr, context
                    .getDomain().getName()
                    + "-"
                    + context.getAccount().getAccountName());
            CreateLogicalRouterAnswer answer = (CreateLogicalRouterAnswer) _agentMgr
                    .easySend(niciraNvpHost.getId(), cmd);
            if (answer.getResult() == false) {
                s_logger.error("Failed to create Logical Router for network "
                        + network.getDisplayText());
                return false;
            }
View Full Code Here

            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;
        }
View Full Code Here

            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;
        }

        DeleteLogicalSwitchPortCommand cmd = new DeleteLogicalSwitchPortCommand(
                nicMap.getLogicalSwitchUuid(),
                nicMap.getLogicalSwitchPortUuid());
        DeleteLogicalSwitchPortAnswer answer = (DeleteLogicalSwitchPortAnswer) _agentMgr
                .easySend(niciraNvpHost.getId(), cmd);

        if (answer == null || !answer.getResult()) {
            s_logger.error("DeleteLogicalSwitchPortCommand failed");
            return false;
        }
View Full Code Here

            s_logger.error("No NiciraNvp Controller on physical network "
                    + network.getPhysicalNetworkId());
            return false;
        }
        NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
        HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());

        if (_networkModel.isProviderSupportServiceInNetwork(network.getId(),
                Service.SourceNat, Provider.NiciraNvp)) {
            s_logger.debug("Apparently we were providing SourceNat on this network");

            // Deleting the LogicalRouter will also take care of all provisioned
            // nat rules.
            NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
                    .findByNetworkId(network.getId());
            if (routermapping == null) {
                s_logger.warn("No logical router uuid found for network "
                        + network.getDisplayText());
                // This might be cause by a failed deployment, so don't make shutdown fail as well.
                return true;
            }

            DeleteLogicalRouterCommand cmd = new DeleteLogicalRouterCommand(routermapping.getLogicalRouterUuid());
            DeleteLogicalRouterAnswer answer =
                    (DeleteLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
            if (answer.getResult() == false) {
                s_logger.error("Failed to delete LogicalRouter for network "
                        + network.getDisplayText());
                return false;
            }
View Full Code Here

    }

    @Override
    public NiciraNvpDeviceResponse createNiciraNvpDeviceResponse(
            NiciraNvpDeviceVO niciraNvpDeviceVO) {
        HostVO niciraNvpHost = _hostDao.findById(niciraNvpDeviceVO.getHostId());
        _hostDao.loadDetails(niciraNvpHost);

        NiciraNvpDeviceResponse response = new NiciraNvpDeviceResponse();
        response.setDeviceName(niciraNvpDeviceVO.getDeviceName());
        PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(niciraNvpDeviceVO.getPhysicalNetworkId());
        if (pnw != null) {
            response.setPhysicalNetworkId(pnw.getUuid());
        }
        response.setId(niciraNvpDeviceVO.getUuid());
        response.setProviderName(niciraNvpDeviceVO.getProviderName());
        response.setHostName(niciraNvpHost.getDetail("ip"));
        response.setTransportZoneUuid(niciraNvpHost.getDetail("transportzoneuuid"));
        response.setL3GatewayServiceUuid(niciraNvpHost.getDetail("l3gatewayserviceuuid"));
        response.setObjectName("niciranvpdevice");
        return response;
    }
View Full Code Here

        if(vm.getState() == State.Running)
            return vm.getHostId();
       
        // check if lastHostId is available
        if(vm.getLastHostId() != null){
           HostVO lastHost =  _hostDao.findById(vm.getLastHostId());
           if(lastHost.getStatus() == com.cloud.host.Status.Up && !lastHost.isInMaintenanceStates())
               return lastHost.getId();
        }
       
        List<VolumeVO> listVolumes = _volumeDao.findByInstance(vmId);
        if (listVolumes == null || listVolumes.size() == 0) {
            throw new InvalidParameterValueException("vmInstance has no volumes");
View Full Code Here

                    }
                }
            }
        }

        HostVO niciraHost = _hostDao.findById(niciraNvpDevice.getHostId());
        Long hostId = niciraHost.getId();

        niciraHost.setResourceState(ResourceState.Maintenance);
        _hostDao.update(hostId, niciraHost);
        _resourceMgr.deleteHost(hostId, false, false);

        _niciraNvpDao.remove(niciraDeviceId);
        return true;
View Full Code Here

                s_logger.error("No NiciraNvp Controller on physical network "
                        + network.getPhysicalNetworkId());
                return false;
            }
            NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
            HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());
            _hostDao.loadDetails(niciraNvpHost);

            NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
                    .findByNetworkId(network.getId());
            if (routermapping == null) {
                s_logger.error("No logical router uuid found for network "
                        + network.getDisplayText());
                return false;
            }

            List<String> cidrs = new ArrayList<String>();
            for (PublicIpAddress ip : ipAddress) {
                if (ip.getState() == IpAddress.State.Releasing) {
                    // If we are releasing we don't need to push this ip to
                    // the Logical Router
                    continue;
                }
                cidrs.add(ip.getAddress().addr() + "/" + NetUtils.getCidrSize(ip.getNetmask()));
            }
            ConfigurePublicIpsOnLogicalRouterCommand cmd = new ConfigurePublicIpsOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(),
                    niciraNvpHost.getDetail("l3gatewayserviceuuid"), cidrs);
            ConfigurePublicIpsOnLogicalRouterAnswer answer = (ConfigurePublicIpsOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);
            //FIXME answer can be null if the host is down
            return answer.getResult();
        }
        else {
            s_logger.debug("No need to provision ip addresses as we are not providing L3 services.");
View Full Code Here

            s_logger.error("No NiciraNvp Controller on physical network "
                    + network.getPhysicalNetworkId());
            return false;
        }
        NiciraNvpDeviceVO niciraNvpDevice = devices.get(0);
        HostVO niciraNvpHost = _hostDao.findById(niciraNvpDevice.getHostId());

        NiciraNvpRouterMappingVO routermapping = _niciraNvpRouterMappingDao
                .findByNetworkId(network.getId());
        if (routermapping == null) {
            s_logger.error("No logical router uuid found for network "
                    + network.getDisplayText());
            return false;
        }

        List<StaticNatRuleTO> staticNatRules = new ArrayList<StaticNatRuleTO>();
        for (StaticNat rule : rules) {
            IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
            // Force the nat rule into the StaticNatRuleTO, no use making a new TO object
            // we only need the source and destination ip. Unfortunately no mention if a rule
            // is new.
            StaticNatRuleTO ruleTO = new StaticNatRuleTO(1,
                    sourceIp.getAddress().addr(), 0, 65535,
                    rule.getDestIpAddress(), 0, 65535,
                    "any", rule.isForRevoke(), false);
            staticNatRules.add(ruleTO);
        }

        ConfigureStaticNatRulesOnLogicalRouterCommand cmd =
                new ConfigureStaticNatRulesOnLogicalRouterCommand(routermapping.getLogicalRouterUuid(), staticNatRules);
        ConfigureStaticNatRulesOnLogicalRouterAnswer answer = (ConfigureStaticNatRulesOnLogicalRouterAnswer) _agentMgr.easySend(niciraNvpHost.getId(), cmd);

        return answer.getResult();
    }
View Full Code Here

TOP

Related Classes of com.cloud.host.HostVO

Copyright © 2018 www.massapicom. 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.