Package com.cloud.dc

Examples of com.cloud.dc.ClusterVO


        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


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

        imageStore = new ImageStoreVO();
        imageStore.setName(UUID.randomUUID().toString());
        imageStore.setDataCenterId(dcId);
        imageStore.setProviderName(DataStoreProvider.NFS_IMAGE);
View Full Code Here

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

            // setup vcenter
            ClusterDetailsVO clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "url", null);
            this.clusterDetailsDao.persist(clusterDetailVO);
            clusterDetailVO = new ClusterDetailsVO(cluster.getId(), "username", null);
            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");
            host.setAvailable(true);
            host.setSetup(true);
            host.setPodId(podId);
            host.setLastPinged(0);
            host.setResourceState(ResourceState.Enabled);
            host.setHypervisorType(HypervisorType.VMware);
            host.setClusterId(cluster.getId());

            host = hostDao.persist(host);

            imageStore = new ImageStoreVO();
            imageStore.setName(imageStoreName);
View Full Code Here

            _clusterDao.update(cluster.getId(), cluster);
        } catch (EntityExistsException e) {
            SearchCriteriaService<ClusterVO, ClusterVO> sc = SearchCriteria2.create(ClusterVO.class);
            sc.addAnd(sc.getEntity().getGuid(), Op.EQ, guid);
            List<ClusterVO> clusters = sc.list();
            ClusterVO clu = clusters.get(0);
            List<HostVO> clusterHosts = _resourceMgr.listAllHostsInCluster(clu.getId());
            if (clusterHosts == null || clusterHosts.size() == 0) {
                clu.setGuid(null);
                _clusterDao.update(clu.getId(), clu);
                _clusterDao.update(cluster.getId(), cluster);
                return;
            }
            throw e;
        }
View Full Code Here

      String msg = "must specify pod Id when add host";
      s_logger.debug(msg);
      throw new RuntimeException(msg);
    }

        ClusterVO cluster = _clusterDao.findById(clusterId);
        if(cluster == null || cluster.getHypervisorType() != HypervisorType.XenServer) {
          if(s_logger.isInfoEnabled())
                s_logger.info("invalid cluster id or cluster is not for XenServer hypervisors");
        return null;
        }

        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();
            Queue<String> pass=new LinkedList<String>();
            pass.add(password);
            String masterIp = _connPool.getMasterIp(hostIp, username, pass);
            conn = _connPool.masterConnect(masterIp, username, pass);
            if (conn == null) {
                String msg = "Unable to get a connection to " + url;
                s_logger.debug(msg);
                throw new DiscoveryException(msg);
            }

            Set<Pool> pools = Pool.getAll(conn);
            Pool pool = pools.iterator().next();
            Pool.Record pr = pool.getRecord(conn);
            String poolUuid = pr.uuid;
            Map<Host, Host.Record> hosts = Host.getAllRecords(conn);

            /*set cluster hypervisor type to xenserver*/
            ClusterVO clu = _clusterDao.findById(clusterId);
            if ( clu.getGuid()== null ) {
                setClusterGuid(clu, poolUuid);
            } else {
                List<HostVO> clusterHosts = _resourceMgr.listAllHostsInCluster(clusterId);
                if( clusterHosts != null && clusterHosts.size() > 0) {
                    if (!clu.getGuid().equals(poolUuid)) {
                        if (hosts.size() == 1) {
                            if (!addHostsToPool(conn, hostIp, clusterId)) {
                                String msg = "Unable to add host(" + hostIp + ") to cluster " + clusterId;
                                s_logger.warn(msg);
                                throw new DiscoveryException(msg);
                            }
                        } else {
                            String msg = "Host (" + hostIp + ") is already in pool(" + poolUuid + "), can to join pool(" + clu.getGuid() + ")";
                            s_logger.warn(msg);
                            throw new DiscoveryException(msg);
                        }
                    }
                } else {
                    setClusterGuid(clu, poolUuid);
                }
            }
            // can not use this conn after this point, because this host may join a pool, this conn is retired
            if (conn != null) {
                try{
                    Session.logout(conn);
                } catch (Exception e ) {
                }
                conn.dispose();
                conn = null;
            }

            poolUuid = clu.getGuid();
            _clusterDao.update(clusterId, clu);


            if (_checkHvm) {
                for (Map.Entry<Host, Host.Record> entry : hosts.entrySet()) {
View Full Code Here

            } catch (ConfigurationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } else if (host.getHypervisorType() == HypervisorType.VMware) {
            ClusterVO cluster = clusterDao.findById(host.getClusterId());
            String url = clusterDetailsDao.findDetail(cluster.getId(), "url").getValue();
            URI uri;
            try {
                uri = new URI(url);
                String userName = clusterDetailsDao.findDetail(cluster.getId(), "username").getValue();
                String password = clusterDetailsDao.findDetail(cluster.getId(), "password").getValue();
                VmwareServerDiscoverer discover = new VmwareServerDiscoverer();

                Map<? extends ServerResource, Map<String, String>> resources = discover.find(host.getDataCenterId(),
                        host.getPodId(), host.getClusterId(), uri, userName, password, null);
                for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) {
View Full Code Here

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

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

            host = hostDao.persist(host);

            imageStore = new ImageStoreVO();
            imageStore.setName(imageStoreName);
View Full Code Here

      String msg = "must specify pod Id when add host";
      s_logger.debug(msg);
      throw new CloudRuntimeException(msg);
    }

    ClusterVO cluster = _clusterDao.findById(clusterId);
    if (cluster == null
        || (cluster.getHypervisorType() != HypervisorType.Ovm)) {
      if (s_logger.isInfoEnabled())
        s_logger.info("invalid cluster id or cluster is not for Ovm hypervisors");
      return null;
    }

    String agentUsername = _params.get("agentusername");
    if (agentUsername == null) {
      throw new CloudRuntimeException("Agent user name must be specified");
    }

    String agentPassword = _params.get("agentpassword");
    if (agentPassword == null) {
      throw new CloudRuntimeException("Agent password must be specified");
    }

    try {
      String hostname = url.getHost();
      InetAddress ia = InetAddress.getByName(hostname);
      String hostIp = ia.getHostAddress();
      String guid = UUID.nameUUIDFromBytes(hostIp.getBytes()).toString();

      if (checkIfExisted(guid)) {
        throw new CloudRuntimeException("The host " + hostIp
            + " has been added before");
      }

      s_logger.debug("Ovm discover is going to disover host having guid "
          + guid);

      ClusterVO clu = _clusterDao.findById(clusterId);
      if (clu.getGuid() == null) {
        clu.setGuid(UUID.randomUUID().toString());
        _clusterDao.update(clusterId, clu);
      }

      com.trilead.ssh2.Connection sshConnection = new com.trilead.ssh2.Connection(
          hostIp, 22);
View Full Code Here

                if(s_logger.isDebugEnabled()) {
                    s_logger.debug(msg);
                }
                throw new RuntimeException(msg);
            } else {
                ClusterVO clu = _clusterDao.findById(clusterId);
                if (clu == null
                        || (clu.getHypervisorType() != HypervisorType.Simulator)) {
                    if (s_logger.isInfoEnabled())
                        s_logger.info("invalid cluster id or cluster is not for Simulator hypervisors");
                    return null;
                }
                cluster = Long.toString(clusterId);
                if(clu.getGuid() == null) {
                    clu.setGuid(UUID.randomUUID().toString());
                }
                _clusterDao.update(clusterId, clu);
            }

            String pod;
View Full Code Here

      // in the clusterId specified.

      // First check if the cluster is of type vmware. If not,
      // throw an exception. VSMs are tightly integrated with vmware clusters.

      ClusterVO cluster = _clusterDao.findById(clusterId);
      if (cluster == null) {
        throw new InvalidParameterValueException("Cluster with specified ID not found!");
      }
      if (cluster.getHypervisorType() != HypervisorType.VMware) {
        InvalidParameterValueException ex = new InvalidParameterValueException("Cluster with specified id is not a VMWare hypervisor cluster");
        throw ex;
      }

      // Next, check if the cluster already has a VSM associated with it.
View Full Code Here

TOP

Related Classes of com.cloud.dc.ClusterVO

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.