2012-02-16 04:53:29 -05:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/openstack/models/compute/security_group'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
2012-02-21 11:09:26 -05:00
|
|
|
class OpenStack
|
2012-02-16 04:53:29 -05:00
|
|
|
|
|
|
|
class SecurityGroups < Fog::Collection
|
|
|
|
|
2012-02-21 11:09:26 -05:00
|
|
|
model Fog::Compute::OpenStack::SecurityGroup
|
2012-02-16 04:53:29 -05:00
|
|
|
|
|
|
|
def all
|
|
|
|
load(connection.list_security_groups.body['security_groups'])
|
|
|
|
end
|
|
|
|
|
|
|
|
def get(security_group_id)
|
|
|
|
if security_group_id
|
|
|
|
new(connection.get_security_group(security_group_id).body['security_group'])
|
|
|
|
end
|
2012-02-21 11:09:26 -05:00
|
|
|
rescue Fog::Compute::OpenStack::NotFound
|
2012-02-16 04:53:29 -05:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-02-21 11:09:26 -05:00
|
|
|
end
|