Alona Kaplan has uploaded a new change for review.

Change subject: engine: introducing GetCapabilitiesCommand
......................................................................

engine: introducing GetCapabilitiesCommand

GetCapabilitiesCommand will sync the backend with GetVdsCaps and
GetHardwareInfo data.

Today this sync is done just after few actions like activating a host.
The purpose of the new command is to allow performing this sync manually.
The command is allowed just if the host status is maintenance, up or non
operational.

Change-Id: Iba25577a7b66f3acedc3b32b258560861d19c621
Signed-off-by: Alona Kaplan <alkap...@redhat.com>
---
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVdsCapabilitiesCommand.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/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.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/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
M 
frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
M 
frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
M 
frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
12 files changed, 107 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/40/15640/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVdsCapabilitiesCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVdsCapabilitiesCommand.java
new file mode 100644
index 0000000..da0958b
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/GetVdsCapabilitiesCommand.java
@@ -0,0 +1,85 @@
+package org.ovirt.engine.core.bll;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.ovirt.engine.core.common.AuditLogType;
+import org.ovirt.engine.core.common.action.VdsActionParameters;
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSStatus;
+import org.ovirt.engine.core.common.errors.VdcBllMessages;
+import org.ovirt.engine.core.common.locks.LockingGroup;
+import org.ovirt.engine.core.common.utils.Pair;
+import org.ovirt.engine.core.utils.lock.EngineLock;
+import org.ovirt.engine.core.vdsbroker.ResourceManager;
+
+@LockIdNameAttribute
+@NonTransactiveCommandAttribute
+public class GetVdsCapabilitiesCommand<T extends VdsActionParameters> extends 
VdsCommand<T> {
+
+    public GetVdsCapabilitiesCommand(T parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected void executeCommand() {
+        final VDS vds = getVds();
+        EngineLock monitoringLock =
+                new 
EngineLock(Collections.singletonMap(getParameters().getVdsId().toString(),
+                        new Pair<String, String>(LockingGroup.VDS_INIT.name(), 
"")), null);
+        log.infoFormat("Before acquiring lock in order to prevent monitoring 
for host {0} from data-center {1}",
+                vds.getName(),
+                vds.getStoragePoolName());
+        getLockManager().acquireLockWait(monitoringLock);
+        log.infoFormat("Lock acquired, from now a monitoring of host will be 
skipped for host {0} from data-center {1}",
+                vds.getName(),
+                vds.getStoragePoolName());
+        try {
+            
ResourceManager.getInstance().GetVdsManager(getVdsId()).refreshCapabilities(new 
AtomicBoolean(), getVds());
+            setSucceeded(true);
+        } catch (Exception e) {
+            setSucceeded(false);
+        } finally {
+            getLockManager().releaseLock(monitoringLock);
+            log.infoFormat("Get Capabilities finished. Lock released. 
Monitoring can run now for host {0} from data-center {1}",
+                    vds.getName(),
+                    vds.getStoragePoolName());
+        }
+    }
+
+    @Override
+    protected boolean canDoAction() {
+        if (getVds() == null) {
+            return 
failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_HOST_NOT_EXIST);
+        }
+        if (!isValidVdsStatus()) {
+            
addCanDoActionMessage(VdcBllMessages.VAR__HOST_STATUS__UP_MAINTENANCE_OR_NON_OPERATIONAL);
+            
addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VDS_STATUS_ILLEGAL);
+            return false;
+        }
+        return true;
+    }
+
+    private boolean isValidVdsStatus() {
+        VDSStatus hostStatus = getVds().getStatus();
+        return ((hostStatus == VDSStatus.Maintenance) || (hostStatus == 
VDSStatus.Up) || (hostStatus == VDSStatus.NonOperational));
+    }
+
+    @Override
+    protected Map<String, Pair<String, String>> getExclusiveLocks() {
+        return Collections.singletonMap(getParameters().getVdsId().toString(),
+                LockMessagesMatchUtil.makeLockingPair(LockingGroup.VDS, 
VdcBllMessages.ACTION_TYPE_FAILED_OBJECT_LOCKED));
+    }
+
+    @Override
+    protected void setActionMessageParameters() {
+        addCanDoActionMessage(VdcBllMessages.VAR__ACTION__GET_CAPABILITIES);
+        addCanDoActionMessage(VdcBllMessages.VAR__TYPE__HOST);
+    }
+
+    @Override
+    public AuditLogType getAuditLogTypeValue() {
+        return getSucceeded() ? AuditLogType.VDS_GET_CAPABILITIES : 
AuditLogType.VDS_GET_CAPABILITIES_FAILED;
+    }
+}
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 6a6efba..98bf187 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
@@ -75,6 +75,9 @@
     // Proxy host selection
     PROXY_HOST_SELECTION(605),
 
+    VDS_GET_CAPABILITIES(606),
+    VDS_GET_CAPABILITIES_FAILED(607),
+
     // -- IRS Log types --
     IRS_FAILURE(22, AuditLogTimeInterval.HOUR.getValue() * 12),
     IRS_DISK_SPACE_LOW(26, AuditLogTimeInterval.HOUR.getValue() * 12),
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 8c6fa1b..d17e633 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
@@ -69,6 +69,7 @@
     StopVds(122, ActionGroup.MANIPUTLATE_HOST, QuotaDependency.NONE),
     HandleVdsVersion(124, QuotaDependency.NONE),
     ChangeVDSCluster(125, ActionGroup.EDIT_HOST_CONFIGURATION, false, 
QuotaDependency.NONE),
+    GetVdsCapabilities(126, ActionGroup.MANIPUTLATE_HOST, 
QuotaDependency.NONE),
     // Network
     UpdateNetworkToVdsInterface(149, ActionGroup.CONFIGURE_HOST_NETWORK, 
QuotaDependency.NONE),
     AttachNetworkToVdsInterface(150, ActionGroup.CONFIGURE_HOST_NETWORK, 
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 0a7e0a6..d3e5204 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
@@ -239,6 +239,7 @@
     
ACTION_TYPE_FAILED_PM_ENABLED_WITHOUT_AGENT_CREDENTIALS(ErrorType.BAD_PARAMETERS),
     ACTION_TYPE_FAILED_AGENT_NOT_SUPPORTED(ErrorType.CONFLICT),
     VDS_CANNOT_CHECK_VERSION_HOST_NON_RESPONSIVE(ErrorType.CONFLICT),
+
     // VDS_CANNOT_RUN_VM_FAILED_TO_RUN, // EINAV: not in use
     // internal const string VDS_CANNOT_REMOVE_VDS_DETECTED_RUNNING_VM =
     /**
@@ -455,6 +456,7 @@
     VAR__ACTION__DETACH,
     VAR__ACTION__ACTIVATE,
     VAR__ACTION__DEACTIVATE,
+    VAR__ACTION__GET_CAPABILITIES,
     VAR__ACTION__RECONSTRUCT_MASTER,
     VAR__ACTION__RECOVER_POOL,
     VAR__ACTION__DESTROY_DOMAIN,
diff --git 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
index 9f080e9..bff78bd 100644
--- 
a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
+++ 
b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
@@ -288,6 +288,8 @@
         severities.put(AuditLogType.SYSTEM_FAILED_VDS_RESTART, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VDS_ACTIVATE, AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.VDS_ACTIVATE_FAILED, 
AuditLogSeverity.ERROR);
+        severities.put(AuditLogType.VDS_GET_CAPABILITIES, 
AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.VDS_GET_CAPABILITIES_FAILED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.USER_UPDATE_VDS, AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.USER_FAILED_UPDATE_VDS, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.USER_REMOVE_VDS, AuditLogSeverity.NORMAL);
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 c1cb4c3..0e10f42 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties
@@ -269,6 +269,7 @@
 VAR__ACTION__DETACH=$action detach
 VAR__ACTION__ACTIVATE=$action activate
 VAR__ACTION__DEACTIVATE=$action deactivate
+VAR__ACTION__GET_CAPABILITIES=$action refresh capabilities
 VAR__ACTION__RECONSTRUCT_MASTER=$action reconstruct master
 VAR__ACTION__RECOVER_POOL=$action recover Data Center
 VAR__ACTION__DESTROY_DOMAIN=$action destroy
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 772ea2e..18fd65a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -183,6 +183,8 @@
 VDS_ACTIVATE_ASYNC=Host ${VdsName} was autorecovered.
 VDS_ACTIVATE_FAILED=Failed to activate Host ${VdsName}.(User: ${UserName}).
 VDS_ACTIVATE_FAILED_ASYNC=Failed to autorecover Host ${VdsName}.
+VDS_GET_CAPABILITIES=Host ${VdsName} refresh capabilities finished 
successfully.
+VDS_GET_CAPABILITIES_FAILED=Failed to refresh Host ${VdsName} capabilities.
 VDS_DETECTED=Detected new Host ${VdsName}. Host state was set to ${VdsStatus}.
 VDS_FAILURE=Host ${VdsName} is non-responsive.
 VDS_MAINTENANCE=Host ${VdsName} was switched to Maintenance Mode.
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 2552f38..995a5e4 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
@@ -736,6 +736,9 @@
     @DefaultStringValue("$action deactivate")
     String VAR__ACTION__DEACTIVATE();
 
+    @DefaultStringValue("$action refresh capabilities")
+    String VAR__ACTION__GET_CAPABILITIES();
+
     @DefaultStringValue("$action reconstruct master")
     String VAR__ACTION__RECONSTRUCT_MASTER();
 
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
index a9460b8..b373914 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/LocalizedEnums.java
@@ -187,6 +187,10 @@
 
        String AuditLogType___VDS_ACTIVATE_FAILED();
 
+    String AuditLogType___VDS_GET_CAPABILITIES();
+
+    String AuditLogType___VDS_GET_CAPABILITIES_FAILED();
+
        String AuditLogType___VDS_RECOVER_FAILED();
 
        String AuditLogType___VDS_SLOW_STORAGE_RESPONSE_TIME();
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
index 6dd181f..1eb80a6 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
+++ 
b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties
@@ -89,6 +89,8 @@
 AuditLogType___VDS_MAINTENANCE=Host was switched to Maintenance Mode
 AuditLogType___VDS_MAINTENANCE_FAILED=Failed to switch Host to Maintenance mode
 AuditLogType___VDS_ACTIVATE_FAILED=Failed to activate Host
+AuditLogType___VDS_GET_CAPABILITIES=Host ${VdsName} refresh capabilities 
finished successfully.
+AuditLogType___VDS_GET_CAPABILITIES_FAILED=Failed to refresh Host ${VdsName} 
capabilities.
 AuditLogType___VDS_RECOVER_FAILED=Host failed to recover
 AuditLogType___VDS_SLOW_STORAGE_RESPONSE_TIME=Slow storage response time
 AuditLogType___VDS_APPROVE_FAILED=Failed to approve Host
diff --git 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
index c958c03..8b1d73b 100644
--- 
a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
+++ 
b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties
@@ -268,6 +268,7 @@
 VAR__ACTION__DETACH=$action detach
 VAR__ACTION__ACTIVATE=$action activate
 VAR__ACTION__DEACTIVATE=$action deactivate
+VAR__ACTION__GET_CAPABILITIES=$action refresh capabilities
 VAR__ACTION__RECONSTRUCT_MASTER=$action reconstruct master
 VAR__ACTION__RECOVER_POOL=$action recover Data Center
 VAR__ACTION__DESTROY_DOMAIN=$action destroy
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 dc3d3c1..9274e0a 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
@@ -272,6 +272,7 @@
 VAR__ACTION__DETACH=$action detach
 VAR__ACTION__ACTIVATE=$action activate
 VAR__ACTION__DEACTIVATE=$action deactivate
+VAR__ACTION__GET_CAPABILITIES=$action refresh capabilities
 VAR__ACTION__RECONSTRUCT_MASTER=$action reconstruct master
 VAR__ACTION__RECOVER_POOL=$action recover Data Center
 VAR__ACTION__DESTROY_DOMAIN=$action destroy


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iba25577a7b66f3acedc3b32b258560861d19c621
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