Sha256: 6722ee814db0c118ee3aa0874953c5a4c04f0fefc99b832be92401c64883b6f5

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

module Kontena::Plugin::Azure::Nodes
  class TerminateCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions

    parameter "NAME", "Node name"
    option "--subscription-id", "SUBSCRIPTION ID", "Azure subscription id", required: true
    option "--subscription-cert", "CERTIFICATE", "Path to Azure management certificate", attribute_name: :certificate, required: true

    def execute
      require_api_url
      require_current_grid

      require 'kontena/machine/azure'

      grid = fetch_grid
      destroyer = destroyer(client(require_token), subscription_id, certificate)
      destroyer.run!(grid, name)
    end

    def fetch_grid
      client(require_token).get("grids/#{current_grid}")
    end

    # @param [Kontena::Client] client
    # @param [String] subscription_id
    # @param [String] certificate
    # @return [Kontena::Machine::Azure::NodeDestroyer]
    def destroyer(client, subscription_id, certificate)
      Kontena::Machine::Azure::NodeDestroyer.new(client, subscription_id, certificate)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kontena-plugin-azure-0.2.5 lib/kontena/plugin/azure/nodes/terminate_command.rb
kontena-plugin-azure-0.2.2 lib/kontena/plugin/azure/nodes/terminate_command.rb
kontena-plugin-azure-0.2.0 lib/kontena/plugin/azure/nodes/terminate_command.rb
kontena-plugin-azure-0.2.0.pre1 lib/kontena/plugin/azure/nodes/terminate_command.rb
kontena-plugin-azure-0.1.0 lib/kontena/plugin/azure/nodes/terminate_command.rb