Sha256: 846cdd316566c8eca36656339873aa280222e0073c59532c3555cb1452aa7246

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 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
          #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

12 entries across 12 versions & 5 rubygems

Version Path
hpfog-0.0.20 lib/fog/libvirt/models/compute/nic.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/libvirt/models/compute/nic.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/libvirt/models/compute/nic.rb
fog-1.11.1 lib/fog/libvirt/models/compute/nic.rb
fog-1.11.0 lib/fog/libvirt/models/compute/nic.rb
fog-1.10.1 lib/fog/libvirt/models/compute/nic.rb
fog-test-me-1.10.0 lib/fog/libvirt/models/compute/nic.rb
fog-1.10.0 lib/fog/libvirt/models/compute/nic.rb
fog-1.9.0 lib/fog/libvirt/models/compute/nic.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/libvirt/models/compute/nic.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/libvirt/models/compute/nic.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/libvirt/models/compute/nic.rb