Sha256: 69541d55114463a548cf835d970ebbc75f18c5288af3d8c33be93e0e14b3362a
Contents?: true
Size: 1.31 KB
Versions: 14
Compression:
Stored size: 1.31 KB
Contents
require 'aptible/api' module Aptible module CLI module Helpers module Operation POLL_INTERVAL = 1 def poll_for_success(operation) wait_for_completion operation return if operation.status == 'succeeded' fail Thor::Error, 'Operation failed. Please contact support@aptible.com' end def wait_for_completion(operation) while %w(queued running).include? operation.status sleep 1 operation.get end end def attach_to_operation_logs(operation) host = operation.resource.account.bastion_host port = operation.resource.account.dumptruck_port set_env('ACCESS_TOKEN', fetch_token) set_env('APTIBLE_OPERATION', operation.id.to_s) set_env('APTIBLE_CLI_COMMAND', 'oplog') opts = " -o 'SendEnv=*' -o StrictHostKeyChecking=no " \ '-o UserKnownHostsFile=/dev/null -o LogLevel=quiet' result = Kernel.system "ssh #{opts} -p #{port} root@#{host}" # If Dumptruck is down, fall back to polling for success. If the # operation failed, poll_for_success will immediately fall through to # the error message. poll_for_success(operation) unless result end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems