Class: Cloudspeq::Providers::Base::Machine
- Inherits:
-
Object
- Object
- Cloudspeq::Providers::Base::Machine
- Defined in:
- lib/cloudspeq/providers/base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #attributes ⇒ Object
- #destroy ⇒ Object
-
#exec(command, settings) ⇒ Object
most of the time, execution requires prefixing.
-
#exec!(command, settings) ⇒ Object
execute without prefixing.
-
#initialize(machine) ⇒ Machine
constructor
A new instance of Machine.
- #restart ⇒ Object
-
#root_exec(command) ⇒ Object
exec as root.
- #shutdown ⇒ Object
- #startup ⇒ Object
- #sync(settings) ⇒ Object
Constructor Details
#initialize(machine) ⇒ Machine
Returns a new instance of Machine.
93 94 95 |
# File 'lib/cloudspeq/providers/base.rb', line 93 def initialize(machine) @attributes = RecursiveOpenStruct.new(machine) end |
Instance Method Details
#attributes ⇒ Object
97 98 99 |
# File 'lib/cloudspeq/providers/base.rb', line 97 def attributes @attributes end |
#destroy ⇒ Object
110 111 |
# File 'lib/cloudspeq/providers/base.rb', line 110 def destroy end |
#exec(command, settings) ⇒ Object
most of the time, execution requires prefixing
114 115 116 117 118 |
# File 'lib/cloudspeq/providers/base.rb', line 114 def exec(command,settings) user = settings.user prefix = settings.command_prefix command_exec(user,attributes.ip_address,prefix,command) end |
#exec!(command, settings) ⇒ Object
execute without prefixing
121 122 123 124 125 |
# File 'lib/cloudspeq/providers/base.rb', line 121 def exec!(command,settings) user = settings.user prefix = settings.command_prefix command_exec(user,attributes.ip_address,"",command) end |
#restart ⇒ Object
104 105 |
# File 'lib/cloudspeq/providers/base.rb', line 104 def restart end |
#root_exec(command) ⇒ Object
exec as root
128 129 130 |
# File 'lib/cloudspeq/providers/base.rb', line 128 def root_exec(command) command_exec('root',attributes.ip_address,"",command) end |
#shutdown ⇒ Object
101 102 |
# File 'lib/cloudspeq/providers/base.rb', line 101 def shutdown end |
#startup ⇒ Object
107 108 |
# File 'lib/cloudspeq/providers/base.rb', line 107 def startup end |
#sync(settings) ⇒ Object
132 133 134 135 136 137 138 139 140 |
# File 'lib/cloudspeq/providers/base.rb', line 132 def sync(settings) command = 'rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no -x " ' command += "--exclude='.git/' --exclude='log/' --exclude='tmp/' " settings.sync_excludes.each do |exc| command += "--include='#{exc}' " end command += ". #{settings.user}@#{attributes.ip_address}:#{settings.remote_project_directory}" `#{command}` end |