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, #symbolize_keys, #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



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

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

#delete_all_metadataObject



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

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

#delete_all_tagsObject



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

def delete_all_tags
  requires :id

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

#delete_metadata(keyname) ⇒ Object

Raises:

  • (ArgumentError)


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

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)


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

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



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

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

#ready?Boolean

Returns:

  • (Boolean)


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

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

#rebootObject



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

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

#resize(flavor) ⇒ Object



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

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

#snapshotsObject



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

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

#startObject



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

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

#stopObject



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

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

#stopped?Boolean

Returns:

  • (Boolean)


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

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

#tagsObject



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

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

#update_metadata(data = {}) ⇒ Object



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

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