Examples of HostPodVO


Examples of com.cloud.dc.HostPodVO

          if(currentCountOfHosts >= maxHosts){
            throw new AgentAuthnException("Number of running Routing hosts in the Zone:"+ zone.getName() +" is already at the max limit:"+maxHosts+", cannot start one more host");
          }
        }
       
        HostPodVO pod = null;
       
      if(startup.getPrivateIpAddress() == null){
           s_logger.warn("No private IP address passed in for the agent, cannot not find pod for agent");
        throw new AgentAuthnException("No private IP address passed in for the agent, cannot not find pod for agent");
      }
     
      if(startup.getPrivateNetmask() == null){
           s_logger.warn("No netmask passed in for the agent, cannot not find pod for agent");
        throw new AgentAuthnException("No netmask passed in for the agent, cannot not find pod for agent");
      }
             
        if(host.getPodId() != null){
          if(s_logger.isDebugEnabled()){
            s_logger.debug("Pod is already created for this agent, looks like agent is reconnecting...");
          }
          pod = _podDao.findById(host.getPodId());
          if(!checkCIDR(type, pod, startup.getPrivateIpAddress(),
          startup.getPrivateNetmask())){
            pod = null;
              if(s_logger.isDebugEnabled()){
                s_logger.debug("Subnet of Pod does not match the subnet of the agent, not using this Pod: "+host.getPodId());
              }           
          }else{
            updatePodNetmaskIfNeeded(pod, startup.getPrivateNetmask());
          }
        }
       
        if(pod == null){
        if(s_logger.isDebugEnabled()){
          s_logger.debug("Trying to detect the Pod to use from the agent's ip address and netmask passed in ");
        }
       
          //deduce pod
        boolean podFound = false;
          List<HostPodVO> podsInZone = _podDao.listByDataCenterId(zoneId);
      for (HostPodVO hostPod : podsInZone) {
        if (checkCIDR(type, hostPod, startup.getPrivateIpAddress(),
            startup.getPrivateNetmask())) {
          pod = hostPod;
         
          //found the default POD having the same subnet.
          updatePodNetmaskIfNeeded(pod, startup.getPrivateNetmask());
          podFound = true;
          break;
        }
      }

       
          if (!podFound) {
            if(s_logger.isDebugEnabled()){
              s_logger.debug("Creating a new Pod since no default Pod found that matches the agent's ip address and netmask passed in ");
            }
           
            if(startup.getGatewayIpAddress() == null){
                 s_logger.warn("No Gateway IP address passed in for the agent, cannot create a new pod for the agent");
              throw new AgentAuthnException("No Gateway IP address passed in for the agent, cannot create a new pod for the agent");
            }
            //auto-create a new pod, since pod matching the agent's ip is not found
            String podName = "POD-"+ (podsInZone.size()+1);
            try{
              String gateway = startup.getGatewayIpAddress();
              String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, startup.getPrivateNetmask());
                String[] cidrPair = cidr.split("\\/");
                String cidrAddress = cidrPair[0];
                long cidrSize = Long.parseLong(cidrPair[1]);
              String startIp = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize);
              String endIp = NetUtils.getIpRangeEndIpFromCidr(cidrAddress, cidrSize);
              pod = _configurationManager.createPod(-1, podName, zoneId, gateway, cidr, startIp, endIp, null, true);
            }catch (Exception e) {
          // no longer tolerate exception during the cluster creation phase
          throw new CloudRuntimeException("Unable to create new Pod "
              + podName + " in Zone: "
              + zoneId, e);
        }
           
          }
        }
        final StartupRoutingCommand scc = (StartupRoutingCommand) startup;

        ClusterVO cluster = null;
        if(host.getClusterId() != null){
          if(s_logger.isDebugEnabled()){
            s_logger.debug("Cluster is already created for this agent, looks like agent is reconnecting...");
          }         
          cluster = _clusterDao.findById(host.getClusterId());
        }
        if(cluster == null){
            //auto-create cluster - assume one host per cluster
            String clusterName = "Cluster-" + startup.getPrivateIpAddress();
            ClusterVO existingCluster = _clusterDao.findBy(clusterName, pod.getId());
            if (existingCluster != null) {
                cluster = existingCluster;
            } else {
                if(s_logger.isDebugEnabled()){
                    s_logger.debug("Creating a new Cluster for this agent with name: "+clusterName + " in Pod: " +pod.getId() +", in Zone:"+zoneId);
                }

                cluster = new ClusterVO(zoneId, pod.getId(), clusterName);
                cluster.setHypervisorType(scc.getHypervisorType().toString());
                try {
                    cluster = _clusterDao.persist(cluster);
                } catch (Exception e) {
                    // no longer tolerate exception during the cluster creation phase
                    throw new CloudRuntimeException("Unable to create cluster "
                            + clusterName + " in pod " + pod.getId() + " and data center "
                            + zoneId, e);
                }
            }
        }

      if(s_logger.isDebugEnabled()){
        s_logger.debug("Detected Zone: "+zoneId+", Pod: " +pod.getId() +", Cluster:" +cluster.getId());
      }       
    host.setDataCenterId(zone.getId());
        host.setPodId(pod.getId());
        host.setClusterId(cluster.getId());
        host.setPrivateIpAddress(startup.getPrivateIpAddress());
        host.setPrivateNetmask(startup.getPrivateNetmask());
        host.setPrivateMacAddress(startup.getPrivateMacAddress());
        host.setPublicIpAddress(startup.getPublicIpAddress());
View Full Code Here

Examples of com.cloud.dc.HostPodVO

        }
        if(s_logger.isDebugEnabled()){
            s_logger.debug("Successfully loaded the DataCenter from the zone token passed in ");
        }
       
        HostPodVO pod = findPod(startup, zone.getId(), Host.Type.Routing); //yes, routing
        Long podId = null;
        if (pod != null) {
            s_logger.debug("Found pod " + pod.getName() + " for the secondary storage host " + startup.getName());
            podId = pod.getId();
        }
        host.setDataCenterId(zone.getId());
        host.setPodId(podId);
        host.setClusterId(null);
        host.setPrivateIpAddress(startup.getPrivateIpAddress());
View Full Code Here

Examples of com.cloud.dc.HostPodVO

        }

    }
 
  private HostPodVO findPod(StartupCommand startup, long zoneId, Host.Type type) {
      HostPodVO pod = null;
      List<HostPodVO> podsInZone = _podDao.listByDataCenterId(zoneId);
        for (HostPodVO hostPod : podsInZone) {
            if (checkCIDR(type, hostPod, startup.getPrivateIpAddress(),
                    startup.getPrivateNetmask())) {
                pod = hostPod;
View Full Code Here

Examples of com.cloud.dc.HostPodVO

    StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
    if (ssCmd.getHypervisorType() != HypervisorType.XenServer) {
      return null;
    }

    HostPodVO pod = _podDao.findById(host.getPodId());
    DataCenterVO dc = _dcDao.findById(host.getDataCenterId());
    s_logger.info("Host: " + host.getName() + " connected with hypervisor type: " + HypervisorType.XenServer + ". Checking CIDR...");
    _resourceMgr.checkCIDR(pod, dc, ssCmd.getPrivateIpAddress(), ssCmd.getPrivateNetmask());
    return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.XenServer, details, hostTags);
    }
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                "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();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                "10.0.0.1/24", null, null, DataCenter.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(), "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();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                    "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(), 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();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

        } else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown) {
            throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName() +
                    " is in shutdown state in the physical network: " + cmd.getPhysicalNetworkId() + "to add this device");
        }
       
        HostPodVO pod = _podDao.findById(cmd.getPodId());
        if (pod == null) {
            throw new IllegalArgumentException("Could not find pod with ID: " + cmd.getPodId());
        }
       
        List<HostVO> pxes = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.BaremetalPxe, null, cmd.getPodId(), zoneId);
        if (pxes.size() != 0) {
            throw new IllegalArgumentException("Already had a PXE server in Pod: " + cmd.getPodId() + " zone: " + zoneId);
        }
       
        String storageServerIp = pcmd.getPingStorageServerIp();
        if (storageServerIp == null) {
            throw new IllegalArgumentException("No IP for storage server specified");
        }
        String pingDir = pcmd.getPingDir();
        if (pingDir == null) {
            throw new IllegalArgumentException("No direcotry for storage server specified");
        }
        String tftpDir = pcmd.getTftpDir();
        if (tftpDir == null) {
            throw new IllegalArgumentException("No TFTP directory specified");
        }
       
        String cifsUsername = pcmd.getPingStorageServerUserName();
        if (cifsUsername == null || cifsUsername.equalsIgnoreCase("")) {
            cifsUsername = "xxx";
        }
        String cifsPassword = pcmd.getPingStorageServerPassword();
        if (cifsPassword == null || cifsPassword.equalsIgnoreCase("")) {
            cifsPassword = "xxx";
        }
       
       
        URI uri;
        try {
            uri = new URI(cmd.getUrl());
        } catch (Exception e) {
            s_logger.debug(e);
            throw new IllegalArgumentException(e.getMessage());
        }
        String ipAddress = uri.getHost();
       
        String guid = getPxeServerGuid(Long.toString(zoneId+ "-" + pod.getId(), BaremetalPxeType.PING.toString(), ipAddress);
       
        ServerResource resource = null;
        Map params = new HashMap<String, String>();
        params.put(BaremetalPxeService.PXE_PARAM_ZONE, Long.toString(zoneId));
        params.put(BaremetalPxeService.PXE_PARAM_POD, String.valueOf(pod.getId()));
        params.put(BaremetalPxeService.PXE_PARAM_IP, ipAddress);
        params.put(BaremetalPxeService.PXE_PARAM_USERNAME, cmd.getUsername());
        params.put(BaremetalPxeService.PXE_PARAM_PASSWORD, cmd.getPassword());
        params.put(BaremetalPxeService.PXE_PARAM_PING_STORAGE_SERVER_IP, storageServerIp);
        params.put(BaremetalPxeService.PXE_PARAM_PING_ROOT_DIR, pingDir);
        params.put(BaremetalPxeService.PXE_PARAM_TFTP_DIR, tftpDir);
        params.put(BaremetalPxeService.PXE_PARAM_PING_STORAGE_SERVER_USERNAME, cifsUsername);
        params.put(BaremetalPxeService.PXE_PARAM_PING_STORAGE_SERVER_PASSWORD, cifsPassword);
        params.put(BaremetalPxeService.PXE_PARAM_GUID, guid);
       
        resource = new BaremetalPingPxeResource();
        try {
            resource.configure("PING PXE resource", params);
        } catch (Exception e) {
            s_logger.debug(e);
            throw new CloudRuntimeException(e.getMessage());
        }
       
        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.setPodId(pod.getId());
        vo.setPhysicalNetworkId(pcmd.getPhysicalNetworkId());
        vo.setDeviceType(BaremetalPxeType.PING.toString());
        txn.start();
        _pxeDao.persist(vo);
        txn.commit();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                    "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(), 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();
View Full Code Here

Examples of com.cloud.dc.HostPodVO

                "10.0.0.1/24", null, null, DataCenter.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(), "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();
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.