Class: Chef::Knife::Cloud::OraclecloudServerCreate

Inherits:
ServerCreateCommand
  • Object
show all
Includes:
OraclecloudServiceHelpers, OraclecloudServiceOptions, ServerCreateOptions
Defined in:
lib/chef/knife/oraclecloud_server_create.rb

Instance Method Summary collapse

Methods included from OraclecloudServiceHelpers

#check_for_missing_config_values!, #create_service_instance, #verify_ssl?

Methods included from OraclecloudServiceOptions

included

Instance Method Details

#before_bootstrapObject



96
97
98
99
100
101
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 96

def before_bootstrap
  super

  config[:chef_node_name] = locate_config_value(:chef_node_name) ? locate_config_value(:chef_node_name) : server.name
  config[:bootstrap_ip_address] = ip_address
end

#before_exec_commandObject



79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 79

def before_exec_command
  super

  @create_options = {
    name:             locate_config_value(:hostname),
    shape:            locate_config_value(:shape),
    image:            locate_config_value(:image),
    label:            label,
    public_ip:        public_ip,
    sshkeys:          sshkeys
  }
end

#ip_addressObject



92
93
94
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 92

def ip_address
  locate_config_value(:public_ip) ? server.public_ip_addresses.first : server.ip_address
end

#labelObject



75
76
77
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 75

def label
  locate_config_value(:label) ? locate_config_value(:label) : locate_config_value(:hostname)
end

#public_ipObject



63
64
65
66
67
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 63

def public_ip
  return nil unless locate_config_value(:public_ip)

  (locate_config_value(:public_ip) == 'pool') ? :pool : "ipreservation:#{locate_config_value(:public_ip)}"
end

#sshkeysObject



69
70
71
72
73
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 69

def sshkeys
  return [] unless locate_config_value(:sshkeys)

  locate_config_value(:sshkeys).split(',').map { |key| service.prepend_identity_domain(key) }
end

#validate_params!Object



58
59
60
61
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 58

def validate_params!
  super
  check_for_missing_config_values!(:image, :shape, :hostname)
end