Class: Dployr::Commands::Base
- Inherits:
-
Object
- Object
- Dployr::Commands::Base
show all
- Includes:
- Utils
- Defined in:
- lib/dployr/commands/base.rb
Instance Method Summary
collapse
Methods included from Utils
parse_attributes, parse_flags, parse_matrix
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/dployr/commands/base.rb', line 14
def initialize(options)
@options = options
@name = options[:name]
@log = Logger.new STDOUT
@attrs = parse_attributes @options[:attributes]
@options[:public_ip] = false if !options[:public_ip]
@provider = options[:provider].upcase if options[:provider]
@region = options[:region]
raise "Missing provider argument. Use -p <provider>" unless @provider
raise "Missing region argument. Use -r <region>" unless @region
create
get_config
end
|
Instance Method Details
#create ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/dployr/commands/base.rb', line 29
def create
begin
@dployr = Dployr::Init.new @attrs
@dployr.load_config @options[:file]
rescue => e
raise "Cannot load the config: #{e}"
end
end
|
#create_compute_client ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/dployr/commands/base.rb', line 38
def create_compute_client
begin
Dployr::Compute.const_get(@provider.to_sym).new @regions
rescue => e
raise "Provider '#{@provider}' is not supported: #{e}"
end
end
|
#get_config ⇒ Object
46
47
48
49
|
# File 'lib/dployr/commands/base.rb', line 46
def get_config
@config = get_region_config @options
@p_attrs = @config[:attributes]
end
|
#get_region_config(options) ⇒ Object
51
52
53
|
# File 'lib/dployr/commands/base.rb', line 51
def get_region_config(options)
@dployr.config.get_region options[:name], options[:provider], options[:region]
end
|