Sha256: dc48953ff0655f68865d4dc4f4b2d7a1d8d37f7402cb2e5cd6f4bc57336efc0d
Contents?: true
Size: 1.28 KB
Versions: 10
Compression:
Stored size: 1.28 KB
Contents
module Kontena module Machine module Packet class NodeRestarter include RandomName include PacketCommon include Kontena::Cli::ShellSpinner attr_reader :client # @param [String] token Packet api token def initialize(token) @client = login(token) end # @param [String] project_id Packet project id # @param [String] token Node hostname def run!(project_id, name) device = client.list_devices(project_id).find{|d| d.hostname == name} abort("Device #{name.colorize(:cyan)} not found in Packet") unless device abort("Your version of 'packethost' gem does not support rebooting servers") unless client.respond_to?(:reboot_device) spinner "Restarting Packet device #{device.hostname.colorize(:cyan)} " do begin response = client.reboot_device(device) raise unless response.success? rescue abort "Cannot delete device #{name.colorize(:cyan)} in Packet" end sleep 5 until device && device.state == :active device = find_device(project.id, device.hostname) rescue nil sleep 1 end end end end end end end
Version data entries
10 entries across 10 versions & 1 rubygems