Change in vdsm[master]: schema: Change the format for specifying unions

agl at us.ibm.com agl at us.ibm.com
Thu Sep 6 21:26:43 UTC 2012


Adam Litke has uploaded a new change for review.

Change subject: schema: Change the format for specifying unions
......................................................................

schema: Change the format for specifying unions

Unions are regular types but with methods to 'cast' the internal object to one
of the member types.  We need to do it this way to support languages that lack
the concept of type casting (ie. Python).  Change the schema to accomodate this
new way of representing unions:
 - 'data': contains fields that are common to all sub-types in the union.
   Useful for identifying what the generic type should be casted to (eg.
   VmDevice.deviceType).
 - 'union': A list of types to which this object may be cast.  Causes the proper
   casting methods to be generated.

Change-Id: I93004dd7d4096b9afd93e125a59baa210fcb04a0
Signed-off-by: Adam Litke <agl at us.ibm.com>
---
M vdsm_api/vdsmapi-schema.json
1 file changed, 55 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/37/7837/1

diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 3cf3ad1..a80ce5d 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -563,10 +563,14 @@
 #
 # A discriminated record to store information about a VDSM network.
 #
+# @bridged:  If True, the union is a 'NetInfoBridgedNetwork'
+#            If False, the union is a 'NetInfoBridgelessNetwork'
+#
 # Since: 4.10.0
 ##
-{'union': 'NetInfoNetwork',
- 'data': ['NetInfoBridgedNetwork', 'NetInfoBridgelessNetwork']}
+{'type': 'NetInfoNetwork',
+ 'data': {'bridged': 'bool'},
+ 'union': ['NetInfoBridgedNetwork', 'NetInfoBridgelessNetwork']}
 
 ##
 # @NetInfoNic:
@@ -1794,10 +1798,13 @@
 #
 # A discriminated record of device address information.
 #
+# @addressType:  The device address type
+#
 # Since: 4.10.0
 ##
-{'union': 'VmDeviceAddress',
- 'data': ['VmDevicePciAddress', 'VmDeviceIdeAddress',
+{'type': 'VmDeviceAddress',
+ 'data': {'addressType': 'VmDeviceAddressType'},
+ 'union': ['VmDevicePciAddress', 'VmDeviceIdeAddress',
           'VmDeviceVirtioSerialAddress']}
 
 ##
@@ -2250,10 +2257,13 @@
 #
 # A discriminated record containing VM device properties.
 #
+# @deviceType:  Indicates the specific device type
+#
 # Since: 4.10.0
 ##
-{'union': 'VmDevice',
- 'data': ['VmDiskDevice', 'VmInterfaceDevice', 'VmVideoDevice',
+{'type': 'VmDevice',
+ 'data': {'deviceType': 'VmDeviceType',},
+ 'union': ['VmDiskDevice', 'VmInterfaceDevice', 'VmVideoDevice',
           'VmSoundDevice', 'VmControllerDevice', 'VmBalloonDevice',
           'VmChannelDevice']}
 
@@ -2353,7 +2363,18 @@
 ##
 {'alias': 'VmFullStatus', 'data': 'VmDefinition'}
 
-{'union': 'VmInfo', 'data': ['VmFullStatus', 'VmShortStatus']}
+##
+# @VmInfo:
+#
+# A discriminated record of VM status information.
+#
+# XXX: This type lacks an identifier to indicate the union type
+#
+# Since: 4.10.0
+##
+{'type': 'VmInfo',
+ 'data': {},
+ 'union': ['VmFullStatus', 'VmShortStatus']}
 
 ##
 # @Host.getVMList:
@@ -2564,11 +2585,14 @@
 #
 # A discriminated record of parameters used to establish a ConnectionRef.
 #
+# XXX: This type lacks an identifier to indicate the union type
+#
 # Since: 4.10.0
 ##
-{'union': 'ConnectionRefParameters',
- 'data': ['IscsiConnectionParameters', 'PosixFsConnectionParameters',
-          'NfsConnectionParameters', 'LocalFsConnectionParameters']}
+{'type': 'ConnectionRefParameters',
+ 'data': {},
+ 'union': ['IscsiConnectionParameters', 'PosixFsConnectionParameters',
+           'NfsConnectionParameters', 'LocalFsConnectionParameters']}
 
 ##
 # @ConnectionRefType:
@@ -3010,11 +3034,13 @@
 #
 # Since: 4.10.0
 # XXX: Union is not a dict
+# XXX: This type lacks an identifier to indicate the union type
 ##
-{'union': 'StorageDomainCreateArguments',
- 'data': ['StorageDomainCreateArgumentsBlock',
-          'StorageDomainCreateArgumentsLocal',
-          'StorageDomainCreateArgumentsNfs']}
+{'type': 'StorageDomainCreateArguments',
+ 'data': {}
+ 'union': ['StorageDomainCreateArgumentsBlock',
+           'StorageDomainCreateArgumentsLocal',
+           'StorageDomainCreateArgumentsNfs']}
 
 ##
 # @StorageDomain.create:
@@ -4198,10 +4224,13 @@
 #
 # A discriminated record containing a VM drive specification
 #
+# XXX: This type lacks an identifier to indicate the union type
+#
 # Since: 4.10.0
 ##
-{'union': 'DriveSpec',
- 'data': ['DriveSpecVolume', 'DriveSpecGUID', 'DriveSpecUUID',
+{'type': 'DriveSpec',
+ 'data': {},
+ 'union': ['DriveSpecVolume', 'DriveSpecGUID', 'DriveSpecUUID',
           'DriveSpecPayload', 'DriveSpecPath']}
 
 ##
@@ -4592,13 +4621,13 @@
 #
 # A discriminated record containing virtual machine statistics.
 #
-# @ExitedVmStats:   Statistica for a VM that has exited
-#
-# @RunningVmStats:  Statistics for a running VM
+# XXX: This type lacks an identifier to indicate the union type
 #
 # Since: 4.10.0
 ##
-{'union': 'VmStats', 'data': ['ExitedVmStats', 'RunningVmStats']}
+{'type': 'VmStats',
+ 'data': {},
+ 'union': ['ExitedVmStats', 'RunningVmStats']}
 
 ##
 # @VM.getStats:
@@ -5016,11 +5045,14 @@
 #
 # A discriminated record of snapshot information for a VM disk.
 #
+# XXX: This type lacks an identifier to indicate the union type
+#
 # Since: 4.10.0
 ##
-{'union': 'SnapshotDriveInfo',
- 'data': ['SnapshotVolumeDriveInfo', 'SnapshotGUIDDriveInfo',
-          'SnapshotUUIDDriveInfo']}
+{'type': 'SnapshotDriveInfo',
+ 'data': {},
+ 'union': ['SnapshotVolumeDriveInfo', 'SnapshotGUIDDriveInfo',
+           'SnapshotUUIDDriveInfo']}
 
 ##
 # @VM.snapshot:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I93004dd7d4096b9afd93e125a59baa210fcb04a0
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <agl at us.ibm.com>


More information about the vdsm-patches mailing list