diff -uNr nova/chef/cookbooks/nova/metadata.rb nova.inktank/chef/cookbooks/nova/metadata.rb --- nova/chef/cookbooks/nova/metadata.rb 2012-10-26 11:22:46.000000000 -0500 +++ nova.inktank/chef/cookbooks/nova/metadata.rb 2012-10-08 13:38:30.000000000 -0500 @@ -11,3 +11,4 @@ depends "openssl" depends "rabbitmq" depends "nagios" +depends "ceph" diff -uNr nova/chef/cookbooks/nova/recipes/compute.rb nova.inktank/chef/cookbooks/nova/recipes/compute.rb --- nova/chef/cookbooks/nova/recipes/compute.rb 2012-10-26 11:22:46.000000000 -0500 +++ nova.inktank/chef/cookbooks/nova/recipes/compute.rb 2012-10-17 15:29:28.000000000 -0500 @@ -24,6 +24,24 @@ nova_package("compute") + + +if not node["nova"]["ceph_instance"].empty? + secret_file_path = "/etc/ceph/ceph-secret.xml" + + env_filter = " AND ceph_config_environment:ceph-config-#{node[:nova][:ceph_instance]}" + mon_server = search(:node, "roles:ceph-mon#{env_filter}") + ceph_fsid = mon_server[0]['ceph']['config']['fsid'] + + execute "set the Ceph secret in virsh" do + command <<-EOH + CEPH_ACCESS_KEY=`ceph-authtool #{node["nova"]["ceph_key_path"]} -p -n #{node["nova"]["ceph_client"]}` + virsh secret-define --file #{secret_file_path} + virsh secret-set-value --secret #{ceph_fsid} --base64 $CEPH_ACCESS_KEY + EOH + end +end #Ceph section + # # These two files are to handle: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/996840 # This is a hack until that gets fixed. diff -uNr nova/chef/cookbooks/nova/recipes/config.rb nova.inktank/chef/cookbooks/nova/recipes/config.rb --- nova/chef/cookbooks/nova/recipes/config.rb 2012-10-26 11:22:46.000000000 -0500 +++ nova.inktank/chef/cookbooks/nova/recipes/config.rb 2012-10-08 13:38:30.000000000 -0500 @@ -172,6 +172,88 @@ eqlx_params = nil end +# do the Ceph stuff +def ceph_get_client_key(pool, service) + #TODO cluster name + cluster = 'ceph' + hostname = %x[hostname] + hostname.chomp! + client_name = "client.#{service}" + key_path = "/var/lib/ceph/bootstrap-client/#{cluster}.#{client_name}.keyring" + final_key_path = "/etc/ceph/#{cluster}.#{client_name}.keyring" + + execute "create ceph client keyring" do + command <<-EOH + CLIENT_KEY=`ceph --cluster #{cluster} --name client.bootstrap-client --keyring /var/lib/ceph/bootstrap-client/#{cluster}.keyring auth get-or-create-key #{client_name} mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=#{pool}'` + ceph-authtool #{final_key_path} --create-keyring --name=#{client_name} --add-key="$CLIENT_KEY" + EOH + creates final_key_path + end + + return ["#{client_name}", final_key_path] +end + +ceph_client = nil +ceph_client_id = nil +ceph_fsid = nil +if not node["nova"]["ceph_instance"].empty? + include_recipe "ceph::bootstrap_client" + + is_volume_node = node['recipes'].count("nova::volume") >= 1 + is_compute_node = node['recipes'].count("nova::compute") >= 1 + is_controller_node = node['recipes'].count("nova::scheduler") >= 1 + + # set up CEPH_ARGS and extra metadata for nova-volume and nova-compute + ceph_client, ceph_key_loc = ceph_get_client_key("rbd", "nova") + ceph_client_id = ceph_client.sub(/^client\./, '') # get rid of client. prefix for use by kvm as --id + + if is_volume_node or is_compute_node + execute "change the ceph keyring owner" do + command <<-EOH + sudo chown nova.nova #{ceph_key_loc} + EOH + end + node["nova"]["ceph_client"] = ceph_client + node["nova"]["ceph_key_path"] = ceph_key_loc + end + + ceph_args_value = "-n #{ceph_client}" + file_content = "env 'CEPH_ARGS=#{ceph_args_value}'" + + if is_volume_node + file "/etc/init/nova-volume.override" do + owner "root" + group "root" + mode "0640" + content file_content + end + end + if is_compute_node + file "/etc/init/nova-compute.override" do + owner "root" + group "root" + mode "0640" + content file_content + end + end + + # we need to generate a common virsh secret everywhere + secret_file_path = "/etc/ceph/ceph-secret.xml" + + env_filter = " AND ceph_config_environment:ceph-config-#{node[:nova][:ceph_instance]}" + mon_server = search(:node, "roles:ceph-mon#{env_filter}") + ceph_fsid = mon_server[0]['ceph']['config']['fsid'] + + file secret_file_path do + owner "root" + group "root" + mode "0640" + content " #{ceph_fsid} client.admin secret " + end #file secret_file_path +end + + + template "/etc/nova/nova.conf" do source "nova.conf.erb" owner node[:nova][:user] @@ -186,7 +268,8 @@ :glance_server_ip => glance_server_ip, :glance_server_port => glance_server_port, :vncproxy_public_ip => vncproxy_public_ip, - :eqlx_params => eqlx_params + :eqlx_params => eqlx_params, + :ceph_client => ceph_client_id, + :uuid_secret => ceph_fsid ) end - diff -uNr nova/chef/cookbooks/nova/templates/default/nova.conf.erb nova.inktank/chef/cookbooks/nova/templates/default/nova.conf.erb --- nova/chef/cookbooks/nova/templates/default/nova.conf.erb 2012-10-26 11:22:46.000000000 -0500 +++ nova.inktank/chef/cookbooks/nova/templates/default/nova.conf.erb 2012-10-08 13:38:30.000000000 -0500 @@ -80,6 +80,9 @@ compute_manager=nova.compute.manager.ComputeManager instance_name_template=instance-%08x compute_scheduler_driver=nova.scheduler.filter_scheduler.FilterScheduler +<% if not node["nova"]["ceph_instance"].empty? -%> +rbd_secret_uuid=<%= @uuid_secret %> +<%end -%> # VNCPROXY <% unless @vncproxy_public_ip.nil? -%> @@ -108,3 +111,9 @@ <%= k + '=' + v.to_s %> <% end -%> <% end -%> +<% if not node["nova"]["ceph_instance"].empty? -%> +volume_driver=nova.volume.driver.RBDDriver +rbd_store_ceph_conf = /etc/ceph/ceph.conf +rbd_pool=rbd +rbd_user=<%= @ceph_client %> +<%end -%> diff -uNr nova/chef/data_bags/crowbar/bc-template-nova.json nova.inktank/chef/data_bags/crowbar/bc-template-nova.json --- nova/chef/data_bags/crowbar/bc-template-nova.json 2012-10-26 11:22:46.000000000 -0500 +++ nova.inktank/chef/data_bags/crowbar/bc-template-nova.json 2012-10-08 13:37:21.000000000 -0500 @@ -6,6 +6,7 @@ "keystone_instance": "none", "service_user": "nova", "glance_instance": "none", + "ceph_instance": "none", "libvirt_type": "kvm", "use_novnc": true, "verbose": true, diff -uNr nova/chef/data_bags/crowbar/bc-template-nova.schema nova.inktank/chef/data_bags/crowbar/bc-template-nova.schema --- nova/chef/data_bags/crowbar/bc-template-nova.schema 2012-10-26 11:22:46.000000000 -0500 +++ nova.inktank/chef/data_bags/crowbar/bc-template-nova.schema 2012-10-08 13:37:21.000000000 -0500 @@ -16,6 +16,7 @@ "service_user": { "type": "str", "required": true }, "service_password": { "type": "str" }, "glance_instance": { "type": "str", "required": true }, + "ceph_instance": { "type": "str", "required": false }, "libvirt_type": { "type": "str", "required": true }, "use_novnc": { "type": "bool", "required": true }, "verbose": { "type": "bool", "required": true }, diff -uNr nova/crowbar_framework/app/models/nova_service.rb nova.inktank/crowbar_framework/app/models/nova_service.rb --- nova/crowbar_framework/app/models/nova_service.rb 2012-10-26 11:22:46.000000000 -0500 +++ nova.inktank/crowbar_framework/app/models/nova_service.rb 2012-10-09 18:42:33.000000000 -0500 @@ -111,6 +111,19 @@ @logger.info("Nova create_proposal: no glance found") end + base["attributes"]["nova"]["ceph_instance"] = "" + begin + cephService = CephService.new(@logger) + cephs = cephService.list_active[1] + if cephs.empty? + # No actives, look for proposals + cephs = cephService.proposals[1] + end + base["attributes"]["nova"]["ceph_instance"] = cephs[0] unless cephs.empty? + rescue + @logger.info("Nova create_proposal: no ceph found") + end + base["attributes"]["nova"]["db"]["password"] = random_password @logger.debug("Nova create_proposal: exiting") @@ -148,6 +161,12 @@ end @logger.debug("Nova apply_role_pre_chef_call: leaving") + + if not role.default_attributes["nova"]["ceph_instance"].empty? + all_nodes.each do |node| + net_svc.allocate_ip("default", "storage", "host", node) + end + end end end diff -uNr nova/crowbar_framework/app/views/barclamp/nova/_edit_attributes.html.haml nova.inktank/crowbar_framework/app/views/barclamp/nova/_edit_attributes.html.haml --- nova/crowbar_framework/app/views/barclamp/nova/_edit_attributes.html.haml 2012-10-26 11:22:46.000000000 -0500 +++ nova.inktank/crowbar_framework/app/views/barclamp/nova/_edit_attributes.html.haml 2012-10-08 13:37:21.000000000 -0500 @@ -20,6 +20,9 @@ %label{ :for => :glance_instance }= t('.glance_instance') = instance_selector("glance", :glance_instance, "glance_instance", @proposal) %p + %label{ :for => :ceph_instance }= t('.ceph_instance') + = instance_selector("ceph", :ceph_instance, "ceph_instance", @proposal) + %p %label{ :for => :verbose }= t('.verbose') = select_tag :verbose, options_for_select([['true','true'], ['false', 'false']], @proposal.raw_data['attributes'][@proposal.barclamp]["verbose"].to_s), :onchange => "update_value('verbose', 'verbose', 'boolean')" %p diff -uNr nova/crowbar.yml nova.inktank/crowbar.yml --- nova/crowbar.yml 2012-11-01 14:50:34.000000000 -0500 +++ nova.inktank/crowbar.yml 2012-10-17 15:30:59.000000000 -0500 @@ -23,6 +23,7 @@ - @crowbar - mysql - glance + - ceph - keystone - nova_dashboard member: @@ -45,6 +46,7 @@ service_user: Keystone Service User service_password: Keystone Service Password glance_instance: Glance + ceph_instance: Ceph verbose: Verbose use_novnc: Use NoVNC (otherwise VPN-VNC) dhcp_enabled: DHCP Enabled