Class: Xen::Vif

Inherits:
Object
  • Object
show all
Defined in:
lib/xen/config.rb

Overview

Virtual Network Interface

wiki.xensource.com/xenwiki/XenNetworking

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Vif

Returns a new instance of Vif.



93
94
95
96
97
98
99
# File 'lib/xen/config.rb', line 93

def initialize(*args)
  options = args.extract_options!
  @ip = options[:ip] 
  @mac = options[:mac]
  @bridge = options[:bridge]
  @vifname = options[:vifname]
end

Instance Attribute Details

#bridgeObject

Returns the value of attribute bridge.



92
93
94
# File 'lib/xen/config.rb', line 92

def bridge
  @bridge
end

#ipObject

Returns the value of attribute ip.



92
93
94
# File 'lib/xen/config.rb', line 92

def ip
  @ip
end

#macObject

Returns the value of attribute mac.



92
93
94
# File 'lib/xen/config.rb', line 92

def mac
  @mac
end

#vifnameObject

Returns the value of attribute vifname.



92
93
94
# File 'lib/xen/config.rb', line 92

def vifname
  @vifname
end

Class Method Details

.from_str(value) ⇒ Object



101
102
103
104
# File 'lib/xen/config.rb', line 101

def self.from_str(value)
  options = value.scan(/(\w+)=([^,]+)/).inject({}){ |m, (k, v)| m[k.to_sym] = v; m }
  new(options)
end

Instance Method Details

#to_strObject



106
107
108
109
110
# File 'lib/xen/config.rb', line 106

def to_str
  %w(ip mac bridge vifname).collect { |key| 
    "#{key}=#{instance_variable_get('@' + key)}" if !instance_variable_get('@'+key).nil?
  }.compact.join(',')
end