You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2013/04/04 08:54:31 UTC
[1/6] git commit: Mock: Fixed filtering of images using owner_id
Updated Branches:
refs/heads/master 61122c833 -> 3b6bf5620
Mock: Fixed filtering of images using owner_id
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/009ed0cd
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/009ed0cd
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/009ed0cd
Branch: refs/heads/master
Commit: 009ed0cd7d0f8d9ae6db93b3775c9207f7c41d29
Parents: 61122c8
Author: Michal Fojtik <mf...@redhat.com>
Authored: Wed Apr 3 17:43:17 2013 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Wed Apr 3 17:43:17 2013 +0200
----------------------------------------------------------------------
server/lib/deltacloud/drivers/mock/mock_driver.rb | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/009ed0cd/server/lib/deltacloud/drivers/mock/mock_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index 07c67e2..51a568c 100644
--- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
+++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
@@ -114,7 +114,7 @@ module Deltacloud::Drivers::Mock
results
end
- def filter_by_owner(images, owner_id)
+ def filter_by_owner(credentials, images, owner_id)
return images unless owner_id
if owner_id == 'self'
images.select { |e| e.owner_id == credentials.user }
@@ -131,7 +131,7 @@ module Deltacloud::Drivers::Mock
images = @client.build_all(Image)
images = filter_on(images, opts, :id, :architecture)
- images = filter_by_owner(images, opts[:owner_id])
+ images = filter_by_owner(credentials, images, opts[:owner_id])
# Add hardware profiles to each image
images = images.map { |i| (i.hardware_profiles = hardware_profiles(nil)) && i }
[5/6] git commit: Client: Updated tests for #url and InstanceAddress
(DTACLOUD-523)
Posted by mf...@apache.org.
Client: Updated tests for #url and InstanceAddress (DTACLOUD-523)
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/42fad4f3
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/42fad4f3
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/42fad4f3
Branch: refs/heads/master
Commit: 42fad4f3db9f4837da02cc32534bf24cda8a5f19
Parents: ff137e0
Author: Michal Fojtik <mf...@redhat.com>
Authored: Wed Apr 3 16:08:15 2013 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Thu Apr 4 08:54:12 2013 +0200
----------------------------------------------------------------------
client/tests/methods/instance_test.rb | 6 ++++++
client/tests/models/image_test.rb | 2 ++
2 files changed, 8 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/42fad4f3/client/tests/methods/instance_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/methods/instance_test.rb b/client/tests/methods/instance_test.rb
index 47b3934..4abe1b2 100644
--- a/client/tests/methods/instance_test.rb
+++ b/client/tests/methods/instance_test.rb
@@ -50,6 +50,12 @@ describe Deltacloud::Client::Methods::Instance do
@client.must_respond_to :instance
result = @client.instance('inst1')
result.must_be_instance_of Deltacloud::Client::Instance
+ result.public_addresses.wont_be_empty
+ result.public_addresses.first[:type].must_equal :hostname
+ result.public_addresses.first.type.must_equal :hostname
+ result.public_addresses.first[:value].must_equal 'img1.inst1.public.com'
+ result.public_addresses.first.value.must_equal 'img1.inst1.public.com'
+ result.public_addresses.first.to_s.must_equal 'img1.inst1.public.com'
lambda { @client.instance(nil) }.must_raise Deltacloud::Client::NotFound
lambda { @client.instance('foo') }.must_raise Deltacloud::Client::NotFound
end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/42fad4f3/client/tests/models/image_test.rb
----------------------------------------------------------------------
diff --git a/client/tests/models/image_test.rb b/client/tests/models/image_test.rb
index 6c32d06..a9305ed 100644
--- a/client/tests/models/image_test.rb
+++ b/client/tests/models/image_test.rb
@@ -58,6 +58,8 @@ describe Deltacloud::Client::Image do
it 'supports #id' do
img = @client.image('img1')
lambda { img.id.must_equal 'img1' }.must_output nil, "[DEPRECATION] `id` is deprecated because of a possible conflict with Object#id. Use `_id` instead.\n"
+ img.must_respond_to :url
+ img.url.must_equal 'http://localhost:3001/api/images/img1'
end
end
[2/6] git commit: Client: Added #actions and #create_image for
Instance
Posted by mf...@apache.org.
Client: Added #actions and #create_image for Instance
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/3b6bf562
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/3b6bf562
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/3b6bf562
Branch: refs/heads/master
Commit: 3b6bf56201cefb30e4650a8b0b9ee23e94721e21
Parents: 42fad4f
Author: Michal Fojtik <mf...@redhat.com>
Authored: Wed Apr 3 16:15:33 2013 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Thu Apr 4 08:54:12 2013 +0200
----------------------------------------------------------------------
client/lib/deltacloud/client/models/instance.rb | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/3b6bf562/client/lib/deltacloud/client/models/instance.rb
----------------------------------------------------------------------
diff --git a/client/lib/deltacloud/client/models/instance.rb b/client/lib/deltacloud/client/models/instance.rb
index 01e1882..77d3498 100644
--- a/client/lib/deltacloud/client/models/instance.rb
+++ b/client/lib/deltacloud/client/models/instance.rb
@@ -26,6 +26,7 @@ module Deltacloud::Client
attr_reader :owner_id
attr_reader :image_id
attr_reader :hardware_profile_id
+ attr_reader :actions
attr_accessor :state
attr_accessor :public_addresses
@@ -74,6 +75,15 @@ module Deltacloud::Client
super
end
+ def can_create_image?
+ actions.include? :create_image
+ end
+
+ def create_image(create_opts={})
+ return false unless can_create_image?
+ super(_id, create_opts)
+ end
+
# Helper for is_STATE?
#
# is_running?
@@ -100,7 +110,8 @@ module Deltacloud::Client
),
:private_addresses => InstanceAddress.convert(
xml_body.xpath('private_addresses/address')
- )
+ ),
+ :actions => xml_body.xpath('actions/link').map { |a| a['rel'].to_sym }
}
end
[3/6] git commit: Client: Added #url method to all client objects
Posted by mf...@apache.org.
Client: Added #url method to all client objects
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/ff137e06
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/ff137e06
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/ff137e06
Branch: refs/heads/master
Commit: ff137e063d2f1f1b8dc446d1721b9bbbb954138a
Parents: 1cd40ce
Author: Michal Fojtik <mf...@redhat.com>
Authored: Wed Apr 3 16:07:52 2013 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Thu Apr 4 08:54:12 2013 +0200
----------------------------------------------------------------------
client/lib/deltacloud/client/models/base.rb | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ff137e06/client/lib/deltacloud/client/models/base.rb
----------------------------------------------------------------------
diff --git a/client/lib/deltacloud/client/models/base.rb b/client/lib/deltacloud/client/models/base.rb
index dbf34f7..cfdab5d 100644
--- a/client/lib/deltacloud/client/models/base.rb
+++ b/client/lib/deltacloud/client/models/base.rb
@@ -27,6 +27,7 @@ module Deltacloud::Client
# - obj_id -> The :id of Deltacloud API model (eg. instance ID)
#
attr_reader :obj_id
+ attr_reader :url
attr_reader :name
attr_reader :description
@@ -122,6 +123,7 @@ module Deltacloud::Client
attrs = parse(body)
attrs.merge!({
:_id => body['id'],
+ :url => body['href'],
:_client => client_ref,
:name => body.text_at(:name),
:description => body.text_at(:description)
[4/6] git commit: Client: Added base64#encode for user_data
(DTACLOUD-522)
Posted by mf...@apache.org.
Client: Added base64#encode for user_data (DTACLOUD-522)
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/c9816011
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/c9816011
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/c9816011
Branch: refs/heads/master
Commit: c981601180e7a60b2258101bb1b10066b7e080a3
Parents: 009ed0c
Author: Michal Fojtik <mf...@redhat.com>
Authored: Wed Apr 3 15:57:01 2013 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Thu Apr 4 08:54:12 2013 +0200
----------------------------------------------------------------------
client/lib/deltacloud/client.rb | 1 +
client/lib/deltacloud/client/methods/instance.rb | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c9816011/client/lib/deltacloud/client.rb
----------------------------------------------------------------------
diff --git a/client/lib/deltacloud/client.rb b/client/lib/deltacloud/client.rb
index c7048dd..7304146 100644
--- a/client/lib/deltacloud/client.rb
+++ b/client/lib/deltacloud/client.rb
@@ -19,6 +19,7 @@ module Deltacloud
require 'ostruct'
require 'nokogiri'
require 'faraday'
+ require 'base64'
# Core extensions
require_relative './core_ext'
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/c9816011/client/lib/deltacloud/client/methods/instance.rb
----------------------------------------------------------------------
diff --git a/client/lib/deltacloud/client/methods/instance.rb b/client/lib/deltacloud/client/methods/instance.rb
index 506c338..3ed6a31 100644
--- a/client/lib/deltacloud/client/methods/instance.rb
+++ b/client/lib/deltacloud/client/methods/instance.rb
@@ -52,6 +52,7 @@ module Deltacloud::Client
# Returns created instance, or list of created instances or all instances.
#
def create_instance(image_id, create_opts={})
+ create_opts[:user_data] = Base64::encode64(create_opts[:user_data]) if create_opts[:user_data]
r = create_resource :instance, create_opts.merge(
:image_id => image_id,
:no_convert_model => true
[6/6] git commit: Client: Make possible to retrieve attrs from
InstanceAddress (DTACLOUD-522)
Posted by mf...@apache.org.
Client: Make possible to retrieve attrs from InstanceAddress (DTACLOUD-522)
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/1cd40ce1
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/1cd40ce1
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/1cd40ce1
Branch: refs/heads/master
Commit: 1cd40ce15de49dbdc544df2a7cf8aaa30313f5d0
Parents: c981601
Author: Michal Fojtik <mf...@redhat.com>
Authored: Wed Apr 3 15:57:34 2013 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Thu Apr 4 08:54:12 2013 +0200
----------------------------------------------------------------------
.../deltacloud/client/models/instance_address.rb | 19 +++++++++-----
1 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/1cd40ce1/client/lib/deltacloud/client/models/instance_address.rb
----------------------------------------------------------------------
diff --git a/client/lib/deltacloud/client/models/instance_address.rb b/client/lib/deltacloud/client/models/instance_address.rb
index f40c264..1099c8b 100644
--- a/client/lib/deltacloud/client/models/instance_address.rb
+++ b/client/lib/deltacloud/client/models/instance_address.rb
@@ -14,10 +14,18 @@
# under the License.
module Deltacloud::Client
- class InstanceAddress < OpenStruct
+ class InstanceAddress
- attr_reader :type
- attr_reader :value
+ attr_reader :type, :value
+
+ def initialize(type, value)
+ @type = type
+ @value = value
+ end
+
+ def [](attr)
+ instance_variable_get("@#{attr}")
+ end
def to_s
@value
@@ -25,10 +33,7 @@ module Deltacloud::Client
def self.convert(address_xml_block)
address_xml_block.map do |addr|
- new(
- :type => addr['type'],
- :value => addr.text
- )
+ new(addr['type'].to_sym, addr.text)
end
end
end