Example #1
0
  /**
   * Checking that the interfaces are all configured, interfaces with no network are allowed only if
   * network linking is supported.
   *
   * @return true if all VM network interfaces are attached to existing cluster networks, or to no
   *     network (when network linking is supported).
   */
  protected ValidationResult validateInterfacesConfigured(VM vm) {
    for (VmNetworkInterface nic : vm.getInterfaces()) {
      if (nic.getVnicProfileId() == null) {
        return FeatureSupported.networkLinking(vm.getVdsGroupCompatibilityVersion())
            ? ValidationResult.VALID
            : new ValidationResult(
                VdcBllMessages.ACTION_TYPE_FAILED_INTERFACE_NETWORK_NOT_CONFIGURED);
      }
    }

    return ValidationResult.VALID;
  }
Example #2
0
  /**
   * @param clusterNetworksNames cluster logical networks names
   * @param interfaceNetworkNames VM interface network names
   * @return true if all VM network interfaces are attached to existing cluster networks
   */
  protected ValidationResult validateInterfacesAttachedToClusterNetworks(
      VM vm, final Set<String> clusterNetworkNames, final Set<String> interfaceNetworkNames) {

    Set<String> result = new HashSet<String>(interfaceNetworkNames);
    result.removeAll(clusterNetworkNames);
    if (FeatureSupported.networkLinking(vm.getVdsGroupCompatibilityVersion())) {
      result.remove(null);
    }

    // If after removing the cluster network names we still have objects, then we have interface on
    // networks that
    // aren't attached to the cluster
    return result.isEmpty()
        ? ValidationResult.VALID
        : new ValidationResult(
            VdcBllMessages.ACTION_TYPE_FAILED_NETWORK_NOT_IN_CLUSTER,
            String.format("$networks %1$s", StringUtils.join(result, ",")));
  }