1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/compute/models/virtual_box/network_adapters.rb

42 lines
1 KiB
Ruby

require 'fog/core/collection'
require 'fog/compute/models/virtual_box/network_adapter'
module Fog
module Compute
class VirtualBox
class NetworkAdapters < Fog::Collection
model Fog::Compute::VirtualBox::NetworkAdapter
attr_accessor :machine
def all
requires :machine
data = []
raw_machine = machine.instance_variable_get(:@raw)
connection.system_properties.network_adapter_count.times do |index|
data << {
:raw => raw_machine.get_network_adapter(index)
}
end
load(data)
end
def get(network_adapter_slot)
requires :machine
raw_machine = machine.instance_variable_get(:@raw)
network_adapter = raw_machine.get_network_adapter(network_adapter_slot)
new(:raw => network_adapter)
end
def new(attributes = {})
requires :machine
super({ :machine => machine }.merge!(attributes))
end
end
end
end
end