2012-02-16 17:53:29 +08:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/openstack/models/compute/security_group'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Compute
|
2012-02-22 00:09:26 +08:00
|
|
|
class OpenStack
|
2012-02-16 17:53:29 +08:00
|
|
|
|
|
|
|
class SecurityGroups < Fog::Collection
|
|
|
|
|
2012-02-22 00:09:26 +08:00
|
|
|
model Fog::Compute::OpenStack::SecurityGroup
|
2012-02-16 17:53:29 +08: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-22 00:09:26 +08:00
|
|
|
rescue Fog::Compute::OpenStack::NotFound
|
2012-02-16 17:53:29 +08:00
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-02-22 00:09:26 +08:00
|
|
|
end
|