From: marios <[email protected]> requires latest openstack rubygem - >= 1.0.8
Signed-off-by: marios <[email protected]> --- server/deltacloud-core.gemspec | 2 +- .../deltacloud/collections/storage_snapshots.rb | 4 +++- .../drivers/openstack/openstack_driver.rb | 25 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/server/deltacloud-core.gemspec b/server/deltacloud-core.gemspec index 70cd576..0555c21 100644 --- a/server/deltacloud-core.gemspec +++ b/server/deltacloud-core.gemspec @@ -111,7 +111,7 @@ Gem::Specification.new do |s| s.add_dependency('uuidtools', '>= 2.1.1') # Openstack Compute and Object-Storage - s.add_dependency('openstack', '>= 1.0.7') + s.add_dependency('openstack', '>= 1.0.8') # Aruba Cloud s.add_dependency('savon', '>= 1.0.0') diff --git a/server/lib/deltacloud/collections/storage_snapshots.rb b/server/lib/deltacloud/collections/storage_snapshots.rb index dca253a..c18bb41 100644 --- a/server/lib/deltacloud/collections/storage_snapshots.rb +++ b/server/lib/deltacloud/collections/storage_snapshots.rb @@ -26,7 +26,9 @@ module Deltacloud::Collections standard_show_operation operation :create, :with_capability => :create_storage_snapshot do - param :volume_id, :string, :required + param :volume_id, :string, :required + param :name, :string, :optional + param :description, :string, :optional control do @storage_snapshot = driver.create_storage_snapshot(credentials, params) status 201 # Created diff --git a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb index 6d0ae9c..b9be595 100644 --- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb +++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb @@ -435,19 +435,33 @@ module Deltacloud def storage_snapshots(credentials, opts={}) vs = new_client(credentials, "volume") + snapshots = [] safely do + if opts[:id] + snapshots << convert_snapshot(vs.get_snapshot(opts[:id])) + else + vs.snapshots.each do |snap| + snapshots << convert_snapshot(snap) + end + end end + snapshots end def create_storage_snapshot(credentials, opts={}) vs = new_client(credentials, "volume") safely do + name = opts[:name] || "snapshot_#{Time.now.to_i}" + description = opts[:description] || "snapshot from volume #{opts[:volume_id]}" + params = {:volume_id => opts[:volume_id], :display_name=>name, :display_description=>description} + convert_snapshot(vs.create_snapshot(params)) end end def destroy_storage_snapshot(credentials, opts={}) vs = new_client(credentials, "volume") safely do + vs.delete_snapshot(opts[:id]) end end @@ -607,6 +621,17 @@ private }) end + def convert_snapshot(snapshot) + StorageSnapshot.new( + :id => snapshot.id, + :name => snapshot.display_name, + :description => snapshot.display_description || snapshot.display_name, + :state => snapshot.status, + :storage_volume_id => snapshot.volume_id, + :created => snapshot.created_at + ) + end + #IN: path1='server_path1'. content1='contents1', path2='server_path2', content2='contents2' etc #OUT:{local_path=>server_path, local_path1=>server_path2 etc} def extract_personality(opts) -- 1.7.11.7
