コード例 #1
0
  private void logChangedDisplayNetwork(
      VDS host,
      Collection<Network> engineHostNetworks,
      Collection<VdsNetworkInterface> engineInterfaces) {

    if (isVmRunningOnHost(host.getId())) {
      final Network engineDisplayNetwork =
          findDisplayNetwork(host.getVdsGroupId(), engineHostNetworks);

      if (engineDisplayNetwork == null) {
        return;
      }

      final IsNetworkOnInterfacePredicate isNetworkOnInterfacePredicate =
          new IsNetworkOnInterfacePredicate(engineDisplayNetwork.getName());
      final VdsNetworkInterface vdsmDisplayInterface =
          LinqUtils.firstOrNull(host.getInterfaces(), isNetworkOnInterfacePredicate);
      final VdsNetworkInterface engineDisplayInterface =
          LinqUtils.firstOrNull(engineInterfaces, isNetworkOnInterfacePredicate);
      final DisplayInterfaceEqualityPredicate displayIneterfaceEqualityPredicate =
          new DisplayInterfaceEqualityPredicate(engineDisplayInterface);
      if (vdsmDisplayInterface == null // the display interface is't on host anymore
          || !displayIneterfaceEqualityPredicate.eval(vdsmDisplayInterface)) {
        final AuditLogableBase loggable = new AuditLogableBase(host.getId());
        auditLogDirector.log(loggable, AuditLogType.NETWORK_UPDATE_DISPLAY_FOR_HOST_WITH_ACTIVE_VM);
      }
    }
  }
コード例 #2
0
 private void updateModel() {
   if (currentSelectedHost != null) {
     errataCountModel.setGuid(currentSelectedHost.getId());
     errataCountModel.setEntity(currentSelectedHost);
     errataCountModel.runQuery(currentSelectedHost.getId());
   }
 }
コード例 #3
0
  public static void ProcessStorageOnVdsInactive(VDS vds) {

    // Clear the problematic timers since the VDS is in maintenance so it doesn't make sense to
    // check it
    // anymore.
    IrsBrokerCommand.clearVdsFromCache(
        vds.getstorage_pool_id(), vds.getvds_id(), vds.getvds_name());

    if (!vds.getstorage_pool_id().equals(Guid.Empty)
        && StoragePoolStatus.Uninitialized
            != DbFacade.getInstance().getStoragePoolDAO().get(vds.getstorage_pool_id()).getstatus()
        && Backend.getInstance()
            .getResourceManager()
            .RunVdsCommand(
                VDSCommandType.DisconnectStoragePool,
                new DisconnectStoragePoolVDSCommandParameters(
                    vds.getvds_id(), vds.getstorage_pool_id(), vds.getvds_spm_id()))
            .getSucceeded()) {
      StoragePoolParametersBase tempVar = new StoragePoolParametersBase(vds.getstorage_pool_id());
      tempVar.setVdsId(vds.getvds_id());
      tempVar.setTransactionScopeOption(TransactionScopeOption.RequiresNew);
      Backend.getInstance()
          .runInternalAction(VdcActionType.DisconnectHostFromStoragePoolServers, tempVar);
    }
  }
コード例 #4
0
 private void mockHostSupportsSriov(boolean support) {
   final VDS host = new VDS();
   final Version version = Version.v3_6;
   host.setVdsGroupCompatibilityVersion(version);
   mockConfigRule.mockConfigValue(ConfigValues.NetworkSriovSupported, version, support);
   when(vdsDao.get(HOST_ID)).thenReturn(host);
 }
コード例 #5
0
 private List<VDS> mockVdsInDb(VDSStatus status) {
   List<VDS> vdsList = new ArrayList<>();
   VDS vds = new VDS();
   vds.setStatus(status);
   vdsList.add(vds);
   return vdsList;
 }
コード例 #6
0
  private NonOperationalReason enforceNetworkCompliance(
      VDS host, boolean skipManagementNetwork, List<Network> clusterNetworks) {
    if (host.getStatus() != VDSStatus.Maintenance) {
      if (skipManagementNetwork) {
        skipManagementNetworkCheck(host.getInterfaces(), clusterNetworks, host.getVdsGroupId());
      }

      Map<String, String> customLogValues;

      // here we check if the host networks match it's cluster networks
      String networks = getMissingOperationalClusterNetworks(host, clusterNetworks);
      if (networks.length() > 0) {
        customLogValues = new HashMap<>();
        customLogValues.put("Networks", networks);

        setNonOperational(host, NonOperationalReason.NETWORK_UNREACHABLE, customLogValues);
        return NonOperationalReason.NETWORK_UNREACHABLE;
      }

      // Check that VM networks are implemented above a bridge.
      networks = getVmNetworksImplementedAsBridgeless(host, clusterNetworks);
      if (networks.length() > 0) {
        customLogValues = new HashMap<>();
        customLogValues.put("Networks", networks);

        setNonOperational(host, NonOperationalReason.VM_NETWORK_IS_BRIDGELESS, customLogValues);
        return NonOperationalReason.VM_NETWORK_IS_BRIDGELESS;
      }
    }

    return NonOperationalReason.NONE;
  }
コード例 #7
0
 private VDS mockVds() {
   Guid vdsId = Guid.newGuid();
   VDS vds = new VDS();
   vds.setId(vdsId);
   when(vdsDao.get(vdsId)).thenReturn(vds);
   return vds;
 }
コード例 #8
0
 protected VDS getEntity(int index) {
   VDS vds = setUpEntityExpectations(control.createMock(VDS.class), index);
   VdsStatic vdsStatic = control.createMock(VdsStatic.class);
   expect(vdsStatic.getId()).andReturn(GUIDS[2]).anyTimes();
   expect(vds.getStaticData()).andReturn(vdsStatic).anyTimes();
   return vds;
 }
コード例 #9
0
 private void vdsExist() {
   VDS vds = new VDS();
   vds.setStatus(VDSStatus.Up);
   List<VDS> vdsList = new ArrayList<>();
   vdsList.add(vds);
   when(vdsDao.getAllForCluster(any(Guid.class))).thenReturn(vdsList);
 }
コード例 #10
0
ファイル: StorageModel.java プロジェクト: nirs/ovirt-engine
  private void host_SelectedItemChanged() {
    VDS host = getHost().getSelectedItem();
    if (getCurrentStorageItem() != null) {
      // When changing host clear items for san storage model.
      if (getCurrentStorageItem() instanceof SanStorageModelBase) {
        SanStorageModelBase sanStorageModel = (SanStorageModelBase) getCurrentStorageItem();
        if (getStorage() == null) {
          sanStorageModel.setItems(null);
        }
      }

      if (host != null) {
        getCurrentStorageItem().getUpdateCommand().execute();

        String prefix = host.isOvirtNode() ? localFSPath : ""; // $NON-NLS-1$
        if (!StringHelper.isNullOrEmpty(prefix)) {
          for (Object item : getStorageModels()) {
            if (item instanceof LocalStorageModel) {
              LocalStorageModel model = (LocalStorageModel) item;
              model.getPath().setEntity(prefix);
              model.getPath().setIsChangeable(false);
            }
          }
        }
      }
    }
  }
コード例 #11
0
 /** Mock VDS */
 protected void mockVds() {
   VDS vds = new VDS();
   vds.setVdsGroupCompatibilityVersion(new Version("3.1"));
   command.setVdsId(Guid.Empty);
   doReturn(vdsDao).when(command).getVdsDao();
   when(vdsDao.get(Guid.Empty)).thenReturn(vds);
 }
コード例 #12
0
  public boolean CanMaintananceVds(Guid vdsId, java.util.ArrayList<String> reasons) {
    boolean returnValue = true;
    // VDS vds = ResourceManager.Instance.getVds(vdsId);
    VDS vds = DbFacade.getInstance().getVdsDAO().get(vdsId);
    // we can get here when vds status was set already to Maintenance
    if ((vds.getstatus() != VDSStatus.Maintenance)
        && (vds.getstatus() != VDSStatus.NonResponsive)
        && (vds.getstatus() != VDSStatus.Up)
        && (vds.getstatus() != VDSStatus.Error)
        && (vds.getstatus() != VDSStatus.PreparingForMaintenance)
        && (vds.getstatus() != VDSStatus.Down)) {
      returnValue = false;
      reasons.add(VdcBllMessages.VDS_CANNOT_MAINTENANCE_VDS_IS_NOT_OPERATIONAL.toString());
    }

    orderListOfRunningVmsOnVds(vdsId);

    for (VM vm : vms) {
      if (vm.getMigrationSupport() != MigrationSupport.MIGRATABLE) {
        reasons.add(VdcBllMessages.VDS_CANNOT_MAINTENANCE_IT_INCLUDES_NON_MIGRATABLE_VM.toString());
        return false;
      }
    }

    return returnValue;
  }
コード例 #13
0
  protected boolean stopSpm() {
    boolean commandSucceeded = true;
    if (getStoragePool().getSpmVdsId() != null) {
      // if spm host id is different from selected host get the spm
      // in order to try and perform stop spm
      VDS spm;
      if (getStoragePool().getSpmVdsId().equals(getVds().getId())) {
        spm = getVds();
      } else {
        spm = vdsDao.get(getStoragePool().getSpmVdsId());
      }
      if (spm != null) {
        ResetIrsVDSCommandParameters tempVar2 =
            new ResetIrsVDSCommandParameters(getStoragePool().getId(), spm.getId());
        tempVar2.setIgnoreStopFailed(true);
        commandSucceeded = runVdsCommand(VDSCommandType.ResetIrs, tempVar2).getSucceeded();

        // if spm host is up switch to use it in the following logic
        if (spm.getStatus() == VDSStatus.Up) {
          setVdsId(spm.getId());
          setVds(spm);
        }
      }
    }
    return commandSucceeded;
  }
コード例 #14
0
  private GlusterVolumeEntity getNewVolume() {
    GlusterVolumeEntity volume = new GlusterVolumeEntity();
    volume.setName(NEW_VOL_NAME);
    volume.setClusterId(CLUSTER_ID);
    volume.setId(NEW_VOL_ID);
    volume.setVolumeType(GlusterVolumeType.DISTRIBUTE);
    volume.addTransportType(TransportType.TCP);
    volume.setReplicaCount(0);
    volume.setStripeCount(0);
    volume.setStatus(GlusterStatus.UP);
    volume.setOption("auth.allow", "*");
    volume.addAccessProtocol(AccessProtocol.GLUSTER);
    volume.addAccessProtocol(AccessProtocol.NFS);

    GlusterBrickEntity brick = new GlusterBrickEntity();
    brick.setVolumeId(NEW_VOL_ID);
    brick.setServerId(existingServer1.getId());
    brick.setServerName(existingServer1.getHostName());
    brick.setBrickDirectory("/export/testvol1");
    brick.setStatus(GlusterStatus.UP);
    brick.setBrickOrder(0);
    volume.addBrick(brick);

    return volume;
  }
コード例 #15
0
 private VDS createServer(Guid serverId, String hostname) {
   VDS vds = new VDS();
   vds.setId(serverId);
   vds.setHostName(hostname);
   vds.setStatus(VDSStatus.Up);
   return vds;
 }
コード例 #16
0
 private void clusterHasVds() {
   VDS vds = new VDS();
   vds.setStatus(VDSStatus.Up);
   vds.setSupportedClusterLevels(VERSION_1_1.toString());
   List<VDS> vdsList = new ArrayList<>();
   vdsList.add(vds);
   when(vdsDao.getAllForCluster(any(Guid.class))).thenReturn(vdsList);
 }
コード例 #17
0
 private void vdsExistWithHigherVersion() {
   VDS vds = new VDS();
   vds.setStatus(VDSStatus.Up);
   vds.setClusterCompatibilityVersion(VERSION_1_2);
   List<VDS> vdsList = new ArrayList<>();
   vdsList.add(vds);
   when(vdsDao.getAllForCluster(any(Guid.class))).thenReturn(vdsList);
 }
コード例 #18
0
 private VDS getVds(VDSStatus status) {
   VDS vds = new VDS();
   vds.setId(Guid.newGuid());
   vds.setVdsName("gfs1");
   vds.setClusterId(clusterId);
   vds.setStatus(status);
   return vds;
 }
 private VDS getVds(VDSStatus status) {
   VDS vds = new VDS();
   vds.setId(Guid.newGuid());
   vds.setVdsName("gfs1");
   vds.setVdsGroupId(CLUSTER_ID);
   vds.setStatus(status);
   return vds;
 }
コード例 #20
0
ファイル: Linq.java プロジェクト: derekhiggins/ovirt-engine
 public static ArrayList<VDS> FindAllVDSByPmEnabled(ArrayList<VDS> items) {
   ArrayList<VDS> ret = new ArrayList<VDS>();
   for (VDS i : items) {
     if (i.getpm_enabled()) {
       ret.add(i);
     }
   }
   return ret;
 }
コード例 #21
0
ファイル: StorageModel.java プロジェクト: nirs/ovirt-engine
  private VDS getSPM(Iterable<VDS> hosts) {
    for (VDS host : hosts) {
      if (host.getSpmStatus() == VdsSpmStatus.SPM) {
        return host;
      }
    }

    return null;
  }
コード例 #22
0
 private GlusterBrickEntity createBrick(Guid existingVolDistId, VDS server, String brickDir) {
   GlusterBrickEntity brick = new GlusterBrickEntity();
   brick.setVolumeId(existingVolDistId);
   brick.setServerId(server.getId());
   brick.setServerName(server.getHostName());
   brick.setBrickDirectory(brickDir);
   brick.setStatus(GlusterStatus.UP);
   return brick;
 }
コード例 #23
0
  @Before
  public void setupMocks() {
    when(dbFacade.getVdsDao()).thenReturn(vdsDao);

    when(vdsDao.get(eq(TARGET_HOST_ID))).thenReturn(targetHost);
    when(targetHost.getId()).thenReturn(TARGET_HOST_ID);

    when(vdsDao.get(eq(PROXY_HOST_ID))).thenReturn(proxyHost);
    when(proxyHost.getId()).thenReturn(PROXY_HOST_ID);
    when(proxyHost.getVdsGroupCompatibilityVersion()).thenReturn(Version.getLast());
  }
コード例 #24
0
ファイル: NetworkUtils.java プロジェクト: nirs/ovirt-engine
 /**
  * resolve the host ip address
  *
  * @param host the host which it's address is about to be resolved
  * @return if succeeded, string representing the host ip in IPv4 format, null otherwise
  */
 public static String getHostByIp(VDS host) {
   try {
     final InetAddress address = InetAddress.getByName(host.getHostName());
     return address.getHostAddress().trim();
   } catch (UnknownHostException ex) {
     final String msg = "Failed to resolve host ip by name '{}'";
     log.warn(msg, " Details: '{}' ", host.getHostName(), ex.getCause());
     log.debug(msg, host.getHostName(), ex);
     return null;
   }
 }
コード例 #25
0
ファイル: AddVdsCommand.java プロジェクト: oVirt/ovirt-engine
  @Override
  public Map<String, String> getJobMessageProperties() {
    if (jobProperties == null) {
      jobProperties = super.getJobMessageProperties();
      VDS vds = getParameters().getvds();

      String vdsName = (vds != null && vds.getName() != null) ? vds.getName() : "";
      jobProperties.put(VdcObjectType.VDS.name().toLowerCase(), vdsName);
    }
    return jobProperties;
  }
コード例 #26
0
 /**
  * The following method will clear a cache for problematic domains, which were reported by vds
  *
  * @param vds
  */
 private void clearDomainCache(final VDS vds) {
   eventQueue.submitEventSync(
       new Event(vds.getStoragePoolId(), null, vds.getId(), EventType.VDSCLEARCACHE, ""),
       new Callable<EventResult>() {
         @Override
         public EventResult call() {
           IrsBrokerCommand.clearVdsFromCache(vds.getStoragePoolId(), vds.getId(), vds.getName());
           return new EventResult(true, EventType.VDSCLEARCACHE);
         }
       });
 }
コード例 #27
0
ファイル: AddVdsCommand.java プロジェクト: oVirt/ovirt-engine
 private boolean clusterHasNonInitializingServers() {
   for (VDS vds : vdsDao.getAllForCluster(getClusterId())) {
     if (vds.getStatus() != VDSStatus.Installing
         && vds.getStatus() != VDSStatus.InstallingOS
         && vds.getStatus() != VDSStatus.PendingApproval
         && vds.getStatus() != VDSStatus.Initializing
         && vds.getStatus() != VDSStatus.InstallFailed) {
       return true;
     }
   }
   return false;
 }
コード例 #28
0
  @Override
  protected boolean validate() {
    if (!super.validate()
        || !checkStoragePool()
        || !checkStoragePoolStatusNotEqual(
            StoragePoolStatus.Up, EngineMessage.ERROR_CANNOT_REMOVE_ACTIVE_STORAGE_POOL)) {
      return false;
    }

    if (getStoragePool().getStatus() != StoragePoolStatus.Uninitialized
        && !getParameters().getForceDelete()
        && !initializeVds()) {
      return false;
    }

    final List<StorageDomain> poolDomains =
        getStorageDomainDao().getAllForStoragePool(getStoragePool().getId());
    final List<StorageDomain> activeOrLockedDomains = getActiveOrLockedDomainList(poolDomains);

    if (!activeOrLockedDomains.isEmpty()) {
      return failValidation(EngineMessage.ERROR_CANNOT_REMOVE_POOL_WITH_ACTIVE_DOMAINS);
    }
    if (!getParameters().getForceDelete()) {
      if (poolDomains.size() > 1) {
        return failValidation(
            EngineMessage.ERROR_CANNOT_REMOVE_STORAGE_POOL_WITH_NONMASTER_DOMAINS);
      }
      if (!poolDomains.isEmpty() && !canDetachStorageDomainWithVmsAndDisks(poolDomains.get(0))) {
        return false;
      }
    } else {
      List<VDS> poolHosts = getVdsDao().getAllForStoragePool(getParameters().getStoragePoolId());

      sharedLocks = new HashMap<>();
      for (VDS host : poolHosts) {
        sharedLocks.put(
            host.getId().toString(),
            LockMessagesMatchUtil.makeLockingPair(
                LockingGroup.VDS, EngineMessage.ACTION_TYPE_FAILED_OBJECT_LOCKED));
      }

      if (!poolHosts.isEmpty() && acquireLockInternal()) {
        for (VDS host : poolHosts) {
          if (host.getStatus() != VDSStatus.Maintenance) {
            return failValidation(
                EngineMessage.ERROR_CANNOT_FORCE_REMOVE_STORAGE_POOL_WITH_VDS_NOT_IN_MAINTENANCE);
          }
        }
      }
    }
    return true;
  }
コード例 #29
0
  @Override
  public NonOperationalReason persistAndEnforceNetworkCompliance(
      VDS host, boolean skipManagementNetwork, UserConfiguredNetworkData userConfiguredData) {

    List<VdsNetworkInterface> dbIfaces = interfaceDao.getAllInterfacesForVds(host.getId());
    List<Network> clusterNetworks = networkDao.getAllForCluster(host.getVdsGroupId());

    persistTopology(host, dbIfaces, clusterNetworks, userConfiguredData);
    NonOperationalReason nonOperationalReason =
        enforceNetworkCompliance(host, skipManagementNetwork, clusterNetworks);
    auditNetworkCompliance(host, dbIfaces, clusterNetworks);
    return nonOperationalReason;
  }
コード例 #30
0
  public void OnSelectHost() {
    MoveHost model = (MoveHost) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (!model.Validate()) {
      return;
    }

    model.setSelectedHosts(new java.util.ArrayList<VDS>());
    for (EntityModel a : Linq.<EntityModel>Cast(model.getItems())) {
      if (a.getIsSelected()) {
        model.getSelectedHosts().add((VDS) a.getEntity());
      }
    }

    VDSGroup cluster = (VDSGroup) model.getCluster().getSelectedItem();

    java.util.ArrayList<VdcActionParametersBase> paramerterList =
        new java.util.ArrayList<VdcActionParametersBase>();
    for (VDS host : model.getSelectedHosts()) {
      // Try to change host's cluster as neccessary.
      if (host.getvds_group_id() != null && !host.getvds_group_id().equals(cluster.getId())) {
        paramerterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
      }
    }
    model.StartProgress(null);
    Frontend.RunMultipleAction(
        VdcActionType.ChangeVDSCluster,
        paramerterList,
        new IFrontendMultipleActionAsyncCallback() {
          @Override
          public void Executed(FrontendMultipleActionAsyncResult result) {

            ClusterGuideModel clusterGuideModel = (ClusterGuideModel) result.getState();
            java.util.ArrayList<VDS> hosts =
                ((MoveHost) clusterGuideModel.getWindow()).getSelectedHosts();
            java.util.ArrayList<VdcReturnValueBase> retVals =
                (java.util.ArrayList<VdcReturnValueBase>) result.getReturnValue();
            if (retVals != null && hosts.size() == retVals.size()) {
              int i = 0;
              for (VDS selectedHost : hosts) {
                if (selectedHost.getstatus() == VDSStatus.PendingApproval
                    && retVals.get(i) != null
                    && retVals.get(i).getSucceeded()) {
                  Frontend.RunAction(
                      VdcActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()));
                }
              }
              i++;
            }
            clusterGuideModel.getWindow().StopProgress();
            clusterGuideModel.Cancel();
            clusterGuideModel.PostAction();
          }
        },
        this);
  }