separate lacp config and repo from main scripts

Change-Id: If2385b9f29e996f596154557f5a820a850f68d36
This commit is contained in:
Kanzhe Jiang 2015-12-16 01:04:36 -08:00
parent 737b80d3e4
commit 7b97cd8fc0
7 changed files with 225 additions and 57 deletions

View File

@ -0,0 +1,32 @@
#
# Copyright 2015 BigSwitch Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
notice('MODULAR: bigswitch/common-repo.pp')
class bcf::common-repo {
$binpath = "/usr/local/bin/:/bin/:/usr/bin:/usr/sbin:/usr/local/sbin:/sbin"
package { 'python-pip':
ensure => 'installed',
}
exec { 'bsnstacklib':
command => 'pip install "bsnstacklib<2015.2"',
path => "/usr/local/bin/:/usr/bin/:/bin",
require => Package['python-pip']
}
}

View File

@ -0,0 +1,18 @@
#
# Copyright 2015 BigSwitch Networks
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
notice("MODULAR: bigswitch controller-network-config")
include bcf::params
include bcf::p_only::controller-network

View File

@ -0,0 +1,32 @@
#
# Copyright 2015 BigSwitch Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
notice('MODULAR: bigswitch purge-os.pp')
file { '/etc/bigswitch':
ensure => 'directory',
}
file { '/etc/bigswitch/purge_all.sh':
source => 'puppet:///modules/bcf/purge_all.sh',
ensure => file,
}
exec { 'purge openstack neutron objects':
command => 'bash /etc/bigswitch/purge_all.sh',
path => "/usr/local/bin/:/usr/bin/:/bin",
require => File['/etc/bigswitch/purge_all.sh']
}

View File

@ -0,0 +1,47 @@
#!/bin/bash
# This template deletes all network related resources for fresh installation.
# We are not using it anywhere for now, but keep it hear for future uses.
source ~/openrc
keystone tenant-list
if [[ $? != 0 ]]; then
echo 'Unable to establish connection for ospurge'
exit 1
fi
# delete all routers
routers=$(neutron router-list | awk '$2 != "id" {print $2}' | awk 'NF && $1!~/^#/')
for router in $routers; do
# delete all subnets that have interface on router
subnets=$(neutron router-port-list $router | awk '$0 ~ /.*subnet_id.*/ {print $0}' | awk '{print $(NF - 3)}' | tr -d ,| tr -d \")
for subnet in $subnets; do
neutron router-interface-delete $router $subnet
done
neutron router-gateway-clear $router
neutron router-delete $router
done
# delete floating ips
floatingips=$(neutron floatingip-list | awk '$2 != "id" {print $2}' | awk 'NF && $1!~/^#/')
for floatingip in $floatingips; do
neutron floatingip-delete $floatingip
done
# delete nova instances
instances=$(nova list --all-tenants | awk '$2 != "ID" {print $2}' | awk 'NF && $1!~/^#/')
for instance in $instances; do
nova delete $instance
done
# delete all subnets
subnets=$(neutron subnet-list | awk '$2 != "id" {print $2}' | awk 'NF && $1!~/^#/')
for subnet in $subnets; do
neutron subnet-delete $subnet
done
# delete all networks
nets=$(neutron net-list | awk '$2 != "id" {print $2}' | awk 'NF && $1!~/^#/')
for net in $nets; do
neutron net-delete $net
done

View File

@ -0,0 +1,58 @@
#
# Copyright 2015 BigSwitch Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
class bcf::p_only::controller-network {
include bcf
include bcf::params
$binpath = "/usr/local/bin/:/bin/:/usr/bin:/usr/sbin:/usr/local/sbin:/sbin"
$sys_desc_lacp = "5c:16:c7:00:00:04"
# lldp
$a = file('/etc/fuel/plugins/fuel-plugin-bigswitch-1.0/python_scripts/send_lldp','/dev/null')
if($a != '') {
file { "/bin/send_lldp":
content => $a,
ensure => file,
mode => 0777,
}
}
file { "/etc/init/send_lldp.conf":
ensure => file,
content => "
description \"BCF LLDP\"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
exec /bin/send_lldp --system-desc $sys_desc_lacp --system-name $(uname -n) -i 10 --network_interface $bcf::itfs
end script
",
}
service { "send_lldp":
ensure => running,
enable => true,
require => [File['/bin/send_lldp'], File['/etc/init/send_lldp.conf']],
}
# load bonding module
file_line {'load bonding on boot':
path => '/etc/modules',
line => 'bonding',
match => '^bonding$',
}
}

View File

@ -19,55 +19,6 @@ class bcf::p_only::controller {
include bcf::params
$binpath = "/usr/local/bin/:/bin/:/usr/bin:/usr/sbin:/usr/local/sbin:/sbin"
$ifcfg_bond0 = "/etc/network/interfaces.d/ifcfg-bond0"
$sys_desc_lacp = "5c:16:c7:00:00:04"
$sys_desc_xor = "5c:16:c7:00:00:00"
if $bcf::bond {
# ensure bond-mode is 802.3ad
exec { "ensure ${bcf::bond_lacp} in $ifcfg_bond0":
command => "echo '${bcf::bond_lacp}' >> $ifcfg_bond0",
unless => "grep -qe '${bcf::bond_lacp}' -- $ifcfg_bond0",
path => "/bin:/usr/bin",
require => Exec["update bond-mode in $ifcfg_bond0"],
}
exec { "update bond-mode in $ifcfg_bond0":
command => "sed -i 's/bond-mode.*/${bcf::bond_lacp}/' $ifcfg_bond0",
path => "/bin:/usr/bin"
}
$sys_desc = $bcf::sys_desc_lacp
}
else {
$sys_desc = $bcf::sys_desc_xor
}
# lldp
$a = file('/etc/fuel/plugins/fuel-plugin-bigswitch-1.0/python_scripts/send_lldp','/dev/null')
if($a != '') {
file { "/bin/send_lldp":
content => $a,
ensure => file,
mode => 0777,
}
}
file { "/etc/init/send_lldp.conf":
ensure => file,
content => "
description \"BCF LLDP\"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
script
exec /bin/send_lldp --system-desc $sys_desc --system-name $(uname -n) -i 10 --network_interface $bcf::itfs
end script
",
}
service { "send_lldp":
ensure => running,
enable => true,
require => [File['/bin/send_lldp'], File['/etc/init/send_lldp.conf']],
}
package { 'python-pip':
ensure => 'installed',
}
@ -77,13 +28,6 @@ end script
require => Package['python-pip']
}
# load bonding module
file_line {'load bonding on boot':
path => '/etc/modules',
line => 'bonding',
match => '^bonding$',
}
# purge bcf controller public key
exec { 'purge bcf key':
command => "rm -rf /etc/neutron/plugins/ml2/host_certs/*",

View File

@ -1,11 +1,39 @@
# These tasks will be merged into deployment graph. Here you
# can specify new tasks for any roles, even built-in ones.
- id: openstack-primary-controller-bigswitch
# Install common packages
- id: bigswitch-repo
type: puppet
groups: [primary-controller, controller, compute]
required_for: [deploy_end]
requires: [deploy_start]
parameters:
puppet_manifest: puppet/manifests/common-repo.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: primary-controller-lacp-bond
type: puppet
groups: [primary-controller, controller]
required_for: [openstack-controller]
requires: [netconfig]
parameters:
puppet_manifest: puppet/manifests/controller-network-config.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: primary-controller-cleanup
type: puppet
role: [primary-controller]
required_for: [post_deployment_end]
requires: [post_deployment_start]
parameters:
puppet_manifest: puppet/manifests/purge-os.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: openstack-primary-controller-bigswitch
type: puppet
role: [primary-controller]
required_for: [post_deployment_end]
requires: [primary-controller-cleanup]
parameters:
puppet_manifest: puppet/manifests/controller-config.pp
puppet_modules: puppet/modules:/etc/puppet/modules
@ -29,6 +57,15 @@
puppet_manifest: puppet/manifests/compute-config.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
- id: ceph-config
type: puppet
role: [ceph-osd]
required_for: [post_deployment_end]
requires: [post_deployment_start]
parameters:
puppet_manifest: puppet/manifests/ceph-config.pp
puppet_modules: puppet/modules:/etc/puppet/modules
timeout: 720
#- id: fuel-plugin-bigswitch-deployment-puppet
# type: puppet
# groups: [fuel-plugin-bigswitch]