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



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

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



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

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



94
95
96
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 94

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

#labelObject



77
78
79
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 77

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

#public_ipObject



65
66
67
68
69
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 65

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



71
72
73
74
75
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 71

def sshkeys
  return [] unless locate_config_value(:sshkeys)

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

#validate_params!Object



60
61
62
63
# File 'lib/chef/knife/oraclecloud_server_create.rb', line 60

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