Package com.cloud.host

Examples of com.cloud.host.Host


    @Override
    public List<Host> allocateTo(VirtualMachineProfile<? extends VirtualMachine> vmProfile, DeploymentPlan plan, Type type,
            ExcludeList avoid, int returnUpTo, boolean considerReservedCapacity) {
        List<Host> availableHosts = new ArrayList<Host>();
        Host host = null;     
        if (type == Host.Type.Routing && _routingHost != null) {
            host = _hostDao.findById(_routingHost);
        } else if (type == Host.Type.Storage && _storageHost != null) {
            host = _hostDao.findById(_storageHost);
        }
View Full Code Here


        if (!add) {
          // "delete" would remove all the rules(if using ovs) related to this vm
          op = "delete";
        }
        Network network = _networkDao.findById(nic.getNetworkId());
        Host host = _hostDao.findById(hostId);
        String networkTag = _networkModel.getNetworkTag(host.getHypervisorType(), network);
      PvlanSetupCommand cmd = PvlanSetupCommand.createVmSetup(op, nic.getBroadCastUri(), networkTag, nic.getMacAddress());
        Answer answer = null;
        try {
            answer = _agentMgr.send(hostId, cmd);
        } catch (OperationTimedoutException e) {
View Full Code Here

        if (owner.getState() == Account.State.disabled) {
            throw new PermissionDeniedException("The owner of " + vm
                    + " is disabled: " + vm.getAccountId());
        }

        Host destinationHost = null;
        if (hostId != null) {
            Account account = UserContext.current().getCaller();
            if (!_accountService.isRootAdmin(account.getType())) {
                throw new PermissionDeniedException(
                        "Parameter hostid can only be specified by a Root Admin, permission denied");
            }
            destinationHost = _hostDao.findById(hostId);
            if (destinationHost == null) {
                throw new InvalidParameterValueException(
                        "Unable to find the host to deploy the VM, host id="
                                + hostId);
            }
        }

        // check if vm is security group enabled
        if (_securityGroupMgr.isVmSecurityGroupEnabled(vmId) && _securityGroupMgr.getSecurityGroupsForVm(vmId).isEmpty() && !_securityGroupMgr.isVmMappedToDefaultSecurityGroup(vmId) && _networkModel.canAddDefaultSecurityGroup()) {
            // if vm is not mapped to security group, create a mapping
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Vm "
                        + vm
                        + " is security group enabled, but not mapped to default security group; creating the mapping automatically");
            }

            SecurityGroup defaultSecurityGroup = _securityGroupMgr
                    .getDefaultSecurityGroup(vm.getAccountId());
            if (defaultSecurityGroup != null) {
                List<Long> groupList = new ArrayList<Long>();
                groupList.add(defaultSecurityGroup.getId());
                _securityGroupMgr.addInstanceToGroups(vmId, groupList);
            }
        }

        DataCenterDeployment plan = null;
        if (destinationHost != null) {
            s_logger.debug("Destination Host to deploy the VM is specified, specifying a deployment plan to deploy the VM");
            plan = new DataCenterDeployment(vm.getDataCenterId(),
                    destinationHost.getPodId(), destinationHost.getClusterId(),
                    destinationHost.getId(), null, null);
        }

        // Set parameters
        Map<VirtualMachineProfile.Param, Object> params = null;
        VMTemplateVO template = null;
View Full Code Here

        }
        Set<Pair<Long, Long>> avoidPcs = new HashSet<Pair<Long, Long>>();
        Set<Long> hostIdsToAvoid = avoid.getHostsToAvoid();
        if(hostIdsToAvoid != null){
          for (Long hostId : hostIdsToAvoid) {
            Host h = _hostDao.findById(hostId);
            if(h != null){
              avoidPcs.add(new Pair<Long, Long>(h.getPodId(), h.getClusterId()));
            }
          }
        }
       
        for (Pair<Long, Long> pcId : avoidPcs) {
View Full Code Here

        if(cmd.getExclZones() != null){
          hostDetails.put("exclZones", cmd.getExclZones());
        }
       

        Host trafficMonitor = _resourceMgr.addHost(zoneId, resource, Host.Type.TrafficMonitor, hostDetails);
        return trafficMonitor;
    }
View Full Code Here

    }

    @Override
    public F5LoadBalancerResponse createF5LoadBalancerResponse(ExternalLoadBalancerDeviceVO lbDeviceVO) {
        F5LoadBalancerResponse response = new F5LoadBalancerResponse();
        Host lbHost = _hostDao.findById(lbDeviceVO.getHostId());
        Map<String, String> lbDetails = _detailsDao.findDetails(lbDeviceVO.getHostId());

        response.setId(lbDeviceVO.getUuid());
        response.setIpAddress(lbHost.getPrivateIpAddress());
        PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(lbDeviceVO.getPhysicalNetworkId());
        if (pnw != null) {
            response.setPhysicalNetworkId(pnw.getUuid());
        }
        response.setPublicInterface(lbDetails.get("publicInterface"));
View Full Code Here

    @Test
    public void testExecuteForResult() throws Exception {

        addHostCmd._resourceService = resourceService;
        addHostCmd._responseGenerator = responseGenerator;
        Host host = Mockito.mock(Host.class);
        Host[] mockArray = new Host[] { host };

        HostResponse responseHost = new HostResponse();
        responseHost.setName("Test");
        Mockito.when(resourceService.discoverHosts(addHostCmd)).thenReturn(
View Full Code Here

    @Override
    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
    ResourceAllocationException {
        try {
            Host device = nwDeviceMgr.addNetworkDevice(this);
            NetworkDeviceResponse response = nwDeviceMgr.getApiResponse(device);
            response.setObjectName("networkdevice");
            response.setResponseName(getCommandName());
            this.setResponseObject(response);
        } catch (InvalidParameterValueException ipve) {
View Full Code Here

            resource.configure("KickStart PXE resource", params);
        } catch (Exception e) {
            throw new CloudRuntimeException(e.getMessage(), e);
        }

        Host pxeServer = _resourceMgr.addHost(zoneId, resource, Host.Type.BaremetalPxe, params);
        if (pxeServer == null) {
            throw new CloudRuntimeException("Cannot add PXE server as a host");
        }

        BaremetalPxeVO vo = new BaremetalPxeVO();
        Transaction txn = Transaction.currentTxn();
        vo.setHostId(pxeServer.getId());
        vo.setNetworkServiceProviderId(ntwkSvcProvider.getId());
        vo.setPhysicalNetworkId(kcmd.getPhysicalNetworkId());
        vo.setDeviceType(BaremetalPxeType.KICK_START.toString());
        txn.start();
        _pxeDao.persist(vo);
View Full Code Here

        Transaction txn = Transaction.currentTxn();
        try {
            resource.configure(cmd.getHost(), hostdetails);

            Host host = _resourceMgr.addHost(zoneId, resource,
                    Host.Type.L2Networking, params);
            if (host != null) {
                txn.start();

                niciraNvpDevice = new NiciraNvpDeviceVO(host.getId(),
                        physicalNetworkId, ntwkSvcProvider.getProviderName(),
                        deviceName);
                _niciraNvpDao.persist(niciraNvpDevice);

                DetailVO detail = new DetailVO(host.getId(),
                        "niciranvpdeviceid", String.valueOf(niciraNvpDevice
                                .getId()));
                _hostDetailsDao.persist(detail);

                txn.commit();
View Full Code Here

TOP

Related Classes of com.cloud.host.Host

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.