Class: OVH::Provisioner::APIObject::DedicatedServer
- Defined in:
- lib/ovh/provisioner/api_object/dedicated_server.rb
Overview
Represent a dedicated server
Constant Summary collapse
- IDLE =
install_status const
'Server is not being installed or reinstalled at the moment'
- NO_OS =
'none_64'
Instance Attribute Summary collapse
-
#boot ⇒ Object
readonly
Returns the value of attribute boot.
-
#dc ⇒ Object
readonly
Returns the value of attribute dc.
-
#flavor ⇒ Object
readonly
Returns the value of attribute flavor.
-
#flavor_tag ⇒ Object
readonly
Returns the value of attribute flavor_tag.
-
#install_status ⇒ Object
readonly
Returns the value of attribute install_status.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#os ⇒ Object
readonly
Returns the value of attribute os.
-
#reverse ⇒ Object
readonly
Returns the value of attribute reverse.
-
#server_id ⇒ Object
readonly
Returns the value of attribute server_id.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#vrack ⇒ Object
readonly
Returns the value of attribute vrack.
-
#vrack_id ⇒ Object
readonly
Returns the value of attribute vrack_id.
Attributes inherited from APIObject
Instance Method Summary collapse
- #define_reverse(domain, name = newname) ⇒ Object
- #install ⇒ Object
- #ipmi ⇒ Object
- #newname ⇒ Object
- #rename(domain, name = newname) ⇒ Object
- #to_s ⇒ Object
Methods inherited from APIObject
#<=>, attr_reader, attributes, #attributes, classname, #config, #delete, entrypoint, #get, #init_properties, #initialize, #post, underscore
Constructor Details
This class inherits a constructor from OVH::Provisioner::APIObject::APIObject
Instance Attribute Details
#boot ⇒ Object (readonly)
Returns the value of attribute boot.
30 31 32 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 30 def boot @boot end |
#dc ⇒ Object (readonly)
Returns the value of attribute dc.
30 31 32 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 30 def dc @dc end |
#flavor ⇒ Object (readonly)
Returns the value of attribute flavor.
32 33 34 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 32 def flavor @flavor end |
#flavor_tag ⇒ Object (readonly)
Returns the value of attribute flavor_tag.
32 33 34 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 32 def flavor_tag @flavor_tag end |
#install_status ⇒ Object (readonly)
Returns the value of attribute install_status.
34 35 36 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 34 def install_status @install_status end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
30 31 32 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 30 def ip @ip end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
30 31 32 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 30 def location @location end |
#os ⇒ Object (readonly)
Returns the value of attribute os.
30 31 32 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 30 def os @os end |
#reverse ⇒ Object (readonly)
Returns the value of attribute reverse.
30 31 32 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 30 def reverse @reverse end |
#server_id ⇒ Object (readonly)
Returns the value of attribute server_id.
30 31 32 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 30 def server_id @server_id end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
31 32 33 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 31 def state @state end |
#vrack ⇒ Object (readonly)
Returns the value of attribute vrack.
33 34 35 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 33 def vrack @vrack end |
#vrack_id ⇒ Object (readonly)
Returns the value of attribute vrack_id.
33 34 35 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 33 def vrack_id @vrack_id end |
Instance Method Details
#define_reverse(domain, name = newname) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 79 def define_reverse(domain, name = newname) full_name = "#{name}.#{domain.id}" return "#{reverse}: no change" if reverse == full_name add_reverse(full_name) end |
#install ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 36 def install raise 'Please provide a valid template' if config['template'].nil? ok, reason = can_install if ok result = post('install/start', install_body) if result.is_a?(String) # Meaning an error message reason = result ok = false end end "#{id}: #{ok ? 'ok' : 'failed'}\n #{reason}" end |
#ipmi ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 86 def ipmi request_ipmi (1..10).each do |_| result = get('features/ipmi/access?type=kvmipJnlp') unless result.is_a?(String) launch_ipmi(result['value']) break end sleep(1) end end |
#newname ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 57 def newname name_scheme = Provisioner.config['name_scheme'] return reverse if name_scheme.nil? subst = attributes.map { |a| { a => send(a) } }.reduce(&:merge) name_scheme % subst end |
#rename(domain, name = newname) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 65 def rename(domain, name = newname) full_name = "#{name}.#{domain.id}" return "#{reverse}: no change" if reverse == full_name # check if name is already used records = domain.filter_records('subdomain' => newname) return "#{reverse}: name already used" unless records.list.empty? # remove old name (only if it belongs to the same domain) remove_old_names(domain) domain.add_record(name, 'A', ip) end |
#to_s ⇒ Object
50 51 52 53 54 55 |
# File 'lib/ovh/provisioner/api_object/dedicated_server.rb', line 50 def to_s "#{reverse}[#{id}/#{server_id}]" \ "\n #{location} - #{flavor} - #{vrack}:#{ip} " \ "- #{boot}:#{os} - #{state}" \ "\n #{install_status}" end |