diff --git a/lib/fog/hp/compute.rb b/lib/fog/hp/compute.rb index b726de999..b4c256e57 100644 --- a/lib/fog/hp/compute.rb +++ b/lib/fog/hp/compute.rb @@ -15,6 +15,8 @@ module Fog collection :images model :key_pair collection :key_pairs + model :security_group + collection :security_groups model :server collection :servers diff --git a/lib/fog/hp/models/compute/security_group.rb b/lib/fog/hp/models/compute/security_group.rb new file mode 100644 index 000000000..e2c2658d4 --- /dev/null +++ b/lib/fog/hp/models/compute/security_group.rb @@ -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 diff --git a/lib/fog/hp/models/compute/security_groups.rb b/lib/fog/hp/models/compute/security_groups.rb new file mode 100644 index 000000000..1951c8640 --- /dev/null +++ b/lib/fog/hp/models/compute/security_groups.rb @@ -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 \ No newline at end of file