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
|
|
|
|
|
2015-05-07 05:46:17 -04:00
|
|
|
def get_by_name(network)
|
|
|
|
data = service.list_networks({:network => network})
|
2014-06-18 04:18:53 -04:00
|
|
|
load(data).first
|
2014-06-16 16:09:46 -04:00
|
|
|
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
|