From 836876b4b0763e01526c9aa9c1fc34e1d82416aa Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 14 Sep 2016 13:13:29 -0700 Subject: [bugfix] leap vm: make the default instance type 't2.nano' --- lib/leap_cli/cloud/cloud.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/leap_cli/cloud/cloud.rb b/lib/leap_cli/cloud/cloud.rb index 231274a5..753041f6 100644 --- a/lib/leap_cli/cloud/cloud.rb +++ b/lib/leap_cli/cloud/cloud.rb @@ -34,6 +34,9 @@ module LeapCli class Cloud + DEFAULT_INSTANCE_OPTIONS = { + "InstanceType" => "t2.nano" + } LEAP_SG_NAME = 'leap_default' LEAP_SG_DESC = 'Default security group for LEAP nodes' @@ -50,7 +53,7 @@ module LeapCli @name = name @conf = conf @compute = nil - @options = nil + @options = DEFAULT_INSTANCE_OPTIONS @image = nil raise ArgumentError, 'name missing' unless @name @@ -62,12 +65,21 @@ module LeapCli credentials[:provider] = @conf["vendor"] @compute = Fog::Compute.new(credentials) - @options = @conf['default_options'] || {} - @image = @conf['default_image'] || Cloud.aws_image(credentials[:region]) + if @conf['default_options'] + @options = @options.merge(@conf['default_options']) + end + @image = @conf['default_image'] || Cloud.aws_image(credentials[:region]) if @node - @options = node.vm.options if node['vm.options'] + @options = @options.merge(node.vm.options) if node['vm.options'] @image = node.vm.image if node['vm.image'] end + + unless @options['InstanceType'] + raise ArgumentError, 'VM instance type is required. See https://leap.se/virtual-machines for more information.' + end + unless @image + raise ArgumentError, 'VM image is required. See https://leap.se/virtual-machines for more information.' + end end # -- cgit v1.2.3