Merge "Optimize Nova disk_cachemodes and hw_disk_discard options for RBD"
[apex-tripleo-heat-templates.git] / puppet / manifests / ringbuilder.pp
index 1897dcd..a623da2 100644 (file)
@@ -13,8 +13,6 @@
 # License for the specific language governing permissions and limitations
 # under the License.
 
-include tripleo::packages
-
 define add_devices(
   $swift_zones = '1'
 ){
@@ -37,44 +35,46 @@ define add_devices(
   $base = regsubst($name,'^r1.*-(.*)$','\1')
   $object = regsubst($base, '%PORT%', '6000')
   ring_object_device { $object:
-    zone        => '1',
-    weight      => 100,
+    zone   => '1',
+    weight => 100,
   }
   $container = regsubst($base, '%PORT%', '6001')
   ring_container_device { $container:
-    zone        => '1',
-    weight      => 100,
+    zone   => '1',
+    weight => 100,
   }
   $account = regsubst($base, '%PORT%', '6002')
   ring_account_device { $account:
-    zone        => '1',
-    weight      => 100,
+    zone   => '1',
+    weight => 100,
   }
 }
 
 class tripleo::ringbuilder (
   $swift_zones     = '1',
   $devices         = '',
-  $build_ring      = 'True',
+  $build_ring      = true,
   $part_power,
   $replicas,
   $min_part_hours,
 ) {
 
-  if str2bool(downcase("$build_ring")) {
+  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       => $replicas,
+      replicas       => min(count($device_array), $replicas),
       min_part_hours => $min_part_hours,
     } ->
 
     # add all other devices
     add_devices {$device_array:
-      swift_zones => $swift_zones
+      swift_zones => $swift_zones,
     } ->
 
     # rebalance
@@ -89,6 +89,6 @@ class tripleo::ringbuilder (
   }
 }
 
-include ::tripleo::ringbuilder
-
-package_manifest{'/var/lib/tripleo/installed-packages/ringbuilder': ensure => present}
+if hiera('step') >= 3 {
+  include ::tripleo::ringbuilder
+}