mirror of
https://github.com/puppetlabs/vmpooler-provider-vsphere.git
synced 2026-01-26 03:18:41 -05:00
Added mock info for guest ip address, fix existing tests, add dns config
This commit is contained in:
parent
c0a23ff0d0
commit
08bc1ed814
2 changed files with 54 additions and 6 deletions
|
|
@ -198,13 +198,24 @@ MockVirtualDiskManager = Object
|
|||
MockVirtualMachine = Struct.new(
|
||||
# https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.VirtualMachine.html
|
||||
# From VirtualMachine
|
||||
:config, :runtime, :snapshot, :summary,
|
||||
:config, :runtime, :snapshot, :summary, :guest,
|
||||
# From ManagedEntity
|
||||
:name,
|
||||
# From RbVmomi::VIM::ManagedEntity
|
||||
# https://github.com/vmware/rbvmomi/blob/master/lib/rbvmomi/vim/ManagedEntity.rb
|
||||
:path
|
||||
)
|
||||
) do
|
||||
# From RbVmomi::VIM::VirtualMachine
|
||||
# https://github.com/ManageIQ/rbvmomi2/blob/59a5904031a0d7558f306e8d2a05001f9b6822de/lib/rbvmomi/vim/VirtualMachine.rb#L20
|
||||
def guest_ip
|
||||
g = self.guest
|
||||
if g.ipAddress
|
||||
g.ipAddress
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
MockVirtualMachineSnapshot = Struct.new(
|
||||
# https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.Snapshot.html
|
||||
|
|
@ -347,6 +358,12 @@ MockVirtualMachineGuestSummary = Struct.new(
|
|||
:hostName
|
||||
)
|
||||
|
||||
MockVirtualMachineGuestInfo = Struct.new(
|
||||
# https://developer.vmware.com/apis/1311/vsphere
|
||||
# From Data Object - GuestInfo(vim.vm.GuestInfo)
|
||||
:ipAddress
|
||||
)
|
||||
|
||||
MockVirtualMachineRuntimeInfo = Struct.new(
|
||||
# https://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/vim.vm.RuntimeInfo.html
|
||||
# From VirtualMachineRuntimeInfo
|
||||
|
|
@ -801,6 +818,7 @@ end
|
|||
def mock_RbVmomi_VIM_VirtualMachine(options = {})
|
||||
options[:snapshot_tree] = nil if options[:snapshot_tree].nil?
|
||||
options[:name] = 'VM' + rand(65536).to_s if options[:name].nil?
|
||||
options[:ip] = '169.254.255.255' if options[:ip].nil?
|
||||
options[:path] = [] if options[:path].nil?
|
||||
|
||||
mock = MockVirtualMachine.new()
|
||||
|
|
@ -810,11 +828,13 @@ def mock_RbVmomi_VIM_VirtualMachine(options = {})
|
|||
mock.summary.runtime = MockVirtualMachineRuntimeInfo.new()
|
||||
mock.summary.guest = MockVirtualMachineGuestSummary.new()
|
||||
mock.runtime = mock.summary.runtime
|
||||
mock.guest = MockVirtualMachineGuestInfo.new()
|
||||
|
||||
mock.name = options[:name]
|
||||
mock.summary.guest.hostName = options[:hostname]
|
||||
mock.runtime.bootTime = options[:boottime]
|
||||
mock.runtime.powerState = options[:powerstate]
|
||||
mock.guest.ipAddress = options[:ip]
|
||||
|
||||
unless options[:snapshot_tree].nil?
|
||||
mock.snapshot = MockVirtualMachineSnapshotInfo.new()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue