Sha256: e562828e8f7c14708c074e09918b9dcca956a7b80c0afb7deec1e72ad6bb7c3a

Contents?: true

Size: 1.04 KB

Versions: 2

Compression:

Stored size: 1.04 KB

Contents

require 'kontena/plugin/upcloud/prompts'

module Kontena::Plugin::Upcloud::Nodes
  class CreateCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions

    parameter "[NAME]", "Node name"

    include Kontena::Plugin::Upcloud::Prompts::Create

    option "--count", "COUNT", "How many nodes should be created"

    requires_current_master_token

    def execute

      abort_unless_api_access

      require 'kontena/machine/upcloud'
      grid = fetch_grid
      provisioner = Kontena::Machine::Upcloud::NodeProvisioner.new(client, username, password)
      provisioner.run!(
        master_uri: api_url,
        grid_token: grid['token'],
        grid: current_grid,
        ssh_key: ssh_key,
        count: count,
        name: name,
        plan: plan,
        zone: zone,
        version: version
      )
    end

    # @param [String] id
    # @return [Hash]
    def fetch_grid
      client.get("grids/#{current_grid}")
    end

    def default_count
      prompt.ask('How many servers:', default: 1)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kontena-plugin-upcloud-0.3.2 lib/kontena/plugin/upcloud/nodes/create_command.rb
kontena-plugin-upcloud-0.3.1 lib/kontena/plugin/upcloud/nodes/create_command.rb