You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/11/10 16:32:47 UTC
[PATCH core 2/2] Core: Added support for dynamic provider list in /api/drivers/:id
From: Michal Fojtik <mf...@redhat.com>
Signed-off-by: Michal fojtik <mf...@redhat.com>
---
server/lib/deltacloud/base_driver/base_driver.rb | 1 +
server/lib/deltacloud/models.rb | 1 +
server/lib/deltacloud/models/provider.rb | 27 ++++++++++++++++++++++
server/lib/deltacloud/server.rb | 1 +
server/views/drivers/show.xml.haml | 13 +++++++---
5 files changed, 39 insertions(+), 4 deletions(-)
create mode 100644 server/lib/deltacloud/models/provider.rb
diff --git a/server/lib/deltacloud/base_driver/base_driver.rb b/server/lib/deltacloud/base_driver/base_driver.rb
index 931ef5c..1aa68e1 100644
--- a/server/lib/deltacloud/base_driver/base_driver.rb
+++ b/server/lib/deltacloud/base_driver/base_driver.rb
@@ -155,6 +155,7 @@ module Deltacloud
# def delete_firewall(credentials, opts)
# def create_firewall_rule(credentials, opts)
# def delete_firewall_rule(credentials, opts)
+ # def providers(credentials)
def realm(credentials, opts)
realms = realms(credentials, opts).first if has_capability?(:realms)
end
diff --git a/server/lib/deltacloud/models.rb b/server/lib/deltacloud/models.rb
index e8cd035..a794192 100644
--- a/server/lib/deltacloud/models.rb
+++ b/server/lib/deltacloud/models.rb
@@ -29,3 +29,4 @@ require 'deltacloud/models/blob'
require 'deltacloud/models/load_balancer'
require 'deltacloud/models/firewall'
require 'deltacloud/models/firewall_rule'
+require 'deltacloud/models/provider'
diff --git a/server/lib/deltacloud/models/provider.rb b/server/lib/deltacloud/models/provider.rb
new file mode 100644
index 0000000..1fc2c7d
--- /dev/null
+++ b/server/lib/deltacloud/models/provider.rb
@@ -0,0 +1,27 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership. The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# Model to store the hardware profile applied to an instance together with
+# any instance-specific overrides
+
+class Provider < BaseModel
+ attr_accessor :url
+ attr_accessor :name
+
+ def initialize(opts={})
+ super(opts)
+ end
+
+end
diff --git a/server/lib/deltacloud/server.rb b/server/lib/deltacloud/server.rb
index 2a5d481..3124659 100644
--- a/server/lib/deltacloud/server.rb
+++ b/server/lib/deltacloud/server.rb
@@ -148,6 +148,7 @@ EOS
param :id, :string
control do
@name = params[:id].to_sym
+ @providers = driver.providers(credentials) if driver.respond_to? :providers
@driver = settings.drivers[@name]
return [404, "Driver #{@name} not found"] unless @driver
respond_to do |format|
diff --git a/server/views/drivers/show.xml.haml b/server/views/drivers/show.xml.haml
index ea5f508..3734c4d 100644
--- a/server/views/drivers/show.xml.haml
+++ b/server/views/drivers/show.xml.haml
@@ -1,7 +1,12 @@
%driver{ :href => driver_url(@name), :id => @name }
%name<
= @driver[:name]
- - driver_provider(@driver).each do |prov, details|
- %provider{ :id => prov }
- - details.each do |kind, url|
- %entrypoint{ :kind => kind }<=cdata(url)
+ - if @providers.nil?
+ - driver_provider(@driver).each do |prov, details|
+ %provider{ :id => prov }
+ - details.each do |kind, url|
+ %entrypoint{ :kind => kind }<=cdata(url)
+ - else
+ - @providers.each do |p|
+ %provider{ :id => p.id }
+ %entrypoint{ :kind => p.name }<=p.url
--
1.7.4.4
Re: [PATCH core 2/2] Core: Added support for dynamic provider list
in /api/drivers/:id
Posted by Michal Fojtik <mi...@mifo.sk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ping. Anyone willing to review this?
-- Michal
mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
>
>
> Signed-off-by: Michal fojtik <mf...@redhat.com> ---
> server/lib/deltacloud/base_driver/base_driver.rb | 1 +
> server/lib/deltacloud/models.rb | 1 +
> server/lib/deltacloud/models/provider.rb | 27
> ++++++++++++++++++++++ server/lib/deltacloud/server.rb
> | 1 + server/views/drivers/show.xml.haml | 13
> +++++++--- 5 files changed, 39 insertions(+), 4 deletions(-) create
> mode 100644 server/lib/deltacloud/models/provider.rb
>
> diff --git a/server/lib/deltacloud/base_driver/base_driver.rb
> b/server/lib/deltacloud/base_driver/base_driver.rb index
> 931ef5c..1aa68e1 100644 ---
> a/server/lib/deltacloud/base_driver/base_driver.rb +++
> b/server/lib/deltacloud/base_driver/base_driver.rb @@ -155,6 +155,7
> @@ module Deltacloud # def delete_firewall(credentials, opts) # def
> create_firewall_rule(credentials, opts) # def
> delete_firewall_rule(credentials, opts) + # def
> providers(credentials) def realm(credentials, opts) realms =
> realms(credentials, opts).first if has_capability?(:realms) end diff
> --git a/server/lib/deltacloud/models.rb
> b/server/lib/deltacloud/models.rb index e8cd035..a794192 100644 ---
> a/server/lib/deltacloud/models.rb +++
> b/server/lib/deltacloud/models.rb @@ -29,3 +29,4 @@ require
> 'deltacloud/models/blob' require 'deltacloud/models/load_balancer'
> require 'deltacloud/models/firewall' require
> 'deltacloud/models/firewall_rule' +require
> 'deltacloud/models/provider' diff --git
> a/server/lib/deltacloud/models/provider.rb
> b/server/lib/deltacloud/models/provider.rb new file mode 100644 index
> 0000000..1fc2c7d --- /dev/null +++
> b/server/lib/deltacloud/models/provider.rb @@ -0,0 +1,27 @@ +#
> Licensed to the Apache Software Foundation (ASF) under one or more +#
> contributor license agreements. See the NOTICE file distributed
> with +# this work for additional information regarding copyright
> ownership. The +# ASF licenses this file to you under the Apache
> License, Version 2.0 (the +# "License"); you may not use this file
> except in compliance with the +# License. You may obtain a copy of
> the License at +# +#
> http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by
> applicable law or agreed to in writing, software +# distributed under
> the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES
> OR CONDITIONS OF ANY KIND, either express or implied. See the +#
> License for the specific language governing permissions and
> limitations +# under the License. + +# Model to store the hardware
> profile applied to an instance together with +# any instance-specific
> overrides + +class Provider < BaseModel + attr_accessor :url +
> attr_accessor :name + + def initialize(opts={}) + super(opts) +
> end + +end diff --git a/server/lib/deltacloud/server.rb
> b/server/lib/deltacloud/server.rb index 2a5d481..3124659 100644 ---
> a/server/lib/deltacloud/server.rb +++
> b/server/lib/deltacloud/server.rb @@ -148,6 +148,7 @@ EOS param :id,
> :string control do @name = params[:id].to_sym + @providers =
> driver.providers(credentials) if driver.respond_to? :providers
> @driver = settings.drivers[@name] return [404, "Driver #{@name} not
> found"] unless @driver respond_to do |format| diff --git
> a/server/views/drivers/show.xml.haml
> b/server/views/drivers/show.xml.haml index ea5f508..3734c4d 100644
> --- a/server/views/drivers/show.xml.haml +++
> b/server/views/drivers/show.xml.haml @@ -1,7 +1,12 @@ %driver{ :href
> => driver_url(@name), :id => @name } %name< = @driver[:name] - -
> driver_provider(@driver).each do |prov, details| - %provider{ :id
> => prov } - - details.each do |kind, url| - %entrypoint{
> :kind => kind }<=cdata(url) + - if @providers.nil? + -
> driver_provider(@driver).each do |prov, details| + %provider{
> :id => prov } + - details.each do |kind, url| +
> %entrypoint{ :kind => kind }<=cdata(url) + - else + -
> @providers.each do |p| + %provider{ :id => p.id } +
> %entrypoint{ :kind => p.name }<=p.url
- --
- ----------------------------------------------------------------
Michal Fojtik
deltacloud.org - Deltacloud API
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJOx+/zAAoJEBGIkweUFTuYAaIIAIrit0n/5qKd7zHjaJ0Q+ed6
9oYyCWRh5DiTzEAbZbfLRGqtHT4npbeX4vY1IT2pbxmNX7YI9T/vN+/tJEq1U1J5
nrwrLjK4XVRXDbMItNubYHiLR02MKIut65wwJtJHJ324JOmzUvyvVTa6AmP8tlw8
0YUp2eqlS1hHCaMxr0egagFnMlU4JqpC83hGe3m0+gEurxUAm+u6h+OHHnDZ1ddE
vUxBKxBjTxhlI5dhFnxMYvoYgKzVuMBmtuTdO+YNLZTDbL+DG+RlhG0CEC7rENEl
rZhGsa48A4kL1jacn9A7nl4L/FQhanVBJbXxp5OyR0TELrnZeSP80v/IMOJljhA=
=tdC2
-----END PGP SIGNATURE-----