Skip to content

Commit

Permalink
Merge "Partial-Bug: #1533386 Server Manager Support DPDK provisioning"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jan 23, 2016
2 parents 8978631 + 8df9dee commit cac1b48
Show file tree
Hide file tree
Showing 14 changed files with 338 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,29 @@
Facter::Util::Resolution.exec('python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"')
end
end
Facter.add(:contrail_mem_sz) do
setcode do
Facter::Util::Resolution.exec(File.join(File.dirname(__FILE__), 'mem_size.sh'))
end
end
Facter.add(:contrail_pg_sz) do
setcode do
Facter::Util::Resolution.exec(File.join(File.dirname(__FILE__), 'pg_sz.sh'))
end
end
Facter.add(:contrail_reserv_pg) do
setcode do
Facter::Util::Resolution.exec(File.join(File.dirname(__FILE__), 'reserv_pg.sh'))
end
end
Facter.add(:contrail_dpdk_bind_if) do
setcode do
Facter::Util::Resolution.exec('ifconfig vhost > /dev/null && grep "^physical_interface=" /etc/contrail/contrail-vrouter-agent.conf | awk -F= "{print $2}"')
end
end
Facter.add(:contrail_dpdk_bind_pci_address) do
setcode do
Facter::Util::Resolution.exec('ifconfig vhost > /dev/null && grep "^physical_interface_address=" /etc/contrail/contrail-vrouter-agent.conf | awk -F= "{print $2}"')
end
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require 'facter'

Facter.add(:contrail_interfaces) do
setcode do
contrail_interfaces = {}
interface_list_str = %x[ifconfig -a | grep HWaddr | awk \'{ print $1 \'}]
intf_list = interface_list_str.split("\n")

intf_list.each do |intf|
intf_detail = {}
vlan_intf = %x[ip addr show #{intf} | head -1| cut -f2 -d':' | grep -o '@.*']
if (vlan_intf != "")
intf_detail["vlan"] = true
intf_detail["parent"] = vlan_intf.delete("\n").delete('@')
else
intf_detail["vlan"] = false
pci_address = %x[udevadm info -a -p /sys/class/net/#{intf} | awk -F/ '/device.*eth/ {print $4}']
intf_detail["pci_address"] = pci_address.delete("\n")
end
contrail_interfaces[intf] = intf_detail
end
contrail_interfaces
end
end
2 changes: 2 additions & 0 deletions contrail/environment/modules/contrail/lib/facter/mem_size.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
grep MemTotal /proc/meminfo | tr -s ' ' | cut -d' ' -f 2
2 changes: 2 additions & 0 deletions contrail/environment/modules/contrail/lib/facter/pg_sz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
grep Hugepagesize /proc/meminfo | tr -s ' ' | cut -d' ' -f 2
2 changes: 2 additions & 0 deletions contrail/environment/modules/contrail/lib/facter/reserv_pg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
grep HugePages_total /proc/meminfo | tr -s ' ' | cut -d' ' -f 2
2 changes: 1 addition & 1 deletion contrail/environment/modules/contrail/manifests/common.pp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
originator => 'Debian'
} ->
apt::pin { 'contrail_repo_preferences':
priority => '999',
priority => '998',
codename => 'contrail'
} ->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
$contrail_host_roles = $::contrail::params::host_roles,
$enable_lbass = $::contrail::params::enable_lbass,
$xmpp_auth_enable = $::contrail::params::xmpp_auth_enable,
$enable_dpdk= $::contrail::params::enable_dpdk,
) {
$config_ip_to_use = $::contrail::params::config_ip_to_use
$keystone_ip_to_use = $::contrail::params::keystone_ip_to_use
Expand All @@ -58,10 +59,51 @@
}
$physical_dev = get_device_name($vhost_ip)
if ($physical_dev != 'vhost0') {
#when compute provision runs for the first time.
#IP address is on the actual phsyical interface
$contrail_dev = $physical_dev

#find pci_address
$intf_dict = $contrail_interfaces[$physical_dev]
notify { "intf_dict = ${intf_dict}":; }
if ( 'bond' in $physical_dev) {
$pci_address = '0000:00:00.0'
} elsif($intf_dict["parent"]) {
#vlan interface
$parent_intf = $contrail_interfaces[$intf_dict["parent"]]
$pci_address = $parent_intf["pci_address"]

notify { "has a parent":; }
notify { "pci_address = ${pci_address}":; }
} else {

notify { "is master":; }
$pci_address = $intf_dict["pci_address"]
notify { "pci_address = ${pci_address}":; }
}

} else {
#when compute provision runs the second time
#vhost is already setup
#in case of non dpdk setup old interface still exists
#and details can de derived from that
#in case of dpdk,actual physical inerface is taken away from the kernel
#so get the details with the help of the facts

$contrail_dev_mac = inline_template("<%= scope.lookupvar('macaddress_' + @physical_dev) %>")
$contrail_dev = get_device_name_by_mac($contrail_dev_mac)
if ($enable_dpdk == false) {
$contrail_dev = get_device_name_by_mac($contrail_dev_mac)
} else {
if ($contrail_dpdk_bind_if == "" or $contrail_dpdk_bind_if == undef) {
fail('dpdk interface is not setup properly')
}
if ($contrail_dpdk_bind_pci_address == "" or $contrail_dpdk_bind_pci_address == undef) {
fail('dpdk interface is not setup properly')
}

$contrail_dev = $contrail_dpdk_bind_if
$pci_address = $contrail_dpdk_bind_pci_address
}
}

if ($physical_dev == undef) {
Expand Down Expand Up @@ -97,6 +139,16 @@
$contrail_router_type = ''
$nova_compute_status = 'true'
}

#variables used in templates for vrouter_agent.conf
if ($enable_dpdk) {
$contrail_work_mode = "dpdk"
} else {
$contrail_work_mode = "default"
}



# Debug Print all variable values
notify {"host_control_ip = ${host_control_ip}":; } ->
notify {"config_ip = ${config_ip}":; } ->
Expand Down Expand Up @@ -156,6 +208,21 @@
content => "manual",
}
}
if ($enable_dpdk == true) {
#Looks like this is still seen as re-declaration by puppet
/*
file { 'remove_supervisor_vrouter_override':
path => "/etc/init/supervisor-vrouter.override",
ensure => absent,
}->
*/
exec { 'remove_supervisor_override':
command => "rm -rf /etc/init/supervisor-vrouter.override",
provider => shell,
logoutput => $contrail_logoutput,
}

}
}

# Install interface rename package for centos.
Expand Down Expand Up @@ -251,6 +318,9 @@
'DEFAULT/xmpp_server_cert' : value => "/etc/contrail/ssl/certs/server.pem";
'DEFAULT/xmpp_server_key' : value => "/etc/contrail/ssl/private/server-privkey.pem";
'DEFAULT/xmpp_ca_cert' : value => "/etc/contrail/ssl/certs/ca-cert.pem";
'DEFAULT/platform' : value => "$contrail_work_mode";
'DEFAULT/physical_interface_address' : value => "$pci_address";
'DEFAULT/physical_interface_mac' : value => "$contrail_macaddr";
'DISCOVERY/server' : value => "$discovery_ip";
'DISCOVERY/max_control_nodes' : value => "$number_control_nodes";
'HYPERVISOR/type' : value => "$hypervisor_type";
Expand Down Expand Up @@ -284,6 +354,9 @@
openstack_ip => $openstack_ip
}
->
contrail::lib::setup_hugepages{ 'huge_pages':
}
->
class {'::contrail::compute::setup_compute_server_setup':}
->
reboot { 'compute':
Expand Down
29 changes: 26 additions & 3 deletions contrail/environment/modules/contrail/manifests/compute/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
) {
$cur_kernel_version = $::kernelrelease
$dist_kernel_version = "${::contrail::params::contrail_dist_kernel_version}-generic"

notify{"###DEBUG dist_kernel_version_test $dist_kernel_version_test ":;}
notify{"###DEBUG contrail_dist_kernel_version $dist_kernel_version and system kernel version is $cur_kernel_version":;}

#Temporary work around untill we find out the root cause for inconsistent reboot resource behavior.
if ((($::contrail::params::kernel_upgrade == 'yes') or
($::contrail::params::kernel_upgrade == true)) and $cur_kernel_version != $dist_kernel_version ) {
Expand All @@ -34,7 +34,30 @@

if ($::operatingsystem == 'Ubuntu'){
if ($::lsbdistrelease == '14.04') {
if ($::kernelrelease == '3.13.0-40-generic') {
notify { "enable_dpdk = ${enable_dpdk}":; }
if ($enable_dpdk == true ) {
notify { "settting up DPDK":; }
->
#Might be temporary
#create the override and remove it
#create an overrride so that supervisor-vrouter doesnt start
#when installing the package
#This is needed only for dpdk
#as the prestart script uses config files
file { 'create_supervisor_vrouter_override':
path => "/etc/init/supervisor-vrouter.override",
ensure => present,
content => "manual",
}
->
#This package dependancy should
#be ideally resolved libvirt-bin or supervisor-vrouter atleast.
package { 'libcgmanager0':
ensure => '0.24-0ubuntu7.5',
}

$vrouter_pkg = 'contrail-vrouter-dpdk-init'
} elsif ($::kernelrelease == '3.13.0-40-generic') {
$vrouter_pkg = 'contrail-vrouter-3.13.0-40-generic'
} else {
$vrouter_pkg = 'contrail-vrouter-dkms'
Expand Down
5 changes: 5 additions & 0 deletions contrail/environment/modules/contrail/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,8 @@
$contrail_version = '',
$xmpp_auth_enable = false,
$package_sku = "juno",
$core_mask = '',
$huge_pages = '',
) {
class { '::contrail::params':
# Common Parameters
Expand Down Expand Up @@ -770,6 +772,9 @@
compute_ip_list => hiera(contrail::compute::compute_ip_list, hiera(contrail::params::compute_ip_list, $compute_ip_list)),
compute_name_list => hiera(contrail::compute::compute_name_list, hiera(contrail::params::compute_name_list, $compute_name_list)),
compute_passwd_list => hiera(contrail::compute::compute_passwd_list, hiera(contrail::params::compute_passwd_list, $compute_passwd_list)),
huge_pages => hiera(contrail::compute::dpdk::huge_pages, hiera(contrail::params::huge_pages, $huge_pages)),
core_mask => hiera(contrail::compute::dpdk::core_mask, hiera(contrail::params::core_mask, $core_mask)),

# VMWare Parameters
vmware_ip => hiera(contrail::vmware::vmware_ip, hiera(contrail::params::vmware_ip, $vmware_ip)),
vmware_username => hiera(contrail::vmware::vmware_username, hiera(contrail::params::vmware_username, $vmware_username)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
define contrail::lib::contrail_setup_repo(
$contrail_repo_ip,
$contrail_logoutput = false,
$host_roles = $::contrail::params::host_roles,
) {
$contrail_repo_name = $name
if ($operatingsystem == "Centos" or $operatingsystem == "Fedora") {
Expand All @@ -17,4 +18,7 @@
release => 'contrail',
}
}
if ('compute' in $host_roles) {
contrail::lib::setup_dpdk_depends{ 'dpdk_depends':}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
define contrail::lib::setup_coremask(
$contrail_logoutput = false,
$core_mask= $::contrail::params::core_mask,
$enable_dpdk = $::contrail::params::enable_dpdk,
) {

if ($enable_dpdk) {
if ( ',' in coremask or '-' in coremask ) {
$taskset_params = " -C"
} else {
$taskset_params = ""
}

$vrouter_file = '/etc/contrail/supervisord_vrouter_files/contrail-vrouter-dpdk.ini'

#try startuing a dummy task with coremask,
#if that goes through set in the supervisor file.
exec { 'try_core_mask' :
command => "taskset${taskset_params} ${core_mask} true",
provider => 'shell',
logoutput => $contrail_logoutput
} ->
#unable to use file_line as it works only on whole
#lines and not on wordS
exec { 'change_supervisor' :
command => "sed -i \"s/command=/command=taskset${taskset_params} ${core_mask} /g\" ${vrouter_file}",
provider => 'shell',
logoutput => $contrail_logoutput
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
define contrail::lib::setup_dpdk_depends(
$contrail_logoutput = false,
$enable_dpdk = $::contrail::params::enable_dpdk,
$contrail_repo_name = $::contrail::params::contrail_repo_name,
)
{
if ($enable_dpdk) {

if ($::operatingsystem == "Ubuntu") {


notify { "settting up DPDK Repo":; }
->
apt::source { 'contrail-dpdk-depends':
location => "http://puppet/contrail/repo/${contrail_repo_name}/dpdk_depends",
repos => 'main',
release => 'contrail-dpdk-depends',
}
->
apt::pin { 'contrail-dpdk-depreds-repo_preferences':
priority => '999',
codename => 'contrail-dpdk-depends'
}


#for setting up the repo without apt at any stage
#as there given the stages for now
#apt module can only be used in first stage.

/*
file { '/etc/apt/sources.list.d/contrail_dpdk.list' :
ensure => present,
content => template("${module_name}/contrail_dpdk_depends_sources.list.erb")
}
->
file { '/etc/apt/preferences.d/contrail_dpdk_preferences.pref' :
ensure => present,
content => template("${module_name}/contrail_dpdk_preferences.pref")
}
->
exec { 'apt_get_update' :
command => 'apt-get update',
provider => 'shell',
logoutput => $contrail_logoutput
}
*/

#for setting up a local repo of dpdk-packages
/*
package { dpdk-depends-packages :
ensure => present,
}
->
file_line { "add_dpdk_depends":
path => '/etc/apt/sources.list',
line => 'deb file:/opt/contrail/contrail_install_repo_dpdk ./',
}
->
exec { 'scan_packages' :
command => 'dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz',
provider => 'shell',
cwd => '/opt/contrail/contrail_install_repo_dpdk',
logoutput => $contrail_logoutput,
}
->
exec { 'apt_get_update' :
command => 'apt-get update',
provider => 'shell',
logoutput => $contrail_logoutput
}
*/
}
}
}

0 comments on commit cac1b48

Please sign in to comment.