diff --git a/lib/fog/google/models/compute/server.rb b/lib/fog/google/models/compute/server.rb index 9b7c53e12..71329c20f 100644 --- a/lib/fog/google/models/compute/server.rb +++ b/lib/fog/google/models/compute/server.rb @@ -20,6 +20,8 @@ module Fog attribute :service_accounts, :aliases => 'serviceAccounts' attribute :tags, :squash => 'items' attribute :self_link, :aliases => 'selfLink' + attribute :auto_restart + attribute :on_host_maintenance def image_name=(args) Fog::Logger.deprecation("image_name= is no longer used [light_black](#{caller.first})[/]") @@ -153,7 +155,9 @@ module Fog 'disks' => disks, 'metadata' => metadata, 'serviceAccounts' => service_accounts, - 'tags' => tags + 'tags' => tags, + 'auto_restart' => auto_restart, + 'on_host_maintenance' => on_host_maintenance }.delete_if {|key, value| value.nil?} if service_accounts diff --git a/lib/fog/google/requests/compute/insert_server.rb b/lib/fog/google/requests/compute/insert_server.rb index 12b3e2d36..5ce835e20 100644 --- a/lib/fog/google/requests/compute/insert_server.rb +++ b/lib/fog/google/requests/compute/insert_server.rb @@ -151,6 +151,21 @@ module Fog networkInterfaces << networkInterface end + scheduling = { + 'automaticRestart' => false, + 'onHostMaintenance' => "MIGRATE" + } + if options.has_key? 'auto_restart' + scheduling['automaticRestart'] = options.delete 'auto_restart' + scheduling['automaticRestart'] = scheduling['automaticRestart'].class == TrueClass + end + if options.has_key? 'on_host_maintenance' + ohm = options.delete 'on_host_maintenance' + scheduling['onHostMaintenance'] = (ohm.respond_to?("upcase") && + ohm.upcase == "MIGRATE" && "MIGRATE") || "TERMINATE" + end + body_object['scheduling'] = scheduling + # TODO: add other networks body_object['networkInterfaces'] = networkInterfaces