This moves the ringbuilder puppet code to puppet-tripleo and migrates to the composable services format. Closes-Bug: #1601857 Change-Id: I0ea2230072d3ff61a4047ffff1f4187951370f67 Depends-On: I427f0b5ee93a0870d43419009178e0690ac66bd6changes/51/338551/6
parent
393db0231f
commit
1f1489b635
@ -1,99 +0,0 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
define add_devices(
|
||||
$swift_zones = '1'
|
||||
){
|
||||
|
||||
# NOTE(dprince): Swift zones is not yet properly wired into the Heat
|
||||
# templates. See: https://review.openstack.org/#/c/97758/3
|
||||
# For now our regex supports the r1z1-192.0.2.6:%PORT%/d1 syntax or the
|
||||
# newer r1z%<controller or SwiftStorage><N>%-192.0.2.6:%PORT%/d1 syntax.
|
||||
$server_num_or_device = regsubst($name,'^r1z%+[A-Za-z]*([0-9]+)%+-(.*)$','\1')
|
||||
if (is_integer($server_num_or_device)) {
|
||||
$server_num = $server_num_or_device
|
||||
} else {
|
||||
$server_num = '1'
|
||||
}
|
||||
# Function to place server in its zone. Zone is calculated by
|
||||
# server number in heat template modulo the number of zones + 1.
|
||||
$zone = (($server_num%$swift_zones) + 1)
|
||||
|
||||
# add the rings
|
||||
$base = regsubst($name,'^r1.*-(.*)$','\1')
|
||||
$object = regsubst($base, '%PORT%', '6000')
|
||||
ring_object_device { $object:
|
||||
zone => '1',
|
||||
weight => 100,
|
||||
}
|
||||
$container = regsubst($base, '%PORT%', '6001')
|
||||
ring_container_device { $container:
|
||||
zone => '1',
|
||||
weight => 100,
|
||||
}
|
||||
$account = regsubst($base, '%PORT%', '6002')
|
||||
ring_account_device { $account:
|
||||
zone => '1',
|
||||
weight => 100,
|
||||
}
|
||||
}
|
||||
|
||||
class tripleo::ringbuilder (
|
||||
$swift_zones = '1',
|
||||
$devices = '',
|
||||
$build_ring = true,
|
||||
$part_power,
|
||||
$replicas,
|
||||
$min_part_hours,
|
||||
) {
|
||||
|
||||
validate_bool($build_ring)
|
||||
|
||||
if $build_ring {
|
||||
|
||||
$device_array = strip(split(rstrip($devices), ','))
|
||||
|
||||
# create local rings
|
||||
swift::ringbuilder::create{ ['object', 'account', 'container']:
|
||||
part_power => $part_power,
|
||||
replicas => min(count($device_array), $replicas),
|
||||
min_part_hours => $min_part_hours,
|
||||
} ->
|
||||
|
||||
# add all other devices
|
||||
add_devices {$device_array:
|
||||
swift_zones => $swift_zones,
|
||||
} ->
|
||||
|
||||
# rebalance
|
||||
swift::ringbuilder::rebalance{ ['object', 'account', 'container']:
|
||||
seed => 999,
|
||||
}
|
||||
|
||||
Ring_object_device<| |> ~> Exec['rebalance_object']
|
||||
Ring_object_device<| |> ~> Exec['rebalance_account']
|
||||
Ring_object_device<| |> ~> Exec['rebalance_container']
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if hiera('step') >= 2 {
|
||||
# pre-install swift here so we can build rings
|
||||
include ::swift
|
||||
}
|
||||
|
||||
if hiera('step') >= 3 {
|
||||
include ::tripleo::ringbuilder
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
heat_template_version: 2016-04-08
|
||||
|
||||
description: >
|
||||
OpenStack Swift Ringbuilder
|
||||
|
||||
parameters:
|
||||
EndpointMap:
|
||||
default: {}
|
||||
description: Mapping of service endpoint -> protocol. Typically set
|
||||
via parameter_defaults in the resource registry.
|
||||
type: json
|
||||
SwiftMinPartHours:
|
||||
type: number
|
||||
default: 1
|
||||
description: The minimum time (in hours) before a partition in a ring can be moved following a rebalance.
|
||||
SwiftPartPower:
|
||||
default: 10
|
||||
description: Partition Power to use when building Swift rings
|
||||
type: number
|
||||
SwiftRingBuild:
|
||||
default: true
|
||||
description: Whether to manage Swift rings or not
|
||||
type: boolean
|
||||
SwiftReplicas:
|
||||
type: number
|
||||
default: 3
|
||||
description: How many replicas to use in the swift rings.
|
||||
|
||||
outputs:
|
||||
role_data:
|
||||
description: Role data for Swift Ringbuilder configuration.
|
||||
value:
|
||||
service_name: swift-ringbuilder
|
||||
config_settings:
|
||||
tripleo::profile::base::swift::ringbuilder::build_ring: {get_param: SwiftRingBuild}
|
||||
tripleo::profile::base::swift::ringbuilder::replicas: {get_param: SwiftReplicas}
|
||||
swift::ringbuilder::part_power: {get_param: SwiftPartPower}
|
||||
swift::ringbuilder::min_part_hours: {get_param: SwiftMinPartHours}
|
||||
step_config: |
|
||||
include ::tripleo::profile::base::swift::ringbuilder
|
Loading…
Reference in new issue