aws-ec2 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +0,0 @@
1
- require 'yaml'
2
- require 'active_support/core_ext/hash'
3
-
4
- module AwsEc2
5
- class UserData
6
- include TemplateHelper
7
- include Util
8
-
9
- def initialize(options)
10
- @options = options
11
- end
12
-
13
- def run
14
- puts user_data(@options[:name], false)
15
- end
16
- end
17
- end
data/lib/aws_ec2/util.rb DELETED
@@ -1,64 +0,0 @@
1
- module AwsEc2
2
- module Util
3
- include TemplateHelper
4
-
5
- def pretty_display(data)
6
- data = data.deep_stringify_keys
7
-
8
- message = "base64-encoded: use aws-ec2 userdata command to view"
9
- # TODO: generalize this
10
- data["user_data"] = message if data["user_data"]
11
- data["spot_fleet_request_config"]["launch_specifications"].each do |spec|
12
- spec["user_data"] = message if spec["user_data"]
13
- end if data["spot_fleet_request_config"] && data["spot_fleet_request_config"]["launch_specifications"]
14
-
15
- puts YAML.dump(data)
16
- end
17
-
18
- def load_profiles(profile_name)
19
- return @profile_params if @profile_params
20
-
21
- profile_file = "#{root}/profiles/#{profile_name}.yml"
22
- base_path = File.dirname(profile_file)
23
- default_file = "#{base_path}/default.yml"
24
-
25
- params_exit_check!(profile_file, default_file)
26
-
27
- params = File.exist?(profile_file) ?
28
- load_profile(profile_file) :
29
- load_profile(default_file)
30
- @profile_params = params
31
- end
32
-
33
- def params_exit_check!(profile_file, default_file)
34
- return if File.exist?(profile_file) or File.exist?(default_file)
35
-
36
- puts "Unable to find a #{profile_file} or #{default_file} profile file."
37
- puts "Please double check."
38
- exit # EXIT HERE
39
- end
40
-
41
- def load_profile(file)
42
- return {} unless File.exist?(file)
43
-
44
- puts "Using profile: #{file}"
45
- data = YAML.load(erb_result(file))
46
- data ? data : {} # in case the file is empty
47
- data.has_key?("run_instances") ? data["run_instances"] : data
48
- end
49
-
50
- def profile_name
51
- # allow user to specify the path also
52
- if @options[:profile] && File.exist?(@options[:profile])
53
- profile = File.basename(@options[:profile], '.yml')
54
- end
55
-
56
- # conventional profile is the name of the ec2 instance
57
- profile || @options[:profile] || @options[:name]
58
- end
59
-
60
- def root
61
- ENV['AWS_EC2_ROOT'] || '.'
62
- end
63
- end
64
- end