Class: Pec::Command::Up

Inherits:
Base
  • Object
show all
Defined in:
lib/pec/command/up.rb

Class Method Summary collapse

Methods inherited from Base

print_exception, run

Class Method Details

.task(host_name, options, server, config) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pec/command/up.rb', line 3

def self.task(host_name, options, server, config)
  unless server
    Pec::Logger.info "make start #{config.name}"

    attribute = {name: config.name}
    config.keys.each do |k|
      Pec::Handler.constants.each do |c|
        _handler = Object.const_get("Pec::Handler::#{c}")
        attribute.deep_merge!(_handler.build(config)) if _handler.kind == k
      end
    end

    attribute[:user_data] = Base64.encode64("#cloud-config\n" + attribute[:user_data].to_yaml) if attribute[:user_data]

    Yao::Server.create(attribute)
    Pec::Logger.info "create success! #{config.name}"
  else
    Pec::Logger.notice "already server: #{config.name}"
  end
end