Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect encryption status of cloud volume snapshot #259

Merged
merged 1 commit into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def snapshots
:creation_time => snap['start_time'],
:description => snap['description'],
:size => snap['volume_size'].to_i.gigabytes,
:cloud_volume => persister.cloud_volumes.lazy_find(snap['volume_id'])
:cloud_volume => persister.cloud_volumes.lazy_find(snap['volume_id']),
:encrypted => snap['encrypted'],
)
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def cloud_volume_snapshots(extra_attributes = {})
:description,
:size,
:cloud_volume,
:encrypted,
],
:builder_params => {
:ems_id => ->(persister) { persister.manager.try(:ebs_storage_manager).try(:id) || persister.manager.id },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def parse_snapshot(snap)
:creation_time => snap.start_time,
:description => snap.description,
:size => snap.volume_size.to_i.gigabytes,
:volume => @data_index.fetch_path(:cloud_volumes, snap.volume_id)
:volume => @data_index.fetch_path(:cloud_volumes, snap.volume_id),
:encrypted => snap.encrypted,
}

return uid, new_result
Expand Down
3 changes: 2 additions & 1 deletion spec/models/manageiq/providers/amazon/aws_stubs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,8 @@ def mocked_cloud_volume_snapshots
:volume_size => 1,
:state => "completed",
:volume_id => "volume_id_#{i}",
:tags => [{ :key => "name", :value => "snapshot_#{i}" }]
:tags => [{ :key => "name", :value => "snapshot_#{i}" }],
:encrypted => (i == 0 ? true : false),
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def refresh_spec_full
refresh_spec_counts

assert_specific_snapshot
assert_unencrypted_snapshot
assert_specific_volume
assert_unencrypted_volume
end
Expand Down Expand Up @@ -196,22 +197,38 @@ def assert_ems
end

def assert_specific_snapshot
@snapshot = ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolumeSnapshot.where(:ems_ref => "snapshot_id_0").first
snapshot = ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolumeSnapshot.where(:ems_ref => "snapshot_id_0").first

expect(@snapshot).not_to be_nil
expect(@snapshot).to have_attributes(
expect(snapshot).not_to be_nil
expect(snapshot).to have_attributes(
:ems_ref => "snapshot_id_0",
:name => "snapshot_0",
:description => "snapshot_desc_0",
:status => "completed",
:size => 1.gigabyte
:size => 1.gigabyte,
:encrypted => true,
)

expect(@snapshot.ext_management_system).to eq(@ems.ebs_storage_manager)
expect(snapshot.ext_management_system).to eq(@ems.ebs_storage_manager)
end

def assert_unencrypted_snapshot
snapshot = ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolumeSnapshot.where(:ems_ref => "snapshot_id_1").first

expect(snapshot).not_to be_nil
expect(snapshot).to have_attributes(
:ems_ref => "snapshot_id_1",
:name => "snapshot_1",
:description => "snapshot_desc_1",
:status => "completed",
:size => 1.gigabyte,
:encrypted => false,
)
end

def assert_specific_volume
@volume = ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolume.where(:ems_ref => "volume_id_0").first
snapshot = ManageIQ::Providers::Amazon::StorageManager::Ebs::CloudVolumeSnapshot.where(:ems_ref => "snapshot_id_0").first

expect(@volume).not_to be_nil
expect(@volume).to have_attributes(
Expand All @@ -225,7 +242,7 @@ def assert_specific_volume
)

expect(@volume.ext_management_system).to eq(@ems.ebs_storage_manager)
expect(@volume.base_snapshot).to eq(@snapshot)
expect(@volume.base_snapshot).to eq(snapshot)

# EBS manager is updating attributes of the pre-existing disk so we need to reload the disk
# before checking if the update was successful.
Expand Down