public ValidationResult passthroughProfileContainsSupportedProperties() { return ValidationResult.failWith( EngineMessage.ACTION_TYPE_FAILED_PASSTHROUGH_PROFILE_CONTAINS_NOT_SUPPORTED_PROPERTIES) .when( vnicProfile.isPassthrough() && (vnicProfile.isPortMirroring() || vnicProfile.getNetworkQosId() != null)); }
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); }
protected List<VM> getVmsUsingProfile() { if (vms == null) { vms = getDbFacade().getVmDao().getAllForVnicProfile(vnicProfile.getId()); } return vms; }
protected VnicProfile getOldVnicProfile() { if (oldVnicProfile == null) { oldVnicProfile = getDbFacade().getVnicProfileDao().get(vnicProfile.getId()); } return oldVnicProfile; }
protected List<VnicProfile> getVnicProfiles() { if (vnicProfiles == null) { vnicProfiles = getDbFacade().getVnicProfileDao().getAllForNetwork(vnicProfile.getNetworkId()); } return vnicProfiles; }
protected Network getNetwork() { if (network == null) { network = getDbFacade().getNetworkDao().get(vnicProfile.getNetworkId()); } return network; }
public ValidationResult passthroughNotChangedIfUsedByVms() { if (vnicProfile.isPassthrough() == getOldVnicProfile().isPassthrough()) { return ValidationResult.VALID; } return vnicProfileNotUsedByVms(); }
public ValidationResult portMirroringNotChangedIfUsedByVms() { if (vnicProfile.isPortMirroring() == getOldVnicProfile().isPortMirroring()) { return ValidationResult.VALID; } return vnicProfileNotUsedByVms(); }
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); }
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(); } }); }
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; }
public ValidationResult vnicProfileNotUsedByTemplates() { return vnicProfileNotUsed( getDbFacade().getVmTemplateDao().getAllForVnicProfile(vnicProfile.getId()), EngineMessage.VAR__ENTITIES__VM_TEMPLATES, EngineMessage.VAR__ENTITIES__VM_TEMPLATE); }
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); }
public ValidationResult portMirroringNotSetIfExternalNetwork() { return !vnicProfile.isPortMirroring() || !getNetwork().isExternal() ? ValidationResult.VALID : new ValidationResult( EngineMessage.ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_PORT_MIRRORED); }