Class: Fog::Compute::Joyent::Server

Inherits:
Server show all
Defined in:
lib/fog/joyent/models/compute/server.rb

Instance Attribute Summary

Attributes inherited from Server

#private_key, #private_key_path, #public_key, #public_key_path, #ssh_port, #username

Attributes inherited from Model

#collection, #service

Instance Method Summary collapse

Methods inherited from Server

#scp, #scp_download, #ssh, #sshable?

Methods inherited from Model

#initialize, #inspect, #reload, #symbolize_keys, #to_json, #wait_for

Methods included from Attributes::ClassMethods

#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes

Methods included from Fog::Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#add_tags(tags_hash = {}) ⇒ Object



97
98
99
100
# File 'lib/fog/joyent/models/compute/server.rb', line 97

def add_tags(tags_hash = {})
  requires :id
  service.add_machine_tags(self.id, tags_hash).body
end

#delete_all_metadataObject



86
87
88
89
90
# File 'lib/fog/joyent/models/compute/server.rb', line 86

def 
  requires :id
  service.(self.id)
  true
end

#delete_all_tagsObject



110
111
112
113
114
115
# File 'lib/fog/joyent/models/compute/server.rb', line 110

def delete_all_tags
  requires :id

  service.delete_all_machine_tags(self.id)
  true
end

#delete_metadata(keyname) ⇒ Object

Raises:

  • (ArgumentError)


78
79
80
81
82
83
84
# File 'lib/fog/joyent/models/compute/server.rb', line 78

def (keyname)
  raise ArgumentError, "Must provide a key name to delete" if keyname.nil? || keyname.empty?
  requires :id

  service.(self.id, keyname)
  true
end

#delete_tag(tagname) ⇒ Object

Raises:

  • (ArgumentError)


102
103
104
105
106
107
108
# File 'lib/fog/joyent/models/compute/server.rb', line 102

def delete_tag(tagname)
  requires :id

  raise ArgumentError, "Must provide a tag name to delete" if tagname.nil? || tagname.empty?
  service.delete_machine_tag(self.id, tagname)
  true
end

#destroyObject



34
35
36
37
38
# File 'lib/fog/joyent/models/compute/server.rb', line 34

def destroy
  requires :id
  service.delete_machine(id)
  true
end

#public_ip_addressObject



21
22
23
# File 'lib/fog/joyent/models/compute/server.rb', line 21

def public_ip_address
  ips.empty? ? nil : ips.first
end

#ready?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/fog/joyent/models/compute/server.rb', line 25

def ready?
  self.state == 'running'
end

#rebootObject



60
61
62
63
64
# File 'lib/fog/joyent/models/compute/server.rb', line 60

def reboot
  requires :id
  service.reboot_machine(id)
  true
end

#resize(flavor) ⇒ Object



54
55
56
57
58
# File 'lib/fog/joyent/models/compute/server.rb', line 54

def resize(flavor)
  requires :id
  service.resize_machine(id, flavor.name)
  true
end

#snapshotsObject



66
67
68
69
# File 'lib/fog/joyent/models/compute/server.rb', line 66

def snapshots
  requires :id
  service.snapshots.all(id)
end

#startObject



40
41
42
43
44
45
# File 'lib/fog/joyent/models/compute/server.rb', line 40

def start
  requires :id
  service.start_machine(id)
  self.wait_for { ready? }
  true
end

#stopObject



47
48
49
50
51
52
# File 'lib/fog/joyent/models/compute/server.rb', line 47

def stop
  requires :id
  service.stop_machine(id)
  self.wait_for { stopped? }
  true
end

#stopped?Boolean

Returns:

  • (Boolean)


29
30
31
32
# File 'lib/fog/joyent/models/compute/server.rb', line 29

def stopped?
  requires :id
  self.state == 'stopped'
end

#tagsObject



92
93
94
95
# File 'lib/fog/joyent/models/compute/server.rb', line 92

def tags
  requires :id
  service.list_machine_tags(id).body
end

#update_metadata(data = {}) ⇒ Object



71
72
73
74
75
76
# File 'lib/fog/joyent/models/compute/server.rb', line 71

def (data = {})
  requires :id
  service.(self.id, data)
  self.reload
  true
end