Sha256: 3f8e4651558989dc9bdecf1d8006cd7a71d2896b24ce414fc8036948ab01edf0
Contents?: true
Size: 1.27 KB
Versions: 11
Compression:
Stored size: 1.27 KB
Contents
require 'shell-spinner' module Kontena module Machine module Packet class NodeRestarter include RandomName include PacketCommon 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) ShellSpinner "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 5 end end end end end end end
Version data entries
11 entries across 11 versions & 2 rubygems