Sha256: 804dce6afe94a73b1370d4cb10b7c848ef9b6aae28f90c94bf20b2fb0049faf4

Contents?: true

Size: 1.16 KB

Versions: 14

Compression:

Stored size: 1.16 KB

Contents

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

Version data entries

14 entries across 14 versions & 8 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/libvirt/models/compute/nic.rb
fog-nirvanix-1.8.1 lib/fog/libvirt/models/compute/nic.rb
fog-parser-fix-1.6.1 lib/fog/libvirt/models/compute/nic.rb
fog-test-again-1.6.0 lib/fog/libvirt/models/compute/nic.rb
fog-parser-fix-1.6.0 lib/fog/libvirt/models/compute/nic.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/libvirt/models/compute/nic.rb
fog-sgonyea-1.8.1 lib/fog/libvirt/models/compute/nic.rb
fog-1.8.0 lib/fog/libvirt/models/compute/nic.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/libvirt/models/compute/nic.rb
fog-1.7.0 lib/fog/libvirt/models/compute/nic.rb
fog-1.6.0 lib/fog/libvirt/models/compute/nic.rb
fog-1.5.0 lib/fog/libvirt/models/compute/nic.rb
fog-1.4.0 lib/fog/libvirt/models/compute/nic.rb
michiels-fog-1.3.1 lib/fog/libvirt/models/compute/nic.rb