Change in vdsm[master]: ceph: Support authentication using libvirt secrets

nsoffer at redhat.com nsoffer at redhat.com
Mon May 4 16:04:51 UTC 2015


Nir Soffer has uploaded a new change for review.

Change subject: ceph: Support authentication using libvirt secrets
......................................................................

ceph: Support authentication using libvirt secrets

When using network disk and Libvirt secerts, for example cephx
authentication, engine will send a new "auth" key, with the
authentication information:

    "auth": {"type": "ceph",
             "uuid": "abcdef",
             "username": "cinder"}

Vdsm adds an "auth" element tied the underlying libvirt secret:

    <auth username="cinder">
        <secret type="ceph" uuid="abcdef"/>
    </auth>

Libvirt secret configuration will be handled in a future patch.

Change-Id: Id90dc385059414680aad5a1ae895347351ffbb3f
Signed-off-by: Daniel Erez <derez at redhat.com>
Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
M tests/vmStorageTests.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/virt/vmdevices/storage.py
3 files changed, 60 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/05/40505/1

diff --git a/tests/vmStorageTests.py b/tests/vmStorageTests.py
index 04f4182..6fb4bf5 100644
--- a/tests/vmStorageTests.py
+++ b/tests/vmStorageTests.py
@@ -145,6 +145,34 @@
             """
         self.check({}, conf, xml, is_block_device=None)
 
+    def test_network_with_auth(self):
+        conf = drive_config(
+            auth={"type": "ceph", "uuid": "abcdef", "username": "cinder"},
+            diskType=DISK_TYPE.NETWORK,
+            hosts=[
+                dict(name='1.2.3.41', port='6789', transport='tcp'),
+                dict(name='1.2.3.42', port='6789', transport='tcp'),
+            ],
+            path='poolname/volumename',
+            protocol='rbd',
+        )
+        xml = """
+            <disk device="disk" snapshot="no" type="network">
+                <source name="poolname/volumename" protocol="rbd">
+                    <host name="1.2.3.41" port="6789" transport="tcp"/>
+                    <host name="1.2.3.42" port="6789" transport="tcp"/>
+                </source>
+                <auth username="cinder">
+                    <secret type="ceph" uuid="abcdef"/>
+                </auth>
+                <target bus="virtio" dev="vda"/>
+                <serial>54-a672-23e5b495a9ea</serial>
+                <driver cache="none" error_policy="stop"
+                        io="threads" name="qemu" type="raw"/>
+            </disk>
+            """
+        self.check({}, conf, xml, is_block_device=None)
+
     def check(self, vm_conf, device_conf, xml, is_block_device=False):
         drive = Drive(vm_conf, self.log, **device_conf)
         # Patch to skip the block device checking.
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index 2369504..f60dbed 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -2565,6 +2565,22 @@
  'data': {'name': 'str', 'port': 'str', 'transport': 'str'}}
 
 ##
+# @NetworkDiskAuthInfo:
+#
+# Authentication credentials needed to access a network disk
+#
+# @username:  Identifies the username
+#
+# @type:      Libvirt secret object type
+#
+# @uuid:      Libvirt secert object uuid
+#
+# Since: 4.17.0
+##
+{'type': 'NetworkDiskAuthInfo',
+ 'data': {'username': 'str', 'type': 'str', 'uuid': 'UUID'}}
+
+##
 # @VmDiskDevice:
 #
 # Properties of a VM disk device.
@@ -2635,6 +2651,8 @@
 #                    set to "network"
 #                    Since: 4.17.0
 #
+# @auth:             #optional Network disk auth info
+#                    Since: 4.17.0
 #
 # Since: 4.10.0
 ##
@@ -2650,7 +2668,8 @@
           'optional': 'bool', 'shared': 'VmSharedDriveType',
           'truesize': 'uint', 'volumeChain': ['VmDiskDeviceVolumeChainEntry'],
           '*baseVolumeID': 'UUID', '*diskType': 'str',
-          '*hosts': ['NetworkDiskHostInfo'], '*protocol': 'str'}}
+          '*hosts': ['NetworkDiskHostInfo'], '*protocol': 'str',
+          '*auth': 'NetworkDiskAuthInfo'}}
 
 ##
 # @VmInterfaceDeviceType:
diff --git a/vdsm/virt/vmdevices/storage.py b/vdsm/virt/vmdevices/storage.py
index 843bd2c..329b227 100644
--- a/vdsm/virt/vmdevices/storage.py
+++ b/vdsm/virt/vmdevices/storage.py
@@ -60,7 +60,7 @@
                  'index', 'name', 'optional', 'shared', 'truesize',
                  'volumeChain', 'baseVolumeID', 'serial', 'reqsize', 'cache',
                  '_blockDev', 'extSharedState', 'drv', 'sgio', 'GUID',
-                 'diskReplicate', '_diskType', 'hosts', 'protocol')
+                 'diskReplicate', '_diskType', 'hosts', 'protocol', 'auth')
     VOLWM_CHUNK_SIZE = (config.getint('irs', 'volume_utilization_chunk_mb') *
                         constants.MEGAB)
     VOLWM_FREE_PCT = 100 - config.getint('irs', 'volume_utilization_percent')
@@ -347,6 +347,10 @@
         diskelem.setAttrs(snapshot='no')
 
         diskelem.appendChild(_getSourceXML(self))
+
+        if hasattr(self, 'auth'):
+            diskelem.appendChild(self._getAuthXML())
+
         diskelem.appendChild(self._getTargetXML())
 
         if self.extSharedState == DRIVE_SHARED_TYPE.SHARED:
@@ -384,6 +388,13 @@
         disk.appendChild(_getDriverXML(self.diskReplicate))
         return disk
 
+    def _getAuthXML(self):
+        auth = vmxml.Element("auth", username=self.auth["username"])
+        auth.appendChildWithArgs("secret",
+                                 type=self.auth["type"],
+                                 uuid=self.auth["uuid"])
+        return auth
+
     def _getTargetXML(self):
         target = vmxml.Element('target', dev=self.name)
         if self.iface:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id90dc385059414680aad5a1ae895347351ffbb3f
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <nsoffer at redhat.com>


More information about the vdsm-patches mailing list