Class: Fog::Compute::Server
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Server
show all
- Defined in:
- lib/rackspace-fog/compute/models/server.rb
Direct Known Subclasses
AWS::Server, Bluebox::Server, Brightbox::Server, Cloudstack::Server, Glesys::Server, GoGrid::Server, HP::Server, IBM::Server, Joyent::Server, Libvirt::Server, Linode::Server, Ninefold::Server, OpenStack::Server, Ovirt::Server, Rackspace::Server, Fog::Compute::StormOnDemand::Server, Voxel::Server, Vsphere::Server, XenServer::Server
Instance Attribute Summary
Attributes inherited from Model
#collection, #connection
Instance Method Summary
collapse
Methods inherited from Model
#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#private_key=(key_data) ⇒ Object
7
8
9
|
# File 'lib/rackspace-fog/compute/models/server.rb', line 7
def private_key=(key_data)
@private_key = key_data
end
|
#scp(local_path, remote_path, upload_options = {}) ⇒ Object
Also known as:
scp_upload
11
12
13
14
15
16
17
18
|
# File 'lib/rackspace-fog/compute/models/server.rb', line 11
def scp(local_path, remote_path, upload_options = {})
require 'net/scp'
requires :public_ip_address, :username
scp_options = {:port => ssh_port}
scp_options[:key_data] = [private_key] if private_key
Fog::SCP.new(public_ip_address, username, scp_options).upload(local_path, remote_path, upload_options)
end
|
#scp_download(remote_path, local_path, download_options = {}) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/rackspace-fog/compute/models/server.rb', line 22
def scp_download(remote_path, local_path, download_options = {})
require 'net/scp'
requires :public_ip_address, :username
scp_options = {:port => ssh_port}
scp_options[:key_data] = [private_key] if private_key
Fog::SCP.new(public_ip_address, username, scp_options).download(remote_path, local_path, download_options)
end
|
#ssh(commands, options = {}, &blk) ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/rackspace-fog/compute/models/server.rb', line 31
def ssh(commands, options={}, &blk)
require 'net/ssh'
requires :public_ip_address, :username
options[:key_data] = [private_key] if private_key
options[:port] ||= ssh_port
Fog::SSH.new(public_ip_address, username, options).run(commands, &blk)
end
|
#ssh_port ⇒ Object
40
41
42
|
# File 'lib/rackspace-fog/compute/models/server.rb', line 40
def ssh_port
22
end
|
#sshable? ⇒ Boolean
44
45
46
47
48
|
# File 'lib/rackspace-fog/compute/models/server.rb', line 44
def sshable?
ready? && !public_ip_address.nil? && !!Timeout::timeout(8) { ssh 'pwd' }
rescue SystemCallError, Net::SSH::AuthenticationFailed, Timeout::Error
false
end
|