Sha256: ea224a939ffba55deb9a2fc2ec0bde63cc6ce9021ce3a56d2bb63f4d89570b2d

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 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 'kontena/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

4 entries across 4 versions & 1 rubygems

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