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
|
2012-12-22 18:24:36 -05:00
|
|
|
load(service.list_security_groups.body['security_groups'])
|
2012-02-16 04:53:29 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(security_group_id)
|
|
|
|
if security_group_id
|
2012-12-22 18:24:36 -05:00
|
|
|
new(service.get_security_group(security_group_id).body['security_group'])
|
2012-02-16 04:53:29 -05:00
|
|
|
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
|