aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Hardy <shardy@redhat.com>2016-09-02 09:09:58 +0100
committerJiri Stransky <jistr@redhat.com>2016-09-02 17:22:48 +0200
commit4b006b7c328ae9c5842f69044284948155da5fee (patch)
treeb49518e7130b2d1d327a484f5afb40f7c16db3ba
parentaaf9dc5b55742cc92fbc8e2e525db00fd7f93104 (diff)
Convert ringbuilder to build devices array
Currently we have some hard-coded mangling in t-h-t but we instead need to build the array based on the nodes running swift storage, combined with the SwiftRawDisks parameter. This will enable running SwiftStorage on nodes other than Controller and SwiftStorage roles, and is required for custom-roles due to the hard-coded stuff in the role templates and overcloud.yaml Change-Id: I11deed1df712ecccf85d36a75b3bd2e9d226af36 Partially-Implements: blueprint custom-roles
-rw-r--r--lib/puppet/parser/functions/tripleo_swift_devices.rb39
-rw-r--r--manifests/profile/base/swift/ringbuilder.pp30
2 files changed, 65 insertions, 4 deletions
diff --git a/lib/puppet/parser/functions/tripleo_swift_devices.rb b/lib/puppet/parser/functions/tripleo_swift_devices.rb
new file mode 100644
index 0000000..b320d62
--- /dev/null
+++ b/lib/puppet/parser/functions/tripleo_swift_devices.rb
@@ -0,0 +1,39 @@
+# Build Swift devices list from the parts, e.g. for:
+# raw_disk_prefix = 'r1z1-'
+# swift_storage_node_ips = ['192.168.1.12', '192.168.1.13']
+# raw_disks = [':%PORT%/device1', ':%PORT%/device2']
+#
+# devices will be ['r1z1-192.168.1.12:%PORT%/device1',
+# 'r1z1-192.168.1.12:%PORT%/device2'
+# 'r1z1-192.168.1.13:%PORT%/device1'
+# 'r1z1-192.168.1.13:%PORT%/device2']
+module Puppet::Parser::Functions
+ newfunction(:tripleo_swift_devices, :arity =>3, :type => :rvalue,
+ :doc => ("Build list of swift devices the TripleO way:" +
+ "from a raw disk prefix, a list of swift storage" +
+ "node IPs, and a list of raw disks.")) do |args|
+
+ raw_disk_prefix = args[0]
+ swift_node_ips = args[1]
+ raw_disks = args[2]
+
+ unless raw_disk_prefix.is_a?(String)
+ raise Puppet::ParseError, "tripleo_swift_devices: Argument 'raw_disk_prefix' must be a string. The value given was: #{raw_disk_prefix}"
+ end
+ unless swift_node_ips.is_a?(Array)
+ raise Puppet::ParseError, "tripleo_swift_devices: Argument 'swift_node_ips' must be an array. The value given was: #{swift_node_ips}"
+ end
+ unless raw_disks.is_a?(Array)
+ raise Puppet::ParseError, "tripleo_swift_devices: Argument 'raw_disks' must be an array. The value given was: #{raw_disks}"
+ end
+
+ devices = []
+ for ip in swift_node_ips do
+ for disk in raw_disks do
+ devices << "#{raw_disk_prefix}#{ip}#{disk}"
+ end
+ end
+
+ return devices
+ end
+end
diff --git a/manifests/profile/base/swift/ringbuilder.pp b/manifests/profile/base/swift/ringbuilder.pp
index e0f67cd..98a09a0 100644
--- a/manifests/profile/base/swift/ringbuilder.pp
+++ b/manifests/profile/base/swift/ringbuilder.pp
@@ -26,7 +26,8 @@
# Defaults to true
#
# [*devices*]
-# (Optional) The swift devices
+# (Optional) DEPRECATED The swift devices
+# Should pass raw_disk_prefix, raw_disks and swift_storage_node_ips instead
# Defaults to ''
#
# [*step*]
@@ -38,12 +39,30 @@
# (Optional) The swift zones
# Defaults to 1
#
+# [*raw_disk_prefix*]
+# (Optional) Disk prefix used to create devices list
+# Defaults to 'r1z1-'
+#
+# [*raw_disks*]
+# (Optional) list of raw disks in format
+# [':%PORT%/device1', ':%PORT%/device2']
+# Combined with raw_disk_prefix and swift_storage_node_ips
+# to create devices list
+# Defaults to an empty list
+#
+# [*swift_storage_node_ips*]
+# (Optional) list of ip addresses for nodes running swift_storage service
+# Defaults to hiera('swift_storage_node_ips') or an empty list
+#
class tripleo::profile::base::swift::ringbuilder (
$replicas,
$build_ring = true,
- $devices = '',
+ $devices = undef,
$step = hiera('step'),
$swift_zones = '1',
+ $raw_disk_prefix = 'r1z1-',
+ $raw_disks = [],
+ $swift_storage_node_ips = hiera('swift_storage_node_ips', []),
) {
if $step >= 2 {
# pre-install swift here so we can build rings
@@ -54,8 +73,11 @@ class tripleo::profile::base::swift::ringbuilder (
validate_bool($build_ring)
if $build_ring {
-
- $device_array = strip(split(rstrip($devices), ','))
+ if $devices {
+ $device_array = strip(split(rstrip($devices), ','))
+ } else {
+ $device_array = tripleo_swift_devices($raw_disk_prefix, $swift_storage_node_ips, $raw_disks)
+ }
# create local rings
swift::ringbuilder::create{ ['object', 'account', 'container']: