mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
9d78d29a19
* moved to using requests * added vm nic/nics * kept compatability with the existing interfaces * moved util classes into util subdir Signed-off-by: Amos Benari <abenari@redhat.com>
54 lines
1.2 KiB
Ruby
54 lines
1.2 KiB
Ruby
require 'fog/core/model'
|
|
|
|
module Fog
|
|
module Compute
|
|
class Libvirt
|
|
|
|
class Nic < Fog::Model
|
|
|
|
identity :mac
|
|
attribute :type
|
|
attribute :network
|
|
attribute :bridge
|
|
attribute :model
|
|
|
|
attr_accessor :server
|
|
|
|
TYPES = ["network", "bridge", "user"]
|
|
|
|
def new?
|
|
mac.nil?
|
|
end
|
|
|
|
def initialize attributes
|
|
super defaults.merge(attributes)
|
|
raise Fog::Errors::Error.new("#{type} is not a supported nic type") if new? && !TYPES.include?(type)
|
|
end
|
|
|
|
def save
|
|
raise Fog::Errors::Error.new('Creating a new nic is not yet implemented. Contributions welcome!')
|
|
#requires :server
|
|
#connection.attach_nic(domain , self)
|
|
end
|
|
|
|
def destroy
|
|
raise Fog::Errors::Error.new('Destroying an interface is not yet implemented. Contributions welcome!')
|
|
#requires :server
|
|
##detach the nic
|
|
#connection.detach_nic(domain, mac)
|
|
end
|
|
|
|
private
|
|
def defaults
|
|
{
|
|
:type => "bridge",
|
|
:model => "virtio"
|
|
}
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|
|
|
|
end
|