Class: Fog::Compute::Libvirt::Interfaces
- Inherits:
-
Fog::Collection
- Object
- Array
- Fog::Collection
- Fog::Compute::Libvirt::Interfaces
- Defined in:
- lib/fog/libvirt/models/compute/interfaces.rb
Instance Attribute Summary
Attributes inherited from Fog::Collection
Instance Method Summary collapse
- #all(filter = nil) ⇒ Object
- #get(key) ⇒ Object
-
#get_by_mac(mac) ⇒ Object
Retrieve the interface by name.
-
#get_by_name(name) ⇒ Object
private # Making these private, screws up realod Retrieve the interface by name.
Methods inherited from Fog::Collection
#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all(filter = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fog/libvirt/models/compute/interfaces.rb', line 12 def all(filter=nil) data=[] if filter.nil? connection.raw.list_interfaces.each do |ifname| interface=connection.raw.lookup_interface_by_name(ifname) data << { :raw => interface } end connection.raw.list_defined_interfaces.each do |ifname| interface=connection.raw.lookup_interface_by_name(ifname) data << { :raw => interface } end else interface=nil begin interface=get_by_name(filter[:name]) if filter.has_key?(:name) interface=get_by_mac(filter[:mac]) if filter.has_key?(:mac) rescue ::Libvirt::RetrieveError return nil end data << { :raw => interface} end load(data) end |
#get(key) ⇒ Object
38 39 40 |
# File 'lib/fog/libvirt/models/compute/interfaces.rb', line 38 def get(key) self.all(:name => name).first end |
#get_by_mac(mac) ⇒ Object
Retrieve the interface by name
51 52 53 54 55 |
# File 'lib/fog/libvirt/models/compute/interfaces.rb', line 51 def get_by_mac(mac) interface=connection.raw.lookup_interface_by_mac(mac) return interface # new(:raw => interface) end |
#get_by_name(name) ⇒ Object
private # Making these private, screws up realod Retrieve the interface by name
44 45 46 47 48 |
# File 'lib/fog/libvirt/models/compute/interfaces.rb', line 44 def get_by_name(name) interface=connection.raw.lookup_interface_by_name(name) return interface # new(:raw => interface) end |