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

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Server

#scp, #scp_download, #ssh

Methods inherited from Model

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

Methods included from Attributes::ClassMethods

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

Methods included from Attributes::InstanceMethods

#_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

#add_tags(tags_hash = {}) ⇒ Object



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

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

#delete_all_metadataObject



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

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

#delete_all_tagsObject



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

def delete_all_tags
  requires :id

  self.connection.delete_all_machine_tags(self.id)
  true
end

#delete_metadata(keyname) ⇒ Object

Raises:

  • (ArgumentError)


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

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

  self.connection.(self.id, keyname)
  true
end

#delete_tag(tagname) ⇒ Object

Raises:

  • (ArgumentError)


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

def delete_tag(tagname)
  requires :id

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

#destroyObject



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

def destroy
  requires :id
  self.connection.delete_machine(id)
  true
end

#ready?Boolean

Returns:

  • (Boolean)


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

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

#rebootObject



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

def reboot
  requires :id
  self.connection.reboot_machine(id)
  true
end

#resize(flavor) ⇒ Object



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

def resize(flavor)
  requires :id
  self.connection.resize(id, flavor)
  true
end

#snapshotsObject



63
64
65
66
# File 'lib/fog/joyent/models/compute/server.rb', line 63

def snapshots
  requires :id
  self.connection.snapshots.all(id)
end

#startObject



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

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

#stopObject



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

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

#stopped?Boolean

Returns:

  • (Boolean)


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

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

#tagsObject



89
90
91
92
# File 'lib/fog/joyent/models/compute/server.rb', line 89

def tags
  requires :id
  self.connection.list_machine_tags(id).body
end

#update_metadata(data = {}) ⇒ Object



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

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