2014-04-02 08:57:15 -04:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/opennebula/models/compute/network'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
|
|
|
class OpenNebula
|
|
|
|
class Networks < Fog::Collection
|
|
|
|
model Fog::Compute::OpenNebula::Network
|
|
|
|
|
|
|
|
def all(filter={})
|
2014-11-13 15:32:34 -05:00
|
|
|
self.get_by_filter(filter)
|
2014-04-02 08:57:15 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(id)
|
2014-06-16 16:09:46 -04:00
|
|
|
data = service.list_networks({:id => id})
|
|
|
|
load(data).first
|
|
|
|
rescue Fog::Compute::OpenNebula::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_by_name(name)
|
|
|
|
data = service.list_networks({:name => name})
|
|
|
|
load(data)
|
|
|
|
rescue Fog::Compute::OpenNebula::NotFound
|
|
|
|
nil
|
2014-04-02 08:57:15 -04:00
|
|
|
end
|
|
|
|
|
2014-11-07 13:50:11 -05:00
|
|
|
def get_by_filter(filter)
|
2014-11-13 15:32:34 -05:00
|
|
|
load(service.list_networks(filter))
|
2014-11-07 13:50:11 -05:00
|
|
|
end
|
|
|
|
|
2014-04-02 08:57:15 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|