Daniel Erez has uploaded a new change for review.

Change subject: core: support Cinder disks on run VM
......................................................................

core: support Cinder disks on run VM

Modified VmInfoBuilder to support Cinder disk
build on 'buildVmDrives' method.

Change-Id: I52521834d049f22c2e9f183b2c57ae558853cfa4
Bug-Url: https://bugzilla.redhat.com/1185826
Signed-off-by: Daniel Erez <de...@redhat.com>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
2 files changed, 64 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/57/39657/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
index 78e3785..f647845 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
@@ -341,6 +341,13 @@
     public static final String Fdc = "fdc";
     public static final String Guid = "GUID";
     public static final String Disk = "disk";
+    public static final String Tcp = "tcp";
+    public static final String DiskType = "diskType";
+    public static final String NetworkDiskName = "name";
+    public static final String NetworkDiskPort = "port";
+    public static final String NetworkDiskTransport = "transport";
+    public static final String NetworkDiskHosts = "hosts";
+
     // iotune
     public static final String Iotune = "ioTune";
     public static final String TotalBytesSec = "total_bytes_sec";
diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
index f51fee1..96d6fc1 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
@@ -31,6 +31,9 @@
 import org.ovirt.engine.core.common.businessentities.network.VmNic;
 import org.ovirt.engine.core.common.businessentities.network.VnicProfile;
 import org.ovirt.engine.core.common.businessentities.qos.StorageQos;
+import 
org.ovirt.engine.core.common.businessentities.storage.CinderConnectionInfo;
+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.Disk;
 import org.ovirt.engine.core.common.businessentities.storage.DiskStorageType;
 import org.ovirt.engine.core.common.businessentities.storage.DiskImage;
@@ -352,26 +355,30 @@
                     struct.put(VdsProperties.Index, 0);
                 }
                 addAddress(vmDevice, struct);
-                if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
-                    DiskImage diskImage = (DiskImage) disk;
-                    struct.put(VdsProperties.PoolId, 
diskImage.getStoragePoolId().toString());
-                    struct.put(VdsProperties.DomainId, 
diskImage.getStorageIds().get(0).toString());
-                    struct.put(VdsProperties.ImageId, 
diskImage.getId().toString());
-                    struct.put(VdsProperties.VolumeId, 
diskImage.getImageId().toString());
-                    struct.put(VdsProperties.Format, 
diskImage.getVolumeFormat().toString()
-                            .toLowerCase());
-                    struct.put(VdsProperties.PropagateErrors, 
disk.getPropagateErrors().toString()
-                            .toLowerCase());
+                switch (disk.getDiskStorageType()) {
+                    case IMAGE:
+                        DiskImage diskImage = (DiskImage) disk;
+                        struct.put(VdsProperties.PoolId, 
diskImage.getStoragePoolId().toString());
+                        struct.put(VdsProperties.DomainId, 
diskImage.getStorageIds().get(0).toString());
+                        struct.put(VdsProperties.ImageId, 
diskImage.getId().toString());
+                        struct.put(VdsProperties.VolumeId, 
diskImage.getImageId().toString());
+                        struct.put(VdsProperties.Format, 
diskImage.getVolumeFormat().toString()
+                                .toLowerCase());
+                        struct.put(VdsProperties.PropagateErrors, 
disk.getPropagateErrors().toString()
+                                .toLowerCase());
 
-                    handleIoTune(vm, vmDevice, diskImage, 
diskProfileStorageQosMap, storageQosIoTuneMap);
-                } else {
-                    LunDisk lunDisk = (LunDisk) disk;
-                    struct.put(VdsProperties.Guid, 
lunDisk.getLun().getLUN_id());
-                    struct.put(VdsProperties.Format, 
VolumeFormat.RAW.toString().toLowerCase());
-                    struct.put(VdsProperties.PropagateErrors, 
PropagateErrors.Off.toString()
-                            .toLowerCase());
+                        handleIoTune(vm, vmDevice, diskImage, 
diskProfileStorageQosMap, storageQosIoTuneMap);
+                        break;
+                    case LUN:
+                        LunDisk lunDisk = (LunDisk) disk;
+                        struct.put(VdsProperties.Guid, 
lunDisk.getLun().getLUN_id());
+                        struct.put(VdsProperties.Format, 
VolumeFormat.RAW.toString().toLowerCase());
+                        struct.put(VdsProperties.PropagateErrors, 
PropagateErrors.Off.toString().toLowerCase());
+                        break;
+                    case CINDER:
+                        buildCinderDisk((CinderDisk) disk, struct);
+                        break;
                 }
-
                 addBootOrder(vmDevice, struct);
                 struct.put(VdsProperties.Shareable,
                         (vmDevice.getSnapshotId() != null && 
FeatureSupported.hotPlugDiskSnapshot(vm.getVdsGroupCompatibilityVersion())) ? 
VdsProperties.Transient
@@ -388,6 +395,38 @@
         ArchStrategyFactory.getStrategy(vm.getClusterArch()).run(new 
CreateAdditionalControllers(devices));
     }
 
+    public static void buildCinderDisk(CinderDisk cinderDisk, Map<String, 
Object> struct) {
+        CinderConnectionInfo connectionInfo = 
cinderDisk.getCinderConnectionInfo();
+        CinderVolumeDriver cinderVolumeDriver = 
CinderVolumeDriver.forValue(connectionInfo.getDriverVolumeType());
+        if (cinderVolumeDriver == null) {
+            log.error("Unsupported Cinder volume driver: '{}' (disk: '{}')",
+                    connectionInfo.getDriverVolumeType(), 
cinderDisk.getDiskAlias());
+            return;
+        }
+        switch (cinderVolumeDriver) {
+            case RBD:
+                String path = (String) 
cinderDisk.getCinderConnectionInfo().getData().get("name");
+                struct.put(VdsProperties.Path, path);
+                struct.put(VdsProperties.Format, 
VolumeFormat.RAW.toString().toLowerCase());
+                struct.put(VdsProperties.PropagateErrors, 
PropagateErrors.Off.toString().toLowerCase());
+                struct.put(VdsProperties.Protocol, 
cinderDisk.getCinderConnectionInfo().getDriverVolumeType());
+                struct.put(VdsProperties.DiskType, VdsProperties.NETWORK);
+
+                List<String> hostAddresses = (ArrayList<String>) 
cinderDisk.getCinderConnectionInfo().getData().get("hosts");
+                List<String> hostPorts = (ArrayList<String>) 
cinderDisk.getCinderConnectionInfo().getData().get("ports");
+                List<Map<String, Object>> hosts = new ArrayList<>();
+                for (int i = 0; i < hostAddresses.size(); i++) {
+                    Map<String, Object> hostMap = new HashMap<>();
+                    hostMap.put(VdsProperties.NetworkDiskName, 
hostAddresses.get(i));
+                    hostMap.put(VdsProperties.NetworkDiskPort, 
hostPorts.get(i));
+                    hostMap.put(VdsProperties.NetworkDiskTransport, 
VdsProperties.Tcp);
+                    hosts.add(hostMap);
+                }
+                struct.put(VdsProperties.NetworkDiskHosts, hosts);
+                break;
+        }
+    }
+
     /**
      * Prepare the ioTune limits map and add it to the specParams if supported 
by the cluster
      *


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

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