コード例 #1
0
  @Override
  public List<DomainRouterVO> startRouters(
      final RouterDeploymentDefinition routerDeploymentDefinition)
      throws StorageUnavailableException, InsufficientCapacityException,
          ConcurrentOperationException, ResourceUnavailableException {

    final List<DomainRouterVO> runningRouters = new ArrayList<DomainRouterVO>();

    for (DomainRouterVO router : routerDeploymentDefinition.getRouters()) {
      boolean skip = false;
      final State state = router.getState();
      if (router.getHostId() != null && state != State.Running) {
        final HostVO host = _hostDao.findById(router.getHostId());
        if (host == null || host.getState() != Status.Up) {
          skip = true;
        }
      }
      if (!skip) {
        if (state != State.Running) {
          router =
              startVirtualRouter(
                  router,
                  _accountMgr.getSystemUser(),
                  _accountMgr.getSystemAccount(),
                  routerDeploymentDefinition.getParams());
        }
        if (router != null) {
          runningRouters.add(router);
        }
      }
    }
    return runningRouters;
  }
コード例 #2
0
  /*
   * Ovm won't support any system. So we have to choose a partner cluster in
   * the same pod to start domain router for us
   */
  protected HypervisorType getClusterToStartDomainRouterForOvm(final long podId) {
    final List<ClusterVO> clusters = _clusterDao.listByPodId(podId);
    for (final ClusterVO cv : clusters) {
      if (cv.getHypervisorType() == HypervisorType.Ovm
          || cv.getHypervisorType() == HypervisorType.BareMetal) {
        continue;
      }

      final List<HostVO> hosts = _resourceMgr.listAllHostsInCluster(cv.getId());
      if (hosts == null || hosts.isEmpty()) {
        continue;
      }

      for (final HostVO h : hosts) {
        if (h.getState() == Status.Up) {
          s_logger.debug(
              "Pick up host that has hypervisor type "
                  + h.getHypervisorType()
                  + " in cluster "
                  + cv.getId()
                  + " to start domain router for OVM");
          return h.getHypervisorType();
        }
      }
    }

    final String errMsg =
        new StringBuilder("Cannot find an available cluster in Pod ")
            .append(podId)
            .append(
                " to start domain router for Ovm. \n Ovm won't support any system vm including domain router, ")
            .append(
                "please make sure you have a cluster with hypervisor type of any of xenserver/KVM/Vmware in the same pod")
            .append(
                " with Ovm cluster. And there is at least one host in UP status in that cluster.")
            .toString();
    throw new CloudRuntimeException(errMsg);
  }