class Chef::Knife::IonoscloudDatacenterCreate
Attributes
description[R]
required_options[R]
Public Class Methods
new(args = [])
click to toggle source
Calls superclass method
# File lib/chef/knife/ionoscloud_datacenter_create.rb, line 27 def initialize(args = []) super(args) @description = "Unless you are planning to manage an existing Ionoscloud environment, "\ "the first step will typically involve choosing the location for a new virtual data center"\ "A list of locations can be obtained with location command.\n\n\t"\ "```text\nknife ionoscloud location list\n```\n\n"\ "Make a note of the desired location ID and now the data center can be created.\n" @required_options = [:location, :ionoscloud_username, :ionoscloud_password] end
Public Instance Methods
run()
click to toggle source
# File lib/chef/knife/ionoscloud_datacenter_create.rb, line 38 def run $stdout.sync = true handle_extra_config validate_required_params(@required_options, config) print "#{ui.color('Creating data center...', :magenta)}" datacenter_api = Ionoscloud::DataCenterApi.new(api_client) datacenter, _, headers = datacenter_api.datacenters_post_with_http_info({ properties: { name: config[:name], description: config[:description], location: config[:location], }.compact, }) dot = ui.color('.', :magenta) api_client.wait_for { print dot; is_done? get_request_id headers } puts "\n" puts "#{ui.color('ID', :cyan)}: #{datacenter.id}" puts "#{ui.color('Name', :cyan)}: #{datacenter.properties.name}" puts "#{ui.color('Description', :cyan)}: #{datacenter.properties.description}" puts "#{ui.color('Location', :cyan)}: #{datacenter.properties.location}" puts 'done' end