コード例 #1
0
 protected void buildVmNetworkCluster() {
   // set Display network
   List<NetworkCluster> all =
       DbFacade.getInstance().getNetworkClusterDao().getAllForCluster(vm.getVdsGroupId());
   NetworkCluster networkCluster = null;
   for (NetworkCluster tempNetworkCluster : all) {
     if (tempNetworkCluster.isDisplay()) {
       networkCluster = tempNetworkCluster;
       break;
     }
   }
   if (networkCluster != null) {
     Network net = null;
     List<Network> allNetworks = DbFacade.getInstance().getNetworkDao().getAll();
     for (Network tempNetwork : allNetworks) {
       if (tempNetwork.getId().equals(networkCluster.getNetworkId())) {
         net = tempNetwork;
         break;
       }
     }
     if (net != null) {
       createInfo.put(VdsProperties.DISPLAY_NETWORK, net.getName());
     }
   }
 }
 public ValidationResult clusterNetworkNotUsedByBricks() {
   return networkNotUsed(
       getGlusterBrickDao()
           .getAllByClusterAndNetworkId(networkCluster.getClusterId(), network.getId()),
       EngineMessage.VAR__ENTITIES__GLUSTER_BRICKS,
       EngineMessage.VAR__ENTITIES__GLUSTER_BRICK);
 }
 public ValidationResult clusterNetworkNotUsedByVms() {
   return networkNotUsed(
       getVmStaticDao()
           .getAllByGroupAndNetworkName(networkCluster.getClusterId(), network.getName()),
       EngineMessage.VAR__ENTITIES__VMS,
       EngineMessage.VAR__ENTITIES__VM);
 }
コード例 #4
0
  private void attachNetworkToClusters(Guid networkGuid) {
    final Guid networkId = getNetwork().getId() == null ? networkGuid : getNetwork().getId();
    final List<NetworkCluster> networkAttachments = new ArrayList<>();

    for (NetworkClusterModel networkClusterModel : getClustersToAttach()) {
      // Init default NetworkCluster values (required, display, status)
      NetworkCluster networkCluster = new NetworkCluster();
      networkCluster.setNetworkId(networkId);
      networkCluster.setClusterId(networkClusterModel.getEntity().getId());
      networkCluster.setRequired(networkClusterModel.isRequired());
      networkAttachments.add(networkCluster);
    }

    if (!networkAttachments.isEmpty()) {
      Frontend.getInstance()
          .runAction(
              VdcActionType.ManageNetworkClusters,
              new ManageNetworkClustersParameters(networkAttachments));
    }
  }
コード例 #5
0
  private void attachNetworkToClusters(
      final Network network, Collection<VDSGroup> clusters, final boolean publicUse) {
    NetworkCluster networkCluster = new NetworkCluster();
    networkCluster.setRequired(false);
    network.setCluster(networkCluster);
    List<VdcActionParametersBase> parameters = new LinkedList<VdcActionParametersBase>();
    for (VDSGroup cluster : clusters) {
      parameters.add(new AttachNetworkToVdsGroupParameter(cluster, network));
    }

    Frontend.getInstance()
        .runMultipleActions(
            VdcActionType.AttachNetworkToVdsGroup,
            parameters,
            new IFrontendActionAsyncCallback() {

              @Override
              public void executed(FrontendActionAsyncResult result) {
                addVnicProfile(network, publicUse);
              }
            });
  }
 public ValidationResult clusterNetworkNotUsedByTemplates() {
   List<VmTemplate> templatesUsingNetwork = new ArrayList<>();
   for (VmTemplate template :
       getVmTemplateDao().getAllForVdsGroup(networkCluster.getClusterId())) {
     for (VmNetworkInterface nic :
         getVmNetworkInterfaceDao().getAllForTemplate(template.getId())) {
       if (network.getName().equals(nic.getNetworkName())) {
         templatesUsingNetwork.add(template);
       }
     }
   }
   return networkNotUsed(
       templatesUsingNetwork,
       EngineMessage.VAR__ENTITIES__VM_TEMPLATES,
       EngineMessage.VAR__ENTITIES__VM_TEMPLATE);
 }
コード例 #7
0
  @Override
  protected void executeCommand() {
    updateVdsData();
    if (NeedToUpdateVdsBroker()) {
      initializeVds();
    }

    if (getParameters().isInstallHost()) {
      InstallVdsParameters tempVar =
          new InstallVdsParameters(getVdsId(), getParameters().getPassword());
      tempVar.setIsReinstallOrUpgrade(getParameters().isReinstallOrUpgrade());
      tempVar.setoVirtIsoFile(getParameters().getoVirtIsoFile());
      if (getVdsDao().get(getVdsId()).getStatus() == VDSStatus.InstallingOS) {
        // TODO: remove hack when reinstall api will provider override-firewall parameter.
        // https://bugzilla.redhat.com/show_bug.cgi?id=1177126 - for now we override firewall
        // configurations on each deploy for provisioned host to avoid wrong deployment.
        tempVar.setOverrideFirewall(true);
      } else {
        tempVar.setOverrideFirewall(getParameters().getOverrideFirewall());
      }
      tempVar.setOverrideFirewall(getParameters().getOverrideFirewall());
      tempVar.setActivateHost(getParameters().getActivateHost());
      tempVar.setNetworkProviderId(getParameters().getNetworkProviderId());
      tempVar.setNetworkMappings(getParameters().getNetworkMappings());
      tempVar.setAuthMethod(getParameters().getAuthMethod());
      ArrayList<VdcReturnValueBase> resultList =
          runInternalMultipleActions(
              actionType, new ArrayList<VdcActionParametersBase>(Arrays.asList(tempVar)));

      // Since Host status is set to "Installing", failure of InstallVdsCommand will hang the Host
      // to in that
      // status, therefore needed to fail the command to revert the status.
      if (!resultList.isEmpty()) {
        VdcReturnValueBase vdcReturnValueBase = resultList.get(0);
        if (vdcReturnValueBase != null && !vdcReturnValueBase.getCanDoAction()) {
          ArrayList<String> canDoActionMessages = vdcReturnValueBase.getCanDoActionMessages();
          if (!canDoActionMessages.isEmpty()) {
            // add can do action messages to return value so error messages
            // are returned back to the client
            getReturnValue().getCanDoActionMessages().addAll(canDoActionMessages);
            log.error(
                "Installation/upgrade of Host '{}', '{}' failed: {}",
                getVdsId(),
                getVdsName(),
                StringUtils.join(
                    Backend.getInstance()
                        .getErrorsTranslator()
                        .TranslateErrorText(canDoActionMessages),
                    ","));
          }
          // set can do action to false so can do action messages are
          // returned back to client
          getReturnValue().setCanDoAction(false);
          setSucceeded(false);
          // add old vds dynamic data to compensation context. This
          // way the status will revert back to what it was before
          // starting installation process
          getCompensationContext().snapshotEntityStatus(oldHost.getDynamicData());
          getCompensationContext().stateChanged();
          return;
        }
      }
    }

    if (oldHost.getProtocol() != getParameters().getVdsStaticData().getProtocol()) {
      ResourceManager.getInstance().reestablishConnection(oldHost.getId());
    }

    // set clusters network to be operational (if needed)
    if (oldHost.getStatus() == VDSStatus.Up) {
      List<NetworkCluster> networkClusters =
          DbFacade.getInstance().getNetworkClusterDao().getAllForCluster(oldHost.getVdsGroupId());
      List<Network> networks =
          DbFacade.getInstance().getNetworkDao().getAllForCluster(oldHost.getVdsGroupId());
      for (NetworkCluster item : networkClusters) {
        for (Network net : networks) {
          if (net.getId().equals(item.getNetworkId())) {
            NetworkClusterHelper.setStatus(oldHost.getVdsGroupId(), net);
          }
        }
      }
    }
    alertIfPowerManagementNotConfigured(getParameters().getVdsStaticData());
    testVdsPowerManagementStatus(getParameters().getVdsStaticData());
    checkKdumpIntegrationStatus();
    setSucceeded(true);
  }
コード例 #8
0
ファイル: NetworkUtils.java プロジェクト: nirs/ovirt-engine
 /**
  * returns whether the network has a role in the cluster
  *
  * @param networkCluster
  * @return whether the network has a role (display, migration or gluster) in the cluster
  */
 public static boolean isRoleNetwork(NetworkCluster networkCluster) {
   return networkCluster.isDisplay() || networkCluster.isMigration() || networkCluster.isGluster();
 }