Sha256: fc4c20e1c2cc0ac76f2f311b12b6d41f745d45b8e4cc344e93480e8833d8907d

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

require 'fog/core/model'

module Fog
  module Libvirt
    class Compute
      class Nic < Fog::Model
        identity :mac
        attribute :id
        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
          #service.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
          #service.detach_nic(domain, mac)
        end

        private
        def defaults
          {
            :type  => "bridge",
            :model => "virtio"
          }
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
fog-libvirt-0.13.1 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.13.0 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.12.2 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.12.1 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.12.0 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.11.0 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.10.1 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.10.0 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-csem-0.9.0 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.9.0 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.8.0 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.7.0 lib/fog/libvirt/models/compute/nic.rb
fog-libvirt-0.6.0 lib/fog/libvirt/models/compute/nic.rb