Merge "Remove cells v1 code"

This commit is contained in:
Zuul 2019-05-02 21:27:29 +00:00 committed by Gerrit Code Review
commit efafd9b395
8 changed files with 5 additions and 706 deletions

View File

@ -1,92 +0,0 @@
#
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
# Francois Charlier <francois.charlier@enovance.com>
#
# 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.
#
#
# nova_cells provider
#
# CELL v1 IS DEPRECATED AND WILL BE REMOVED
#
require File.join(File.dirname(__FILE__), '..','..','..', 'puppet/provider/nova')
Puppet::Type.type(:nova_cells).provide(
:nova_manage,
:parent => Puppet::Provider::Nova
) do
desc "Manage nova cells"
def self.instances
begin
cells_list = nova_manage_request("cell", "list")
rescue Exception => e
if e.message =~ /No cells defined/
return []
else
raise(e)
end
end
cells_list.split("\n")[1..-1].collect do |net|
if net =~ /^(\S+)\s+(\S+)/
new(:name => $2 )
end
end.compact
end
def create
optional_opts = []
{
:name => '--name',
:cell_type => '--cell_type',
:rabbit_username => '--username',
:rabbit_password => '--password',
:rabbit_hosts => '--hostname',
:rabbit_port => '--port',
:rabbit_virtual_host => '--virtual_host',
:weight_offset => '--woffset',
:weight_scale => '--wscale'
}.each do |param, opt|
if resource[param]
optional_opts.push(opt).push(resource[param])
end
end
nova_manage_request('cell', 'create',
optional_opts
)
end
def exists?
begin
cells_list = nova_manage_request("cell", "list")
return cells_list.split("\n")[1..-1].detect do |n|
n =~ /^(\S+)\s+(#{resource[:cells].split('/').first})/
end
rescue
return false
end
end
def destroy
nova_manage_request("cell", "delete", resource[:name])
end
end

View File

@ -1,117 +0,0 @@
#
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
# Francois Charlier <francois.charlier@enovance.com>
#
# 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.
#
#
# nova_cells type
#
# CELL v1 IS DEPRECATED AND WILL BE REMOVED
#
# == Parameters
# [*name*]
# Name for the new cell
# Optional
#
# [*cell_type*]
# Whether the cell is a 'parent' or 'child'
# Required
#
# [*rabbit_username*]
# Username for the message broker in this cell
# Optional
#
# [*rabbit_password*]
# Password for the message broker in this cell
# Optional
#
# [*rabbit_hosts*]
# Address of the message broker in this cell
# Optional
#
# [*rabbit_port*]
# Port number of the message broker in this cell
# Optional
#
# [*rabbit_virtual_host*]
# The virtual host of the message broker in this cell
# Optional
#
# [*weight_offset*]
# It might be used by some cell scheduling code in the future
# Optional
#
# [*weight_scale*]
# It might be used by some cell scheduling code in the future
# Optional
#
Puppet::Type.newtype(:nova_cells) do
@doc = "Manage creation/deletion of nova cells."
ensurable
newparam(:name) do
desc "Name for the new cell"
defaultto "api"
end
newparam(:cell_type) do
desc 'Whether the cell is a parent or child'
end
newparam(:rabbit_username) do
desc 'Username for the message broker in this cell'
defaultto "guest"
end
newparam(:rabbit_password) do
desc 'Password for the message broker in this cell'
defaultto "guest"
end
newparam(:rabbit_port) do
desc 'Port number for the message broker in this cell'
defaultto "5672"
end
newparam(:rabbit_hosts) do
desc 'Address of the message broker in this cell'
defaultto "localhost"
end
newparam(:rabbit_virtual_host) do
desc 'The virtual host of the message broker in this cell'
defaultto "/"
end
newparam(:weight_offset) do
desc 'It might be used by some cell scheduling code in the future'
defaultto "1.0"
end
newparam(:weight_scale) do
desc 'It might be used by some cell scheduling code in the future'
defaultto "1.0"
end
validate do
raise(Puppet::Error, 'Cell type must be set') unless self[:cell_type]
end
end

View File

@ -1,222 +0,0 @@
#
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
# Francois Charlier <francois.charlier@enovance.com>
#
# 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: nova::cells
#
# Installs the Nova Cells
#
# CELL v1 IS DEPRECATED AND THIS WILL BE REMOVED.
#
# === Parameters:
#
# [*enabled*]
# Use Nova Cells or not
# Defaults to true
#
# [*manage_service*]
# (optional) Whether to start/stop the service
# Defaults to true
#
# [*ensure_package*]
# Desired ensure state of packages.
# Defaults to present
#
# [*instance_updated_at_threshold*]
# Number of seconds after an instance was updated or deleted to continue to update cells
# Defaults to '3600'
#
# [*max_hop_count*]
# Maximum number of hops for cells routing
# Defaults to '10'
#
# [*scheduler*]
# Cells scheduler to use
# Defaults to 'nova.cells.scheduler.CellsScheduler'
#
# [*instance_update_num_instances*]
# Number of instances to update per periodic task run
# Defaults to '1'
#
# [*cell_name*]
# name of this cell
# Defaults to 'nova'
#
# [*cell_parent_name*]
# * If a child cell, this is the name of the 'parent' cell.
# * If a parent cell, should be left to undef.
#
# [*capabilities*]
# Key/Multi-value list with the capabilities of the cell
# Defaults to 'hypervisor=xenserver;kvm,os=linux;windows'
#
# [*call_timeout*]
# Seconds to wait for response from a call to a cell
# Defaults to '60'
#
# [*reserve_percent*]
# Percentage of cell capacity to hold in reserve. Affects both memory and disk utilization
# Defaults to '10.0'
#
# [*cell_type*]
# Type of cell: parent or child
# Defaults to 'None'
#
# [*mute_child_interval*]
# Number of seconds after which a lack of capability and
# capacity updates signals the child cell is to be treated as a mute
# Defaults to '300'
#
# [*bandwidth_update_interval*]
# Seconds between bandwidth updates for cells
# Defaults to '600'
#
# [*rpc_driver_queue_base*]
# Base queue name to use when communicating between cells
# Various topics by message type will be appended to this
# Defaults to 'cells.intercell'
#
# [*scheduler_filter_classes*]
# Filter classes the cells scheduler should use
# Defaults to 'nova.cells.filters.all_filters'
#
# [*scheduler_weight_classes*]
# Weigher classes the cells scheduler should use
# Defaults to 'nova.cells.weights.all_weighers'
#
# [*scheduler_retries*]
# How many retries when no cells are available
# Defaults to '10'
#
# [*scheduler_retry_delay*]
# How often to retry in seconds when no cells are available
# Defaults to '2'
#
# [*db_check_interval*]
# Seconds between getting fresh cell info from db
# Defaults to '60'
#
# [*mute_weight_multiplier*]
# Multiplier used to weigh mute children (The value should be negative)
# Defaults to '-10.0'
#
# [*mute_weight_value*]
# Weight value assigned to mute children (The value should be positive)
# Defaults to '1000.0'
#
# [*ram_weight_multiplier*]
# Multiplier used for weighing ram. Negative numbers mean to stack vs spread
# Defaults to '10.0'
#
# [*weight_offset*]
# It might be used by some cell scheduling code in the future
# Defaults to '1.0'
#
# [*weight_scale*]
# It might be used by some cell scheduling code in the future
# Defaults to '1.0'
#
#### DEPRECATED PARAMETERS
#
# [*create_cells*]
# Create cells with nova-manage
# Defaults to 'True'
#
class nova::cells (
$bandwidth_update_interval = '600',
$call_timeout = '60',
$capabilities = ['hypervisor=xenserver;kvm','os=linux;windows'],
$cell_name = 'nova',
$cell_type = undef,
$cell_parent_name = undef,
$db_check_interval = '60',
$enabled = true,
$ensure_package = 'present',
$instance_updated_at_threshold = '3600',
$instance_update_num_instances = '1',
$manage_service = true,
$max_hop_count = '10',
$mute_child_interval = '300',
$mute_weight_multiplier = '-10.0',
$mute_weight_value = '1000.0',
$ram_weight_multiplier = '10.0',
$reserve_percent = '10.0',
$rpc_driver_queue_base = 'cells.intercell',
$scheduler_filter_classes = 'nova.cells.filters.all_filters',
$scheduler = 'nova.cells.scheduler.CellsScheduler',
$scheduler_retries = '10',
$scheduler_retry_delay = '2',
$scheduler_weight_classes = 'nova.cells.weights.all_weighers',
$weight_offset = '1.0',
$weight_scale = '1.0',
## DEPRECATED PARAMETERS
$create_cells = undef,
) {
include ::nova::deps
include ::nova::params
warning('nova::cells v1 is deprecated and will be removed in a future release')
case $cell_type {
'parent': {
nova_config { 'DEFAULT/compute_api_class': value => 'nova.compute.cells_api.ComputeCellsAPI' }
nova_config { 'cells/cell_type': value => 'api' }
}
'child': {
nova_config { 'DEFAULT/quota_driver': value => 'nova.quota.NoopQuotaDriver' }
nova_config { 'cells/cell_type': value => 'compute' }
}
default: { fail("Unsupported cell_type parameter value: '${cell_type}'. Should be 'parent' or 'child'.") }
}
nova_config {
'cells/bandwidth_update_interval': value => $bandwidth_update_interval;
'cells/call_timeout': value => $call_timeout;
'cells/capabilities': value => join($capabilities, ',');
'cells/db_check_interval': value => $db_check_interval;
'cells/enable': value => $enabled;
'cells/instance_updated_at_threshold': value => $instance_updated_at_threshold;
'cells/instance_update_num_instances': value => $instance_update_num_instances;
'cells/max_hop_count': value => $max_hop_count;
'cells/mute_child_interval': value => $mute_child_interval;
'cells/mute_weight_multiplier': value => $mute_weight_multiplier;
'cells/mute_weight_value': value => $mute_weight_value;
'cells/name': value => $cell_name;
'cells/ram_weight_multiplier': value => $ram_weight_multiplier;
'cells/reserve_percent': value => $reserve_percent;
'cells/rpc_driver_queue_base': value => $rpc_driver_queue_base;
'cells/scheduler_filter_classes': value => $scheduler_filter_classes;
'cells/scheduler_retries': value => $scheduler_retries;
'cells/scheduler_retry_delay': value => $scheduler_retry_delay;
'cells/scheduler': value => $scheduler;
'cells/scheduler_weight_classes': value => $scheduler_weight_classes;
}
nova::generic_service { 'cells':
enabled => $enabled,
manage_service => $manage_service,
package_name => $::nova::params::cells_package_name,
service_name => $::nova::params::cells_service_name,
ensure_package => $ensure_package,
}
if $create_cells {
warning('cells v1 is deprecated and nova::cells::create_cells has no effect')
}
}

View File

@ -38,16 +38,9 @@ class nova::deps {
-> Package<| tag == 'nova-support-package'|>
-> Anchor['nova::install::end']
# TODO(aschultz): check if we can remove these as I think they are no longer
# valid since nova_cells is replaced by cell_v2 and the others are part of
# nova network
# The following resources are managed by calling 'nova manage' and so the
# database must be provisioned before they can be applied.
Anchor['nova::dbsync_api::end']
-> Nova_cells<||>
Anchor['nova::dbsync::end']
-> Nova_cells<||>
Anchor['nova::dbsync_api::end']
-> Nova_floating<||>
Anchor['nova::dbsync::end']
-> Nova_floating<||>

View File

@ -1,94 +0,0 @@
#
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
# Francois Charlier <francois.charlier@enovance.com>
#
# 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.
#
#
# Configuring the database in each cell
#
# CELL v1 IS DEPRECATED AND WILL BE REMOVED
#
# == Namevar
# The namevar will be the name of the cell
#
# == Parameters
# [*cell_type*]
# (optional) Whether the cell is a 'parent' or 'child'
# Defaults to 'parent'
#
# [*cell_parent_name*]
# (optional) If a child cell, this is the name of the 'parent' cell.
# If a parent cell, should be left to undef.
# Defaults to undef
#
# [*rabbit_username*]
# (optional) Username for the message broker in this cell
# Defaults to 'guest'
#
# [*rabbit_password*]
# (optional) Password for the message broker in this cell
# Defaults to 'guest'
#
# [*rabbit_hosts*]
# (optional) Address of the message broker in this cell
# Defaults to ['localhost']
#
# [*rabbit_port*]
# (optional) Port number of the message broker in this cell
# Defaults to '5672'
#
# [*rabbit_virtual_host*]
# (optional) The virtual host of the message broker in this cell
# Defaults to '/'
#
# [*weight_offset*]
# (optional) It might be used by some cell scheduling code in the future
# Defaults to '1.0'
#
# [*weight_scale*]
# (optional) It might be used by some cell scheduling code in the future
# Defaults to '1.0'
#
define nova::manage::cells (
$cell_type = 'parent',
$cell_parent_name = undef,
$rabbit_username = 'guest',
$rabbit_password = 'guest',
$rabbit_hosts = ['localhost'],
$rabbit_port = '5672',
$rabbit_virtual_host = '/',
$weight_offset = '1.0',
$weight_scale = '1.0'
) {
include ::nova::deps
warning('nova::cells v1 is deprecated and will be removed in a future release')
nova_cells { $name:
ensure => present,
cell_type => $cell_type,
cell_parent_name => $cell_parent_name,
rabbit_username => $rabbit_username,
rabbit_password => $rabbit_password,
rabbit_hosts => $rabbit_hosts,
rabbit_port => $rabbit_port,
rabbit_virtual_host => $rabbit_virtual_host,
weight_offset => $weight_offset,
weight_scale => $weight_scale
}
}

View File

@ -12,7 +12,6 @@ class nova::params {
'RedHat': {
# package names
$api_package_name = 'openstack-nova-api'
$cells_package_name = 'openstack-nova-cells'
$common_package_name = 'openstack-nova-common'
$python_package_name = "python${pyvers}-nova"
$compute_package_name = 'openstack-nova-compute'
@ -33,7 +32,6 @@ class nova::params {
$genisoimage_package_name = 'genisoimage'
# service names
$api_service_name = 'openstack-nova-api'
$cells_service_name = 'openstack-nova-cells'
$compute_service_name = 'openstack-nova-compute'
$conductor_service_name = 'openstack-nova-conductor'
$consoleauth_service_name = 'openstack-nova-consoleauth'
@ -79,7 +77,6 @@ class nova::params {
'Debian': {
# package names
$api_package_name = 'nova-api'
$cells_package_name = 'nova-cells'
$common_package_name = 'nova-common'
$python_package_name = "python${pyvers}-nova"
$compute_package_name = 'nova-compute'
@ -98,7 +95,6 @@ class nova::params {
$genisoimage_package_name = 'genisoimage'
# service names
$api_service_name = 'nova-api'
$cells_service_name = 'nova-cells'
$compute_service_name = 'nova-compute'
$conductor_service_name = 'nova-conductor'
$consoleauth_service_name = 'nova-consoleauth'

View File

@ -0,0 +1,5 @@
---
upgrade:
- |
The deprecated cells v1 classes nova::cells, nova::manage::cells and the
nova_cells resource is removed.

View File

@ -1,170 +0,0 @@
#
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
# Francois Charlier <francois.charlier@enovance.com>
#
# 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.
#
# Unit tests for nova::cells class
#
require 'spec_helper'
describe 'nova::cells' do
let :pre_condition do
"include nova"
end
let :default_params do
{:enabled => true,
:bandwidth_update_interval => '600',
:call_timeout => '60',
:capabilities => ['hypervisor=xenserver;kvm','os=linux;windows'],
:db_check_interval => '60',
:instance_updated_at_threshold => '3600',
:instance_update_num_instances => '1',
:max_hop_count => '10',
:mute_child_interval => '300',
:mute_weight_multiplier => '-10.0',
:mute_weight_value => '1000.0',
:ram_weight_multiplier => '10.0',
:reserve_percent => '10.0',
:rpc_driver_queue_base => 'cells.intercell',
:scheduler_filter_classes => 'nova.cells.filters.all_filters',
:scheduler => 'nova.cells.scheduler.CellsScheduler',
:scheduler_retries => '10',
:scheduler_retry_delay => '2',
:scheduler_weight_classes => 'nova.cells.weights.all_weighers',
:weight_offset => '1.0',
:weight_scale => '1.0'}
end
shared_examples_for 'nova-cells' do
it { is_expected.to contain_class('nova::params') }
it 'installs nova-cells package' do
is_expected.to contain_package('nova-cells').with(
:ensure => 'present',
:name => platform_params[:cells_package_name],
:tag => ['openstack', 'nova-package']
)
end
it 'configures nova-cells service' do
is_expected.to contain_service('nova-cells').with(
:ensure => 'running',
:name => platform_params[:cells_service_name],
:tag => 'nova-service'
)
end
it 'configures cell' do
is_expected.to contain_nova_config('cells/bandwidth_update_interval').with(:value => '600')
is_expected.to contain_nova_config('cells/call_timeout').with(:value => '60')
is_expected.to contain_nova_config('cells/capabilities').with(:value => 'hypervisor=xenserver;kvm,os=linux;windows')
is_expected.to contain_nova_config('cells/db_check_interval').with(:value => '60')
is_expected.to contain_nova_config('cells/instance_updated_at_threshold').with(:value => '3600')
is_expected.to contain_nova_config('cells/instance_update_num_instances').with(:value => '1')
is_expected.to contain_nova_config('cells/max_hop_count').with(:value => '10')
is_expected.to contain_nova_config('cells/mute_child_interval').with(:value => '300')
is_expected.to contain_nova_config('cells/mute_weight_multiplier').with(:value => '-10.0')
is_expected.to contain_nova_config('cells/mute_weight_value').with(:value => '1000.0')
is_expected.to contain_nova_config('cells/ram_weight_multiplier').with(:value => '10.0')
is_expected.to contain_nova_config('cells/reserve_percent').with(:value => '10.0')
is_expected.to contain_nova_config('cells/rpc_driver_queue_base').with(:value => 'cells.intercell')
is_expected.to contain_nova_config('cells/scheduler_filter_classes').with(:value => 'nova.cells.filters.all_filters')
is_expected.to contain_nova_config('cells/scheduler_retries').with(:value => '10')
is_expected.to contain_nova_config('cells/scheduler_retry_delay').with(:value => '2')
is_expected.to contain_nova_config('cells/scheduler_weight_classes').with(:value => 'nova.cells.weights.all_weighers')
is_expected.to contain_nova_config('cells/scheduler').with(:value => 'nova.cells.scheduler.CellsScheduler')
end
end
shared_examples_for 'a parent cell' do
let :params do
{ :enabled => true,
:cell_type => 'parent',
:cell_name => 'mommy' }
end
let :expected_params do
default_params.merge(params)
end
it { is_expected.to contain_nova_config('cells/name').with_value(expected_params[:cell_name]) }
it { is_expected.to contain_nova_config('DEFAULT/compute_api_class').with_value('nova.compute.cells_api.ComputeCellsAPI')}
it { is_expected.to contain_nova_config('cells/cell_type').with_value('api')}
it_configures 'nova-cells'
end
shared_examples_for 'a parent cell with manage_service as false' do
let :params do
{ :enabled => true,
:manage_service => false,
:cell_type => 'parent',
:cell_name => 'mommy' }
end
let :expected_params do
default_params.merge(params)
end
it { is_expected.to contain_service(platform_params[:cells_service_name]).without_ensure }
end
shared_examples_for 'a child cell' do
let :params do
{ :enabled => true,
:cell_type => 'child',
:cell_name => 'henry' }
end
let :expected_params do
default_params.merge(params)
end
it { is_expected.to contain_nova_config('cells/name').with_value(expected_params[:cell_name]) }
it { is_expected.to contain_nova_config('cells/cell_type').with_value('compute')}
it { is_expected.to contain_nova_config('DEFAULT/quota_driver').with_value('nova.quota.NoopQuotaDriver')}
it_configures 'nova-cells'
end
on_supported_os({
:supported_os => OSDefaults.get_supported_os
}).each do |os,facts|
context "on #{os}" do
let (:facts) do
facts.merge!(OSDefaults.get_facts())
end
case facts[:osfamily]
when 'Debian'
let (:platform_params) do
{
:cells_package_name => 'nova-cells',
:cells_service_name => 'nova-cells'
}
end
it_configures 'a parent cell with manage_service as false'
when 'RedHat'
let (:platform_params) do
{
:cells_package_name => 'openstack-nova-cells',
:cells_service_name => 'openstack-nova-cells'
}
end
end
it_configures 'a parent cell'
it_configures 'a child cell'
end
end
end