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

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

Instance Method Summary collapse

Instance Method Details

#add_tags(tags_hash = {}) ⇒ Object


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

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

#delete_all_metadataObject


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

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

#delete_all_tagsObject


115
116
117
118
119
120
# File 'lib/fog/joyent/models/compute/server.rb', line 115

def delete_all_tags
  requires :id

  service.delete_all_machine_tags(self.id)
  true
end

#delete_metadata(keyname) ⇒ Object

Raises:

  • (ArgumentError)

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

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)

107
108
109
110
111
112
113
# File 'lib/fog/joyent/models/compute/server.rb', line 107

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


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

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

#list_tagsObject


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

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

#public_ip_addressObject


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

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

#ready?Boolean

Returns:

  • (Boolean)

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

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

#rebootObject


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

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

#resize(flavor) ⇒ Object


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

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

#snapshotsObject


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

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

#startObject


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

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

#stopObject


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

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

#stopped?Boolean

Returns:

  • (Boolean)

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

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

#update_metadata(data = {}) ⇒ Object


76
77
78
79
80
81
# File 'lib/fog/joyent/models/compute/server.rb', line 76

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