Daniel Erez has uploaded a new change for review.

Change subject: core: update CinderDisks connections on RunVm
......................................................................

core: update CinderDisks connections on RunVm

Invoking updateCinderDisksConnections on RunVmCommand to
retrieve the relevant ConnectionInfo (which should include
a list of available monitors IPs for Ceph) from Cinder.

Change-Id: Ie48e01acd6c3afcbc322603e0358b63e2b2bdf99
Bug-Url: https://bugzilla.redhat.com/1185826
Signed-off-by: Daniel Erez <de...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.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/businessentities/storage/CinderDisk.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
6 files changed, 39 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/56/39656/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
index 9afaeb1..e71a2ec 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImagesHandler.java
@@ -586,7 +586,7 @@
         return filterDisksBasedOnCinder(listOfDisks, false);
     }
 
-    private static List<CinderDisk> filterDisksBasedOnCinder(Collection<? 
extends Disk> listOfDisks,
+    public static List<CinderDisk> filterDisksBasedOnCinder(Collection<? 
extends Disk> listOfDisks,
             boolean onlyPluggedDisks) {
         List<CinderDisk> cinderDisks = new ArrayList<>();
         for (Disk disk : listOfDisks) {
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
index 01dd613..bdbd487 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommand.java
@@ -219,7 +219,7 @@
         if (getVdsToRunOn()) {
             VMStatus status = null;
             try {
-                if (connectLunDisks(getVdsId())) {
+                if (connectLunDisks(getVdsId()) && 
updateCinderDisksConnections()) {
                     status = createVm();
                     ExecutionHandler.setAsyncJob(getExecutionContext(), true);
                 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
index af75647..debdcd5 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RunVmCommandBase.java
@@ -9,21 +9,27 @@
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.TimeUnit;
 
+import com.woorea.openstack.base.client.OpenStackResponseException;
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.bll.job.ExecutionContext;
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.bll.job.JobRepositoryFactory;
 import org.ovirt.engine.core.bll.scheduling.RunVmDelayer;
 import org.ovirt.engine.core.bll.snapshots.SnapshotsValidator;
+import org.ovirt.engine.core.bll.storage.CinderBroker;
 import org.ovirt.engine.core.bll.storage.StorageHelperDirector;
+import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.IdParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VmOperationParameterBase;
+import 
org.ovirt.engine.core.common.businessentities.storage.CinderConnectionInfo;
 import org.ovirt.engine.core.common.businessentities.IVdsAsyncCommand;
 import org.ovirt.engine.core.common.businessentities.StorageServerConnections;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.businessentities.VmStatic;
+import org.ovirt.engine.core.common.businessentities.storage.CinderDisk;
+import 
org.ovirt.engine.core.common.businessentities.storage.CinderVolumeDriver;
 import org.ovirt.engine.core.common.businessentities.storage.LUNs;
 import org.ovirt.engine.core.common.businessentities.storage.LunDisk;
 import org.ovirt.engine.core.common.config.Config;
@@ -268,6 +274,32 @@
         return true;
     }
 
+    protected boolean updateCinderDisksConnections() {
+        if (getVm().getDiskMap().isEmpty()) {
+            VmHandler.updateDisksFromDb(getVm());
+        }
+        List<CinderDisk> cinderDisks = 
ImagesHandler.filterDisksBasedOnCinder(getVm().getDiskMap().values(), true);
+        for (CinderDisk cinderDisk : cinderDisks) {
+            try {
+                CinderBroker cinderBroker = new 
CinderBroker(cinderDisk.getStorageIds().get(0), 
getReturnValue().getExecuteFailedMessages());
+                CinderConnectionInfo connectionInfo = 
cinderBroker.initializeConnectionForDisk(cinderDisk);
+                CinderVolumeDriver cinderVolumeDriver = 
CinderVolumeDriver.forValue(connectionInfo.getDriverVolumeType());
+                if (cinderVolumeDriver == null) {
+                    addCustomValue("DiskAlias", cinderDisk.getDiskAlias());
+                    auditLogDirector.log(this, 
AuditLogType.CINDER_DISK_CONNECTION_VOLUME_DRIVER_UNSUPPORTED);
+                    return false;
+                }
+                cinderDisk.setCinderConnectionInfo(connectionInfo);
+            }
+            catch (OpenStackResponseException ex) {
+                addCustomValue("DiskAlias", cinderDisk.getDiskAlias());
+                auditLogDirector.log(this, 
AuditLogType.CINDER_DISK_CONNECTION_FAILURE);
+                return false;
+            }
+        }
+        return true;
+    }
+
     private void decreasePendingVm() {
         decreasePendingVm(getVm().getStaticData());
     }
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 7639509..5fc3819 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
@@ -1186,7 +1186,9 @@
     MAC_POOL_REMOVE_FAILED(10705, AuditLogSeverity.ERROR),
 
     // Cinder
-    CINDER_PROVIDER_ERROR(10750, AuditLogSeverity.ERROR);
+    CINDER_PROVIDER_ERROR(10750, AuditLogSeverity.ERROR),
+    CINDER_DISK_CONNECTION_FAILURE(10751, AuditLogSeverity.ERROR),
+    CINDER_DISK_CONNECTION_VOLUME_DRIVER_UNSUPPORTED(10752, 
AuditLogSeverity.ERROR);
 
     private int intValue;
     // indicates time interval in seconds on which identical events from same 
instance are suppressed.
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/CinderDisk.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/CinderDisk.java
index 15e75a8..23ace39 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/CinderDisk.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/storage/CinderDisk.java
@@ -1,7 +1,5 @@
 package org.ovirt.engine.core.common.businessentities.storage;
 
-import org.ovirt.engine.core.common.businessentities.CinderConnectionInfo;
-
 public class CinderDisk extends DiskImage {
 
     CinderConnectionInfo cinderConnectionInfo;
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 7c8de66..ebb8a12 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -978,3 +978,5 @@
 IMPORTEXPORT_NO_PROXY_HOST_AVAILABLE_IN_DC=No Host in Data Center 
'${StoragePoolName}' can serve as a proxy to retrieve remote VMs information 
(User: ${UserName}).
 IMPORTEXPORT_HOST_CANNOT_SERVE_AS_PROXY=Host ${VdsName} cannot be used as a 
proxy to retrieve remote VMs information since it is not up (User: ${UserName}).
 CINDER_PROVIDER_ERROR=An error occurred on Cinder provider: 
'${CinderException}'
+CINDER_DISK_CONNECTION_FAILURE=Failed to retrieve connection information for 
Cinder Disk '${DiskAlias}'.
+CINDER_DISK_CONNECTION_VOLUME_DRIVER_UNSUPPORTED=Unsupported volume driver for 
Cinder Disk '${DiskAlias}'.


-- 
To view, visit https://gerrit.ovirt.org/39656
To unsubscribe, visit https://gerrit.ovirt.org/settings

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

Reply via email to