Skip to content

Commit

Permalink
Fix up more changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
douglaswth committed Mar 31, 2014
1 parent 799842e commit f9b8e02
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions libraries/provider_rightscale_backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ class RightscaleBackup < Chef::Provider
#
def load_current_resource
@new_resource.nickname(@new_resource.name) unless @new_resource.nickname
@current_resource = Chef::Resource::RightscaleBackup.new(@new_resource.nickname)
@current_resource = Chef::Resource::RightscaleBackup.new(@new_resource.name)
@current_resource.nickname @new_resource.nickname
node.set['rightscale_backup'] ||= {}

@api_client = initialize_api_client
Expand All @@ -39,7 +40,7 @@ def load_current_resource
# TODO: We don't use this attribute anywhere at the moment. This attribute
# is intended to be used in the +:create+ action at some point later.
unless node['rightscale_backup'].empty?
@current_resource.devices(node['rightscale_backup'][@current_resource.name]['devices'])
@current_resource.devices(node['rightscale_backup'][@current_resource.nickname]['devices'])
end
@current_resource.timeout(@new_resource.timeout) if @new_resource.timeout
@current_resource
Expand Down Expand Up @@ -76,8 +77,8 @@ def action_restore
" Please check the lineage and/or timestamp and try again."
end

node.set['rightscale_backup'][@current_resource.name] ||= {}
node.set['rightscale_backup'][@current_resource.name]['devices'] = []
node.set['rightscale_backup'][@current_resource.nickname] ||= {}
node.set['rightscale_backup'][@current_resource.nickname]['devices'] = []

if backup.volume_snapshots.size > 1
updates = backup.volume_snapshots.sort_by { |snapshot| snapshot['position'].to_i }.each do |snapshot|
Expand All @@ -99,7 +100,7 @@ def action_restore
r.run_action(:create)
r.run_action(:attach)

node.set['rightscale_backup'][@current_resource.name]['devices'] <<
node.set['rightscale_backup'][@current_resource.nickname]['devices'] <<
node['rightscale_volume']["#{@new_resource.nickname}_#{snapshot['position']}"]['device']

r.updated?
Expand All @@ -123,7 +124,7 @@ def action_restore
end
r.run_action(:create)
r.run_action(:attach)
node.set['rightscale_backup'][@current_resource.name]['devices'] <<
node.set['rightscale_backup'][@current_resource.nickname]['devices'] <<
node['rightscale_volume'][@new_resource.nickname]['device']

@new_resource.updated_by_last_action(r.updated?)
Expand Down

0 comments on commit f9b8e02

Please sign in to comment.