From: David Lutterkort lutter@redhat.com
From now on, we solely use hardware profiles
--- client/bin/deltacloudc | 8 +- client/lib/dcloud/flavor.rb | 49 -------------- client/lib/dcloud/instance.rb | 3 - client/lib/deltacloud.rb | 29 --------- client/specs/fixtures/instances/inst0.yml | 1 - client/specs/fixtures/instances/inst1.yml | 1 - client/specs/fixtures/instances/inst2.yml | 1 - client/specs/flavors_spec.rb | 67 -------------------- client/specs/initialization_spec.rb | 2 +- client/specs/instances_spec.rb | 9 --- client/specs/storage_volume_spec.rb | 6 +- server/Rakefile | 1 - server/deltacloud.rb | 1 - server/features/api.feature | 2 - server/features/flavors.feature | 23 ------- server/features/instances.feature | 8 +- server/features/step_definitions/flavors_steps.rb | 5 -- .../features/step_definitions/instances_steps.rb | 11 ++- server/features/support/ec2/config.yaml | 8 +- server/features/support/mock/config.yaml | 3 - server/lib/converters/xml_converter.rb | 8 --- server/lib/deltacloud/base_driver/base_driver.rb | 14 ---- server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 45 ------------- .../drivers/mock/data/instances/inst0.yml | 1 - .../drivers/mock/data/instances/inst1.yml | 1 - .../drivers/mock/data/instances/inst2.yml | 1 - server/lib/deltacloud/drivers/mock/mock_driver.rb | 46 ------------- .../drivers/opennebula/opennebula_driver.rb | 34 +--------- .../drivers/rackspace/rackspace_driver.rb | 16 ----- .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb | 20 +----- .../deltacloud/drivers/rimu/rimu_hosting_driver.rb | 16 +----- server/lib/deltacloud/helpers/conversion_helper.rb | 2 +- server/lib/deltacloud/helpers/driver_helper.rb | 2 +- server/lib/deltacloud/models/flavor.rb | 25 ------- server/lib/deltacloud/models/instance.rb | 1 - server/lib/sinatra/rabbit.rb | 2 +- server/server.rb | 24 ------- server/tests/deltacloud_test.rb | 2 +- server/tests/flavors_test.rb | 65 ------------------- server/tests/images_test.rb | 8 +- server/tests/instances_test.rb | 14 ++-- server/tests/realms_test.rb | 8 +- server/views/flavors/index.html.haml | 21 ------ server/views/flavors/show.html.haml | 16 ----- server/views/instances/index.html.haml | 3 - server/views/instances/show.html.haml | 4 - 46 files changed, 48 insertions(+), 589 deletions(-) delete mode 100644 client/lib/dcloud/flavor.rb delete mode 100644 client/specs/flavors_spec.rb delete mode 100644 server/features/flavors.feature delete mode 100644 server/features/step_definitions/flavors_steps.rb delete mode 100644 server/lib/deltacloud/models/flavor.rb delete mode 100644 server/tests/flavors_test.rb delete mode 100644 server/views/flavors/index.html.haml delete mode 100644 server/views/flavors/show.html.haml
diff --git a/client/bin/deltacloudc b/client/bin/deltacloudc index 246c5b1..1ba0bf5 100755 --- a/client/bin/deltacloudc +++ b/client/bin/deltacloudc @@ -39,7 +39,7 @@ BANNER opts.on( '-i', '--id ID', 'ID for operation') { |id| options[:id] = id } opts.on( '-d', '--image-id ID', 'Image ID') { |id| options[:image_id] = id } opts.on( '-a', '--arch ARCH', 'Architecture (x86, x86_64)') { |id| options[:architecture] = id } - opts.on( '-f', '--flavor_id FLAVOR', 'Flavor') { |id| options[:flavor_id] = id } + opts.on( '-p', '--hardware-profile HARDWARE_PROFILE', 'Hardware Profile') { |id| options[:hwp_id] = id } opts.on( '-n', '--name NAME', 'Name (for instance eg.)') { |name| options[:name] = name } opts.on( '-s', '--state STATE', 'Instance state (RUNNING, STOPPED)') { |state| options[:state] = state } opts.on( '-u', '--url URL', 'API url ($API_URL variable)') { |url| options[:api_url] = url } @@ -97,7 +97,7 @@ if options[:version] exit(0) end
-# List items from collection (typically /flavors) +# List items from collection (typically /instances) # Do same if 'index' operation is set if options[:collection] and ( options[:operation].nil? or options[:operation].eql?('index') ) invalid_usage("Unknown collection: #{options[:collection]}") unless collections.include?(options[:collection].to_sym) @@ -126,7 +126,7 @@ if options[:collection] and options[:operation] end
# If collection is set and requested operation is create new instance, - # --image-id, --flavor-id and --name parameters are used + # --image-id, --hardware-profile and --name parameters are used # Returns created instance in plain form if options[:collection].eql?('instances') and options[:operation].eql?('create') invalid_usage("Missing image-id") unless options[:image_id] @@ -135,7 +135,7 @@ if options[:collection] and options[:operation] end params.merge!(:name => options[:name]) if options[:name] params.merge!(:image_id => options[:image_id]) if options[:image_id] - params.merge!(:flavor_id => options[:flavor_id]) if options[:flavor_id] + params.merge!(:hwp_id => options[:hwp_id]) if options[:hwp_id] instance = client.create_instance(options[:image_id], params) puts instance.to_plain exit(0) diff --git a/client/lib/dcloud/flavor.rb b/client/lib/dcloud/flavor.rb deleted file mode 100644 index dfa3b44..0000000 --- a/client/lib/dcloud/flavor.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -require 'dcloud/base_model' - -module DCloud - class Flavor < BaseModel - - xml_tag_name :flavor - - attribute :memory - attribute :storage - attribute :architecture - - def initialize(client, uri, xml=nil) - super( client, uri, xml ) - end - - def load_payload(xml=nil) - super(xml) - unless xml.nil? - @memory = xml.text( 'memory' ).to_f - @storage = xml.text( 'storage' ).to_f - @architecture = xml.text( 'architecture' ) - end - end - - def to_plain - sprintf("%-15s | %-6s | %10s GB | %10s GB", self.id[0, 15], self.architecture[0,6], - self.memory.to_s[0,10], self.storage.to_s[0,10]) - end - - end -end diff --git a/client/lib/dcloud/instance.rb b/client/lib/dcloud/instance.rb index 00636c6..4898083 100644 --- a/client/lib/dcloud/instance.rb +++ b/client/lib/dcloud/instance.rb @@ -57,7 +57,6 @@ module DCloud attribute :state attribute :actions attribute :image - attribute :flavor attribute :realm attribute :action_urls attribute :instance_profile @@ -121,8 +120,6 @@ module DCloud end image_uri = xml.get_elements( 'image' )[0].attributes['href'] @image = Image.new( @client, image_uri ) - flavor_uri = xml.get_elements( 'flavor' )[0].attributes['href'] - @flavor = Flavor.new( @client, flavor_uri ) # Only use realms if they are there if (!xml.get_elements( 'realm' ).empty?) realm_uri = xml.get_elements( 'realm' )[0].attributes['href'] diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb index dbbd89b..7593a56 100644 --- a/client/lib/deltacloud.rb +++ b/client/lib/deltacloud.rb @@ -18,7 +18,6 @@ require 'rest_client' require 'rexml/document' require 'logger' -require 'dcloud/flavor' require 'dcloud/hardware_profile' require 'dcloud/realm' require 'dcloud/image' @@ -81,34 +80,6 @@ class DeltaCloud @features.has_key?(collection) && @features[collection].include?(name) end
- def flavors(opts={}) - flavors = [] - request(entry_points[:flavors], :get, opts) do |response| - doc = REXML::Document.new( response ) - doc.get_elements( 'flavors/flavor' ).each do |flavor| - uri = flavor.attributes['href'] - flavors << DCloud::Flavor.new( self, uri, flavor ) - end - end - flavors - end - - def flavor(id) - request( entry_points[:flavors], :get, {:id=>id } ) do |response| - doc = REXML::Document.new( response ) - doc.get_elements( '/flavor' ).each do |flavor| - uri = flavor.attributes['href'] - return DCloud::Flavor.new( self, uri, flavor ) - end - end - end - - def fetch_flavor(uri) - xml = fetch_resource( :flavor, uri ) - return DCloud::Flavor.new( self, uri, xml ) if xml - nil - end - def hardware_profiles(opts={}) hardware_profiles = [] request(entry_points[:hardware_profiles], :get, opts) do |response| diff --git a/client/specs/fixtures/instances/inst0.yml b/client/specs/fixtures/instances/inst0.yml index c1880b7..a5b73be 100644 --- a/client/specs/fixtures/instances/inst0.yml +++ b/client/specs/fixtures/instances/inst0.yml @@ -7,7 +7,6 @@ :private_addresses: - img1.inst0.private.com :image_id: img1 -:flavor_id: m1-large :instance_profile: !ruby/object:InstanceProfile id: m1-large memory: "12288" diff --git a/client/specs/fixtures/instances/inst1.yml b/client/specs/fixtures/instances/inst1.yml index aa3f86e..3544d40 100644 --- a/client/specs/fixtures/instances/inst1.yml +++ b/client/specs/fixtures/instances/inst1.yml @@ -4,7 +4,6 @@ :owner_id: mockuser :public_addresses: [ img3.inst1.public.com ] :private_addresses: [ img3.inst1.private.com ] -:flavor_id: m1-small :realm_id: us :instance_profile: !ruby/object:InstanceProfile id: m1-small diff --git a/client/specs/fixtures/instances/inst2.yml b/client/specs/fixtures/instances/inst2.yml index 69d4720..9a70cb8 100644 --- a/client/specs/fixtures/instances/inst2.yml +++ b/client/specs/fixtures/instances/inst2.yml @@ -4,7 +4,6 @@ :owner_id: anotheruser :public_addresses: [ img1.inst2.public.com ] :private_addresses: [ img1.inst2.private.com ] -:flavor_id: m1-small :realm_id: us :instance_profile: !ruby/object:InstanceProfile id: m1-large diff --git a/client/specs/flavors_spec.rb b/client/specs/flavors_spec.rb deleted file mode 100644 index 91a063e..0000000 --- a/client/specs/flavors_spec.rb +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -require 'specs/spec_helper' - -describe "flavors" do - - it_should_behave_like "all resources" - - it "should allow retrieval of all flavors" do - DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client| - flavors = client.flavors - flavors.should_not be_empty - flavors.each do |flavor| - flavor.uri.should_not be_nil - flavor.uri.should be_a(String) - flavor.architecture.should_not be_nil - flavor.architecture.should be_a(String) - flavor.storage.should_not be_nil - flavor.storage.should be_a(Float) - flavor.memory.should_not be_nil - flavor.memory.should be_a(Float) - end - end - end - - it "should allow filtering of flavors by architecture" do - DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client| - flavors = client.flavors( :architecture=>'i386' ) - flavors.should_not be_empty - flavors.size.should eql( 1 ) - flavors.first.architecture.should eql( 'i386' ) - end - end - - it "should allow fetching a flavor by id" do - DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client| - flavor = client.flavor( 'm1-small' ) - flavor.should_not be_nil - flavor.id.should eql( 'm1-small' ) - end - end - - it "should allow fetching a flavor by URI" do - DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client| - flavor = client.fetch_flavor( API_URL + '/flavors/m1-small' ) - flavor.should_not be_nil - flavor.id.should eql( 'm1-small' ) - end - end - -end diff --git a/client/specs/initialization_spec.rb b/client/specs/initialization_spec.rb index 6fcf1a4..98e740b 100644 --- a/client/specs/initialization_spec.rb +++ b/client/specs/initialization_spec.rb @@ -28,7 +28,7 @@ describe "initializing the client" do
it "should discover entry points upon connection" do DeltaCloud.new( "name", "password", API_URL ) do |client| - client.entry_points[:flavors].should eql( "#{API_URL}/flavors" ) + client.entry_points[:hardware_profiles].should eql( "#{API_URL}/hardware_profiles" ) client.entry_points[:images].should eql( "#{API_URL}/images" ) client.entry_points[:instances].should eql( "#{API_URL}/instances" ) client.entry_points[:storage_volumes].should eql( "#{API_URL}/storage_volumes" ) diff --git a/client/specs/instances_spec.rb b/client/specs/instances_spec.rb index 8aaf79f..2e90e99 100644 --- a/client/specs/instances_spec.rb +++ b/client/specs/instances_spec.rb @@ -33,8 +33,6 @@ describe "instances" do instance.owner_id.should be_a( String ) instance.image.should_not be_nil instance.image.should be_a( DCloud::Image ) - instance.flavor.should_not be_nil - instance.flavor.should be_a( DCloud::Flavor ) instance.instance_profile.should_not be_nil instance.instance_profile.should be_a( DCloud::InstanceProfile ) instance.state.should_not be_nil @@ -72,8 +70,6 @@ describe "instances" do instance.public_addresses.first.should eql( "img1.inst0.public.com" ) instance.image.should_not be_nil instance.image.uri.should eql( API_URL + "/images/img1" ) - instance.flavor.should_not be_nil - instance.flavor.uri.should eql( API_URL + "/flavors/m1-large" ) instance.instance_profile.should_not be_nil instance.instance_profile.hardware_profile.should_not be_nil instance.instance_profile.hardware_profile.uri.should eql( API_URL + "/hardware_profiles/m1-large" ) @@ -92,7 +88,6 @@ describe "instances" do instance.id.should match( /inst[0-9]+/ ) instance.name.should eql( 'TestInstance' ) instance.image.id.should eql( 'img1' ) - instance.flavor.id.should eql( 'm1-large' ) instance.instance_profile.id.should eql( 'm1-large' ) instance.realm.id.should eql( 'us' ) end @@ -105,7 +100,6 @@ describe "instances" do instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} ) instance.id.should match( /inst[0-9]+/ ) instance.image.id.should eql( 'img1' ) - instance.flavor.id.should eql( 'm1-large' ) instance.instance_profile.id.should eql( 'm1-large' ) instance.realm.id.should eql( 'eu' ) end @@ -119,7 +113,6 @@ describe "instances" do instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} ) instance.id.should match( /inst[0-9]+/ ) instance.image.id.should eql( 'img1' ) - instance.flavor.id.should eql( 'm1-xlarge' ) instance.instance_profile.id.should eql( 'm1-xlarge' ) instance.realm.id.should eql( 'us' ) end @@ -133,7 +126,6 @@ describe "instances" do instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} ) instance.id.should match( /inst[0-9]+/ ) instance.image.id.should eql( 'img1' ) - instance.flavor.id.should eql( 'm1-xlarge' ) instance.instance_profile.id.should eql( 'm1-xlarge' ) instance.instance_profile[:memory].should eql( "32768" ) instance.realm.id.should eql( 'us' ) @@ -148,7 +140,6 @@ describe "instances" do instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} ) instance.id.should match( /inst[0-9]+/ ) instance.image.id.should eql( 'img1' ) - instance.flavor.id.should eql( 'm1-xlarge' ) instance.instance_profile.id.should eql( 'm1-xlarge' ) instance.realm.id.should eql( 'eu' ) end diff --git a/client/specs/storage_volume_spec.rb b/client/specs/storage_volume_spec.rb index 204e2b7..ff461d7 100644 --- a/client/specs/storage_volume_spec.rb +++ b/client/specs/storage_volume_spec.rb @@ -46,7 +46,8 @@ describe "storage volumes" do storage_volume.device.should eql( '/dev/sda1' ) storage_volume.instance.should_not be_nil storage_volume.instance.id.should eql( 'inst1' ) - storage_volume.instance.flavor.architecture.should eql( 'i386' ) + ip = storage_volume.instance.instance_profile + ip.hardware_profile.architecture.value.should eql( 'i386' ) end end
@@ -62,7 +63,8 @@ describe "storage volumes" do storage_volume.device.should eql( '/dev/sda1' ) storage_volume.instance.should_not be_nil storage_volume.instance.id.should eql( 'inst1' ) - storage_volume.instance.flavor.architecture.should eql( 'i386' ) + ip = storage_volume.instance.instance_profile + ip.hardware_profile.architecture.value.should eql( 'i386' ) end end
diff --git a/server/Rakefile b/server/Rakefile index 72b7af6..c8b54c4 100644 --- a/server/Rakefile +++ b/server/Rakefile @@ -27,7 +27,6 @@ require 'cucumber/rake/task' desc "Run basic unit tests" Rake::TestTask.new("test") { |t| t.test_files = FileList[ - 'tests/flavors_test.rb', 'tests/realms_test.rb', 'tests/images_test.rb', 'tests/instances_test.rb', diff --git a/server/deltacloud.rb b/server/deltacloud.rb index 2a60679..1c19a5d 100644 --- a/server/deltacloud.rb +++ b/server/deltacloud.rb @@ -6,7 +6,6 @@ require 'deltacloud/hardware_profile' require 'deltacloud/state_machine'
require 'deltacloud/models/base_model' -require 'deltacloud/models/flavor' require 'deltacloud/models/realm' require 'deltacloud/models/image' require 'deltacloud/models/instance' diff --git a/server/features/api.feature b/server/features/api.feature index 25b109a..49dabcb 100644 --- a/server/features/api.feature +++ b/server/features/api.feature @@ -5,7 +5,6 @@ Feature: Working with API Given I want to get XML When I request for entry points Then I should see these entry points: - | flavors | | realms | | instances | | images | @@ -19,7 +18,6 @@ Feature: Working with API When I request for entry points Then I should get valid HTML response And I should see these entry points in page: - | flavors | | realms | | instances | | images | diff --git a/server/features/flavors.feature b/server/features/flavors.feature deleted file mode 100644 index 6dd0934..0000000 --- a/server/features/flavors.feature +++ /dev/null @@ -1,23 +0,0 @@ -Feature: Working with flavors - In order to work with flavors - - Background: - Given I want to get XML - - Scenario: I want to get list of all flavors - When I follow flavors link in entry points - Then I should see <FLAVOR_COUNT> flavor inside flavors - And each link in flavors should point me to valid flavor - - Scenario: I want to show flavor details - When I request for '<FLAVOR_ID>' flavor - Then I should get this flavor - And flavor should have valid href parameter - And flavor should include id parameter - And flavor should include architecture parameter - And flavor should include memory parameter - And flavor should include storage parameter - - Scenario: I want filter flavors by architecture - When I want flavors with '<FLAVOR_ARCH>' architecture - Then I should get only flavors with architecture '<FLAVOR_ARCH>' diff --git a/server/features/instances.feature b/server/features/instances.feature index 3bd26e3..f11aa21 100644 --- a/server/features/instances.feature +++ b/server/features/instances.feature @@ -55,12 +55,12 @@ Feature: Managing instances Then I could follow image href attribute And this attribute should point me to valid image
- Scenario: I want to get instance flavor + Scenario: I want to get instance hardware profile Given I am authorized to show instance '<INSTANCE_1_ID>' Given I request for '<INSTANCE_1_ID>' instance - When I want to get details about instance flavor - Then I could follow flavor href attribute - And this attribute should point me to valid flavor + When I want to get details about instance hardware profile + Then I could follow hardware profile href attribute + And this attribute should point me to valid hardware profile
Scenario: I want to get instance realm Given I am authorized to show instance '<INSTANCE_1_ID>' diff --git a/server/features/step_definitions/flavors_steps.rb b/server/features/step_definitions/flavors_steps.rb deleted file mode 100644 index d806aaf..0000000 --- a/server/features/step_definitions/flavors_steps.rb +++ /dev/null @@ -1,5 +0,0 @@ -Then /^flavor should have valid href parameter$/ do - href=Nokogiri::XML(last_response.body).xpath('/flavor').first[:href] - href.should == "http://example.org/api/flavors/#%7BCONFIG%5B:flavor_id%5D%7D" -end - diff --git a/server/features/step_definitions/instances_steps.rb b/server/features/step_definitions/instances_steps.rb index fbffd06..c31682b 100644 --- a/server/features/step_definitions/instances_steps.rb +++ b/server/features/step_definitions/instances_steps.rb @@ -24,17 +24,20 @@ end When /^I want to get details about instance (.+)$/ do |model| end
-Then /^I could follow (image|realm|flavor) href attribute$/ do |model| +Then /^I could follow (image|realm|hardware profile) href attribute$/ do |model| + model.tr!(' ', '-') m = Nokogiri::XML(last_response.body).xpath("/instance/#{model}").first model_url = URI.parse(m[:href]).path get model_url, {} last_response.status.should == 200 end
-Then /^this attribute should point me to valid (image|realm|flavor)$/ do |model| - attribute = Nokogiri::XML(last_response.body).xpath("/#{model}").first +Then /^this attribute should point me to valid (image|realm|hardware profile)$/ do |model| + model_tag = model.tr(' ', '-') + model.tr!(' ', '_') + attribute = Nokogiri::XML(last_response.body).xpath("/#{model_tag}").first attribute.should_not == nil - attribute.name.should == model + attribute.name.should == model_tag end
When /^I want to (.+) this instance$/ do |action| diff --git a/server/features/support/ec2/config.yaml b/server/features/support/ec2/config.yaml index f2e9fe0..6295e42 100644 --- a/server/features/support/ec2/config.yaml +++ b/server/features/support/ec2/config.yaml @@ -1,10 +1,10 @@ ---- +--- :username: mockuser :password: mockpassword :storage_snapshot_id: snap-72a5401b :driver_name: ec2 :instances_count: 2 -:flavor_arch: x86_64 +:hardware_profile_arch: x86_64 :storage_snapshot_state: AVAILABLE :realm_id: us-east-1a :instance_1_name: ami-e4b6538d @@ -19,8 +19,8 @@ :instance_image_id: ami-e4b6538d :image_id: ami-e4b6538d :storage_volume_state: AVAILABLE -:flavor_id: m1-small +:hardware_profile_id: m1-small :instance_realm: us-east-1a :image_count: 2 :storage_volume_count: 2 -:flavor_count: 5 +:hardware_profile_count: 5 diff --git a/server/features/support/mock/config.yaml b/server/features/support/mock/config.yaml index 4ec0d03..6f282ff 100644 --- a/server/features/support/mock/config.yaml +++ b/server/features/support/mock/config.yaml @@ -4,7 +4,6 @@ :storage_snapshot_id: snap2 :driver_name: mock :instances_count: 180 -:flavor_arch: x86_64 :storage_snapshot_state: AVAILABLE :realm_id: us :instance_1_name: 1268827277 testing instance @@ -18,11 +17,9 @@ :instance_image_id: img2 :image_id: img2 :storage_volume_state: AVAILABLE -:flavor_id: m1-small :hardware_profile_id: m1-large :instance_realm: us :image_count: 3 :storage_volume_count: 2 -:flavor_count: 5 :hardware_profile_count: 4 :hardware_profile_arch: x86_64 diff --git a/server/lib/converters/xml_converter.rb b/server/lib/converters/xml_converter.rb index 4b8e78e..82a499d 100644 --- a/server/lib/converters/xml_converter.rb +++ b/server/lib/converters/xml_converter.rb @@ -49,13 +49,6 @@ module Converters end else case ( obj ) - when Flavor - builder.flavor( :href=>@link_builder.send( :flavor_url, obj.id ) ) { - builder.id( obj.id ) - builder.architecture( obj.architecture ) - builder.memory( obj.memory ) - builder.storage( obj.storage ) - } when Image builder.image( :href=>@link_builder.send( :image_url, obj.id ) ) { builder.id( obj.id ) @@ -81,7 +74,6 @@ module Converters builder.name( obj.name ) builder.owner_id( obj.owner_id ) builder.image( :href=>@link_builder.send( :image_url, obj.image_id ) ) - builder.flavor( :href=>@link_builder.send( :flavor_url, obj.flavor_id ) ) builder.__send__( 'hardware-profile', :href=>@link_builder.send( :hardware_profile_url, obj.instance_profile.name) ) do builder.id( obj.instance_profile.name ) obj.instance_profile.overrides.each do |p, v| diff --git a/server/lib/deltacloud/base_driver/base_driver.rb b/server/lib/deltacloud/base_driver/base_driver.rb index a3069e9..a2b3bbe 100644 --- a/server/lib/deltacloud/base_driver/base_driver.rb +++ b/server/lib/deltacloud/base_driver/base_driver.rb @@ -115,20 +115,6 @@ module Deltacloud actions end
- def flavor(credentials, opts) - flavors = flavors(credentials, opts) - return flavors.first unless flavors.empty? - nil - end - - def flavors(credentials, ops) - [] - end - - def flavors_by_architecture(credentials, architecture) - flavors(credentials, :architecture => architecture) - end - def realm(credentials, opts) realms = realms(credentials, opts) return realms.first unless realms.empty? diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb index 11cd41b..155bc8a 100644 --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb @@ -24,42 +24,6 @@ module Deltacloud module EC2 class EC2Driver < Deltacloud::BaseDriver
- # - # Flavors - # - FLAVORS = [ - Flavor.new( { - :id=>'m1-small', - :memory=>1.7, - :storage=>160, - :architecture=>'i386', - } ), - Flavor.new( { - :id=>'m1-large', - :memory=>7.5, - :storage=>850, - :architecture=>'x86_64', - } ), - Flavor.new( { - :id=>'m1-xlarge', - :memory=>15, - :storage=>1690, - :architecture=>'x86_64', - } ), - Flavor.new( { - :id=>'c1-medium', - :memory=>1.7, - :storage=>350, - :architecture=>'x86_64', - } ), - Flavor.new( { - :id=>'c1-xlarge', - :memory=>7, - :storage=>1690, - :architecture=>'x86_64', - } ), - ] - feature :instances, :user_data
define_hardware_profile('m1-small') do @@ -123,14 +87,6 @@ class EC2Driver < Deltacloud::BaseDriver stopped.to( :finish ) .automatically end
- def flavors(credentials, opts=nil) - return FLAVORS if ( opts.nil? ) - results = FLAVORS - results = filter_on( results, :id, opts ) - results = filter_on( results, :architecture, opts ) - results - end - # # Images # @@ -322,7 +278,6 @@ class EC2Driver < Deltacloud::BaseDriver :realm_id=>realm_id, :public_addresses=>( ec2_instance[:dns_name] == '' ? [] : [ec2_instance[:dns_name]] ), :private_addresses=>( ec2_instance[:private_dns_name] == '' ? [] : [ec2_instance[:private_dns_name]] ), - :flavor_id=>ec2_instance[:aws_instance_type].gsub( /./, '-'), :instance_profile => InstanceProfile.new(hwp_name), :actions=>instance_actions_for( ec2_instance[:aws_state].upcase ), } ) diff --git a/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml b/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml index c1880b7..a5b73be 100644 --- a/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml +++ b/server/lib/deltacloud/drivers/mock/data/instances/inst0.yml @@ -7,7 +7,6 @@ :private_addresses: - img1.inst0.private.com :image_id: img1 -:flavor_id: m1-large :instance_profile: !ruby/object:InstanceProfile id: m1-large memory: "12288" diff --git a/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml b/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml index aa3f86e..3544d40 100644 --- a/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml +++ b/server/lib/deltacloud/drivers/mock/data/instances/inst1.yml @@ -4,7 +4,6 @@ :owner_id: mockuser :public_addresses: [ img3.inst1.public.com ] :private_addresses: [ img3.inst1.private.com ] -:flavor_id: m1-small :realm_id: us :instance_profile: !ruby/object:InstanceProfile id: m1-small diff --git a/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml b/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml index 69d4720..9a70cb8 100644 --- a/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml +++ b/server/lib/deltacloud/drivers/mock/data/instances/inst2.yml @@ -4,7 +4,6 @@ :owner_id: anotheruser :public_addresses: [ img1.inst2.public.com ] :private_addresses: [ img1.inst2.private.com ] -:flavor_id: m1-small :realm_id: us :instance_profile: !ruby/object:InstanceProfile id: m1-large diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb index 8841e3f..9671f02 100644 --- a/server/lib/deltacloud/drivers/mock/mock_driver.rb +++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb @@ -23,43 +23,6 @@ module Deltacloud module Mock class MockDriver < Deltacloud::BaseDriver
- # - # Flavors - # - - ( FLAVORS = [ - Flavor.new({ - :id=>'m1-small', - :memory=>1.7, - :storage=>160, - :architecture=>'i386', - }), - Flavor.new({ - :id=>'m1-large', - :memory=>7.5, - :storage=>850, - :architecture=>'x86_64', - }), - Flavor.new({ - :id=>'m1-xlarge', - :memory=>15, - :storage=>1690, - :architecture=>'x86_64', - }), - Flavor.new({ - :id=>'c1-medium', - :memory=>1.7, - :storage=>350, - :architecture=>'x86_64', - }), - Flavor.new({ - :id=>'c1-xlarge', - :memory=>7, - :storage=>1690, - :architecture=>'x86_64', - }), - ] ) unless defined?( FLAVORS ) - ( REALMS = [ Realm.new({ :id=>'us', @@ -129,14 +92,6 @@ class MockDriver < Deltacloud::BaseDriver end end
- def flavors(credentials, opts=nil) - return FLAVORS if ( opts.nil? ) - results = FLAVORS - results = filter_on( results, :id, opts ) - results = filter_on( results, :architecture, opts ) - results - end - def realms(credentials, opts=nil) return REALMS if ( opts.nil? ) results = REALMS @@ -217,7 +172,6 @@ class MockDriver < Deltacloud::BaseDriver :owner_id=>credentials.user, :public_addresses=>["#{image_id}.#{next_id}.public.com"], :private_addresses=>["#{image_id}.#{next_id}.private.com"], - :flavor_id=>hwp.name, :instance_profile => InstanceProfile.new(hwp.name, opts), :realm_id=>realm_id, :actions=>instance_actions_for( 'RUNNING' ) diff --git a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb index 85efeec..c5e1408 100644 --- a/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +++ b/server/lib/deltacloud/drivers/opennebula/opennebula_driver.rb @@ -34,44 +34,15 @@ module Deltacloud class OpennebulaDriver < Deltacloud::BaseDriver
###################################################################### - # Flavors + # Hardware profiles ######################################################################
- (FLAVORS = [ - Flavor.new( { - :id=>'small', - :memory=>'small-memory', - :storage=>'small-storage', - :architecture=>'Any architecture', - } ), - Flavor.new( { - :id=>'medium', - :memory=>'medium-memory', - :storage=>'medium-storage', - :architecture=>'Any architecture', - } ), - Flavor.new( { - :id=>'large', - :memory=>'large-memory', - :storage=>'large-storage', - :architecture=>'Any architecture', - } ), - ] ) unless defined?( FLAVORS ) - define_hardware_profile 'small'
define_hardware_profile 'medium'
define_hardware_profile 'large'
- def flavors(credentials, opts=nil) - return FLAVORS if ( opts.nil? ) - results = FLAVORS - results = filter_on( results, :id, opts ) - results - end - - ###################################################################### # Realms ###################################################################### @@ -223,8 +194,7 @@ class OpennebulaDriver < Deltacloud::BaseDriver :owner_id=>credentials.user, :name=>computehash['NAME'].text, :image_id=>imageid, - :flavor_id=>flavor, - :instance_profile=>InstanceProfile.new(hwp_name), + :instance_profile=>InstanceProfile.new(hwp_name), :realm_id=>'Any realm', :state=>state, :public_addreses=>networks, diff --git a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb index 2b7aa44..3ad5452 100644 --- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb @@ -26,21 +26,6 @@ class RackspaceDriver < Deltacloud::BaseDriver
feature :instances, :user_name
- def flavors(credentials, opts=nil) - racks = new_client( credentials ) - results = racks.list_flavors.map do |flav| - Flavor.new( { - :id=> flav["id"].to_s, - :memory=>flav["ram"].to_f/1024, - :storage=>flav["disk"].to_i, - :architecture=>'x86_64' - } ) - end - results = filter_on( results, :id, opts ) - results = filter_on( results, :architecture, opts ) - results - end - def hardware_profiles(credentials, opts = nil) racks = new_client( credentials ) results = racks.list_flavors.map do |flav| @@ -133,7 +118,6 @@ class RackspaceDriver < Deltacloud::BaseDriver inst.state = srv["status"] == "ACTIVE" ? "RUNNING" : "PENDING" inst.actions = instance_actions_for(inst.state) inst.image_id = srv["imageId"].to_s - inst.flavor_id = srv["flavorId"].to_s inst.instance_profile = InstanceProfile.new(srv["flavorId"].to_s) if srv["addresses"] inst.public_addresses = srv["addresses"]["public"] diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb index fb6aee8..f22ce34 100644 --- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb @@ -83,23 +83,7 @@ class RHEVMDriver < Deltacloud::BaseDriver st end
- # - # Flavors - # - FLAVORS = [ - Flavor.new({ - :id=>"rhevm", - :memory=>"Any Memory", - :storage=>"Any Storage", - :architecture=>"Any Architecture", - }) - ] - - def flavors(credentials, opts=nil) - return FLAVORS if ( opts.nil? || (! opts[:id])) - FLAVORS.select{|f| opts[:id] == f.id} - end - + define_hardware_profile 'rhevm'
# # Realms @@ -207,7 +191,7 @@ class RHEVMDriver < Deltacloud::BaseDriver :owner_id => NO_OWNER, :image_id => vm["TemplateId"], :state => statify(vm["Status"]), - :flavor_id => "rhevm", + :instance_profile => InstanceProfile.new("rhevm"), :actions => instance_actions_for(statify(vm["Status"])), }) end diff --git a/server/lib/deltacloud/drivers/rimu/rimu_hosting_driver.rb b/server/lib/deltacloud/drivers/rimu/rimu_hosting_driver.rb index eb00232..d0ffac9 100755 --- a/server/lib/deltacloud/drivers/rimu/rimu_hosting_driver.rb +++ b/server/lib/deltacloud/drivers/rimu/rimu_hosting_driver.rb @@ -43,20 +43,6 @@ class RimuHostingDriver < Deltacloud::BaseDriver images end
- def flavors(credentials, opts=nil) - rh = RimuHostingClient.new(credentials) - flavors = rh.list_plans.map do | flavor | - Flavor.new({ - :id => flavor["pricing_plan_code"], - :memory => flavor["minimum_memory_mb"].to_f/1024, - :storage => flavor["minimum_disk_gb"].to_i, - :architecture => "x86" - }) - end - flavors = filter_on( flavors, :id, opts) - flavors - end - def hardware_profiles(credentials, opts = nil) rh = RimuHostingClient.new(credentials) results = rh.list_plans.map do |plan| @@ -131,7 +117,7 @@ class RimuHostingDriver < Deltacloud::BaseDriver :name => inst["domain_name"], :realm_id => "RH", :owner_id => "root", - :flavor_id => "none", + :instance_profile => InstanceProfile.new("none"), :actions => instance_actions_for("RUNNING") }) end diff --git a/server/lib/deltacloud/helpers/conversion_helper.rb b/server/lib/deltacloud/helpers/conversion_helper.rb index 6ba85d5..d50f1e6 100644 --- a/server/lib/deltacloud/helpers/conversion_helper.rb +++ b/server/lib/deltacloud/helpers/conversion_helper.rb @@ -21,7 +21,7 @@ load 'converters/xml_converter.rb' module ConversionHelper
def convert_to_xml(type, obj) - if ( [ :flavor, :account, :image, :realm, :instance, :storage_volume, :storage_snapshot ].include?( type ) ) + if ( [ :account, :image, :realm, :instance, :storage_volume, :storage_snapshot ].include?( type ) ) Converters::XMLConverter.new( self, type ).convert(obj) end end diff --git a/server/lib/deltacloud/helpers/driver_helper.rb b/server/lib/deltacloud/helpers/driver_helper.rb index 352253f..9e36468 100644 --- a/server/lib/deltacloud/helpers/driver_helper.rb +++ b/server/lib/deltacloud/helpers/driver_helper.rb @@ -22,7 +22,7 @@ require 'converters/xml_converter' module DriverHelper
def convert_to_xml(type, obj) - if ( [ :flavor, :account, :image, :realm, :instance, :storage_volume, :storage_snapshot ].include?( type ) ) + if ( [ :account, :image, :realm, :instance, :storage_volume, :storage_snapshot ].include?( type ) ) Converters::XMLConverter.new( self, type ).convert(obj) end end diff --git a/server/lib/deltacloud/models/flavor.rb b/server/lib/deltacloud/models/flavor.rb deleted file mode 100644 index a096978..0000000 --- a/server/lib/deltacloud/models/flavor.rb +++ /dev/null @@ -1,25 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -class Flavor < BaseModel - - attr_accessor :architecture - attr_accessor :memory - attr_accessor :storage - -end diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb index e5c1f9c..d313bc7 100644 --- a/server/lib/deltacloud/models/instance.rb +++ b/server/lib/deltacloud/models/instance.rb @@ -20,7 +20,6 @@ class Instance < BaseModel
attr_accessor :owner_id attr_accessor :image_id - attr_accessor :flavor_id attr_accessor :name attr_accessor :realm_id attr_accessor :state diff --git a/server/lib/sinatra/rabbit.rb b/server/lib/sinatra/rabbit.rb index 7091937..6018810 100644 --- a/server/lib/sinatra/rabbit.rb +++ b/server/lib/sinatra/rabbit.rb @@ -153,7 +153,7 @@ module Sinatra # operation is the element URL with the name of the operation # appended # - # This also defines a helper method like show_flavor_url that returns + # This also defines a helper method like show_instance_url that returns # the URL to this operation (in request context) def operation(name, opts = {}, &block) raise DuplicateOperationException if @operations[name] diff --git a/server/server.rb b/server/server.rb index 5c1bd73..43008c8 100644 --- a/server/server.rb +++ b/server/server.rb @@ -99,24 +99,6 @@ end
# Rabbit DSL
-collection :flavors do - description "Within a cloud provider a flavor represents a configuration of resources upon which a machine may be deployed. A flavor defines aspects such as local disk storage, available RAM, and architecture. A future revision of the Deltacloud API will include more aspects, including number and speed of CPUs available. Each provider is free to define as many (or as few) flavors as desired." - - operation :index do - description 'Operation will list all available flavors. For specific architecture use "architecture" parameter.' - param :architecture, :string, :optional, [ 'i386', 'x86_64' ] - param :id, :string, :optional - control { filter_all(:flavors) } - end - - operation :show do - description 'Show an flavor identified by "id" parameter.' - param :id, :string, :required - control { show(:flavor) } - end - -end - collection :realms do description "Within a cloud provider a realm represents a boundary containing resources. The exact definition of a realm is left to the cloud provider. In some cases, a realm may represent different datacenters, different continents, or different pools of resources within a single datacenter. A cloud provider may insist that resources must all exist within a single realm in order to cooperate. For instance, storage volumes may only be allowed to be mounted to instances within the same realm."
@@ -202,7 +184,6 @@ end get "/api/instances/new" do @instance = Instance.new( { :id=>params[:id], :image_id=>params[:image_id] } ) @image = driver.image( credentials, :id => params[:image_id] ) - @flavors = driver.flavors( credentials, { :architecture=>@image.architecture } ) @hardware_profiles = driver.hardware_profiles(credentials, :architecture => @image.architecture ) @realms = driver.realms(credentials) respond_to do |format| @@ -238,13 +219,8 @@ collection :instances do description "Create a new instance" param :image_id, :string, :required param :realm_id, :string, :optional - param :flavor_id, :string, :optional param :hwp_id, :string, :optional control do - # FIXME: Strictly speaking, we'd need to check that only either - # hwp_id or flavor_id are set, but not both. Since flavors will go - # away shortly, we can be a little sloppy - params[:hwp_id] = params[:flavor_id] if params[:flavor_id] @image = driver.image(credentials, :id => params[:image_id]) instance = driver.create_instance(credentials, @image.id, params) respond_to do |format| diff --git a/server/tests/deltacloud_test.rb b/server/tests/deltacloud_test.rb index 2b5cf6c..bf046bf 100644 --- a/server/tests/deltacloud_test.rb +++ b/server/tests/deltacloud_test.rb @@ -26,7 +26,7 @@ module DeltacloudTest end
def test_if_http_status_is_correct_with_wrong_credentials - return if ['flavors', 'realms'].include?(@collection) + return if ['realms'].include?(@collection) wrong_header = rack_headers wrong_header['HTTP_AUTHORIZATION'] = authorization('wronguser', 'wrongpassword') get '/api/'+@collection+'.xml', @params, wrong_header diff --git a/server/tests/flavors_test.rb b/server/tests/flavors_test.rb deleted file mode 100644 index c920b63..0000000 --- a/server/tests/flavors_test.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'tests/deltacloud_test' - -class FlavorsTest < Test::Unit::TestCase - - def initialize(*args) - @collection = 'flavors' - @operations = [:index, :show] - @options = [:id, :architecture, :memory, :storage] - @params = {} - super(*args) - end - - def test_if_flavors_are_not_empty - get '/api/flavors.xml', @params, rack_headers - doc = Nokogiri::XML.parse(last_response.body) - assert_not_equal 0, doc.xpath('/flavors/flavor').size - end - - [:id, :architecture, :memory, :storage].each do |option| - method_name = :"test_if_flavors_index_contain_#{option}" - send :define_method, method_name do - get '/api/flavors.xml', @params, rack_headers - doc = Nokogiri::XML.parse(last_response.body) - flavor = doc.xpath('/flavors/flavor[1]').first - assert_not_nil flavor.xpath(option.to_s).first - end - end - - [:id, :architecture, :memory, :storage].each do |option| - method_name = :"test_if_flavor_show_contain_#{option}" - send :define_method, method_name do - get '/api/flavors/m1-small.xml', @params, rack_headers - doc = Nokogiri::XML.parse(last_response.body) - flavor = doc.xpath('/flavor').first - assert_not_nil flavor.xpath(option.to_s).first - end - end - - def test_flavors_filtering_by_architecture - @params[:architecture] = 'i386' - get '/api/flavors.xml', @params, rack_headers - doc = Nokogiri::XML.parse(last_response.body) - assert_equal 1, doc.xpath('/flavors/flavor').size - assert_equal @params[:architecture], doc.xpath('/flavors/flavor/architecture').first.text - end - - def test_flavors_filtering_by_id - get '/api/flavors.xml', { :id => 'm1-small'}, rack_headers - doc = Nokogiri::XML.parse(last_response.body) - assert_equal 1, doc.xpath('/flavors/flavor').size - assert_equal 'm1-small', doc.xpath('/flavors/flavor/id').first.text - end - - def test_flavors_filtering_by_id_and_architecture - get '/api/flavors.xml', { :architecture => 'x86_64', :id => 'c1-xlarge'}, rack_headers - doc = Nokogiri::XML.parse(last_response.body) - assert_equal 1, doc.xpath('/flavors/flavor').size - assert_equal 'c1-xlarge', doc.xpath('/flavors/flavor/id').first.text - assert_equal 'x86_64', doc.xpath('/flavors/flavor/architecture').first.text - end - - include DeltacloudTest - -end - diff --git a/server/tests/images_test.rb b/server/tests/images_test.rb index 507c81b..177852d 100644 --- a/server/tests/images_test.rb +++ b/server/tests/images_test.rb @@ -20,8 +20,8 @@ class ImagesTest < Test::Unit::TestCase send :define_method, method_name do get '/api/images.xml', @params, rack_headers doc = Nokogiri::XML.parse(last_response.body) - flavor = doc.xpath('/images/image[1]').first - assert_not_nil flavor.xpath(option.to_s).first + elt = doc.xpath('/images/image[1]').first + assert_not_nil elt.xpath(option.to_s).first end end
@@ -30,8 +30,8 @@ class ImagesTest < Test::Unit::TestCase send :define_method, method_name do get '/api/images/img1.xml', @params, rack_headers doc = Nokogiri::XML.parse(last_response.body) - flavor = doc.xpath('/image').first - assert_not_nil flavor.xpath(option.to_s).first + elt = doc.xpath('/image').first + assert_not_nil elt.xpath(option.to_s).first end end
diff --git a/server/tests/instances_test.rb b/server/tests/instances_test.rb index 9504cc0..8dcf8c9 100644 --- a/server/tests/instances_test.rb +++ b/server/tests/instances_test.rb @@ -19,7 +19,7 @@ class InstancesTest < Test::Unit::TestCase assert_not_equal 0, doc.xpath('/instances/instance').size end
- [:id, :name, :owner_id, :image, :flavor, :realm, :state, :actions, :'public-addresses', :'private-addresses'].each do |option| + [:id, :name, :owner_id, :image, :realm, :state, :actions, :'public-addresses', :'private-addresses'].each do |option| method_name = :"test_if_instances_index_contain_#{option}" send :define_method, method_name do get '/api/instances.xml', @params, rack_headers @@ -29,7 +29,7 @@ class InstancesTest < Test::Unit::TestCase end end
- [:id, :name, :owner_id, :image, :flavor, :realm, :state, :actions, :'public-addresses', :'private-addresses'].each do |option| + [:id, :name, :owner_id, :image, :realm, :state, :actions, :'public-addresses', :'private-addresses'].each do |option| method_name = :"test_if_instance_show_contain_#{option}" send :define_method, method_name do get '/api/instances/inst1.xml', @params, rack_headers @@ -77,19 +77,19 @@ class InstancesTest < Test::Unit::TestCase assert_equal @params[:image_id], image_id end
- def test_create_instance_with_flavor_id + def test_create_instance_with_hwp_id
@params = { :name => '_test-instance', :image_id => 'img1', - :flavor_id => 'm1-xlarge' + :hwp_id => 'm1-xlarge' }
post '/api/instances.xml', @params, rack_headers doc = Nokogiri::XML.parse(last_response.body) - flavor_href = doc.xpath('/instance/flavor').first[:href].to_s - flavor_id = flavor_href.gsub(/.*/([\w-]+)$/, '\1') - assert_equal @params[:flavor_id], flavor_id + hwp_href = doc.xpath('/instance/hardware_profile').first[:href].to_s + hwp_id = hwp_href.gsub(/.*/([\w-]+)$/, '\1') + assert_equal @params[:hwp_id], hwp_id end
def test_create_instance_with_realm_id diff --git a/server/tests/realms_test.rb b/server/tests/realms_test.rb index 4048ac6..b6053b3 100644 --- a/server/tests/realms_test.rb +++ b/server/tests/realms_test.rb @@ -21,8 +21,8 @@ class RealmsTest < Test::Unit::TestCase send :define_method, method_name do get '/api/realms.xml', @params, rack_headers doc = Nokogiri::XML.parse(last_response.body) - flavor = doc.xpath('/realms/realm[1]').first - assert_not_nil flavor.xpath(option.to_s).first + realm = doc.xpath('/realms/realm[1]').first + assert_not_nil realm.xpath(option.to_s).first end end
@@ -31,8 +31,8 @@ class RealmsTest < Test::Unit::TestCase send :define_method, method_name do get '/api/realms/us.xml', @params, rack_headers doc = Nokogiri::XML.parse(last_response.body) - flavor = doc.xpath('/realm').first - assert_not_nil flavor.xpath(option.to_s).first + realm = doc.xpath('/realm').first + assert_not_nil realm.xpath(option.to_s).first end end
diff --git a/server/views/flavors/index.html.haml b/server/views/flavors/index.html.haml deleted file mode 100644 index 2b44bb7..0000000 --- a/server/views/flavors/index.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -%h1 - Flavors - -%table.display - %thead - %tr - %th ID - %th Architecture - %th Memory - %th Storage - %tbody - - @flavors.each do |flavor| - %tr - %td - = link_to flavor.id, flavor_url( flavor.id ) - %td - = flavor.architecture - %td - = "#{flavor.memory} GB" - %td - = "#{flavor.storage} GB" diff --git a/server/views/flavors/show.html.haml b/server/views/flavors/show.html.haml deleted file mode 100644 index d81e75b..0000000 --- a/server/views/flavors/show.html.haml +++ /dev/null @@ -1,16 +0,0 @@ -%h1 - = @flavor.id - -%dl - %di - %dt Architecture - %dd - = @flavor.architecture - %di - %dt Memory - %dd - = "#{@flavor.memory} GB" - %di - %dt Storage - %dd - = "#{@flavor.storage} GB" diff --git a/server/views/instances/index.html.haml b/server/views/instances/index.html.haml index 20feb7c..6f3996d 100644 --- a/server/views/instances/index.html.haml +++ b/server/views/instances/index.html.haml @@ -7,7 +7,6 @@ %th Owner %th Name %th Image - %th Flavor %th Realm %th State %th Actions @@ -23,8 +22,6 @@ %td = link_to instance.image_id, image_url( instance.image_id ) %td - = instance.flavor_id ? link_to(instance.flavor_id, flavor_url(instance.flavor_id)) : 'default' - %td = instance.realm_id ? link_to(instance.realm_id, realm_url( instance.realm_id )) : 'default' %td = instance.state diff --git a/server/views/instances/show.html.haml b/server/views/instances/show.html.haml index 2a81c12..dabcc61 100644 --- a/server/views/instances/show.html.haml +++ b/server/views/instances/show.html.haml @@ -15,10 +15,6 @@ %dd = @instance.name %di - %dt Flavor - %dd - = @instance.flavor_id ? link_to(@instance.flavor_id, flavor_url(@instance.flavor_id)) : 'default' - %di %dt Hardware Profile %dd - prof = @instance.instance_profile