Graph-based upgrade approach. Added puppet module.

Part 1. Change implements upgrade-db with Fuel graphs.

  - Added puppet module "octane_tasks".
  - Graph files located in octane_tasks/graphs.
  - Changed rpm spec

Co-Authored-By: Pavel Chechetin <pchechetin@mirantis.com>
Change-Id: I1df0c8b28953c428e90b885c0ec63a1acb1a7476
This commit is contained in:
Roman Sokolkov 2016-08-11 16:13:13 +03:00
parent 65c637467a
commit 58871626aa
16 changed files with 444 additions and 0 deletions

View File

@ -66,3 +66,9 @@ maintainers:
- name: Igor Yozhikov
email: iyozhikov@mirantis.com
IRC: IgorYozhikov
- deployment/:
- name: Roman Sokolkov
email: rsokolkov@mirantis.com
- name: Pavel Chechetin
email: pchechetin@mirantis.com

View File

@ -0,0 +1,16 @@
source 'https://rubygems.org'
group :development, :test do
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint'
gem 'rake'
gem 'rspec-puppet'
end
if puppetversion = ENV['PUPPET_GEM_VERSION']
gem 'puppet', puppetversion, :require => false
else
gem 'puppet', :require => false
end
# vim:ft=ruby

View File

@ -0,0 +1,13 @@
require 'rspec-puppet/rake_task'
begin
if Gem::Specification::find_by_name('puppet-lint')
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"]
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_variable_scope')
task :default => [:rspec, :lint]
end
rescue Gem::LoadError
task :default => :rspec
end

View File

@ -0,0 +1,22 @@
# GROUPS
- id: primary-controller
type: group
role: [primary-controller]
fault_tolerance: 0
- id: controller
type: group
role: [controller]
fault_tolerance: 0
# TASKS
# TODO: Improve with https://review.openstack.org/#/c/342959/
- id: start_haproxy
type: shell
version: 2.1.0
groups: [primary-controller]
requires: []
required_for: []
parameters:
cmd: pcs resource enable clone_p_haproxy
timeout: 180

View File

@ -0,0 +1,51 @@
# GROUPS
- id: primary-controller
type: group
role: [primary-controller]
fault_tolerance: 0
- id: controller
type: group
role: [controller]
fault_tolerance: 0
# TASKS
# TODO: Improve with https://review.openstack.org/#/c/342959/
- id: stop_haproxy
type: shell
version: 2.1.0
groups: [primary-controller]
requires: []
required_for: []
parameters:
cmd: pcs resource disable clone_p_haproxy
timeout: 180
# TODO: Rewrite in puppet and get databases list dynamically
- id: mysqldump_create
type: shell
version: 2.1.0
groups: [primary-controller]
requires: [stop_haproxy]
required_for: []
parameters:
cmd: >
mysqldump
--defaults-file=/root/.my.cnf
--host localhost
--add-drop-database
--lock-all-tables
--databases nova keystone heat neutron cinder glance |
gzip > /var/tmp/dbs.original.sql.gz
timeout: 180
- id: mysqldump_upload_to_master
type: sync
version: 2.1.0
groups: [primary-controller]
requires: [mysqldump_create]
required_for: []
parameters:
src: /var/tmp/dbs.original.sql.gz
dst: rsync://{MASTER_IP}:/octane/tmp/
timeout: 180

View File

@ -0,0 +1,78 @@
# GROUPS
- id: primary-controller
type: group
role: [primary-controller]
fault_tolerance: 0
- id: controller
type: group
role: [controller]
fault_tolerance: 0
# TASKS
- id: rsync_octane
type: sync
version: 2.1.0
groups: [primary-controller, controller]
requires: []
required_for: []
parameters:
src: rsync://{MASTER_IP}:/octane/puppet
dst: /etc/fuel/octane/
timeout: 180
- id: delete_fuel_resources
type: shell
version: 2.1.0
groups: [primary-controller]
requires: [rsync_octane]
required_for: []
parameters:
cmd: >
. /root/openrc;
cd /etc/fuel/octane/puppet/octane_tasks/misc/;
python delete_fuel_resources.py
timeout: 180
- id: stop_controller_services
type: puppet
version: 2.1.0
groups: [primary-controller, controller]
requires: [delete_fuel_resources]
required_for: []
parameters:
puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/stop_controller_services.pp
puppet_modules: /etc/fuel/octane/puppet:/etc/puppet/modules
timeout: 360
- id: mysqldump_download_from_master
type: sync
version: 2.0.0
groups: [primary-controller]
requires: []
required_for: []
parameters:
src: rsync://{MASTER_IP}:/octane/tmp/dbs.original.sql.gz
dst: /var/tmp
timeout: 180
- id: mysqldump_restore
type: shell
version: 2.1.0
groups: [primary-controller]
requires: [mysqldump_download_from_master, stop_controller_services]
required_for: []
parameters:
cmd: zcat /var/tmp/dbs.original.sql.gz | mysql --defaults-file=/root/.my.cnf
timeout: 180
- id: db_sync
type: puppet
version: 2.1.0
groups: [primary-controller]
requires: [mysqldump_restore]
required_for: []
parameters:
puppet_manifest: /etc/fuel/octane/puppet/octane_tasks/modular/db_sync.pp
puppet_modules: /etc/fuel/octane/puppet:/etc/puppet/modules
timeout: 360

View File

@ -0,0 +1,26 @@
# == Class: octane_tasks::dbsync
#
# This class is for applying latest database migrations
#
class octane_tasks::dbsync (
) inherits octane_tasks::params {
include ::nova::db::sync
include ::glance::db::sync
include ::neutron::db::sync
include ::cinder::db::sync
include ::heat::db::sync
if $murano_enabled {
include ::murano::db::sync
}
if $sahara_enabled {
include ::sahara::db::sync
}
# All db sync classes have "refreshonly => true" by default
Exec <||> {
refreshonly => false
}
}

View File

@ -0,0 +1,42 @@
# == Class: octane_tasks::maintenance
#
# This class is for managing OpenStack services on MOS controllers
#
class octane_tasks::maintenance (
$ensure_cluster_services = nil,
$ensure_init_services = nil,
$cluster_services_list = $octane_tasks::params::cluster_services_list,
$init_services_list = $octane_tasks::params::init_services_list,
) inherits octane_tasks::params {
# Manage init services
case $ensure_init_services {
'running', 'stopped', true, false: {
ensure_resource(
'service',
$init_services_list,
{'ensure' => $ensure_init_services}
)
}
default: {
notice("\$ensure_init_services is set to ${ensure_init_services}, skipping")
}
}
# Manage cluster services
case $ensure_cluster_services {
'running', 'stopped', true, false: {
ensure_resource(
'service',
$cluster_services_list,
{'ensure' => $ensure_cluster_services, provider => 'pacemaker'}
)
}
default: {
notice("\$ensure_cluster_services is set to ${ensure_cluster_services}, skipping")
}
}
}

View File

@ -0,0 +1,99 @@
# == Class: octane_tasks::params
#
# This class contains paramaters for octane_tasks
#
class octane_tasks::params (
) {
$ceilometer_hash = hiera_hash('ceilometer', {'enabled' => false})
$sahara_hash = hiera_hash('sahara', {'enabled' => false})
$murano_hash = hiera_hash('murano', {'enabled' => false})
$storage_hash = hiera_hash('storage', {})
$fuel_version = hiera('fuel_version', '9.0')
$ceilometer_enabled = $ceilometer_hash['enabled']
$sahara_enabled = $sahara_hash['enabled']
$murano_enabled = $murano_hash['enabled']
$cinder_vol_on_ctrl = $storage_hash['volumes_ceph']
# Nova
$nova_services_list = [
'nova-api',
'nova-cert',
'nova-consoleauth',
'nova-conductor',
'nova-scheduler',
'nova-novncproxy',
]
# Glance
if $fuel_version >= '9.0' {
$glance_services_list = ['glance-registry', 'glance-api', 'glance-glare']
} else {
$glance_services_list = ['glance-registry', 'glance-api']
}
# Neutron
$neutron_services_list = [
'neutron-server',
]
# Cinder
if $cinder_vol_on_ctrl {
$cinder_services_list = [
'cinder-api',
'cinder-scheduler',
'cinder-volume',
'cinder-backup'
]
} else {
$cinder_services_list = [
'cinder-api',
'cinder-scheduler'
]
}
# Heat
$heat_services_list = [
'heat-api',
'heat-api-cloudwatch',
'heat-api-cfn',
]
# Murano
if $murano_enabled {
$murano_services_list = ['murano-api', 'murano-engine']
} else {
$murano_services_list = []
}
# Sahara
if $sahara_enabled {
$sahara_services_list = ['sahara-all']
} else {
$sahara_services_list = []
}
# Pacemaker services
$cluster_services_list = [
'neutron-openvswitch-agent',
'neutron-l3-agent',
'neutron-metadata-agent',
'neutron-dhcp-agent',
'p_heat-engine',
]
# Concatenate init services
$init_services_list = concat(
$nova_services_list,
$glance_services_list,
$neutron_services_list,
$cinder_services_list,
$heat_services_list,
$murano_services_list,
$sahara_services_list
)
# NOTE: Swift is not supported by Octane
}

View File

@ -0,0 +1,76 @@
# 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.
import glanceclient.client
import keystoneclient.client as ksclient
import neutronclient.neutron.client
def _get_keystone(username, password, tenant_name, auth_url):
klient = ksclient.Client(auth_url=auth_url)
klient.authenticate(
username=username,
password=password,
tenant_name=tenant_name)
return klient
def _get_glance(version=2, endpoint=None, token=None):
return glanceclient.client.Client(version, endpoint=endpoint,
token=token)
def _get_neutron(version='2.0', token=None, endpoint_url=None):
return neutronclient.neutron.client.Client(version,
token=token,
endpoint_url=endpoint_url)
def clenup_resources(username, password, tenant_name, auth_url):
keystone = _get_keystone(username, password, tenant_name, auth_url)
glance_endpoint = keystone.service_catalog.url_for(
service_type='image',
endpoint_type='publicURL')
glance = _get_glance(endpoint=glance_endpoint, token=keystone.auth_token)
neutron_endpoint = keystone.service_catalog.url_for(
service_type='network',
endpoint_type='publicURL')
neutron = _get_neutron(token=keystone.auth_token,
endpoint_url=neutron_endpoint)
for image in glance.images.list():
glance.images.delete(image["id"])
for i in neutron.list_floatingips()["floatingips"]:
neutron.delete_floatingip(i["id"])
for router in neutron.list_routers()["routers"]:
neutron.remove_gateway_router(router['id'])
for j in neutron.list_subnets()["subnets"]:
try:
neutron.remove_interface_router(router['id'],
{"subnet_id": j["id"]})
except Exception:
pass
neutron.delete_subnet(j["id"])
neutron.delete_router(router['id'])
for network in neutron.list_networks()["networks"]:
neutron.delete_network(network["id"])
if __name__ == '__main__':
import os
clenup_resources(
os.environ["OS_USERNAME"],
os.environ["OS_PASSWORD"],
os.environ["OS_TENANT_NAME"],
os.environ["OS_AUTH_URL"],
)

View File

@ -0,0 +1,3 @@
notice('MODULAR: octane_tasks/db_sync.pp')
include ::octane_tasks::dbsync

View File

@ -0,0 +1,6 @@
notice('MODULAR: octane_tasks/stop_controller_services.pp')
class { 'octane_tasks::maintenance':
ensure_cluster_services => 'stopped',
ensure_init_services => 'stopped',
}

View File

@ -0,0 +1 @@
../../../../manifests

View File

@ -0,0 +1 @@
require 'rspec-puppet/spec_helper'

View File

@ -41,8 +41,12 @@ cd %{_builddir}/%{name}-%{version} && OSLO_PACKAGE_VERSION=%{version} %{__python
cd %{_builddir}/%{name}-%{version} && %{__python} setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=%{_builddir}/%{name}-%{version}/INSTALLED_FILES
cp -vr %{_builddir}/%{name}-%{version}/octane/patches ${RPM_BUILD_ROOT}/%{python2_sitelib}/octane/
mkdir -p ${RPM_BUILD_ROOT}/var/www/nailgun/octane
cp -vr %{_builddir}/%{name}-%{version}/deployment/puppet ${RPM_BUILD_ROOT}/var/www/nailgun/octane/puppet
%files -f %{_builddir}/%{name}-%{version}/INSTALLED_FILES
%{python2_sitelib}/octane/patches/*
/var/www/nailgun/octane/puppet/octane_tasks/*
%defattr(-,root,root)