Class: Dployr::Commands::Start

Inherits:
Base
  • Object
show all
Defined in:
lib/dployr/commands/start.rb

Instance Method Summary collapse

Methods inherited from Base

#create, #create_compute_client, #get_config, #get_region_config

Methods included from Utils

parse_attributes, parse_flags, parse_matrix

Constructor Details

#initialize(options) ⇒ Start

Returns a new instance of Start.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/dployr/commands/start.rb', line 7

def initialize(options)
  super options

  puts "Connecting to #{@provider}...".yellow
  @client = Dployr::Compute.const_get(@provider.to_sym).new @options, @p_attrs

  if @p_attrs["type"] == "network"
    puts "Creating network in #{@options[:provider]}: #{@options[:region]}...".yellow
    @network = @client.create_network(@p_attrs["name"], @p_attrs["private_net"], @p_attrs["firewalls"], [])
  else
    puts "Looking for #{@p_attrs["name"]} in #{@options[:region]}...".yellow
    @ip = @client.get_ip

    Dployr::Scripts::Default_Hooks.new @ip, @config, "start", self
  end
end

Instance Method Details

#actionObject



24
25
26
27
28
29
30
31
32
# File 'lib/dployr/commands/start.rb', line 24

def action
  if @ip
    puts "#{@name} found with IP #{@ip}".yellow
  else
    @ip = @client.start
    puts "Startded instance for #{@p_attrs["name"]} in #{@options[:region]} with IP #{@ip} succesfully".yellow
  end
  @ip
end