Sha256: 94ff55ac5eafaa695f203e6df8a7c02eb8726e5df784c5f7502d78cd22ded923

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

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

    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_relative '../../../machine/azure'

      client = ::Azure
      client.management_certificate = certificate
      client.subscription_id        = subscription_id

      client.vm_management.initialize_external_logger(Kontena::Machine::Azure::Logger.new) # We don't want all the output
      spinner "Restarting Azure VM #{name.colorize(:cyan)} " do
        vm = client.vm_management.get_virtual_machine(name, "kontena-#{current_grid}-#{name}")
        if vm
          client.vm_management.restart_virtual_machine(name, "kontena-#{current_grid}-#{name}")
        else
          abort "\nCannot find Virtual Machine #{name.colorize(:cyan)} in Azure"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kontena-plugin-azure-0.3.0 lib/kontena/plugin/azure/nodes/restart_command.rb