Difference between revisions of "OpenStack Configuration Example"

From Xen
(Created page with "The SUSE Cloud project contains a fully operational OpenStack implementation for Xen Project. It is an example of how to successfully employ Xen Project in OpenStack. This page…")
 
(Recipes files)
 
(23 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
== Where to Find the Configuration Files ==
 
== Where to Find the Configuration Files ==
   
The bulk of the Xen Project-specific entries will be in the Barclamp section of the Nova project within OpenStack.
+
The bulk of the Xen Project-specific entries will be in the Barclamp section of the Nova project within OpenStack. Most of these files can be found in the following trees:
  +
  +
* https://github.com/crowbar/barclamp-nova/blob/master/chef/cookbooks/nova/recipes/
  +
* https://github.com/crowbar/barclamp-nova/blob/master/chef/cookbooks/nova/templates/default/
  +
  +
== Recipes files ==
  +
  +
The following portions are the Xen Project-specific segments from [https://github.com/crowbar/barclamp-nova/blob/master/chef/cookbooks/nova/recipes/compute.rb compute.rb]:
  +
<pre>
  +
def set_boot_kernel_and_trigger_reboot(flavor='default')
  +
# only default and xen flavor is supported by this helper right now
  +
default_boot = 0
  +
current_default = nil
  +
  +
# parse menu.lst, to find boot index for selected flavor
  +
File.open('/boot/grub/menu.lst') do |f|
  +
f.lines.each do |line|
  +
current_default = line.scan(/\d/).first.to_i if line.start_with?('default')
  +
  +
if line.start_with?('title')
  +
if flavor.eql?('xen')
  +
# found boot index
  +
break if line.include?('Xen')
  +
else
  +
# take first non-xen kernel as default
  +
break unless line.include?('Xen')
  +
end
  +
  +
default_boot += 1
  +
end
  +
  +
end
  +
end
  +
</pre>
  +
<pre>
  +
when "xen"
  +
%w{kernel-xen xen xen-tools openvswitch-kmp-xen}.each do |pkg|
  +
package pkg do
  +
action :install
  +
end
  +
end
  +
  +
service "xend" do
  +
action :nothing
  +
supports :status => true, :start => true, :stop => true, :restart => true
  +
# restart xend only when xen kernel is already present
  +
only_if { %x[uname -r].include?('xen') }
  +
end
  +
  +
template "/etc/xen/xend-config.sxp" do
  +
source "xend-config.sxp.erb"
  +
group "root"
  +
owner "root"
  +
mode 0644
  +
variables(
  +
:node_platform => node[:platform],
  +
:libvirt_migration => node[:nova]["use_migration"],
  +
:shared_instances => node[:nova]["use_shared_instance_storage"],
  +
:libvirtd_listen_tcp => node[:nova]["use_migration"] ? 1 : 0,
  +
:libvirtd_listen_addr => Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address
  +
)
  +
notifies :restart, "service[xend]", :delayed
  +
end
  +
  +
set_boot_kernel_and_trigger_reboot('xen')
  +
</pre>
  +
  +
The following portions are the Xen Project-specific segments from [https://github.com/crowbar/barclamp-nova/blob/master/chef/cookbooks/nova/recipes/xen.rb xen.rb]:
  +
<pre>
  +
node.set[:nova][:libvirt_type] = "xen"
  +
</pre>
  +
  +
== Template Files ==
  +
  +
Note that these examples use [[libvirt]] to integrate into OpenStack, not [[XAPI]] (aka XenAPI). Many of these files have extensive XenServer integration logic based on XAPI; this is not pertinent here.
  +
  +
The following portions are the Xen Project-specific segments from [https://github.com/crowbar/barclamp-nova/blob/master/chef/cookbooks/nova/templates/default/nova.conf.erb nova.conf.erb]:
  +
<pre>
  +
# Whether to use cow images (boolean value)
  +
<% if @libvirt_type.eql?('xen') -%>
  +
use_cow_images=false
  +
<% else -%>
  +
#use_cow_images=true
  +
<% end -%>
  +
</pre>
  +
  +
<pre>
  +
# Libvirt domain type (valid options are: kvm, lxc, qemu, uml,
  +
# xen) (string value)
  +
# Deprecated group/name - [DEFAULT]/libvirt_type
  +
virt_type=<%= @libvirt_type %>
  +
</pre>
  +
  +
<pre>
  +
<% if @libvirt_type.eql?('xen') -%>
  +
<% if @libvirt_migration and @shared_instances -%>
  +
# Migration target URI (any included "%s" is replaced with the
  +
# migration target hostname) (string value)
  +
live_migration_uri=xenmigr://%s/system
  +
# Migration flags to be set for live migration (string value)
  +
live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_LIVE
  +
# Migration flags to be set for block migration (string value)
  +
#block_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE, VIR_MIGRATE_PEER2PEER, VIR_MIGRATE_NON_SHARED_INC
  +
<% end %>
  +
</pre>
  +
  +
<pre>
  +
# Override the default disk prefix for the devices attached to
  +
# a server, which is dependent on virt_type. (valid options
  +
# are: sd, xvd, uvd, vd) (string value)
  +
# Deprecated group/name - [DEFAULT]/libvirt_disk_prefix
  +
#disk_prefix=<None>
  +
<%= "disk_prefix=xvd" if @libvirt_type.eql?('xen') %>
  +
</pre>
  +
  +
<pre>
  +
# Location where the Xen hvmloader is kept (string value)
  +
#xen_hvmloader_path=/usr/lib/xen/boot/hvmloader
  +
</pre>
  +
  +
The following portions are the Xen Project-specific segments from [https://github.com/crowbar/barclamp-nova/blob/master/chef/cookbooks/nova/templates/default/xend-config.sxp.erb xend-config.sxp.erb]:
  +
<pre>
  +
(xend-unix-server yes)
  +
#
  +
<% if @libvirt_migration -%>
  +
(xend-relocation-server yes)
  +
<% else %>
  +
(xend-relocation-server no)
  +
<% end %>
  +
#
  +
<% if @libvirt_migration -%>
  +
(xend-relocation-address '<%= @libvirtd_listen_addr %>')
  +
<% else %>
  +
(xend-relocation-address '')
  +
<% end %>
  +
#
  +
<% if @libvirt_migration -%>
  +
(xend-relocation-hosts-allow '')
  +
<% else %>
  +
(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
  +
<% end %>
  +
#
  +
<% if @node_platform == "suse" -%>
  +
(network-script )
  +
(vif-script vif-bridge)
  +
<% else %>
  +
(network-script network-bridge)
  +
(vif-script vif-bridge)
  +
<% end %>
  +
#
  +
(dom0-min-mem 256)
  +
(enable-dom0-ballooning yes)
  +
(total_available_memory 0)
  +
(dom0-cpus 0)
  +
(vncpasswd '')
  +
</pre>
  +
  +
The following portions are the Xen Project-specific segments from [https://github.com/crowbar/barclamp-nova/blob/master/chef/cookbooks/nova/templates/default/libvirtd.conf.erb libvirtd.conf.erb]:
  +
<pre>
  +
</pre>
  +
  +
[[Category:OpenStack]]
  +
[[Category:libvirt]]
  +
[[Category:Integration]]

Latest revision as of 10:00, 22 November 2014

The SUSE Cloud project contains a fully operational OpenStack implementation for Xen Project. It is an example of how to successfully employ Xen Project in OpenStack. This page attempts to document the Xen Project-specific configuration elements as an example of what a functional implementation might look like. As such, this page is less a "How To" and more a "What Is".

Where to Find the Configuration Files

The bulk of the Xen Project-specific entries will be in the Barclamp section of the Nova project within OpenStack. Most of these files can be found in the following trees:

Recipes files

The following portions are the Xen Project-specific segments from compute.rb:

def set_boot_kernel_and_trigger_reboot(flavor='default')
# only default and xen flavor is supported by this helper right now
 default_boot = 0
 current_default = nil

 # parse menu.lst, to find boot index for selected flavor
  File.open('/boot/grub/menu.lst') do |f|
  f.lines.each do |line|
   current_default = line.scan(/\d/).first.to_i if line.start_with?('default')

   if line.start_with?('title')
   if flavor.eql?('xen')
    # found boot index
    break if line.include?('Xen')
   else
    # take first non-xen kernel as default
    break unless line.include?('Xen')
   end

  default_boot += 1
  end

 end
end
 when "xen"
  %w{kernel-xen xen xen-tools openvswitch-kmp-xen}.each do |pkg|
   package pkg do
    action :install
   end
  end

 service "xend" do
  action :nothing
  supports :status => true, :start => true, :stop => true, :restart => true
  # restart xend only when xen kernel is already present
  only_if { %x[uname -r].include?('xen') }
 end

 template "/etc/xen/xend-config.sxp" do
  source "xend-config.sxp.erb"
  group "root"
  owner "root"
  mode 0644
  variables(
   :node_platform => node[:platform],
   :libvirt_migration => node[:nova]["use_migration"],
   :shared_instances => node[:nova]["use_shared_instance_storage"],
   :libvirtd_listen_tcp => node[:nova]["use_migration"] ? 1 : 0,
   :libvirtd_listen_addr => Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address
  )
  notifies :restart, "service[xend]", :delayed
 end

 set_boot_kernel_and_trigger_reboot('xen')

The following portions are the Xen Project-specific segments from xen.rb:

node.set[:nova][:libvirt_type] = "xen"

Template Files

Note that these examples use libvirt to integrate into OpenStack, not XAPI (aka XenAPI). Many of these files have extensive XenServer integration logic based on XAPI; this is not pertinent here.

The following portions are the Xen Project-specific segments from nova.conf.erb:

# Whether to use cow images (boolean value)
<% if @libvirt_type.eql?('xen') -%>
use_cow_images=false
<% else -%>
#use_cow_images=true
<% end -%>
# Libvirt domain type (valid options are: kvm, lxc, qemu, uml,
# xen) (string value)
# Deprecated group/name - [DEFAULT]/libvirt_type
virt_type=<%= @libvirt_type %>
<% if @libvirt_type.eql?('xen') -%>
<% if @libvirt_migration and @shared_instances -%>
# Migration target URI (any included "%s" is replaced with the
# migration target hostname) (string value)
live_migration_uri=xenmigr://%s/system
# Migration flags to be set for live migration (string value)
live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_LIVE
# Migration flags to be set for block migration (string value)
#block_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE, VIR_MIGRATE_PEER2PEER, VIR_MIGRATE_NON_SHARED_INC
<% end %>
# Override the default disk prefix for the devices attached to
# a server, which is dependent on virt_type. (valid options
# are: sd, xvd, uvd, vd) (string value)
# Deprecated group/name - [DEFAULT]/libvirt_disk_prefix
#disk_prefix=<None>
<%= "disk_prefix=xvd" if @libvirt_type.eql?('xen') %>
# Location where the Xen hvmloader is kept (string value)
#xen_hvmloader_path=/usr/lib/xen/boot/hvmloader

The following portions are the Xen Project-specific segments from xend-config.sxp.erb:

(xend-unix-server yes)
#
<% if @libvirt_migration -%>
(xend-relocation-server yes)
<% else %>
(xend-relocation-server no)
<% end %>
#
<% if @libvirt_migration -%>
(xend-relocation-address '<%= @libvirtd_listen_addr %>')
<% else %>
(xend-relocation-address '')
<% end %>
#
<% if @libvirt_migration -%>
(xend-relocation-hosts-allow '')
<% else %>
(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$')
<% end %>
#
<% if @node_platform == "suse" -%>
(network-script )
(vif-script vif-bridge)
<% else %>
(network-script network-bridge)
(vif-script vif-bridge)
<% end %>
#
(dom0-min-mem 256)
(enable-dom0-ballooning yes)
(total_available_memory 0)
(dom0-cpus 0)
(vncpasswd '')

The following portions are the Xen Project-specific segments from libvirtd.conf.erb: