test/test_deserialization.rb in rbvmomi-1.0.2 vs test/test_deserialization.rb in rbvmomi-1.1.0

- old
+ new

@@ -1,24 +1,16 @@ require 'test/unit' require 'rbvmomi' -include RbVmomi +VIM ||= RbVmomi::VIM class DeserializationTest < Test::Unit::TestCase def setup - @soap = RbVmomi::Soap.new(ns: 'urn:vim25', rev: '4.0') + @soap = VIM.new(ns: 'urn:vim25', rev: '4.0') end def check str, expected, type got = @soap.xml2obj Nokogiri(str).root, type - - puts "expected:" - pp expected - puts - puts "got:" - pp got - puts - assert_equal expected, got end def test_moref check <<-EOS, VIM.Folder(nil, 'ha-folder-root'), 'Folder' @@ -77,11 +69,11 @@ ) ] ) check <<-EOS, obj, 'ObjectContent' -<root xmlns:xsi="#{RbVmomi::Soap::NS_XSI}"> +<root xmlns:xsi="#{VIM::NS_XSI}"> <obj type="Folder">ha-folder-root</obj> <propSet> <name>childEntity</name> <val xsi:type="ArrayOfManagedObjectReference"> <ManagedObjectReference type="Datacenter" xsi:type="ManagedObjectReference">ha-datacenter</ManagedObjectReference> @@ -94,12 +86,10 @@ def test_array2 obj = VIM.DVPortStatus( dynamicProperty: [], linkUp: true, blocked: false, - vmDirectPathGen2InactiveReasonNetwork: [], - vmDirectPathGen2InactiveReasonOther: [], vlanIds: [ VIM::NumericRange(dynamicProperty: [], start: 5, end: 7), VIM::NumericRange(dynamicProperty: [], start: 10, end: 20), ] ) @@ -121,12 +111,10 @@ end def test_empty_array obj = VIM.DVPortStatus( dynamicProperty: [], - vmDirectPathGen2InactiveReasonNetwork: [], - vmDirectPathGen2InactiveReasonOther: [], linkUp: true, blocked: false, vlanIds: [] ) @@ -147,11 +135,11 @@ faultMessage: [] ) ) check <<-EOS, obj, "LocalizedMethodFault" -<error xmlns:xsi="#{RbVmomi::Soap::NS_XSI}"> +<error xmlns:xsi="#{VIM::NS_XSI}"> <fault xsi:type="InvalidPowerState"> <requestedState>poweredOn</requestedState> <existingState>poweredOff</existingState> </fault> <localizedMessage>The attempted operation cannot be performed in the current state (Powered off).</localizedMessage> @@ -187,11 +175,11 @@ ) ] ) check <<-EOS, obj, "UpdateSet" -<returnval xmlns:xsi="#{RbVmomi::Soap::NS_XSI}"> +<returnval xmlns:xsi="#{VIM::NS_XSI}"> <version>7</version> <filterSet> <filter type="PropertyFilter">session[528BA5EB-335B-4AF6-B49C-6160CF5E8D5B]71E3AC7E-7927-4D9E-8BC3-522769F22DAF</filter> <objectSet> <kind>enter</kind> @@ -236,52 +224,34 @@ <pci>00:07.1</pci> </hostBusAdapter> EOS end +=begin def test_runtime_state obj = VIM::VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeState( dynamicProperty: [], vmDirectPathGen2Active: false, vmDirectPathGen2InactiveReasonOther: ["vmNptIncompatibleHost"], vmDirectPathGen2InactiveReasonVm: [] ) check <<-EOS, obj, 'VirtualMachineDeviceRuntimeInfoDeviceRuntimeState' -<runtimeState xsi:type="VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeState" xmlns:xsi="#{RbVmomi::Soap::NS_XSI}"> +<runtimeState xsi:type="VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeState" xmlns:xsi="#{VIM::NS_XSI}"> <vmDirectPathGen2Active>false</vmDirectPathGen2Active> <vmDirectPathGen2InactiveReasonOther>vmNptIncompatibleHost</vmDirectPathGen2InactiveReasonOther> </runtimeState> EOS end +=end def test_runtime_info - obj = RbVmomi::VIM::VirtualMachineRuntimeInfo( + obj = VIM::VirtualMachineRuntimeInfo( bootTime: Time.parse('2010-08-20 05:44:35 UTC'), connectionState: "connected", - device: [RbVmomi::VIM::VirtualMachineDeviceRuntimeInfo( - dynamicProperty: [], - key: 4000, - runtimeState: RbVmomi::VIM::VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeState( - dynamicProperty: [], - vmDirectPathGen2Active: false, - vmDirectPathGen2InactiveReasonOther: [], - vmDirectPathGen2InactiveReasonVm: ["vmNptIncompatibleAdapterType"] - ) - ), - RbVmomi::VIM::VirtualMachineDeviceRuntimeInfo( - dynamicProperty: [], - key: 4001, - runtimeState: RbVmomi::VIM::VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeState( - dynamicProperty: [], - vmDirectPathGen2Active: false, - vmDirectPathGen2InactiveReasonOther: ["vmNptIncompatibleHost"], - vmDirectPathGen2InactiveReasonVm: [] - ) - )], dynamicProperty: [], faultToleranceState: "notConfigured", - host: RbVmomi::VIM::HostSystem(nil, "host-32"), + host: VIM::HostSystem(nil, "host-32"), maxCpuUsage: 5612, maxMemoryUsage: 3072, memoryOverhead: 128671744, numMksConnections: 1, powerState: "poweredOn", @@ -289,24 +259,10 @@ suspendInterval: 0, toolsInstallerMounted: false ) check <<-EOS, obj, 'VirtualMachineRuntimeInfo' -<val xsi:type="VirtualMachineRuntimeInfo" xmlns:xsi="#{RbVmomi::Soap::NS_XSI}"> - <device> - <runtimeState xsi:type="VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeState"> - <vmDirectPathGen2Active>false</vmDirectPathGen2Active> - <vmDirectPathGen2InactiveReasonVm>vmNptIncompatibleAdapterType</vmDirectPathGen2InactiveReasonVm> - </runtimeState> - <key>4000</key> - </device> - <device> - <runtimeState xsi:type="VirtualMachineDeviceRuntimeInfoVirtualEthernetCardRuntimeState"> - <vmDirectPathGen2Active>false</vmDirectPathGen2Active> - <vmDirectPathGen2InactiveReasonOther>vmNptIncompatibleHost</vmDirectPathGen2InactiveReasonOther> - </runtimeState> - <key>4001</key> - </device> +<val xsi:type="VirtualMachineRuntimeInfo" xmlns:xsi="#{VIM::NS_XSI}"> <host type="HostSystem">host-32</host> <connectionState>connected</connectionState> <powerState>poweredOn</powerState> <faultToleranceState>notConfigured</faultToleranceState> <toolsInstallerMounted>false</toolsInstallerMounted>