diff --git a/README.md b/README.md index bf38ae4..020876c 100644 --- a/README.md +++ b/README.md @@ -110,10 +110,12 @@ License and Author | **Author** | John Dewey () | | **Author** | Abel Lopez () | | **Author** | Sean Gallagher () | +| **Author** | Ionut Artarisi () | | | | | **Copyright** | Copyright (c) 2012, Rackspace US, Inc. | | **Copyright** | Copyright (c) 2012-2013, AT&T Services, Inc. | | **Copyright** | Copyright (c) 2013, Opscode, Inc. | +| **Copyright** | Copyright (c) 2013, SUSE Linux GmbH | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/attributes/default.rb b/attributes/default.rb index 263784d..e43a33f 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -130,11 +130,13 @@ default["openstack"]["block-storage"]["policy"]["admin_api"] = '["is_admin:True" case platform when "fedora", "redhat", "centos" # :pragma-foodcritic: ~FC024 - won't fix this default["openstack"]["block-storage"]["platform"] = { - "cinder_api_packages" => ["openstack-cinder", "python-cinderclient", "MySQL-python"], + "mysql_python_packages" => ["MySQL-python"], + "postgresql_python_packages" => ["python-psycopg2"], + "cinder_api_packages" => ["openstack-cinder", "python-cinderclient"], "cinder_api_service" => "openstack-cinder-api", - "cinder_volume_packages" => ["openstack-cinder", "MySQL-python"], + "cinder_volume_packages" => ["openstack-cinder"], "cinder_volume_service" => "openstack-cinder-volume", - "cinder_scheduler_packages" => ["openstack-cinder", "MySQL-python"], + "cinder_scheduler_packages" => ["openstack-cinder"], "cinder_scheduler_service" => "openstack-cinder-scheduler", "cinder_iscsitarget_packages" => ["scsi-target-utils"], "cinder_iscsitarget_service" => "tgtd", @@ -143,11 +145,13 @@ when "fedora", "redhat", "centos" # :pragma-foodcritic: ~FC024 - won't fix this } when "ubuntu" default["openstack"]["block-storage"]["platform"] = { - "cinder_api_packages" => ["cinder-common", "cinder-api", "python-cinderclient", "python-mysqldb"], + "mysql_python_packages" => ["python-mysqldb"], + "postgresql_python_packages" => ["python-psycopg2"], + "cinder_api_packages" => ["cinder-common", "cinder-api", "python-cinderclient"], "cinder_api_service" => "cinder-api", - "cinder_volume_packages" => ["cinder-volume", "python-mysqldb"], + "cinder_volume_packages" => ["cinder-volume"], "cinder_volume_service" => "cinder-volume", - "cinder_scheduler_packages" => ["cinder-scheduler", "python-mysqldb"], + "cinder_scheduler_packages" => ["cinder-scheduler"], "cinder_scheduler_service" => "cinder-scheduler", "cinder_iscsitarget_packages" => ["tgt"], "cinder_iscsitarget_service" => "tgt", diff --git a/recipes/api.rb b/recipes/api.rb index 0b03406..e953f31 100644 --- a/recipes/api.rb +++ b/recipes/api.rb @@ -5,6 +5,7 @@ # Copyright 2012, Rackspace US, Inc. # Copyright 2012-2013, AT&T Services, Inc. # Copyright 2013, Opscode, Inc. +# Copyright 2013, SUSE Linux Gmbh. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -35,6 +36,13 @@ platform_options["cinder_api_packages"].each do |pkg| end end +db_type = node['openstack']['db']['volume']['db_type'] +platform_options["#{db_type}_python_packages"].each do |pkg| + package pkg do + action :upgrade + end +end + directory ::File.dirname(node["openstack"]["block-storage"]["api"]["auth"]["cache_dir"]) do owner node["openstack"]["block-storage"]["user"] group node["openstack"]["block-storage"]["group"] diff --git a/recipes/scheduler.rb b/recipes/scheduler.rb index 6c65917..27292ad 100644 --- a/recipes/scheduler.rb +++ b/recipes/scheduler.rb @@ -5,6 +5,7 @@ # Copyright 2012, Rackspace US, Inc. # Copyright 2012-2013, AT&T Services, Inc. # Copyright 2013, Opscode, Inc. +# Copyright 2013, SUSE Linux Gmbh. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -31,6 +32,13 @@ platform_options["cinder_scheduler_packages"].each do |pkg| end end +db_type = node['openstack']['db']['volume']['db_type'] +platform_options["#{db_type}_python_packages"].each do |pkg| + package pkg do + action :upgrade + end +end + service "cinder-scheduler" do service_name platform_options["cinder_scheduler_service"] supports :status => true, :restart => true diff --git a/recipes/volume.rb b/recipes/volume.rb index 871b6c5..4d893f9 100644 --- a/recipes/volume.rb +++ b/recipes/volume.rb @@ -5,6 +5,7 @@ # Copyright 2012, Rackspace US, Inc. # Copyright 2012-2013, AT&T Services, Inc. # Copyright 2013, Opscode, Inc. +# Copyright 2013, SUSE Linux Gmbh. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -35,6 +36,13 @@ platform_options["cinder_volume_packages"].each do |pkg| end end +db_type = node['openstack']['db']['volume']['db_type'] +platform_options["#{db_type}_python_packages"].each do |pkg| + package pkg do + action :upgrade + end +end + platform_options["cinder_iscsitarget_packages"].each do |pkg| package pkg do options platform_options["package_overrides"] diff --git a/spec/api-redhat_spec.rb b/spec/api-redhat_spec.rb index 4a5a72e..01d59c1 100644 --- a/spec/api-redhat_spec.rb +++ b/spec/api-redhat_spec.rb @@ -11,9 +11,22 @@ describe "openstack-block-storage::api" do it "installs cinder api packages" do expect(@chef_run).to upgrade_package "openstack-cinder" expect(@chef_run).to upgrade_package "python-cinderclient" + end + + it "installs mysql python packages by default" do expect(@chef_run).to upgrade_package "MySQL-python" end + it "installs postgresql python packages if explicitly told" do + chef_run = ::ChefSpec::ChefRunner.new ::REDHAT_OPTS + node = chef_run.node + node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" + chef_run.converge "openstack-block-storage::api" + + expect(chef_run).to upgrade_package "python-psycopg2" + expect(chef_run).not_to upgrade_package "MySQL-python" + end + it "starts cinder api on boot" do expect(@chef_run).to set_service_to_start_on_boot "openstack-cinder-api" end diff --git a/spec/api_spec.rb b/spec/api_spec.rb index cb33698..6bc5c55 100644 --- a/spec/api_spec.rb +++ b/spec/api_spec.rb @@ -23,9 +23,22 @@ describe "openstack-block-storage::api" do expect(@chef_run).to upgrade_package "cinder-common" expect(@chef_run).to upgrade_package "cinder-api" expect(@chef_run).to upgrade_package "python-cinderclient" + end + + it "installs mysql python packages by default" do expect(@chef_run).to upgrade_package "python-mysqldb" end + it "installs postgresql python packages if explicitly told" do + chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS + node = chef_run.node + node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" + chef_run.converge "openstack-block-storage::api" + + expect(chef_run).to upgrade_package "python-psycopg2" + expect(chef_run).not_to upgrade_package "python-mysqldb" + end + describe "/var/cache/cinder" do before do @dir = @chef_run.directory "/var/cache/cinder" diff --git a/spec/scheduler-redhat_spec.rb b/spec/scheduler-redhat_spec.rb index 7638bb1..5fdf489 100644 --- a/spec/scheduler-redhat_spec.rb +++ b/spec/scheduler-redhat_spec.rb @@ -10,9 +10,22 @@ describe "openstack-block-storage::scheduler" do it "installs cinder api packages" do expect(@chef_run).to upgrade_package "openstack-cinder" + end + + it "installs mysql python packages by default" do expect(@chef_run).to upgrade_package "MySQL-python" end + it "installs postgresql python packages if explicitly told" do + chef_run = ::ChefSpec::ChefRunner.new ::REDHAT_OPTS + node = chef_run.node + node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" + chef_run.converge "openstack-block-storage::scheduler" + + expect(chef_run).to upgrade_package "python-psycopg2" + expect(chef_run).not_to upgrade_package "MySQL-python" + end + it "starts cinder scheduler" do expect(@chef_run).to start_service "openstack-cinder-scheduler" end diff --git a/spec/scheduler_spec.rb b/spec/scheduler_spec.rb index c1a3eaa..76bcc42 100644 --- a/spec/scheduler_spec.rb +++ b/spec/scheduler_spec.rb @@ -21,9 +21,22 @@ describe "openstack-block-storage::scheduler" do it "installs cinder api packages" do expect(@chef_run).to upgrade_package "cinder-scheduler" + end + + it "installs mysql python packages by default" do expect(@chef_run).to upgrade_package "python-mysqldb" end + it "installs postgresql python packages if explicitly told" do + chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS + node = chef_run.node + node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" + chef_run.converge "openstack-block-storage::scheduler" + + expect(chef_run).to upgrade_package "python-psycopg2" + expect(chef_run).not_to upgrade_package "python-mysqldb" + end + it "starts cinder scheduler" do expect(@chef_run).to start_service "cinder-scheduler" end diff --git a/spec/volume-redhat_spec.rb b/spec/volume-redhat_spec.rb index 9b5c9b9..8d08f6f 100644 --- a/spec/volume-redhat_spec.rb +++ b/spec/volume-redhat_spec.rb @@ -10,9 +10,22 @@ describe "openstack-block-storage::volume" do it "installs cinder volume packages" do expect(@chef_run).to upgrade_package "openstack-cinder" + end + + it "installs mysql python packages by default" do expect(@chef_run).to upgrade_package "MySQL-python" end + it "installs postgresql python packages if explicitly told" do + chef_run = ::ChefSpec::ChefRunner.new ::REDHAT_OPTS + node = chef_run.node + node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" + chef_run.converge "openstack-block-storage::volume" + + expect(chef_run).to upgrade_package "python-psycopg2" + expect(chef_run).not_to upgrade_package "MySQL-python" + end + it "installs cinder iscsi packages" do expect(@chef_run).to upgrade_package "scsi-target-utils" end diff --git a/spec/volume_spec.rb b/spec/volume_spec.rb index ccd53f8..31c1a10 100644 --- a/spec/volume_spec.rb +++ b/spec/volume_spec.rb @@ -21,9 +21,22 @@ describe "openstack-block-storage::volume" do it "installs cinder volume packages" do expect(@chef_run).to upgrade_package "cinder-volume" + end + + it "installs mysql python packages by default" do expect(@chef_run).to upgrade_package "python-mysqldb" end + it "installs postgresql python packages if explicitly told" do + chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS + node = chef_run.node + node.set["openstack"]["db"]["volume"]["db_type"] = "postgresql" + chef_run.converge "openstack-block-storage::volume" + + expect(chef_run).to upgrade_package "python-psycopg2" + expect(chef_run).not_to upgrade_package "python-mysqldb" + end + it "installs cinder iscsi packages" do expect(@chef_run).to upgrade_package "tgt" end