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



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

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

#delete_all_metadataObject



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

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

#delete_all_tagsObject



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

def delete_all_tags
  requires :id

  service.delete_all_machine_tags(self.id)
  true
end

#delete_metadata(keyname) ⇒ Object

Raises:

  • (ArgumentError)


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

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)


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

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



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

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

#list_tagsObject



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

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

#public_ip_addressObject



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

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

#ready?Boolean

Returns:

  • (Boolean)


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

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

#rebootObject



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

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

#resize(flavor) ⇒ Object



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

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

#snapshotsObject



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

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

#startObject



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

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

#stopObject



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

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

#stopped?Boolean

Returns:

  • (Boolean)


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

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

#update_metadata(data = {}) ⇒ Object



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

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