1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Enable and add the security groups model layer implementation for the compute services.

This commit is contained in:
Rupak Ganguly 2011-12-02 16:15:56 -05:00
parent c3058e86f3
commit 0c4a03b4bf
3 changed files with 65 additions and 0 deletions

View file

@ -15,6 +15,8 @@ module Fog
collection :images
model :key_pair
collection :key_pairs
model :security_group
collection :security_groups
model :server
collection :servers

View file

@ -0,0 +1,34 @@
require 'fog/core/model'
module Fog
module Compute
class HP
class SecurityGroup < Fog::Model
identity :id
attribute :name
attribute :description
attribute :rules
attribute :tenant_id
def destroy
requires :id
connection.delete_security_group(id)
true
end
def save
requires :name, :description
data = connection.create_security_group(name, description)
merge_attributes(data.body['security_group'])
true
end
end
end
end
end

View file

@ -0,0 +1,29 @@
require 'fog/core/collection'
require 'fog/hp/models/compute/security_group'
module Fog
module Compute
class HP
class SecurityGroups < Fog::Collection
model Fog::Compute::HP::SecurityGroup
def all
items = connection.list_security_groups.body['security_groups']
load(items)
end
def get(security_group_id)
if security_group_id
sec_group = connection.get_security_group(security_group_id).body['security_group']
new(sec_group)
end
rescue Fog::Compute::HP::NotFound
nil
end
end
end
end
end