Alona Kaplan has uploaded a new change for review.

Change subject: engine: introducing RemoveVfsConfigLabelCommand
......................................................................

engine: introducing RemoveVfsConfigLabelCommand

Change-Id: I5d6ddd73a5325fc972435b826cc45571d2db7e5c
Signed-off-by: Alona Kaplan <alkap...@redhat.com>
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/RemoveVfsConfigLabelCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VfsConfigValidator.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VfsConfigValidatorTest.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
M 
frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
10 files changed, 81 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/47/36847/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/RemoveVfsConfigLabelCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/RemoveVfsConfigLabelCommand.java
new file mode 100644
index 0000000..7e2aa41
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/host/RemoveVfsConfigLabelCommand.java
@@ -0,0 +1,47 @@
+package org.ovirt.engine.core.bll.network.host;
+
+import java.util.Set;
+
+import org.ovirt.engine.core.bll.context.CommandContext;
+import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.action.VfsConfigLabelParameters;
+import org.ovirt.engine.core.common.errors.VdcBllMessages;
+
+public class RemoveVfsConfigLabelCommand extends LabelVfsConfigCommandBase {
+
+    public RemoveVfsConfigLabelCommand(VfsConfigLabelParameters parameters) {
+        this(parameters, null);
+    }
+
+    public RemoveVfsConfigLabelCommand(VfsConfigLabelParameters parameters, 
CommandContext commandContext) {
+        super(parameters, commandContext);
+    }
+
+    @Override
+    protected boolean canDoAction() {
+        if (super.canDoAction()) {
+            return 
validate(getVfsConfigValidator().labelInVfsConfig(getLabel()));
+        }
+
+        return false;
+    }
+
+    @Override
+    public AuditLogType getAuditLogTypeValue() {
+        return getSucceeded() ? AuditLogType.REMOVE_VFS_CONFIG_LABEL
+                : AuditLogType.REMOVE_VFS_CONFIG_LABEL_FAILED;
+    }
+
+    @Override
+    protected void setActionMessageParameters() {
+        super.setActionMessageParameters();
+        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__REMOVE);
+    }
+
+    @Override
+    protected Set<String> getUpdatedLabelList() {
+        Set<String> labels = getVfsConfig().getLabels();
+        labels.remove(getLabel());
+        return labels;
+    }
+}
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VfsConfigValidator.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VfsConfigValidator.java
index 86cbd65..e198bdd 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VfsConfigValidator.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VfsConfigValidator.java
@@ -138,6 +138,17 @@
                 .when(getOldVfsConfig().getLabels().contains(label));
     }
 
+    /**
+     * @param label
+     *
+     * @return An error iff the label is not part of the VFs configuration
+     */
+    public ValidationResult labelInVfsConfig(String label) {
+        return 
ValidationResult.failWith(VdcBllMessages.ACTION_TYPE_FAILED_LABEL_NOT_IN_VFS_CONFIG,
+                getNicNameReplacement(), String.format(LABEL_REPLACEMENT, 
label))
+                .when(!getOldVfsConfig().getLabels().contains(label));
+    }
+
     Network getNetwork(Guid networkId) {
         return getDbFacade().getNetworkDao().get(networkId);
     }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VfsConfigValidatorTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VfsConfigValidatorTest.java
index 2962147..9fb8c62 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VfsConfigValidatorTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VfsConfigValidatorTest.java
@@ -311,6 +311,15 @@
                         String.format(VfsConfigValidator.LABEL_REPLACEMENT, 
LABEL)));
     }
 
+    @Test
+    public void labelInVfsConfigNotValid() {
+        labelInVfsConfigCommonTest(false);
+        assertThat(validator.labelInVfsConfig(LABEL),
+                
failsWith(VdcBllMessages.ACTION_TYPE_FAILED_LABEL_NOT_IN_VFS_CONFIG,
+                        String.format(VfsConfigValidator.NIC_NAME_REPLACEMENT, 
nic.getName()),
+                        String.format(VfsConfigValidator.LABEL_REPLACEMENT, 
LABEL)));
+    }
+
     private void labelInVfsConfigCommonTest(boolean inVfsConfig) {
         simulateVfsConfigExists();
 
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index e5ecc08..a261144 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -761,6 +761,8 @@
     REMOVE_VFS_CONFIG_NETWORK_FAILED(1196),
     ADD_VFS_CONFIG_LABEL(1197),
     ADD_VFS_CONFIG_LABEL_FAILED(1198),
+    REMOVE_VFS_CONFIG_LABEL(1199),
+    REMOVE_VFS_CONFIG_LABEL_FAILED(1201),
 
     // NUMA
     NUMA_ADD_VM_NUMA_NODE_SUCCESS(1300),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
index f28deea..7e71402 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
@@ -117,6 +117,10 @@
 
     // SR-IOV
     UpdateHostNicVfsConfig(167, ActionGroup.CONFIGURE_HOST_NETWORK, false, 
QuotaDependency.NONE),
+    AddVfsConfigNetwork(168, ActionGroup.CONFIGURE_HOST_NETWORK, false, 
QuotaDependency.NONE),
+    RemoveVfsConfigNetwork(169, ActionGroup.CONFIGURE_HOST_NETWORK, false, 
QuotaDependency.NONE),
+    AddVfsConfigLabel(173, ActionGroup.CONFIGURE_HOST_NETWORK, false, 
QuotaDependency.NONE),
+    RemoveVfsConfigLabel(174, ActionGroup.CONFIGURE_HOST_NETWORK, false, 
QuotaDependency.NONE),
 
     // NUMA
     AddVmNumaNodes(170, ActionGroup.EDIT_VM_PROPERTIES, false, 
QuotaDependency.NONE),
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
index b233f69..f8c1cde 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java
@@ -601,6 +601,7 @@
     ACTION_TYPE_FAILED_NETWORK_ALREADY_IN_VFS_CONFIG(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_NETWORK_NOT_IN_VFS_CONFIG(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_LABEL_ALREADY_IN_VFS_CONFIG(ErrorType.CONFLICT),
+    ACTION_TYPE_FAILED_LABEL_NOT_IN_VFS_CONFIG(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_STORAGE_DOMAIN_NOT_IN_STORAGE_POOL(ErrorType.CONFLICT),
     
ACTION_TYPE_FAILED_LUNS_ALREADY_PART_OF_STORAGE_DOMAINS(ErrorType.CONFLICT),
     ACTION_TYPE_FAILED_LUNS_ALREADY_USED_BY_DISKS(ErrorType.CONFLICT),
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
index 2292fad..3496ea7 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -542,6 +542,7 @@
 ACTION_TYPE_FAILED_NETWORK_NOT_IN_VFS_CONFIG=Cannot ${action} ${type}. Network 
${networkName} doesn't exist in network interface ${nicName} VFs configuration.
 ACTION_TYPE_FAILED_NETWORK_NOT_EXIST=Cannot ${action} ${type}. Network with id 
${networkId} doesn't exist.
 ACTION_TYPE_FAILED_LABEL_ALREADY_IN_VFS_CONFIG=Cannot ${action} ${type}. Label 
${label} already exists in network interface ${nicName} VFs configuration.
+ACTION_TYPE_FAILED_LABEL_NOT_IN_VFS_CONFIG=Cannot ${action} ${type}. Label 
${Label} doesn't exist in network interface ${nicName} VFs configuration.
 
 ERROR_CANNOT_RECOVERY_STORAGE_POOL_THERE_IS_ACTIVE_DATA_DOMAINS=Cannot recover 
Data Center with active Data Storage Domain in Data Center.
 ERROR_CANNOT_DETACH_LAST_STORAGE_DOMAIN=Cannot remove the master Storage 
Domain from the Data Center without another active Storage Domain to take its 
place.\n\
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index 3288f02..927dc7a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -566,6 +566,8 @@
 ADD_VFS_CONFIG_LABEL_FAILED=Failed to add ${Label} to the VFs configuration of 
network interface card ${NicName}.
 REMOVE_VFS_CONFIG_NETWORK=Network ${NetworkName} was removed from the VFs 
configuration of network interface card ${NicName}.
 REMOVE_VFS_CONFIG_NETWORK_FAILED=Failed to remove ${NetworkName} from the VFs 
configuration of network interface card ${NicName}.
+REMOVE_VFS_CONFIG_LABEL=Label ${Label} was removed from the VFs configuration 
of network interface card ${NicName}.
+REMOVE_VFS_CONFIG_LABEL_FAILED=Failed to remove ${Label} from the VFs 
configuration of network interface card ${NicName}.
 SYSTEM_DEACTIVATED_STORAGE_DOMAIN=Storage Domain ${StorageDomainName} (Data 
Center ${StoragePoolName}) was deactivated by system because it's not visible 
by any of the hosts.
 SYSTEM_DEACTIVATE_STORAGE_DOMAIN_FAILED=Failed to deactivate Storage Domain 
${StorageDomainName} (Data Center ${StoragePoolName}).
 VDS_SET_NONOPERATIONAL_DOMAIN=Host ${VdsName} cannot access the Storage 
Domain(s) ${StorageDomainNames} attached to the Data Center ${StoragePoolName}. 
Setting Host state to Non-Operational.
diff --git 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
index 733fff3..8137e6b 100644
--- 
a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
+++ 
b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java
@@ -1516,6 +1516,9 @@
     @DefaultStringValue("Cannot ${action} ${type}. Label ${label} already 
exists in network interface ${nicName} VFs configuration.")
     String ACTION_TYPE_FAILED_LABEL_ALREADY_IN_VFS_CONFIG();
 
+    @DefaultStringValue("Cannot ${action} ${type}. Label ${label} doesn't 
exist in network interface ${nicName} VFs configuration.")
+    String ACTION_TYPE_FAILED_LABEL_NOT_IN_VFS_CONFIG();
+
     @DefaultStringValue("Cannot recover Data Center with active Data Storage 
Domain in Data Center.")
     String ERROR_CANNOT_RECOVERY_STORAGE_POOL_THERE_IS_ACTIVE_DATA_DOMAINS();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index beac682..714ff26 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -547,6 +547,7 @@
 ACTION_TYPE_FAILED_NETWORK_NOT_IN_VFS_CONFIG=Cannot ${action} ${type}. Network 
${networkName} doesn't exist in network interface ${nicName} VFs configuration.
 ACTION_TYPE_FAILED_NETWORK_NOT_EXIST=Cannot ${action} ${type}. Network with id 
${networkId} doesn't exist.
 ACTION_TYPE_FAILED_LABEL_ALREADY_IN_VFS_CONFIG=Cannot ${action} ${type}. Label 
${label} already exists in network interface ${nicName} VFs configuration.
+ACTION_TYPE_FAILED_LABEL_NOT_IN_VFS_CONFIG=Cannot ${action} ${type}. Label 
${Label} doesn't exist in network interface ${nicName} VFs configuration.
 
 ERROR_CANNOT_RECOVERY_STORAGE_POOL_THERE_IS_ACTIVE_DATA_DOMAINS=Cannot recover 
Data Center with active Data Storage Domain in Data Center.
 ERROR_CANNOT_DETACH_LAST_STORAGE_DOMAIN=Cannot remove the master Storage 
Domain from the Data Center without another active Storage Domain to take its 
place.\n\


-- 
To view, visit http://gerrit.ovirt.org/36847
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5d6ddd73a5325fc972435b826cc45571d2db7e5c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alona Kaplan <alkap...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to