Class: Cloudspeq::Providers::Base::Machine

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudspeq/providers/base.rb

Direct Known Subclasses

DigitalOcean::Machine

Instance Method Summary collapse

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

#attributesObject



97
98
99
# File 'lib/cloudspeq/providers/base.rb', line 97

def attributes
  @attributes
end

#destroyObject



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

#restartObject



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

#shutdownObject



101
102
# File 'lib/cloudspeq/providers/base.rb', line 101

def shutdown
end

#startupObject



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