diff options
author | Joshua Colson <joshua.colson@gmail.com> | 2019-02-18 08:02:54 -0700 |
---|---|---|
committer | Joshua Colson <joshua.colson@gmail.com> | 2019-02-18 08:02:54 -0700 |
commit | 0ab406d69712a4116b7ec11930bf14131d61b181 (patch) | |
tree | c10dc6eabfaf00ebfbf135336d1942a175633e4d | |
parent | 6983bc2a2e58e06ec2d38f0aa5628140c2f07ef7 (diff) | |
download | ohai-0ab406d69712a4116b7ec11930bf14131d61b181.tar.gz |
fix rubocop complaints
Signed-off-by: Joshua Colson <joshua.colson@gmail.com>
-rw-r--r-- | lib/ohai/plugins/vbox_host.rb | 75 | ||||
-rw-r--r-- | spec/unit/plugins/vbox_host_spec.rb | 442 |
2 files changed, 259 insertions, 258 deletions
diff --git a/lib/ohai/plugins/vbox_host.rb b/lib/ohai/plugins/vbox_host.rb index edb31f2a..4dfeeb2a 100644 --- a/lib/ohai/plugins/vbox_host.rb +++ b/lib/ohai/plugins/vbox_host.rb @@ -15,25 +15,25 @@ # Ohai.plugin(:VboxHost) do - depends 'virtualization' - provides 'vbox' + depends "virtualization" + provides "vbox" # determine if this host is configured with virtualbox or not - # the determination is ultimately controlled by the 'virtualization' plugin + # the determination is ultimately controlled by the "virtualization" plugin def vbox_host? host = false - if !virtualization.nil? && (virtualization['system'] == 'vbox' || virtualization['systems']['vbox'] == 'host') - host = true if which('VBoxManage') + if !virtualization.nil? && (virtualization["system"] == "vbox" || virtualization["systems"]["vbox"] == "host") + host = true if which("VBoxManage") end host end # query virtualbox for each configured vm, as well as - # each guest's individual configuration settings + # each guest"s individual configuration settings def vboxmanage_list_vms vms = Mash.new if vbox_host? - so_cmd = 'VBoxManage list --sorted vms' + so_cmd = "VBoxManage list --sorted vms" logger.trace(so_cmd) so = shell_out(so_cmd) @@ -55,7 +55,7 @@ Ohai.plugin(:VboxHost) do end # query the vminfo for particular guest instance, normalizing - # the fields so that they're not enclosed in double-quotes (") + # the fields so that they"re not enclosed in double-quotes (") def vboxmanage_vminfo(machine_id) vm = Mash.new @@ -67,7 +67,7 @@ Ohai.plugin(:VboxHost) do if so.exitstatus == 0 so.stdout.lines.each do |line| line.chomp! - left, right = line.split('=') + left, right = line.split("=") # remove enclosing quotes, if needed key = @@ -79,7 +79,7 @@ Ohai.plugin(:VboxHost) do end # skip the name attribute since that is the parent key - next if left == 'name' + next if left == "name" # remove enclosing quotes, if needed value = @@ -107,9 +107,10 @@ Ohai.plugin(:VboxHost) do # the keys of each k/v pair are normalized to lowercase def vboxmanage_list_blocks(query_type, name_key) # ignore unrecognized query type - supported_queries = %w( - bridgedifs dhcpservers dvds hdds hostdvds hostfloppies - hostonlyifs natnets ostypes) + supported_queries = %w{ + bridgedifs dhcpservers dvds hdds hostdvds + hostfloppies hostonlyifs natnets ostypes + } return nil unless supported_queries.include? query_type results = Mash.new @@ -122,19 +123,19 @@ Ohai.plugin(:VboxHost) do if so.exitstatus == 0 # break the result into paragraph blocks, on successive newlines - so.stdout.each_line('') do |blk| + so.stdout.each_line("") do |blk| # remove the multiple newlines of each record blk.chomp!.chomp! # initialize a blank record hash record = Mash.new # parse the record block into key/value pairs blk.each_line() do |line| - next unless line.include? ':' + next unless line.include? ":" # split the line into key/value pair - key, right = line.split(':', 2) + key, right = line.split(":", 2) # strip the leading/trailing whitespace if the value is not nil - value = right.nil? ? '' : right.strip + value = right.nil? ? "" : right.strip record[key.downcase] = value end @@ -154,53 +155,53 @@ Ohai.plugin(:VboxHost) do # collect the data for a virtualization host running VirtualBox collect_data(:default) do # vbox = Mash.new - ostypes = 'ostypes' - guests = 'guests' - natnets = 'natnets' - hostonlyifs = 'hostonlyifs' - bridgedifs = 'bridgedifs' - dhcpservers = 'dhcpservers' - hdds = 'hdds' - dvds = 'dvds' - hostdvds = 'hostdvds' - hostfloppies = 'hostfloppies' + ostypes = "ostypes" + guests = "guests" + natnets = "natnets" + hostonlyifs = "hostonlyifs" + bridgedifs = "bridgedifs" + dhcpservers = "dhcpservers" + hdds = "hdds" + dvds = "dvds" + hostdvds = "hostdvds" + hostfloppies = "hostfloppies" if vbox_host? # virtualization[vbox] = Mash.new unless virtualization[vbox] vbox Mash.new unless vbox # get a list of virtualbox virtual hard disk drives - vbox[ostypes] = vboxmanage_list_blocks(ostypes, 'ID') + vbox[ostypes] = vboxmanage_list_blocks(ostypes, "ID") # get a list of virtualbox guest vms vbox[guests] = vboxmanage_list_vms # get a list of virtualbox virtual hard disk drives - vbox[hdds] = vboxmanage_list_blocks(hdds, 'Location') + vbox[hdds] = vboxmanage_list_blocks(hdds, "Location") # get a list of virtualbox virtual dvd drives - vbox[dvds] = vboxmanage_list_blocks(dvds, 'Location') + vbox[dvds] = vboxmanage_list_blocks(dvds, "Location") # get a list of virtualbox host dvd drives - vbox[hostdvds] = vboxmanage_list_blocks(hostdvds, 'Name') + vbox[hostdvds] = vboxmanage_list_blocks(hostdvds, "Name") # get a list of virtualbox host floppy drives - vbox[hostfloppies] = vboxmanage_list_blocks(hostfloppies, 'Name') + vbox[hostfloppies] = vboxmanage_list_blocks(hostfloppies, "Name") # get a list of virtualbox hostonly network interfaces - vbox[hostonlyifs] = vboxmanage_list_blocks(hostonlyifs, 'Name') + vbox[hostonlyifs] = vboxmanage_list_blocks(hostonlyifs, "Name") # get a list of virtualbox bridged network interfaces - vbox[bridgedifs] = vboxmanage_list_blocks(bridgedifs, 'Name') + vbox[bridgedifs] = vboxmanage_list_blocks(bridgedifs, "Name") # get a list of virtualbox dhcp servers - vbox[dhcpservers] = vboxmanage_list_blocks(dhcpservers, 'NetworkName') + vbox[dhcpservers] = vboxmanage_list_blocks(dhcpservers, "NetworkName") # get a list of virtualbox nat networks - vbox[natnets] = vboxmanage_list_blocks(natnets, 'NetworkName') + vbox[natnets] = vboxmanage_list_blocks(natnets, "NetworkName") end vbox rescue Ohai::Exceptions::Exec - logger.trace('Plugin VboxHost: Could not collect data for VirtualBox host. Skipping data') + logger.trace("Plugin VboxHost: Could not collect data for VirtualBox host. Skipping data") end end diff --git a/spec/unit/plugins/vbox_host_spec.rb b/spec/unit/plugins/vbox_host_spec.rb index 725a1ac8..da623349 100644 --- a/spec/unit/plugins/vbox_host_spec.rb +++ b/spec/unit/plugins/vbox_host_spec.rb @@ -16,190 +16,190 @@ require_relative "../../spec_helper.rb" vbox_list_ostypes_stdout = <<~EOF -ID: Other -Description: Other/Unknown -Family ID: Other -Family Desc: Other -64 bit: false + ID: Other + Description: Other/Unknown + Family ID: Other + Family Desc: Other + 64 bit: false -ID: Other_64 -Description: Other/Unknown (64-bit) -Family ID: Other -Family Desc: Other -64 bit: true + ID: Other_64 + Description: Other/Unknown (64-bit) + Family ID: Other + Family Desc: Other + 64 bit: true -ID: Windows31 -Description: Windows 3.1 -Family ID: Windows -Family Desc: Microsoft Windows -64 bit: false + ID: Windows31 + Description: Windows 3.1 + Family ID: Windows + Family Desc: Microsoft Windows + 64 bit: false EOF vbox_list_vms_stdout = <<~EOF -"ubuntu-18.04-amd64_1549746024485_35372" {6294f16b-4f05-4430-afb9-773bdb237aec} + "ubuntu-18.04-amd64_1549746024485_35372" {6294f16b-4f05-4430-afb9-773bdb237aec} EOF vbox_vminfo_stdout = <<~EOF -name="ubuntu-18.04-amd64_1549746024485_35372" -groups="/" -ostype="Ubuntu (64-bit)" -UUID="6294f16b-4f05-4430-afb9-773bdb237aec" -CfgFile="/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/ubuntu-18.04-amd64_1549746024485_35372.vbox" -SnapFldr="/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots" -LogFldr="/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Logs" -hardwareuuid="6294f16b-4f05-4430-afb9-773bdb237aec" -memory=1024 -pagefusion="off" -vram=8 -cpuexecutioncap=100 -hpet="off" -chipset="piix3" -firmware="BIOS" -cpus=1 -pae="on" -longmode="on" -triplefaultreset="off" -apic="on" -x2apic="on" -cpuid-portability-level=0 -bootmenu="messageandmenu" -boot1="disk" -boot2="dvd" -boot3="none" -boot4="none" -acpi="on" -ioapic="on" -biosapic="apic" -biossystemtimeoffset=0 -rtcuseutc="off" -hwvirtex="on" -nestedpaging="on" -largepages="on" -vtxvpid="on" -vtxux="on" -paravirtprovider="default" -effparavirtprovider="kvm" -VMState="poweroff" -VMStateChangeTime="2019-02-09T21:00:33.575000000" -monitorcount=1 -accelerate3d="off" -accelerate2dvideo="off" -teleporterenabled="off" -teleporterport=0 -teleporteraddress="" -teleporterpassword="" -tracing-enabled="off" -tracing-allow-vm-access="off" -tracing-config="" -autostart-enabled="off" -autostart-delay=0 -defaultfrontend="" -storagecontrollername0="IDE Controller" -storagecontrollertype0="PIIX4" -storagecontrollerinstance0="0" -storagecontrollermaxportcount0="2" -storagecontrollerportcount0="2" -storagecontrollerbootable0="on" -storagecontrollername1="SATA Controller" -storagecontrollertype1="IntelAhci" -storagecontrollerinstance1="0" -storagecontrollermaxportcount1="30" -storagecontrollerportcount1="1" -storagecontrollerbootable1="on" -"IDE Controller-0-0"="none" -"IDE Controller-0-1"="none" -"IDE Controller-1-0"="none" -"IDE Controller-1-1"="none" -"SATA Controller-0-0"="/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots/{1c182745-4b09-41a1-a147-d3ced46f72f6}.vmdk" -"SATA Controller-ImageUUID-0-0"="1c182745-4b09-41a1-a147-d3ced46f72f6" -natnet1="nat" -macaddress1="080027E5FA8F" -cableconnected1="on" -nic1="nat" -nictype1="82540EM" -nicspeed1="0" -mtu="0" -sockSnd="64" -sockRcv="64" -tcpWndSnd="64" -tcpWndRcv="64" -nic2="none" -nic3="none" -nic4="none" -nic5="none" -nic6="none" -nic7="none" -nic8="none" -hidpointing="ps2mouse" -hidkeyboard="ps2kbd" -uart1="off" -uart2="off" -uart3="off" -uart4="off" -lpt1="off" -lpt2="off" -audio="pulse" -audio_in="false" -audio_out="false" -clipboard="disabled" -draganddrop="disabled" -vrde="on" -vrdeport=-1 -vrdeports="5947" -vrdeaddress="127.0.0.1" -vrdeauthtype="null" -vrdemulticon="off" -vrdereusecon="off" -vrdevideochannel="off" -vrdeproperty[TCP/Ports]="5947" -vrdeproperty[TCP/Address]="127.0.0.1" -usb="off" -ehci="off" -xhci="off" -GuestMemoryBalloon=0 -SnapshotName="base" -SnapshotUUID="085cbbec-70cd-4864-9208-5d938dcabb71" -CurrentSnapshotName="base" -CurrentSnapshotUUID="085cbbec-70cd-4864-9208-5d938dcabb71" -CurrentSnapshotNode="SnapshotName" + name="ubuntu-18.04-amd64_1549746024485_35372" + groups="/" + ostype="Ubuntu (64-bit)" + UUID="6294f16b-4f05-4430-afb9-773bdb237aec" + CfgFile="/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/ubuntu-18.04-amd64_1549746024485_35372.vbox" + SnapFldr="/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots" + LogFldr="/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Logs" + hardwareuuid="6294f16b-4f05-4430-afb9-773bdb237aec" + memory=1024 + pagefusion="off" + vram=8 + cpuexecutioncap=100 + hpet="off" + chipset="piix3" + firmware="BIOS" + cpus=1 + pae="on" + longmode="on" + triplefaultreset="off" + apic="on" + x2apic="on" + cpuid-portability-level=0 + bootmenu="messageandmenu" + boot1="disk" + boot2="dvd" + boot3="none" + boot4="none" + acpi="on" + ioapic="on" + biosapic="apic" + biossystemtimeoffset=0 + rtcuseutc="off" + hwvirtex="on" + nestedpaging="on" + largepages="on" + vtxvpid="on" + vtxux="on" + paravirtprovider="default" + effparavirtprovider="kvm" + VMState="poweroff" + VMStateChangeTime="2019-02-09T21:00:33.575000000" + monitorcount=1 + accelerate3d="off" + accelerate2dvideo="off" + teleporterenabled="off" + teleporterport=0 + teleporteraddress="" + teleporterpassword="" + tracing-enabled="off" + tracing-allow-vm-access="off" + tracing-config="" + autostart-enabled="off" + autostart-delay=0 + defaultfrontend="" + storagecontrollername0="IDE Controller" + storagecontrollertype0="PIIX4" + storagecontrollerinstance0="0" + storagecontrollermaxportcount0="2" + storagecontrollerportcount0="2" + storagecontrollerbootable0="on" + storagecontrollername1="SATA Controller" + storagecontrollertype1="IntelAhci" + storagecontrollerinstance1="0" + storagecontrollermaxportcount1="30" + storagecontrollerportcount1="1" + storagecontrollerbootable1="on" + "IDE Controller-0-0"="none" + "IDE Controller-0-1"="none" + "IDE Controller-1-0"="none" + "IDE Controller-1-1"="none" + "SATA Controller-0-0"="/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots/{1c182745-4b09-41a1-a147-d3ced46f72f6}.vmdk" + "SATA Controller-ImageUUID-0-0"="1c182745-4b09-41a1-a147-d3ced46f72f6" + natnet1="nat" + macaddress1="080027E5FA8F" + cableconnected1="on" + nic1="nat" + nictype1="82540EM" + nicspeed1="0" + mtu="0" + sockSnd="64" + sockRcv="64" + tcpWndSnd="64" + tcpWndRcv="64" + nic2="none" + nic3="none" + nic4="none" + nic5="none" + nic6="none" + nic7="none" + nic8="none" + hidpointing="ps2mouse" + hidkeyboard="ps2kbd" + uart1="off" + uart2="off" + uart3="off" + uart4="off" + lpt1="off" + lpt2="off" + audio="pulse" + audio_in="false" + audio_out="false" + clipboard="disabled" + draganddrop="disabled" + vrde="on" + vrdeport=-1 + vrdeports="5947" + vrdeaddress="127.0.0.1" + vrdeauthtype="null" + vrdemulticon="off" + vrdereusecon="off" + vrdevideochannel="off" + vrdeproperty[TCP/Ports]="5947" + vrdeproperty[TCP/Address]="127.0.0.1" + usb="off" + ehci="off" + xhci="off" + GuestMemoryBalloon=0 + SnapshotName="base" + SnapshotUUID="085cbbec-70cd-4864-9208-5d938dcabb71" + CurrentSnapshotName="base" + CurrentSnapshotUUID="085cbbec-70cd-4864-9208-5d938dcabb71" + CurrentSnapshotNode="SnapshotName" EOF vbox_list_hdds_stdout = <<~EOF -UUID: ebb6dca0-879f-480b-a50e-9efe330bd021 -Parent UUID: base -State: locked read -Type: normal (base) -Location: /virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/ubuntu-18.04-amd64-disk001.vmdk -Storage format: VMDK -Capacity: 65536 MBytes -Encryption: disabled + UUID: ebb6dca0-879f-480b-a50e-9efe330bd021 + Parent UUID: base + State: locked read + Type: normal (base) + Location: /virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/ubuntu-18.04-amd64-disk001.vmdk + Storage format: VMDK + Capacity: 65536 MBytes + Encryption: disabled -UUID: 1c182745-4b09-41a1-a147-d3ced46f72f6 -Parent UUID: ebb6dca0-879f-480b-a50e-9efe330bd021 -State: created -Type: normal (differencing) -Location: /virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots/{1c182745-4b09-41a1-a147-d3ced46f72f6}.vmdk -Storage format: VMDK -Capacity: 65536 MBytes -Encryption: disabled + UUID: 1c182745-4b09-41a1-a147-d3ced46f72f6 + Parent UUID: ebb6dca0-879f-480b-a50e-9efe330bd021 + State: created + Type: normal (differencing) + Location: /virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots/{1c182745-4b09-41a1-a147-d3ced46f72f6}.vmdk + Storage format: VMDK + Capacity: 65536 MBytes + Encryption: disabled EOF vbox_list_dvds_stdout = <<~EOF -UUID: 897aa7bc-1ec1-4e13-a16d-101d3716c72d -State: created -Type: normal (base) -Location: /tmp/test.dvd -Storage format: RAW -Capacity: 100 MBytes -Encryption: disabled + UUID: 897aa7bc-1ec1-4e13-a16d-101d3716c72d + State: created + Type: normal (base) + Location: /tmp/test.dvd + Storage format: RAW + Capacity: 100 MBytes + Encryption: disabled EOF vbox_list_hostdvds_stdout = <<~EOF -UUID: 00445644-0000-0000-2f64-65762f737230 -Name: /dev/sr0 + UUID: 00445644-0000-0000-2f64-65762f737230 + Name: /dev/sr0 EOF @@ -208,82 +208,82 @@ vbox_list_hostfloppies_stdout = <<~EOF EOF vbox_list_hostonlyifs_stdout = <<~EOF -Name: vboxnet0 -GUID: 786f6276-656e-4074-8000-0a0027000000 -DHCP: Disabled -IPAddress: 192.168.33.1 -NetworkMask: 255.255.255.0 -IPV6Address: -IPV6NetworkMaskPrefixLength: 0 -HardwareAddress: 0a:00:27:00:00:00 -MediumType: Ethernet -Wireless: No -Status: Down -VBoxNetworkName: HostInterfaceNetworking-vboxnet0 + Name: vboxnet0 + GUID: 786f6276-656e-4074-8000-0a0027000000 + DHCP: Disabled + IPAddress: 192.168.33.1 + NetworkMask: 255.255.255.0 + IPV6Address: + IPV6NetworkMaskPrefixLength: 0 + HardwareAddress: 0a:00:27:00:00:00 + MediumType: Ethernet + Wireless: No + Status: Down + VBoxNetworkName: HostInterfaceNetworking-vboxnet0 -Name: vboxnet1 -GUID: 786f6276-656e-4174-8000-0a0027000001 -DHCP: Disabled -IPAddress: 192.168.19.1 -NetworkMask: 255.255.255.0 -IPV6Address: fe80::800:27ff:fe00:1 -IPV6NetworkMaskPrefixLength: 64 -HardwareAddress: 0a:00:27:00:00:01 -MediumType: Ethernet -Wireless: No -Status: Up -VBoxNetworkName: HostInterfaceNetworking-vboxnet1 + Name: vboxnet1 + GUID: 786f6276-656e-4174-8000-0a0027000001 + DHCP: Disabled + IPAddress: 192.168.19.1 + NetworkMask: 255.255.255.0 + IPV6Address: fe80::800:27ff:fe00:1 + IPV6NetworkMaskPrefixLength: 64 + HardwareAddress: 0a:00:27:00:00:01 + MediumType: Ethernet + Wireless: No + Status: Up + VBoxNetworkName: HostInterfaceNetworking-vboxnet1 EOF vbox_list_bridgedifs_stdout = <<~EOF -Name: eno1 -GUID: 316f6e65-0000-4000-8000-309c233b62a9 -DHCP: Disabled -IPAddress: 10.143.72.133 -NetworkMask: 255.255.255.224 -IPV6Address: fe80::9226:82e9:1101:60e6 -IPV6NetworkMaskPrefixLength: 64 -HardwareAddress: 30:9c:23:3b:62:a9 -MediumType: Ethernet -Wireless: No -Status: Up -VBoxNetworkName: HostInterfaceNetworking-eno1 + Name: eno1 + GUID: 316f6e65-0000-4000-8000-309c233b62a9 + DHCP: Disabled + IPAddress: 10.143.72.133 + NetworkMask: 255.255.255.224 + IPV6Address: fe80::9226:82e9:1101:60e6 + IPV6NetworkMaskPrefixLength: 64 + HardwareAddress: 30:9c:23:3b:62:a9 + MediumType: Ethernet + Wireless: No + Status: Up + VBoxNetworkName: HostInterfaceNetworking-eno1 EOF vbox_list_dhcpservers_stdout = <<~EOF -NetworkName: HostInterfaceNetworking-vboxnet0 -IP: 192.168.56.100 -NetworkMask: 255.255.255.0 -lowerIPAddress: 192.168.56.101 -upperIPAddress: 192.168.56.254 -Enabled: Yes + NetworkName: HostInterfaceNetworking-vboxnet0 + IP: 192.168.56.100 + NetworkMask: 255.255.255.0 + lowerIPAddress: 192.168.56.101 + upperIPAddress: 192.168.56.254 + Enabled: Yes -NetworkName: HostInterfaceNetworking-vboxnet1 -IP: 192.168.19.2 -NetworkMask: 255.255.255.0 -lowerIPAddress: 192.168.19.3 -upperIPAddress: 192.168.19.254 -Enabled: Yes + NetworkName: HostInterfaceNetworking-vboxnet1 + IP: 192.168.19.2 + NetworkMask: 255.255.255.0 + lowerIPAddress: 192.168.19.3 + upperIPAddress: 192.168.19.254 + Enabled: Yes EOF # output of: VBoxManage list --sorted natnets vbox_list_natnets_stdout = <<~EOF -NetworkName: NatNetwork -IP: 10.0.2.1 -Network: 10.0.2.0/24 -IPv6 Enabled: No -IPv6 Prefix: fd17:625c:f037:2::/64 -DHCP Enabled: Yes -Enabled: Yes -loopback mappings (ipv4) - 127.0.0.1=2 + NetworkName: NatNetwork + IP: 10.0.2.1 + Network: 10.0.2.0/24 + IPv6 Enabled: No + IPv6 Prefix: fd17:625c:f037:2::/64 + DHCP Enabled: Yes + Enabled: Yes + loopback mappings (ipv4) + 127.0.0.1=2 EOF -expected_output = {"ostypes"=>{"Other"=>{"description"=>"Other/Unknown", "family id"=>"Other", "family desc"=>"Other", "64 bit"=>"false"}, "Other_64"=>{"description"=>"Other/Unknown (64-bit)", "family id"=>"Other", "family desc"=>"Other", "64 bit"=>"true"}, "Windows31"=>{"description"=>"Windows 3.1", "family id"=>"Windows", "family desc"=>"Microsoft Windows", "64 bit"=>"false"}}, "guests"=>{"ubuntu-18.04-amd64_1549746024485_35372"=>{"groups"=>"/", "ostype"=>"Ubuntu (64-bit)", "uuid"=>"6294f16b-4f05-4430-afb9-773bdb237aec", "cfgfile"=>"/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/ubuntu-18.04-amd64_1549746024485_35372.vbox", "snapfldr"=>"/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots", "logfldr"=>"/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Logs", "hardwareuuid"=>"6294f16b-4f05-4430-afb9-773bdb237aec", "memory"=>"1024", "pagefusion"=>"off", "vram"=>"8", "cpuexecutioncap"=>"100", "hpet"=>"off", "chipset"=>"piix3", "firmware"=>"BIOS", "cpus"=>"1", "pae"=>"on", "longmode"=>"on", "triplefaultreset"=>"off", "apic"=>"on", "x2apic"=>"on", "cpuid-portability-level"=>"0", "bootmenu"=>"messageandmenu", "boot1"=>"disk", "boot2"=>"dvd", "boot3"=>"none", "boot4"=>"none", "acpi"=>"on", "ioapic"=>"on", "biosapic"=>"apic", "biossystemtimeoffset"=>"0", "rtcuseutc"=>"off", "hwvirtex"=>"on", "nestedpaging"=>"on", "largepages"=>"on", "vtxvpid"=>"on", "vtxux"=>"on", "paravirtprovider"=>"default", "effparavirtprovider"=>"kvm", "vmstate"=>"poweroff", "vmstatechangetime"=>"2019-02-09T21:00:33.575000000", "monitorcount"=>"1", "accelerate3d"=>"off", "accelerate2dvideo"=>"off", "teleporterenabled"=>"off", "teleporterport"=>"0", "teleporteraddress"=>"", "teleporterpassword"=>"", "tracing-enabled"=>"off", "tracing-allow-vm-access"=>"off", "tracing-config"=>"", "autostart-enabled"=>"off", "autostart-delay"=>"0", "defaultfrontend"=>"", "storagecontrollername0"=>"IDE Controller", "storagecontrollertype0"=>"PIIX4", "storagecontrollerinstance0"=>"0", "storagecontrollermaxportcount0"=>"2", "storagecontrollerportcount0"=>"2", "storagecontrollerbootable0"=>"on", "storagecontrollername1"=>"SATA Controller", "storagecontrollertype1"=>"IntelAhci", "storagecontrollerinstance1"=>"0", "storagecontrollermaxportcount1"=>"30", "storagecontrollerportcount1"=>"1", "storagecontrollerbootable1"=>"on", "ide controller-0-0"=>"none", "ide controller-0-1"=>"none", "ide controller-1-0"=>"none", "ide controller-1-1"=>"none", "sata controller-0-0"=>"/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots/{1c182745-4b09-41a1-a147-d3ced46f72f6}.vmdk", "sata controller-imageuuid-0-0"=>"1c182745-4b09-41a1-a147-d3ced46f72f6", "natnet1"=>"nat", "macaddress1"=>"080027E5FA8F", "cableconnected1"=>"on", "nic1"=>"nat", "nictype1"=>"82540EM", "nicspeed1"=>"0", "mtu"=>"0", "socksnd"=>"64", "sockrcv"=>"64", "tcpwndsnd"=>"64", "tcpwndrcv"=>"64", "nic2"=>"none", "nic3"=>"none", "nic4"=>"none", "nic5"=>"none", "nic6"=>"none", "nic7"=>"none", "nic8"=>"none", "hidpointing"=>"ps2mouse", "hidkeyboard"=>"ps2kbd", "uart1"=>"off", "uart2"=>"off", "uart3"=>"off", "uart4"=>"off", "lpt1"=>"off", "lpt2"=>"off", "audio"=>"pulse", "audio_in"=>"false", "audio_out"=>"false", "clipboard"=>"disabled", "draganddrop"=>"disabled", "vrde"=>"on", "vrdeport"=>"-1", "vrdeports"=>"5947", "vrdeaddress"=>"127.0.0.1", "vrdeauthtype"=>"null", "vrdemulticon"=>"off", "vrdereusecon"=>"off", "vrdevideochannel"=>"off", "vrdeproperty[tcp/ports]"=>"5947", "vrdeproperty[tcp/address]"=>"127.0.0.1", "usb"=>"off", "ehci"=>"off", "xhci"=>"off", "guestmemoryballoon"=>"0", "snapshotname"=>"base", "snapshotuuid"=>"085cbbec-70cd-4864-9208-5d938dcabb71", "currentsnapshotname"=>"base", "currentsnapshotuuid"=>"085cbbec-70cd-4864-9208-5d938dcabb71", "currentsnapshotnode"=>"SnapshotName"}}, "hdds"=>{"/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/ubuntu-18.04-amd64-disk001.vmdk"=>{"uuid"=>"ebb6dca0-879f-480b-a50e-9efe330bd021", "parent uuid"=>"base", "state"=>"locked read", "type"=>"normal (base)", "storage format"=>"VMDK", "capacity"=>"65536 MBytes", "encryption"=>"disabled"}, "/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots/{1c182745-4b09-41a1-a147-d3ced46f72f6}.vmdk"=>{"uuid"=>"1c182745-4b09-41a1-a147-d3ced46f72f6", "parent uuid"=>"ebb6dca0-879f-480b-a50e-9efe330bd021", "state"=>"created", "type"=>"normal (differencing)", "storage format"=>"VMDK", "capacity"=>"65536 MBytes", "encryption"=>"disabled"}}, "dvds"=>{"/tmp/test.dvd"=>{"uuid"=>"897aa7bc-1ec1-4e13-a16d-101d3716c72d", "state"=>"created", "type"=>"normal (base)", "storage format"=>"RAW", "capacity"=>"100 MBytes", "encryption"=>"disabled"}}, "hostdvds"=>{"/dev/sr0"=>{"uuid"=>"00445644-0000-0000-2f64-65762f737230"}}, "hostfloppies"=>{}, "hostonlyifs"=>{"vboxnet0"=>{"guid"=>"786f6276-656e-4074-8000-0a0027000000", "dhcp"=>"Disabled", "ipaddress"=>"192.168.33.1", "networkmask"=>"255.255.255.0", "ipv6address"=>"", "ipv6networkmaskprefixlength"=>"0", "hardwareaddress"=>"0a:00:27:00:00:00", "mediumtype"=>"Ethernet", "wireless"=>"No", "status"=>"Down", "vboxnetworkname"=>"HostInterfaceNetworking-vboxnet0"}, "vboxnet1"=>{"guid"=>"786f6276-656e-4174-8000-0a0027000001", "dhcp"=>"Disabled", "ipaddress"=>"192.168.19.1", "networkmask"=>"255.255.255.0", "ipv6address"=>"fe80::800:27ff:fe00:1", "ipv6networkmaskprefixlength"=>"64", "hardwareaddress"=>"0a:00:27:00:00:01", "mediumtype"=>"Ethernet", "wireless"=>"No", "status"=>"Up", "vboxnetworkname"=>"HostInterfaceNetworking-vboxnet1"}}, "bridgedifs"=>{"eno1"=>{"guid"=>"316f6e65-0000-4000-8000-309c233b62a9", "dhcp"=>"Disabled", "ipaddress"=>"10.143.72.133", "networkmask"=>"255.255.255.224", "ipv6address"=>"fe80::9226:82e9:1101:60e6", "ipv6networkmaskprefixlength"=>"64", "hardwareaddress"=>"30:9c:23:3b:62:a9", "mediumtype"=>"Ethernet", "wireless"=>"No", "status"=>"Up", "vboxnetworkname"=>"HostInterfaceNetworking-eno1"}}, "dhcpservers"=>{"HostInterfaceNetworking-vboxnet0"=>{"ip"=>"192.168.56.100", "networkmask"=>"255.255.255.0", "loweripaddress"=>"192.168.56.101", "upperipaddress"=>"192.168.56.254", "enabled"=>"Yes"}, "HostInterfaceNetworking-vboxnet1"=>{"ip"=>"192.168.19.2", "networkmask"=>"255.255.255.0", "loweripaddress"=>"192.168.19.3", "upperipaddress"=>"192.168.19.254", "enabled"=>"Yes"}}, "natnets"=>{"NatNetwork"=>{"ip"=>"10.0.2.1", "network"=>"10.0.2.0/24", "ipv6 enabled"=>"No", "ipv6 prefix"=>"fd17:625c:f037:2::/64", "dhcp enabled"=>"Yes", "enabled"=>"Yes"}}} +expected_output = { "ostypes" => { "Other" => { "description" => "Other/Unknown", "family id" => "Other", "family desc" => "Other", "64 bit" => "false" }, "Other_64" => { "description" => "Other/Unknown (64-bit)", "family id" => "Other", "family desc" => "Other", "64 bit" => "true" }, "Windows31" => { "description" => "Windows 3.1", "family id" => "Windows", "family desc" => "Microsoft Windows", "64 bit" => "false" } }, "guests" => { "ubuntu-18.04-amd64_1549746024485_35372" => { "groups" => "/", "ostype" => "Ubuntu (64-bit)", "uuid" => "6294f16b-4f05-4430-afb9-773bdb237aec", "cfgfile" => "/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/ubuntu-18.04-amd64_1549746024485_35372.vbox", "snapfldr" => "/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots", "logfldr" => "/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Logs", "hardwareuuid" => "6294f16b-4f05-4430-afb9-773bdb237aec", "memory" => "1024", "pagefusion" => "off", "vram" => "8", "cpuexecutioncap" => "100", "hpet" => "off", "chipset" => "piix3", "firmware" => "BIOS", "cpus" => "1", "pae" => "on", "longmode" => "on", "triplefaultreset" => "off", "apic" => "on", "x2apic" => "on", "cpuid-portability-level" => "0", "bootmenu" => "messageandmenu", "boot1" => "disk", "boot2" => "dvd", "boot3" => "none", "boot4" => "none", "acpi" => "on", "ioapic" => "on", "biosapic" => "apic", "biossystemtimeoffset" => "0", "rtcuseutc" => "off", "hwvirtex" => "on", "nestedpaging" => "on", "largepages" => "on", "vtxvpid" => "on", "vtxux" => "on", "paravirtprovider" => "default", "effparavirtprovider" => "kvm", "vmstate" => "poweroff", "vmstatechangetime" => "2019-02-09T21:00:33.575000000", "monitorcount" => "1", "accelerate3d" => "off", "accelerate2dvideo" => "off", "teleporterenabled" => "off", "teleporterport" => "0", "teleporteraddress" => "", "teleporterpassword" => "", "tracing-enabled" => "off", "tracing-allow-vm-access" => "off", "tracing-config" => "", "autostart-enabled" => "off", "autostart-delay" => "0", "defaultfrontend" => "", "storagecontrollername0" => "IDE Controller", "storagecontrollertype0" => "PIIX4", "storagecontrollerinstance0" => "0", "storagecontrollermaxportcount0" => "2", "storagecontrollerportcount0" => "2", "storagecontrollerbootable0" => "on", "storagecontrollername1" => "SATA Controller", "storagecontrollertype1" => "IntelAhci", "storagecontrollerinstance1" => "0", "storagecontrollermaxportcount1" => "30", "storagecontrollerportcount1" => "1", "storagecontrollerbootable1" => "on", "ide controller-0-0" => "none", "ide controller-0-1" => "none", "ide controller-1-0" => "none", "ide controller-1-1" => "none", "sata controller-0-0" => "/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots/{1c182745-4b09-41a1-a147-d3ced46f72f6}.vmdk", "sata controller-imageuuid-0-0" => "1c182745-4b09-41a1-a147-d3ced46f72f6", "natnet1" => "nat", "macaddress1" => "080027E5FA8F", "cableconnected1" => "on", "nic1" => "nat", "nictype1" => "82540EM", "nicspeed1" => "0", "mtu" => "0", "socksnd" => "64", "sockrcv" => "64", "tcpwndsnd" => "64", "tcpwndrcv" => "64", "nic2" => "none", "nic3" => "none", "nic4" => "none", "nic5" => "none", "nic6" => "none", "nic7" => "none", "nic8" => "none", "hidpointing" => "ps2mouse", "hidkeyboard" => "ps2kbd", "uart1" => "off", "uart2" => "off", "uart3" => "off", "uart4" => "off", "lpt1" => "off", "lpt2" => "off", "audio" => "pulse", "audio_in" => "false", "audio_out" => "false", "clipboard" => "disabled", "draganddrop" => "disabled", "vrde" => "on", "vrdeport" => "-1", "vrdeports" => "5947", "vrdeaddress" => "127.0.0.1", "vrdeauthtype" => "null", "vrdemulticon" => "off", "vrdereusecon" => "off", "vrdevideochannel" => "off", "vrdeproperty[tcp/ports]" => "5947", "vrdeproperty[tcp/address]" => "127.0.0.1", "usb" => "off", "ehci" => "off", "xhci" => "off", "guestmemoryballoon" => "0", "snapshotname" => "base", "snapshotuuid" => "085cbbec-70cd-4864-9208-5d938dcabb71", "currentsnapshotname" => "base", "currentsnapshotuuid" => "085cbbec-70cd-4864-9208-5d938dcabb71", "currentsnapshotnode" => "SnapshotName" } }, "hdds" => { "/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/ubuntu-18.04-amd64-disk001.vmdk" => { "uuid" => "ebb6dca0-879f-480b-a50e-9efe330bd021", "parent uuid" => "base", "state" => "locked read", "type" => "normal (base)", "storage format" => "VMDK", "capacity" => "65536 MBytes", "encryption" => "disabled" }, "/virtual/machines/ubuntu-18.04-amd64_1549746024485_35372/Snapshots/{1c182745-4b09-41a1-a147-d3ced46f72f6}.vmdk" => { "uuid" => "1c182745-4b09-41a1-a147-d3ced46f72f6", "parent uuid" => "ebb6dca0-879f-480b-a50e-9efe330bd021", "state" => "created", "type" => "normal (differencing)", "storage format" => "VMDK", "capacity" => "65536 MBytes", "encryption" => "disabled" } }, "dvds" => { "/tmp/test.dvd" => { "uuid" => "897aa7bc-1ec1-4e13-a16d-101d3716c72d", "state" => "created", "type" => "normal (base)", "storage format" => "RAW", "capacity" => "100 MBytes", "encryption" => "disabled" } }, "hostdvds" => { "/dev/sr0" => { "uuid" => "00445644-0000-0000-2f64-65762f737230" } }, "hostfloppies" => {}, "hostonlyifs" => { "vboxnet0" => { "guid" => "786f6276-656e-4074-8000-0a0027000000", "dhcp" => "Disabled", "ipaddress" => "192.168.33.1", "networkmask" => "255.255.255.0", "ipv6address" => "", "ipv6networkmaskprefixlength" => "0", "hardwareaddress" => "0a:00:27:00:00:00", "mediumtype" => "Ethernet", "wireless" => "No", "status" => "Down", "vboxnetworkname" => "HostInterfaceNetworking-vboxnet0" }, "vboxnet1" => { "guid" => "786f6276-656e-4174-8000-0a0027000001", "dhcp" => "Disabled", "ipaddress" => "192.168.19.1", "networkmask" => "255.255.255.0", "ipv6address" => "fe80::800:27ff:fe00:1", "ipv6networkmaskprefixlength" => "64", "hardwareaddress" => "0a:00:27:00:00:01", "mediumtype" => "Ethernet", "wireless" => "No", "status" => "Up", "vboxnetworkname" => "HostInterfaceNetworking-vboxnet1" } }, "bridgedifs" => { "eno1" => { "guid" => "316f6e65-0000-4000-8000-309c233b62a9", "dhcp" => "Disabled", "ipaddress" => "10.143.72.133", "networkmask" => "255.255.255.224", "ipv6address" => "fe80::9226:82e9:1101:60e6", "ipv6networkmaskprefixlength" => "64", "hardwareaddress" => "30:9c:23:3b:62:a9", "mediumtype" => "Ethernet", "wireless" => "No", "status" => "Up", "vboxnetworkname" => "HostInterfaceNetworking-eno1" } }, "dhcpservers" => { "HostInterfaceNetworking-vboxnet0" => { "ip" => "192.168.56.100", "networkmask" => "255.255.255.0", "loweripaddress" => "192.168.56.101", "upperipaddress" => "192.168.56.254", "enabled" => "Yes" }, "HostInterfaceNetworking-vboxnet1" => { "ip" => "192.168.19.2", "networkmask" => "255.255.255.0", "loweripaddress" => "192.168.19.3", "upperipaddress" => "192.168.19.254", "enabled" => "Yes" } }, "natnets" => { "NatNetwork" => { "ip" => "10.0.2.1", "network" => "10.0.2.0/24", "ipv6 enabled" => "No", "ipv6 prefix" => "fd17:625c:f037:2::/64", "dhcp enabled" => "Yes", "enabled" => "Yes" } } } describe Ohai::System, "plugin vbox_host" do let(:plugin) { get_plugin("vbox_host") } |