From: Michal Fojtik <mfoj...@redhat.com>
Signed-off-by: Michal fojtik <mfoj...@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