Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on May 25, 2012
@dprince dprince Set sql_connection variable in glance::api recipe.
Change-Id: I2d738a910ab7caf21c1589e3de663b48a4dec780
a9a8939
Showing with 40 additions and 0 deletions.
  1. +40 −0 cookbooks/glance/recipes/api.rb
View
40 cookbooks/glance/recipes/api.rb
@@ -6,6 +6,43 @@
include_recipe "#{@cookbook_name}::common"
+sql_connection = nil
+if node[:glance][:mysql]
+ Chef::Log.info("Using mysql")
+ package "python-mysqldb"
+ mysqls = nil
+
+ unless Chef::Config[:solo]
+ mysqls = search(:node, "recipes:glance\\:\\:mysql")
+ end
+ if mysqls and mysqls[0]
+ mysql = mysqls[0]
+ Chef::Log.info("Mysql server found at #{mysql[:mysql][:bind_address]}")
+ else
+ mysql = node
+ Chef::Log.info("Using local mysql at #{mysql[:mysql][:bind_address]}")
+ end
+ sql_connection = "mysql://#{mysql[:glance][:db][:user]}:#{mysql[:glance][:db][:password]}@#{mysql[:mysql][:bind_address]}/#{mysql[:glance][:db][:database]}"
+elsif node[:glance][:postgresql]
+ Chef::Log.info("Using postgresql")
+ postgresqls = nil
+
+ unless Chef::Config[:solo]
+ postgresqls = search(:node, "recipes:glance\\:\\:postgresql")
+ end
+ if postgresqls and postgresqls[0]
+ postgresql = postgresqls[0]
+ Chef::Log.info("PostgreSQL server found at #{postgresql[:ipaddress]}")
+ else
+ postgresql = node
+ Chef::Log.info("Using local PostgreSQL at #{postgresql[:ipaddress]}")
+ end
+ sql_connection = "postgresql://#{postgresql[:glance][:db][:user]}:#{postgresql[:glance][:db][:password]}@#{postgresql[:ipaddress]}/#{postgresql[:glance][:db][:database]}"
+else
+ # default to sqlite
+ sql_connection = "sqlite:////var/lib/glance/glance.sqlite"
+end
+
# Locate glance registry and retrieve it's IP
unless Chef::Config[:solo]
registries = search(:node, "recipes:glance\\:\\:registry")
@@ -61,6 +98,9 @@
owner "glance"
group "glance"
mode 0644
+ variables(
+ :sql_connection => sql_connection
+ )
end
template node[:glance][:cache_config_file] do

No commit comments for this range

Something went wrong with that request. Please try again.