Class: CORL::Machine::Raspberrypi

Inherits:
Object
  • Object
show all
Includes:
CORL::Mixin::Machine::SSH
Defined in:
lib/CORL/machine/raspberrypi.rb

Instance Method Summary collapse

Methods included from CORL::Mixin::Machine::SSH

#close_ssh_session, #init_ssh_session, #ssh_download, #ssh_exec, #ssh_terminal, #ssh_upload, #ssh_wait_for_ready

Instance Method Details

#create(options = {}) ⇒ Object




67
68
69
70
71
72
# File 'lib/CORL/machine/raspberrypi.rb', line 67

def create(options = {})
  super do
    logger.warn("Damn!  We can't create new instances of Raspberry Pi machines")
    true
  end
end

#create_image(options = {}) ⇒ Object




119
120
121
122
123
124
# File 'lib/CORL/machine/raspberrypi.rb', line 119

def create_image(options = {})
  super do
    logger.warn("Creating images of Raspberry Pi machines not supported yet")
    true
  end
end

#created?Boolean


Checks



21
22
23
# File 'lib/CORL/machine/raspberrypi.rb', line 21

def created?
  true
end

#destroy(options = {}) ⇒ Object




146
147
148
149
150
151
# File 'lib/CORL/machine/raspberrypi.rb', line 146

def destroy(options = {})
  super do
    logger.warn("If you want to destroy your Raspberry Pi machine, grab a hammer")
    true
  end
end

#download(remote_path, local_path, options = {}, &code) ⇒ Object




76
77
78
79
80
# File 'lib/CORL/machine/raspberrypi.rb', line 76

def download(remote_path, local_path, options = {}, &code)
  super do |config, success|
    ssh_download(remote_path, local_path, config, &code)
  end
end

#exec(commands, options = {}, &code) ⇒ Object




92
93
94
95
96
# File 'lib/CORL/machine/raspberrypi.rb', line 92

def exec(commands, options = {}, &code)
  super do |config|
    ssh_exec(commands, config, &code)
  end
end

#imageObject




52
53
54
# File 'lib/CORL/machine/raspberrypi.rb', line 52

def image
  nil
end

#loadObject


Management



59
60
61
62
63
# File 'lib/CORL/machine/raspberrypi.rb', line 59

def load
  super do
    true
  end
end

#machine_typeObject




46
47
48
# File 'lib/CORL/machine/raspberrypi.rb', line 46

def machine_type
  'raspberrypi'
end

#normalize(reload) ⇒ Object


Machine plugin interface



11
12
13
14
15
16
# File 'lib/CORL/machine/raspberrypi.rb', line 11

def normalize(reload)
  require 'net/ping'

  super
  myself.plugin_name = node.plugin_name if node
end

#public_ipObject


Property accessors / modifiers



34
35
36
# File 'lib/CORL/machine/raspberrypi.rb', line 34

def public_ip
  node[:public_ip]
end

#reload(options = {}) ⇒ Object




108
109
110
111
112
113
114
115
# File 'lib/CORL/machine/raspberrypi.rb', line 108

def reload(options = {})
  super do
    success = node.command('reboot', { :as_admin => true })
    sleep 5
    sleep 1 until running?
    success
  end
end

#running?Boolean




27
28
29
# File 'lib/CORL/machine/raspberrypi.rb', line 27

def running?
  Net::Ping::TCP.new(public_ip, node.ssh_port).ping?
end

#start(options = {}) ⇒ Object




137
138
139
140
141
142
# File 'lib/CORL/machine/raspberrypi.rb', line 137

def start(options = {})
  super do
    logger.warn("Starting a Raspberry Pi machine is not supported right now")
    true
  end
end

#stateObject




40
41
42
# File 'lib/CORL/machine/raspberrypi.rb', line 40

def state
  running? ? :running : :not_running
end

#stop(options = {}) ⇒ Object




128
129
130
131
132
133
# File 'lib/CORL/machine/raspberrypi.rb', line 128

def stop(options = {})
  super do
    logger.warn("Stopping a Raspberry Pi machine is not supported right now")
    true
  end
end

#terminal(user, options = {}) ⇒ Object




100
101
102
103
104
# File 'lib/CORL/machine/raspberrypi.rb', line 100

def terminal(user, options = {})
  super do |config|
    ssh_terminal(user, config)
  end
end

#upload(local_path, remote_path, options = {}, &code) ⇒ Object




84
85
86
87
88
# File 'lib/CORL/machine/raspberrypi.rb', line 84

def upload(local_path, remote_path, options = {}, &code)
  super do |config, success|
    ssh_upload(local_path, remote_path, config, &code)
  end
end