Class: Fog::Rackspace::Databases::Instance

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/rackspace/models/databases/instance.rb

Constant Summary collapse

ACTIVE =

States

'ACTIVE'
BUILD =
'BUILD'
BLOCKED =
'BLOCKED'
REBOOT =
'REBOOT'
RESIZE =
'RESIZE'
SHUTDOWN =
'SHUTDOWN'

Instance Attribute Summary collapse

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

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 Attribute Details

#root_passwordObject

Returns the value of attribute root_password.



26
27
28
# File 'lib/fog/rackspace/models/databases/instance.rb', line 26

def root_password
  @root_password
end

#root_userObject

Returns the value of attribute root_user.



26
27
28
# File 'lib/fog/rackspace/models/databases/instance.rb', line 26

def root_user
  @root_user
end

Instance Method Details

#databasesObject



46
47
48
49
50
51
52
53
# File 'lib/fog/rackspace/models/databases/instance.rb', line 46

def databases
  @databases ||= begin
    Fog::Rackspace::Databases::Databases.new({
      :connection => connection,
      :instance => self
    })
  end
end

#destroyObject



35
36
37
38
39
# File 'lib/fog/rackspace/models/databases/instance.rb', line 35

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

#enable_root_userObject



73
74
75
76
77
78
79
# File 'lib/fog/rackspace/models/databases/instance.rb', line 73

def enable_root_user
  requires :identity
  data = connection.enable_root_user(identity).body['user']
  @root_user = data['name']
  @root_password = data['password']
  true
end

#flavorObject



41
42
43
44
# File 'lib/fog/rackspace/models/databases/instance.rb', line 41

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

#ready?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/fog/rackspace/models/databases/instance.rb', line 64

def ready?
  state == ACTIVE
end

#resize(flavor_id) ⇒ Object



88
89
90
91
92
93
# File 'lib/fog/rackspace/models/databases/instance.rb', line 88

def resize(flavor_id)
  requires :identity
  connection.resize_instance(identity, flavor_id)
  self.state = RESIZE
  true
end

#resize_volume(volume_size) ⇒ Object



95
96
97
98
99
100
# File 'lib/fog/rackspace/models/databases/instance.rb', line 95

def resize_volume(volume_size)
  requires :identity
  connection.resize_instance_volume(identity, volume_size)
  self.state = RESIZE
  true
end

#restartObject



81
82
83
84
85
86
# File 'lib/fog/rackspace/models/databases/instance.rb', line 81

def restart
  requires :identity
  connection.restart_instance(identity)
  self.state = REBOOT
  true
end

#root_user_enabled?Boolean

Returns:

  • (Boolean)


68
69
70
71
# File 'lib/fog/rackspace/models/databases/instance.rb', line 68

def root_user_enabled?
  requires :identity
  connection.check_root_user(identity).body['rootEnabled']
end

#saveObject



28
29
30
31
32
33
# File 'lib/fog/rackspace/models/databases/instance.rb', line 28

def save
  requires :name, :flavor_id, :volume_size
  data = connection.create_instance(name, flavor_id, volume_size)
  merge_attributes(data.body['instance'])
  true
end

#usersObject



55
56
57
58
59
60
61
62
# File 'lib/fog/rackspace/models/databases/instance.rb', line 55

def users
  @users ||= begin
    Fog::Rackspace::Databases::Users.new({
      :connection => connection,
      :instance => self
    })
  end
end