From 6fc3043a2fb543d5df8c2de68c4c64b88525b643 Mon Sep 17 00:00:00 2001 From: Rupak Ganguly Date: Thu, 15 Nov 2012 15:54:42 -0500 Subject: [PATCH] Add code to accept config_drive and block_device_mapping parameters while creating a server instance. --- lib/fog/hp/models/compute/server.rb | 10 +++++++++- lib/fog/hp/requests/compute/create_server.rb | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/fog/hp/models/compute/server.rb b/lib/fog/hp/models/compute/server.rb index e74711379..09c876687 100644 --- a/lib/fog/hp/models/compute/server.rb +++ b/lib/fog/hp/models/compute/server.rb @@ -26,6 +26,7 @@ module Fog attribute :user_id attribute :key_name attribute :security_groups + attribute :config_drive # these are implemented as methods attribute :image_id attribute :flavor_id @@ -39,6 +40,7 @@ module Fog # assign these attributes first to prevent race condition with new_record? self.min_count = attributes.delete(:min_count) self.max_count = attributes.delete(:max_count) + self.block_device_mapping = attributes.delete(:block_device_mapping) @connection = attributes[:connection] super end @@ -146,6 +148,10 @@ module Fog @max_count = new_max_count end + def block_device_mapping=(new_block_device_mapping) + @block_device_mapping = new_block_device_mapping + end + def ready? self.state == 'ACTIVE' end @@ -216,7 +222,9 @@ module Fog 'min_count' => @min_count, 'max_count' => @max_count, 'key_name' => key_name, - 'security_groups' => security_groups + 'security_groups' => security_groups, + 'config_drive' => config_drive, + 'block_device_mapping' => @block_device_mapping } options = options.reject {|key, value| value.nil?} data = connection.create_server(name, flavor_id, image_id, options) diff --git a/lib/fog/hp/requests/compute/create_server.rb b/lib/fog/hp/requests/compute/create_server.rb index bf117db52..019212ac8 100644 --- a/lib/fog/hp/requests/compute/create_server.rb +++ b/lib/fog/hp/requests/compute/create_server.rb @@ -103,6 +103,9 @@ module Fog } end end + if options['config_drive'] + data['server']['config_drive'] = options['config_drive'] + end if options['block_device_mapping'] data['server']['block_device_mapping'] = options['block_device_mapping'] end