Package com.cloud.host

Examples of com.cloud.host.HostVO


              throw new GreTunnelException("Unable to retrieve the source " +
                             "endpoint for the GRE tunnel." +
                             "Failure is on host:" + dest.getHost().getId());
            boolean noHost = true;
      for (Long i : toHostIds) {
        HostVO rHost = _hostDao.findById(i);
        String otherIp = getGreEndpointIP(rHost, nw);
              if (otherIp == null)
                throw new GreTunnelException("Unable to retrieve the remote " +
                               "endpoint for the GRE tunnel." +
                               "Failure is on host:" + rHost.getId());
        Commands cmds = new Commands(
            new OvsCreateTunnelCommand(otherIp, key,
                Long.valueOf(hostId), i, nw.getId(), myIp));
        s_logger.debug("Ask host " + hostId +
            " to create gre tunnel to " + i);
        Answer[] answers = _agentMgr.send(hostId, cmds);
        handleCreateTunnelAnswer(answers);
        noHost = false;
      }
     
      for (Long i : fromHostIds) {
          HostVO rHost = _hostDao.findById(i);
          String otherIp = getGreEndpointIP(rHost, nw);
        Commands cmds = new Commands(
                new OvsCreateTunnelCommand(myIp, key, i,
                               Long.valueOf(hostId),
                                       nw.getId(), otherIp));
View Full Code Here


        }

        try {
            List<HostVO> eHosts = _resourceMgr.listAllHostsInCluster(clusterId);
            if( eHosts.size() > 0 ) {
              HostVO eHost = eHosts.get(0);
              _hostDao.loadDetails(eHost);
            }
            String hostname = url.getHost();
            InetAddress ia = InetAddress.getByName(hostname);
            String hostIp = ia.getHostAddress();
View Full Code Here

        if (startup.getHypervisorType() != HypervisorType.XenServer) {
            s_logger.debug("Not XenServer so moving on.");
            return;
        }

        HostVO host = _hostDao.findById(agentId);

        ClusterVO cluster = _clusterDao.findById(host.getClusterId());
        if ( cluster.getGuid() == null) {
            cluster.setGuid(startup.getPool());
            _clusterDao.update(cluster.getId(), cluster);
        } else if (! cluster.getGuid().equals(startup.getPool()) ) {
            String msg = "pool uuid for cluster " + cluster.getId() + " changed from " + cluster.getGuid() + " to " + startup.getPool();
            s_logger.warn(msg);
            throw new CloudRuntimeException(msg);
        }
        String resource = null;
        Map<String, String> details = startup.getHostDetails();
        String prodBrand = details.get("product_brand").trim();
        String prodVersion = details.get("product_version").trim();

        if (prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4"))) {
            resource = XcpServerResource.class.getName();
        } else if (prodBrand.equals("XCP") && prodVersion.startsWith("1.6")) {
            resource = XcpServer16Resource.class.getName();
        } else if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.0")) {
            resource = XenServer56Resource.class.getName();
        } else if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.0")) {
            resource = XenServer600Resource.class.getName();
        } else if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.2")) {
            resource = XenServer602Resource.class.getName();
        } else if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0")) {
            resource = XenServer610Resource.class.getName();
        } else if (prodBrand.equals("XenServer") && prodVersion.equals("6.2.0")) {
            resource = XenServer620Resource.class.getName();
        } else if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.100")) {
            String prodVersionTextShort = details.get("product_version_text_short").trim();
            if ("5.6 SP2".equals(prodVersionTextShort)) {
                resource = XenServer56SP2Resource.class.getName();
            } else if ("5.6 FP1".equals(prodVersionTextShort)) {
                resource = XenServer56FP1Resource.class.getName();
            }
        } else if (prodBrand.equals("XCP_Kronos")) {
          resource = XcpOssResource.class.getName();
        }

        if( resource == null ){
            String msg = "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6, 5.6 FP1, 5.6 SP2 and Xenserver 6.0 , 6.0.2, 6.1.0, 6.2.0 but this one is " + prodBrand + " " + prodVersion;
            s_logger.debug(msg);
            throw new RuntimeException(msg);
        }
        if (! resource.equals(host.getResource()) ) {
            String msg = "host " + host.getPrivateIpAddress() + " changed from " + host.getResource() + " to " + resource;
            s_logger.debug(msg);
            host.setResource(resource);
            host.setSetup(false);
            _hostDao.update(agentId, host);
            throw new HypervisorVersionChangedException(msg);
        }


        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Setting up host " + agentId);
        }
        HostEnvironment env = new HostEnvironment();

        SetupCommand setup = new SetupCommand(env);
        if (_setupMultipath) {
            setup.setMultipathOn();
        }
        if (!host.isSetup()) {
            setup.setNeedSetup(true);
        }

        try {
            SetupAnswer answer = (SetupAnswer)_agentMgr.send(agentId, setup);
            if (answer != null && answer.getResult()) {
                host.setSetup(true);
                host.setLastPinged((System.currentTimeMillis()>>10) - 5 * 60 );
                _hostDao.update(host.getId(), host);
                if ( answer.needReconnect() ) {
                    throw new ConnectionException(false, "Reinitialize agent after setup.");
                }
                return;
            } else {
View Full Code Here

    @Override
    public BaremetalPxeResponse getApiResponse(BaremetalPxeVO vo) {
        BaremetalPxeResponse response = new BaremetalPxeResponse();
        response.setId(vo.getUuid());
        HostVO host = _hostDao.findById(vo.getHostId());
        response.setUrl(host.getPrivateIpAddress());
        PhysicalNetworkServiceProviderVO providerVO = _physicalNetworkServiceProviderDao.findById(vo.getNetworkServiceProviderId());
        response.setPhysicalNetworkId(providerVO.getUuid());
        PhysicalNetworkVO nwVO = _physicalNetworkDao.findById(vo.getPhysicalNetworkId());
        response.setPhysicalNetworkId(nwVO.getUuid());
        response.setObjectName("baremetalpxeserver");
View Full Code Here

    private long clusterId;
    private long hostId;

    @Test(priority = -1)
    public void setUp() {
        HostVO host = hostDao.findByGuid(getHostGuid());
        if (host != null) {
            hostId = host.getId();
            dcId = host.getDataCenterId();
            clusterId = host.getClusterId();
            return;
        }
        // create data center
        DataCenterVO dc = new DataCenterVO(UUID.randomUUID().toString(), "test", "8.8.8.8", null, "10.0.0.1", null,
                "10.0.0.1/24", null, null, NetworkType.Basic, null, null, true, true, null, null);
        dc = dcDao.persist(dc);
        dcId = dc.getId();
        // create pod

        HostPodVO pod = new HostPodVO(UUID.randomUUID().toString(), dc.getId(), getHostGateway(), getHostCidr(), 8,
                "test");
        pod = podDao.persist(pod);
        // create xen cluster
        ClusterVO cluster = new ClusterVO(dc.getId(), pod.getId(), "devcloud cluster");
        cluster.setHypervisorType(HypervisorType.XenServer.toString());
        cluster.setClusterType(ClusterType.CloudManaged);
        cluster.setManagedState(ManagedState.Managed);
        cluster = clusterDao.persist(cluster);
        clusterId = cluster.getId();
        // create xen host

        host = new HostVO(getHostGuid());
        host.setName("devcloud xen host");
        host.setType(Host.Type.Routing);
        host.setHypervisorType(HypervisorType.XenServer);
        host.setPrivateIpAddress(getHostIp());
        host.setDataCenterId(dc.getId());
        host.setVersion("6.0.1");
        host.setAvailable(true);
        host.setSetup(true);
        host.setLastPinged(0);
        host.setResourceState(ResourceState.Enabled);
        host.setClusterId(cluster.getId());

        host = hostDao.persist(host);
        hostId = host.getId();
    }
View Full Code Here

    String hostTag = null;

        String haVmTag = (String)vmProfile.getParameter(VirtualMachineProfile.Param.HaTag);
       
    if (vm.getLastHostId() != null && haVmTag == null) {
      HostVO h = _hostDao.findById(vm.getLastHostId());
      DataCenter dc = _dcDao.findById(h.getDataCenterId());
      Pod pod = _podDao.findById(h.getPodId());
      Cluster c =  _clusterDao.findById(h.getClusterId());
      s_logger.debug("Start baremetal vm " + vm.getId() + " on last stayed host " + h.getId());
      return new DeployDestination(dc, pod, c, h);
    }
   
    if (haVmTag != null) {
        hostTag = haVmTag;
    } else if (offering.getHostTag() != null) {
      String[] tags = offering.getHostTag().split(",");
      if (tags.length > 0) {
        hostTag = tags[0];
      }
    }
   
    List<ClusterVO> clusters = _clusterDao.listByDcHyType(vm.getDataCenterId(), HypervisorType.BareMetal.toString());
    int cpu_requested;
    long ram_requested;
    HostVO target = null;
    List<HostVO> hosts;
    for (ClusterVO cluster : clusters) {
      hosts = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
      if (hostTag != null) {
        for (HostVO h : hosts) {
          _hostDao.loadDetails(h);
          if (h.getDetail("hostTag") != null && h.getDetail("hostTag").equalsIgnoreCase(hostTag)) {
            target = h;
            break;
          }
        }
      }
    }

    if (target == null) {
      s_logger.warn("Cannot find host with tag " + hostTag + " use capacity from service offering");
      cpu_requested = offering.getCpu() * offering.getSpeed();
      ram_requested = offering.getRamSize() * 1024L * 1024L;
    } else {
      cpu_requested = target.getCpus() * target.getSpeed().intValue();
      ram_requested = target.getTotalMemory();
    }
   
    for (ClusterVO cluster : clusters) {
        if (haVmTag == null) {
            hosts = _resourceMgr.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, cluster.getId(), cluster.getPodId(), cluster.getDataCenterId());
View Full Code Here

        // TODO: order by rand() is slow if there are lot of hosts
        sbuilder.append(" ORDER by rand() limit 1");
        String sql = sbuilder.toString();
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        HostVO host = null;
        Transaction txn = Transaction.currentTxn();

        try {
            pstmt = txn.prepareStatement(sql);
            pstmt.setLong(1, poolId);
            rs = pstmt.executeQuery();
            while (rs.next()) {
                long id = rs.getLong(1);
                host = hostDao.findById(id);
            }
        } catch (SQLException e) {
            s_logger.warn("can't find endpoint", e);
        } finally {
            try {
                if (rs != null) {
                    rs.close();
                }
                if (pstmt != null) {
                    pstmt.close();
                }
            } catch (SQLException e) {
            }
        }

        if (host == null) {
            return null;
        }

        return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(),
                host.getPublicIpAddress());
    }
View Full Code Here

            s_logger.info("No running ssvm is found, so command will be sent to LocalHostEndPoint");
            return LocalHostEndpoint.getEndpoint(); // use local host as endpoint in
            // case of no ssvm existing
        }
        Collections.shuffle(ssAHosts);
        HostVO host = ssAHosts.get(0);
        return RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(),
                host.getPublicIpAddress());
    }
View Full Code Here

    @Override
    public List<EndPoint> selectAll(DataStore store) {
        List<EndPoint> endPoints = new ArrayList<EndPoint>();
        if (store.getScope().getScopeType() == ScopeType.HOST) {
            HostVO host = hostDao.findById(store.getScope().getScopeId());
            endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(),
                    host.getPublicIpAddress()));
        } else if (store.getScope().getScopeType() == ScopeType.CLUSTER) {
            SearchCriteriaService<HostVO, HostVO> sc = SearchCriteria2.create(HostVO.class);
            sc.addAnd(sc.getEntity().getClusterId(), Op.EQ, store.getScope().getScopeId());
            sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
            List<HostVO> hosts = sc.find();
            for (HostVO host : hosts) {
                endPoints.add(RemoteHostEndPoint.getHypervisorHostEndPoint(host.getId(), host.getPrivateIpAddress(),
                        host.getPublicIpAddress()));
            }

        } else {
            throw new CloudRuntimeException("shouldn't use it for other scope");
        }
View Full Code Here

            this.clusterDetailsDao.persist(clusterDetailVO);
            clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "password", null);
            this.clusterDetailsDao.persist(clusterDetailVO);
            // create xen host

            host = new HostVO(this.getHostGuid());
            host.setName("devcloud vmware host");
            host.setType(Host.Type.Routing);
            host.setPrivateIpAddress(this.getHostIp());
            host.setDataCenterId(dc.getId());
            host.setVersion("6.0.1");
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.