fuel_plugin: Working version on Montreal POD
[ovsnfv.git] / fuel-plugin-ovsnfv / deployment_scripts / puppet / modules / ovsdpdk / manifests / postinstall_ovs_dpdk.pp
1 # == Class ovsdpdk::postinstall_ovs_dpdk
2 #
3 # Postinstall configuration of ovs-dpdk service
4 #
5 class ovsdpdk::postinstall_ovs_dpdk (
6   $plugin_dir               = $::ovsdpdk::params::plugin_dir,
7   $nova_conf                = $::ovsdpdk::params::nova_conf,
8   $openvswitch_service_name = $::ovsdpdk::params::openvswitch_service_name,
9   $ml2_conf                 = $::ovsdpdk::params::ml2_conf,
10   $ml2_ovs_conf             = $::ovsdpdk::params::ml2_ovs_conf,
11   $neutron_l3_conf          = $::ovsdpdk::params::neutron_l3_conf,
12   $openvswitch_agent        = $::ovsdpdk::params::openvswitch_agent,
13 ) inherits ovsdpdk {
14
15   require ovsdpdk::install_ovs_dpdk
16
17   package {'crudini': ensure => installed }
18
19   if $compute == 'True' {
20     # adapt configuration files
21     exec {'adapt_nova_conf':
22       command => "${plugin_dir}/files/set_vcpu_pin.sh ${nova_conf}",
23       path    => ['/usr/bin','/bin'],
24       user    => root,
25       onlyif  => "test -f ${nova_conf}",
26       require => Package['crudini'],
27     }
28
29     exec {'adapt_ml2_conf_datapath':
30       command => "sudo crudini --set ${ml2_ovs_conf} ovs datapath_type ${ovs_datapath_type}",
31       path    => ['/usr/bin','/bin'],
32       user    => root,
33       onlyif  => "test -f ${ml2_ovs_conf}",
34       require => Package['crudini'],
35     }
36
37     exec {'adapt_neutron_l3':
38       command => "sudo crudini --set ${neutron_l3_conf} DEFAULT external_network_bridge br-ex",
39       path    => ['/usr/bin','/bin'],
40       user    => root,
41       onlyif  => "test -f ${neutron_l3_conf}",
42       require => Package['crudini'],
43     }
44
45
46     service {"${openvswitch_service_name}": ensure => 'running' }
47
48     # restart OVS to synchronize ovsdb-server with ovs-vswitchd needed
49     # due to several new --no-wait entries
50     exec {'restart_ovs':
51       command => "/usr/sbin/service ${openvswitch_service_name} restart",
52       user    => root,
53       require => Service["${openvswitch_service_name}"],
54     }
55
56     exec { "${plugin_dir}/files/configure_bridges.sh ${ovs_datapath_type}":
57       user    => root,
58       require => Exec['restart_ovs'],
59     }
60
61     service { 'libvirtd': ensure => running }
62
63     exec {'libvirtd_disable_tls':
64       command => "sudo crudini --set /etc/libvirt/libvirtd.conf '' listen_tls 0",
65       path    => ['/usr/bin','/bin'],
66       user    => root,
67       require => Package['crudini'],
68       notify  => Service['libvirtd'],
69     }
70
71     exec {'restart_nova_compute':
72       command => "/usr/sbin/service nova-compute restart",
73       user    => root,
74       require => [ Exec['libvirtd_disable_tls'], Service['libvirtd'] ],
75     }
76   }
77
78   exec {'adapt_ml2_conf_mechanism_driver':
79     command => "sudo crudini --set ${ml2_conf} ml2 mechanism_drivers ovsdpdk",
80     path    => ['/usr/bin','/bin'],
81     user    => root,
82     onlyif  => "test -f ${ml2_conf}",
83     require => Package['crudini'],
84   }
85
86   exec {'adapt_ml2_conf_security_group':
87     command => "sudo crudini --set ${ml2_conf} securitygroup firewall_driver neutron.agent.firewall.NoopFirewallDriver",
88     path    => ['/usr/bin','/bin'],
89     user    => root,
90     onlyif  => "test -f ${ml2_conf}",
91     require => Package['crudini'],
92   }
93
94   if $controller == 'True' {
95     service {'neutron-server':
96       ensure => 'running',
97     }
98
99     exec {'append_NUMATopologyFilter':
100       command => "sudo crudini --set ${nova_conf} DEFAULT scheduler_default_filters RetryFilter,AvailabilityZoneFilter,RamFilter,CoreFilter,DiskFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,NUMATopologyFilter",
101       path    => ['/usr/bin','/bin'],
102       user    => root,
103       onlyif  => "test -f ${nova_conf}",
104       require => Package['crudini'],
105     }
106
107     exec { 'remove_old_agent':
108       command => "${plugin_dir}/files/remove_agent.sh $adminrc_user $adminrc_password $adminrc_tenant $adminrc_hostname",
109       user      => 'root',
110       logoutput => 'true',
111       timeout   => 0,
112       require   => [ Service['neutron-server'], Exec['append_NUMATopologyFilter'] ],
113     }
114
115     exec {'restart_neutron_server':
116       command => "/usr/sbin/service neutron-server restart",
117       user    => root,
118       require => Exec['remove_old_agent'],
119     }
120
121     exec {'restart_nova_scheduler':
122       command => "/usr/sbin/service nova-scheduler restart",
123       user    => root,
124       require => Exec['remove_old_agent'],
125     }
126
127   }
128
129   if $compute == 'True' {
130     exec { 'patch_ovs_agent':
131       command => "cp ${plugin_dir}/files/neutron-plugin-openvswitch-agent.conf /etc/init/neutron-plugin-openvswitch-agent.conf",
132       path    => ['/usr/bin','/bin'],
133       user    => root,
134     }
135
136     service {"${openvswitch_agent}":
137       ensure  => 'running',
138       require => [ Exec['restart_ovs'], Service["${openvswitch_service_name}"], Exec['patch_ovs_agent'] ],
139     }
140
141     exec { "ovs-vsctl --no-wait set Open_vSwitch . other_config:pmd-cpu-mask=${ovs_pmd_core_mask}":
142       path    => ['/usr/bin','/bin'],
143       user    => root,
144       require => Service["${openvswitch_agent}"],
145     }
146   }
147
148 }