Class: Fog::Brightbox::Compute::Server

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

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, #identity, #identity=, #merge_attributes, #new_record?, #requires

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#activate_consoleObject



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

def activate_console
  requires :identity
  response = connection.activate_console_server(identity)
  [response["console_url"], response["console_token"], response["console_token_expires"]]
end

#destroyObject



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

def destroy
  requires :identity
  connection.destroy_server(identity)
  true
end

#flavorObject



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

def flavor
  requires :flavor_id
  connection.flavors.get(flavor_id)
end

#imageObject



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

def image
  requires :image_id
  connection.images.get(image_id)
end

#private_ip_addressObject



74
75
76
# File 'lib/fog/compute/models/brightbox/server.rb', line 74

def private_ip_address
  interfaces.first
end

#public_ip_addressObject



78
79
80
# File 'lib/fog/compute/models/brightbox/server.rb', line 78

def public_ip_address
  cloud_ips.first
end

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
  status == 'active'
end

#rebootObject



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

def reboot
  false
end

#saveObject



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/fog/compute/models/brightbox/server.rb', line 92

def save
  requires :image_id
  options = {
    :image => image_id,
    :server_type => flavor_id,
    :name => name,
    :zone => zone_id,
    :user_data => user_data
  }.delete_if {|k,v| v.nil? || v == "" }
  data = connection.create_server(options)
  merge_attributes(data)
  true
end

#shutdownObject



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

def shutdown
  requires :identity
  connection.shutdown_server(identity)
  true
end

#snapshotObject



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

def snapshot
  requires :identity
  connection.snapshot_server(identity)
end

#startObject



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

def start
  requires :identity
  connection.start_server(identity)
  true
end

#stopObject



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

def stop
  requires :identity
  connection.stop_server(identity)
  true
end