Ejemplo n.º 1
0
 public ValidationResult passthroughProfileContainsSupportedProperties() {
   return ValidationResult.failWith(
           EngineMessage.ACTION_TYPE_FAILED_PASSTHROUGH_PROFILE_CONTAINS_NOT_SUPPORTED_PROPERTIES)
       .when(
           vnicProfile.isPassthrough()
               && (vnicProfile.isPortMirroring() || vnicProfile.getNetworkQosId() != null));
 }
Ejemplo n.º 2
0
  public ValidationResult vnicProfileNameNotUsed() {
    for (VnicProfile profile : getVnicProfiles()) {
      if (profile.getName().equals(vnicProfile.getName())
          && !profile.getId().equals(vnicProfile.getId())) {
        return new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VNIC_PROFILE_NAME_IN_USE);
      }
    }

    return ValidationResult.VALID;
  }
 private void addDefaultNetworks() {
   Network net = new Network();
   net.setId(Guid.newGuid());
   net.setName(managementNetworkUtil.getDefaultManagementNetworkName());
   net.setDescription(AddClusterCommand.DefaultNetworkDescription);
   net.setDataCenterId(getStoragePool().getId());
   net.setVmNetwork(true);
   getNetworkDao().save(net);
   NetworkHelper.addPermissionsOnNetwork(getCurrentUser().getId(), net.getId());
   VnicProfile profile = NetworkHelper.createVnicProfile(net);
   getVnicProfileDao().save(profile);
   NetworkHelper.addPermissionsOnVnicProfile(getCurrentUser().getId(), profile.getId(), true);
 }
  protected static void reportUnsupportedVnicProfileFeatures(
      VM vm,
      VmNic nic,
      VnicProfile vnicProfile,
      List<VNIC_PROFILE_PROPERTIES> unsupportedFeatures) {

    if (unsupportedFeatures.isEmpty()) {
      return;
    }

    AuditLogableBase event = new AuditLogableBase();
    event.setVmId(vm.getId());
    event.setVdsGroupId(vm.getVdsGroupId());
    event.setCustomId(nic.getId().toString());
    event.setCompatibilityVersion(vm.getVdsGroupCompatibilityVersion().toString());
    event.addCustomValue("NicName", nic.getName());
    event.addCustomValue("VnicProfile", vnicProfile == null ? null : vnicProfile.getName());
    String[] unsupportedFeatureNames = new String[unsupportedFeatures.size()];
    for (int i = 0; i < unsupportedFeatures.size(); i++) {
      unsupportedFeatureNames[i] = unsupportedFeatures.get(i).getFeatureName();
    }

    event.addCustomValue("UnsupportedFeatures", StringUtils.join(unsupportedFeatureNames, ", "));
    AuditLogDirector.log(event, AuditLogType.VNIC_PROFILE_UNSUPPORTED_FEATURES);
  }
Ejemplo n.º 5
0
  protected List<VM> getVmsUsingProfile() {
    if (vms == null) {
      vms = getDbFacade().getVmDao().getAllForVnicProfile(vnicProfile.getId());
    }

    return vms;
  }
Ejemplo n.º 6
0
  protected VnicProfile getOldVnicProfile() {
    if (oldVnicProfile == null) {
      oldVnicProfile = getDbFacade().getVnicProfileDao().get(vnicProfile.getId());
    }

    return oldVnicProfile;
  }
Ejemplo n.º 7
0
  protected List<VnicProfile> getVnicProfiles() {
    if (vnicProfiles == null) {
      vnicProfiles = getDbFacade().getVnicProfileDao().getAllForNetwork(vnicProfile.getNetworkId());
    }

    return vnicProfiles;
  }
Ejemplo n.º 8
0
  protected Network getNetwork() {
    if (network == null) {
      network = getDbFacade().getNetworkDao().get(vnicProfile.getNetworkId());
    }

    return network;
  }
Ejemplo n.º 9
0
  public ValidationResult passthroughNotChangedIfUsedByVms() {
    if (vnicProfile.isPassthrough() == getOldVnicProfile().isPassthrough()) {
      return ValidationResult.VALID;
    }

    return vnicProfileNotUsedByVms();
  }
Ejemplo n.º 10
0
  public ValidationResult portMirroringNotChangedIfUsedByVms() {
    if (vnicProfile.isPortMirroring() == getOldVnicProfile().isPortMirroring()) {
      return ValidationResult.VALID;
    }

    return vnicProfileNotUsedByVms();
  }
Ejemplo n.º 11
0
  public ValidationResult networkNotChanged() {
    if (ObjectUtils.equals(vnicProfile.getNetworkId(), getOldVnicProfile().getNetworkId())) {
      return ValidationResult.VALID;
    }

    return new ValidationResult(
        EngineMessage.ACTION_TYPE_FAILED_CANNOT_CHANGE_VNIC_PROFILE_NETWORK);
  }
Ejemplo n.º 12
0
  private void addVnicProfile(Network network, boolean publicUse) {
    VnicProfile vnicProfile = new VnicProfile();
    vnicProfile.setName(network.getName());
    vnicProfile.setNetworkId(network.getId());
    VnicProfileParameters parameters = new VnicProfileParameters(vnicProfile);
    parameters.setPublicUse(publicUse);
    Frontend.getInstance()
        .runAction(
            VdcActionType.AddVnicProfile,
            parameters,
            new IFrontendActionAsyncCallback() {

              @Override
              public void executed(FrontendActionAsyncResult result) {
                sourceListModel.getSearchCommand().execute();
              }
            });
  }
Ejemplo n.º 13
0
  public boolean validateCustomProperties(List<String> messages) {
    StoragePool dataCenter = getDbFacade().getStoragePoolDao().get(getNetwork().getDataCenterId());
    List<ValidationError> errors =
        DevicePropertiesUtils.getInstance()
            .validateProperties(
                dataCenter.getCompatibilityVersion(),
                VmDeviceGeneralType.INTERFACE,
                vnicProfile.getCustomProperties());

    if (!errors.isEmpty()) {
      DevicePropertiesUtils.getInstance().handleCustomPropertiesError(errors, messages);
      return false;
    }

    return true;
  }
Ejemplo n.º 14
0
 public ValidationResult vnicProfileNotUsedByTemplates() {
   return vnicProfileNotUsed(
       getDbFacade().getVmTemplateDao().getAllForVnicProfile(vnicProfile.getId()),
       EngineMessage.VAR__ENTITIES__VM_TEMPLATES,
       EngineMessage.VAR__ENTITIES__VM_TEMPLATE);
 }
Ejemplo n.º 15
0
 public ValidationResult networkQosExistsOrNull() {
   return vnicProfile.getNetworkQosId() == null
           || getDbFacade().getNetworkQosDao().get(vnicProfile.getNetworkQosId()) != null
       ? ValidationResult.VALID
       : new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_NETWORK_QOS_NOT_EXISTS);
 }
Ejemplo n.º 16
0
 public ValidationResult portMirroringNotSetIfExternalNetwork() {
   return !vnicProfile.isPortMirroring() || !getNetwork().isExternal()
       ? ValidationResult.VALID
       : new ValidationResult(
           EngineMessage.ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED);
 }