Module: OVH::Provisioner

Defined in:
lib/ovh/provisioner.rb,
lib/ovh/provisioner/cli.rb,
lib/ovh/provisioner/init.rb,
lib/ovh/provisioner/cli_ip.rb,
lib/ovh/provisioner/spawner.rb,
lib/ovh/provisioner/version.rb,
lib/ovh/provisioner/api_list.rb,
lib/ovh/provisioner/self_cli.rb,
lib/ovh/provisioner/cli_vrack.rb,
lib/ovh/provisioner/cli_domain.rb,
lib/ovh/provisioner/api_object/ip.rb,
lib/ovh/provisioner/api_object/vrack.rb,
lib/ovh/provisioner/api_object/record.rb,
lib/ovh/provisioner/api_object/api_object.rb,
lib/ovh/provisioner/api_object/domain_zone.rb,
lib/ovh/provisioner/api_object/dedicated_server.rb

Overview

Define version

Defined Under Namespace

Modules: APIObject Classes: APIList, Cli, CliDomain, CliIP, CliVrack, Spawner

Constant Summary collapse

VERSION =
'0.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.clientObject (readonly)

Returns the value of attribute client.



27
28
29
# File 'lib/ovh/provisioner/init.rb', line 27

def client
  @client
end

.configObject (readonly)

Returns the value of attribute config.



26
27
28
# File 'lib/ovh/provisioner/init.rb', line 26

def config
  @config
end

.loggerObject

Returns the value of attribute logger.



25
26
27
# File 'lib/ovh/provisioner.rb', line 25

def logger
  @logger
end

.spawnerObject (readonly)

Returns the value of attribute spawner.



28
29
30
# File 'lib/ovh/provisioner/init.rb', line 28

def spawner
  @spawner
end

Class Method Details

.check_missing(config) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/ovh/provisioner/init.rb', line 47

def check_missing(config)
  missing = %w[
    app_key app_secret consumer_key api_url
  ].map { |key| config[key].nil? ? key : nil }.compact

  return config if missing.empty?

  puts "Please provide valid #{missing.join(', ')}"
  exit 1
end

.create_clientObject



58
59
60
61
62
63
64
65
66
67
# File 'lib/ovh/provisioner/init.rb', line 58

def create_client
  return @client unless @client.nil?

  OVH::REST.new(
    config['app_key'],
    config['app_secret'],
    config['consumer_key'],
    config['api_url']
  )
end

.create_spawnerObject



69
70
71
72
73
74
# File 'lib/ovh/provisioner/init.rb', line 69

def create_spawner
  return @spawner unless @spawner.nil?

  spawner = Spawner.new
  Celluloid::Actor[Spawner::NAME] = spawner
end

.init(options) ⇒ Object



30
31
32
33
34
# File 'lib/ovh/provisioner/init.rb', line 30

def init(options)
  @config = load_config(options)
  @client = create_client
  @spawner = create_spawner
end

.load_config(options) ⇒ Object



36
37
38
39
40
41
42
43
44
45
# File 'lib/ovh/provisioner/init.rb', line 36

def load_config(options)
  config_file = options['config_file']
  begin
    config = YAML.load_file config_file if File.exist? config_file
  rescue StandardError => e
    puts "#{e}\nCould not load configuration file: #{config_file}"
    exit 1
  end
  check_missing((config || {}).merge(options))
end

.startObject



31
32
33
34
35
36
37
# File 'lib/ovh/provisioner.rb', line 31

def start
  OVH::Provisioner::Cli.start(ARGV)
rescue StandardError => error
  puts error.message
  puts error.backtrace
  exit 1
end