Class: Rancher::Api::Instance

Inherits:
Object
  • Object
show all
Includes:
Her::Model, Helpers::Model
Defined in:
lib/rancher/api/models/instance.rb,
lib/rancher/api/models/instance/action.rb

Overview

instance usually container

Defined Under Namespace

Classes: Action

Constant Summary

Constants included from Helpers::Model

Helpers::Model::TIMEOUT_LIMIT

Instance Method Summary collapse

Methods included from Helpers::Model

#handle_response, #reload, #run, #self_url, #wait_for_state

Instance Method Details

#container?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rancher/api/models/instance.rb', line 14

def container?
  type == 'container'
end

#execute(command) ⇒ Object

"attachStdin": true,
"attachStdout": true,
"command": [
  "rake",
  "db:create",
  "db:schema:load",
  "db:seed"
],
"tty": true



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rancher/api/models/instance.rb', line 48

def execute(command)
  url = actions['execute']

  data = {
    'attachStdin' => true,
    'attachStdout' => true,
    'command' => command,
    'tty' => true
  }

  action = Action.post(url, data)
  action.run!
end

#logs(lines = 20) ⇒ Object



62
63
64
65
66
67
68
69
70
71
# File 'lib/rancher/api/models/instance.rb', line 62

def logs(lines = 20)
  url = actions['logs']
  data = {
    'follow' => false,
    'lines' => lines
  }

  action = Action.post(url, data)
  action.run!
end