diff --git a/lib/fog/hp.rb b/lib/fog/hp.rb index 8bd209a84..d90e2747a 100644 --- a/lib/fog/hp.rb +++ b/lib/fog/hp.rb @@ -5,7 +5,7 @@ module Fog # define a specific version for the HP Provider unless const_defined?(:VERSION) - VERSION = '0.0.19' + VERSION = '0.0.20' end extend Fog::Provider diff --git a/lib/fog/hp/CHANGELOG.hp b/lib/fog/hp/CHANGELOG.hp index 6f188b6b8..aa91d1418 100644 --- a/lib/fog/hp/CHANGELOG.hp +++ b/lib/fog/hp/CHANGELOG.hp @@ -1,8 +1,18 @@ -0.0.19 18/01/2013 +0.0.20 03/13/2013 +================= +- add Accept header with application/json for all requests +- add support for user_data while creating servers in Compute +- add support for one/two way container synchronisation in Object Storage +- merge with upstream fog v1.10.0 + +0.0.19 01/25/2013 ================= - update Block Storage namespace to be Fog::HP::BlockStorage -- merge with upstream fog v1.8.0 +- merge with upstream fog v1.9.0 - deprecate hp_account_id to use hp_access_key instead +- fix temp_url to use signer that is backward compatible to 1.8.7 +- fix issue in Storage provider with service catalog having an invalid CDN endpoint +- Happy New Year to all... 0.0.18 12/04/2012 ================= diff --git a/lib/fog/hp/block_storage.rb b/lib/fog/hp/block_storage.rb index 530251772..616f2ff50 100644 --- a/lib/fog/hp/block_storage.rb +++ b/lib/fog/hp/block_storage.rb @@ -144,6 +144,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/hp/cdn.rb b/lib/fog/hp/cdn.rb index 16473610c..3ced28ad1 100644 --- a/lib/fog/hp/cdn.rb +++ b/lib/fog/hp/cdn.rb @@ -128,6 +128,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/hp/compute.rb b/lib/fog/hp/compute.rb index 312c1e1af..f04e74ba0 100644 --- a/lib/fog/hp/compute.rb +++ b/lib/fog/hp/compute.rb @@ -227,6 +227,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, diff --git a/lib/fog/hp/models/compute/server.rb b/lib/fog/hp/models/compute/server.rb index bce6828b4..87c711a8f 100644 --- a/lib/fog/hp/models/compute/server.rb +++ b/lib/fog/hp/models/compute/server.rb @@ -27,6 +27,7 @@ module Fog attribute :key_name attribute :security_groups attribute :config_drive + attribute :user_data_encoded # these are implemented as methods attribute :image_id attribute :flavor_id @@ -66,6 +67,10 @@ module Fog metadata.load(metas) end + def user_data=(ascii_userdata) + self.user_data_encoded = [ascii_userdata].pack('m') # same as Base64.encode64 + end + def destroy requires :id service.delete_server(id) @@ -216,15 +221,16 @@ module Fog meta_hash = {} metadata.each { |meta| meta_hash.store(meta.key, meta.value) } options = { - 'metadata' => meta_hash, - 'personality' => personality, - 'accessIPv4' => accessIPv4, - 'accessIPv6' => accessIPv6, - 'min_count' => @min_count, - 'max_count' => @max_count, - 'key_name' => key_name, + 'metadata' => meta_hash, + 'personality' => personality, + 'accessIPv4' => accessIPv4, + 'accessIPv6' => accessIPv6, + 'min_count' => @min_count, + 'max_count' => @max_count, + 'key_name' => key_name, 'security_groups' => security_groups, - 'config_drive' => config_drive + 'config_drive' => config_drive, + 'user_data' => user_data_encoded } options = options.reject {|key, value| value.nil?} # either create a regular server or a persistent server based on input diff --git a/lib/fog/hp/models/storage/directories.rb b/lib/fog/hp/models/storage/directories.rb index dd24961c3..0e7c9bb12 100644 --- a/lib/fog/hp/models/storage/directories.rb +++ b/lib/fog/hp/models/storage/directories.rb @@ -49,7 +49,7 @@ module Fog write_header = nil directory = new(:key => key) for key, value in data.headers - if ['X-Container-Bytes-Used', 'X-Container-Object-Count'].include?(key) + if ['X-Container-Bytes-Used', 'X-Container-Object-Count', 'X-Container-Sync-To', 'X-Container-Sync-Key'].include?(key) directory.merge_attributes(key => value) end if key == 'X-Container-Read' diff --git a/lib/fog/hp/models/storage/directory.rb b/lib/fog/hp/models/storage/directory.rb index b03977c77..a94db0c20 100644 --- a/lib/fog/hp/models/storage/directory.rb +++ b/lib/fog/hp/models/storage/directory.rb @@ -7,10 +7,12 @@ module Fog class Directory < Fog::Model - identity :key, :aliases => 'name' + identity :key, :aliases => 'name' - attribute :bytes, :aliases => 'X-Container-Bytes-Used' - attribute :count, :aliases => 'X-Container-Object-Count' + attribute :bytes, :aliases => 'X-Container-Bytes-Used' + attribute :count, :aliases => 'X-Container-Object-Count' + attribute :sync_to, :aliases => 'X-Container-Sync-To' + attribute :sync_key, :aliases => 'X-Container-Sync-Key' def initialize(attributes = {}) @read_acl = [] @@ -205,10 +207,33 @@ module Fog end end + def sync(target_dir, secret) + requires :key + # do not sync if dir is same as target dir + return false if target_dir.key == key + begin service.head_container(key) + if !target_dir.nil? && target_dir.is_a?(Fog::Storage::HP::Directory) && target_dir.respond_to?(:public_url) && !target_dir.public_url.nil? + # set sync metadata on source dir + self.sync_to = target_dir.public_url + self.sync_key = secret + # set sync metadata on target dir + target_dir.sync_key = secret + target_dir.save + true + else + false + end + rescue Fog::Storage::HP::NotFound + false + end + end + def save(options = {}) requires :key # write out the acls into the headers before save options.merge!(service.perm_acl_to_header(@read_acl, @write_acl)) + options.merge!({'X-Container-Sync-To' => self.sync_to}) unless self.sync_to.nil? + options.merge!({'X-Container-Sync-Key' => self.sync_key}) unless self.sync_key.nil? service.put_container(key, options) # Added an extra check to see if CDN is enabled for the container if (!service.cdn.nil? && service.cdn.enabled?) diff --git a/lib/fog/hp/requests/compute/create_server.rb b/lib/fog/hp/requests/compute/create_server.rb index 4487c5eb3..26e10c652 100644 --- a/lib/fog/hp/requests/compute/create_server.rb +++ b/lib/fog/hp/requests/compute/create_server.rb @@ -63,15 +63,11 @@ module Fog 'name' => name } } - if options['metadata'] - data['server']['metadata'] = options['metadata'] - end - if options['accessIPv4'] - data['server']['accessIPv4'] = options['accessIPv4'] - end - if options['accessIPv6'] - data['server']['accessIPv6'] = options['accessIPv6'] + l_options = ['metadata', 'accessIPv4', 'accessIPv6', 'key_name', 'config_drive', 'user_data'] + l_options.select{|o| options[o]}.each do |key| + data['server'][key] = options[key] end + if options['personality'] data['server']['personality'] = [] for file in options['personality'] @@ -86,9 +82,6 @@ module Fog data['server']['min_count'] = min_count data['server']['max_count'] = max_count - if options['key_name'] - data['server']['key_name'] = options['key_name'] - end if options['security_groups'] data['server']['security_groups'] = [] for sg in options['security_groups'] @@ -97,9 +90,6 @@ module Fog } end end - if options['config_drive'] - data['server']['config_drive'] = options['config_drive'] - end request( :body => Fog::JSON.encode(data), diff --git a/lib/fog/hp/storage.rb b/lib/fog/hp/storage.rb index b42466500..60178d4be 100644 --- a/lib/fog/hp/storage.rb +++ b/lib/fog/hp/storage.rb @@ -291,6 +291,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host, @@ -316,6 +317,7 @@ module Fog response = @connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', + 'Accept' => 'application/json', 'X-Auth-Token' => @auth_token }.merge!(params[:headers] || {}), :host => @host,