Class: Fog::Brightbox::Compute::DatabaseServer

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

Instance Method Summary collapse

Methods included from ResourceLocking

#lock!, #locked?, #unlock!

Methods included from ModelHelper

#collection_name, #resource_name

Instance Method Details

#destroyObject



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

def destroy
  requires :identity
  merge_attributes(service.delete_database_server(identity))
  true
end

#ready?Boolean

Returns:

  • (Boolean)


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

def ready?
  state == "active"
end

#reset_passwordObject



88
89
90
91
92
# File 'lib/fog/brightbox/models/compute/database_server.rb', line 88

def reset_password
  requires :identity
  merge_attributes(service.reset_password_database_server(identity))
  true
end

#saveObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fog/brightbox/models/compute/database_server.rb', line 39

def save
  options = {
    :name => name,
    :description => description
  }

  options[:allow_access] = allow_access if allow_access

  options[:maintenance_weekday] = maintenance_weekday
  options[:maintenance_hour] = maintenance_hour

  if persisted?
    data = update_database_server(options)
  else
    options[:engine] = database_engine if database_engine
    options[:version] = database_version if database_version
    options[:database_type] = flavor_id if flavor_id
    options[:zone] = zone_id if zone_id

    data = create_database_server(options)
  end

  merge_attributes(data)
  true
end

#snapshot(return_snapshot = false) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/fog/brightbox/models/compute/database_server.rb', line 69

def snapshot(return_snapshot = false)
  requires :identity

  response, snapshot_id = service.snapshot_database_server(identity, :return_link => return_snapshot)
  merge_attributes(response)

  if return_snapshot
    service.database_snapshots.get(snapshot_id)
  else
    true
  end
end