licenses: Add license headers
[ovsnfv.git] / fuel-plugin-ovsnfv / deployment_scripts / puppet / modules / ovsdpdk / manifests / uninstall_ovs.pp
1 # Copyright (c) 2016 Open Platform for NFV Project, Inc. and its contributors
2 #
3 #    Licensed under the Apache License, Version 2.0 (the "License");
4 #    you may not use this file except in compliance with the License.
5 #    You may obtain a copy of the License at
6 #
7 #        http://www.apache.org/licenses/LICENSE-2.0
8 #
9 #    Unless required by applicable law or agreed to in writing, software
10 #    distributed under the License is distributed on an "AS IS" BASIS,
11 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 #    See the License for the specific language governing permissions and
13 #    limitations under the License.
14
15 # == Class: ovsdpdk::uninstall_ovs
16 #
17 # Provides uninstallation of openvswitch package (if present) together with removing of kernel module
18 #
19 class ovsdpdk::uninstall_ovs (
20   $openvswitch_service_name = $::ovsdpdk::params::openvswitch_service_name,
21   $openvswitch_agent        = $::ovsdpdk::params::openvswitch_agent,
22   $install_packages         = $::ovsdpdk::params::install_packages,
23 ) inherits ovsdpdk {
24
25   #Due to dependencies to other packages, we won't purge vanilla OVS
26   #package { $remove_packages: ensure => 'purged' }
27
28   if $compute == 'True' {
29     exec { "/usr/sbin/service ${openvswitch_service_name} stop":
30       user   => root,
31       path   => ["/usr/bin", "/bin", "/sbin"],
32     }
33
34     exec { "/usr/sbin/service ${openvswitch_agent} stop":
35       user   => root,
36       path   => ["/usr/bin", "/bin", "/sbin"],
37     }
38
39     exec { '/sbin/modprobe -r openvswitch':
40       onlyif  => "/bin/grep -q '^openvswitch' '/proc/modules'",
41       user    => root,
42       require => Exec["/usr/sbin/service ${openvswitch_service_name} stop"],
43     }
44   }
45
46   if $controller == 'True' {
47     exec { '/usr/sbin/service neutron-server stop':
48       user   => root,
49       path   => ["/usr/bin", "/bin", "/sbin"],
50       onlyif => "ps aux | grep -vws grep | grep -ws neutron-server",
51     }
52   }
53
54   package { $install_packages: ensure => 'installed' }
55
56 }
57