@Override
 protected void executeQueryCommand() {
   if (getParameters().getId() == null || getParameters().getId().equals(Guid.Empty)) {
     getQueryReturnValue()
         .setReturnValue(networkDao.getAll(getUserID(), getParameters().isFiltered()));
   } else {
     getQueryReturnValue()
         .setReturnValue(
             networkDao.getAllForDataCenter(
                 getParameters().getId(), getUserID(), getParameters().isFiltered()));
   }
 }
 /**
  * The algorithm for finding the default management network is:
  *
  * <ol>
  *   <li>Use the default management network defined by the default name (according to <code>
  *       ConfigValues.DefaultManagementNetwork</code>), if exists in the given data center (for
  *       backward compatibility).
  *   <li>If the data center has a single network and that suitable to serve as themangement one
  *       use that.
  *   <li>If the data center has a single management network use that.
  *   <li>Otherwise return <code>null</code>
  * </ol>
  *
  * @see DefaultManagementNetworkFinder#findDefaultManagementNetwork(Guid)
  */
 @Override
 public Network findDefaultManagementNetwork(Guid dataCenterId) {
   final Network defaultEngineManagementNetwork =
       findConfigDefaultEngineManagementNetwork(dataCenterId);
   if (defaultEngineManagementNetwork != null) {
     return defaultEngineManagementNetwork;
   }
   final List<Network> dcNetworks = networkDao.getAllForDataCenter(dataCenterId);
   if (dcNetworks.size() == 1) {
     final Network singleDcNetwork = dcNetworks.get(0);
     if (managementNetworkCandidatePredicate.test(singleDcNetwork)) {
       return singleDcNetwork;
     }
   } else {
     final List<Network> managementNetworks = networkDao.getManagementNetworks(dataCenterId);
     if (managementNetworks.size() == 1) {
       return managementNetworks.get(0);
     }
   }
   return null;
 }
  @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;
  }
示例#4
0
 private void managementNetworkNotFoundById() {
   managementNetworkId = TEST_MANAGEMENT_NETWORK_ID;
   when(networkDao.get(TEST_MANAGEMENT_NETWORK_ID)).thenReturn(null);
 }
 private Network findConfigDefaultEngineManagementNetwork(Guid dataCenterId) {
   return networkDao.getByNameAndDataCenter(
       managementNetworkUtil.getDefaultManagementNetworkName(), dataCenterId);
 }