From 7b97cd8fc064389b5fa5be3f23dc12c917460331 Mon Sep 17 00:00:00 2001 From: Kanzhe Jiang Date: Wed, 16 Dec 2015 01:04:36 -0800 Subject: [PATCH] separate lacp config and repo from main scripts Change-Id: If2385b9f29e996f596154557f5a820a850f68d36 --- .../puppet/manifests/common-repo.pp | 32 ++++++++++ .../manifests/controller-network-config.pp | 18 ++++++ .../puppet/manifests/purge-os.pp | 32 ++++++++++ .../puppet/modules/bcf/files/purge_all.sh | 47 +++++++++++++++ .../manifests/p_only/controller-network.pp | 58 +++++++++++++++++++ .../bcf/manifests/p_only/controller.pp | 56 ------------------ deployment_tasks.yaml | 39 ++++++++++++- 7 files changed, 225 insertions(+), 57 deletions(-) create mode 100644 deployment_scripts/puppet/manifests/common-repo.pp create mode 100755 deployment_scripts/puppet/manifests/controller-network-config.pp create mode 100644 deployment_scripts/puppet/manifests/purge-os.pp create mode 100644 deployment_scripts/puppet/modules/bcf/files/purge_all.sh create mode 100644 deployment_scripts/puppet/modules/bcf/manifests/p_only/controller-network.pp diff --git a/deployment_scripts/puppet/manifests/common-repo.pp b/deployment_scripts/puppet/manifests/common-repo.pp new file mode 100644 index 0000000..a537cee --- /dev/null +++ b/deployment_scripts/puppet/manifests/common-repo.pp @@ -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'] + } +} + diff --git a/deployment_scripts/puppet/manifests/controller-network-config.pp b/deployment_scripts/puppet/manifests/controller-network-config.pp new file mode 100755 index 0000000..093186a --- /dev/null +++ b/deployment_scripts/puppet/manifests/controller-network-config.pp @@ -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 diff --git a/deployment_scripts/puppet/manifests/purge-os.pp b/deployment_scripts/puppet/manifests/purge-os.pp new file mode 100644 index 0000000..f3d97df --- /dev/null +++ b/deployment_scripts/puppet/manifests/purge-os.pp @@ -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'] +} + diff --git a/deployment_scripts/puppet/modules/bcf/files/purge_all.sh b/deployment_scripts/puppet/modules/bcf/files/purge_all.sh new file mode 100644 index 0000000..cdabe0b --- /dev/null +++ b/deployment_scripts/puppet/modules/bcf/files/purge_all.sh @@ -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 diff --git a/deployment_scripts/puppet/modules/bcf/manifests/p_only/controller-network.pp b/deployment_scripts/puppet/modules/bcf/manifests/p_only/controller-network.pp new file mode 100644 index 0000000..fe98c53 --- /dev/null +++ b/deployment_scripts/puppet/modules/bcf/manifests/p_only/controller-network.pp @@ -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$', + } +} + diff --git a/deployment_scripts/puppet/modules/bcf/manifests/p_only/controller.pp b/deployment_scripts/puppet/modules/bcf/manifests/p_only/controller.pp index 13b7fc2..c20f4e9 100644 --- a/deployment_scripts/puppet/modules/bcf/manifests/p_only/controller.pp +++ b/deployment_scripts/puppet/modules/bcf/manifests/p_only/controller.pp @@ -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/*", diff --git a/deployment_tasks.yaml b/deployment_tasks.yaml index 3e642c5..5bd8349 100644 --- a/deployment_tasks.yaml +++ b/deployment_tasks.yaml @@ -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]