From f90ec1ad454c2617728c13f1808025ac232ee571 Mon Sep 17 00:00:00 2001 From: "Christopher H. Laco" Date: Mon, 3 Feb 2014 12:00:37 -0500 Subject: [PATCH] Update resources to be rubocop compliant - Update rubocop config to include resources/** - Update resources to comply with rubocop Change-Id: Ia86977b706c259e81f67dab1287b24bf6a975e35 Implements: blueprint rubocop-for-object-storage --- .rubocop.yml | 2 +- resources/disk.rb | 35 +++++++++---------- resources/mounts.rb | 74 +++++++++++++++++++--------------------- resources/ring_script.rb | 34 +++++++++--------- 4 files changed, 70 insertions(+), 75 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 17b48ac..b13bc6e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,9 +5,9 @@ AllCops: - attributes/** - providers/** - recipes/** + - resources/** Excludes: - libraries/** - - resources/** - spec/** Encoding: diff --git a/resources/disk.rb b/resources/disk.rb index ad9023f..1209fde 100644 --- a/resources/disk.rb +++ b/resources/disk.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Copyright 2011, Dell # @@ -16,18 +17,16 @@ # Author: andi abes # -=begin - Ensure that a disk's partition table matches expectations. - Sample use: - - openstack_object_storage_disk "/dev/sdb" do - part( - {[:type => "xfs", :size =>swift_disk::ONE_GIG*4 ], - [:type => "xfs", :size =>swift_disk::remaining}) - action :ensure_exists - end - -=end +# Ensure that a disk's partition table matches expectations. +# Sample use: +# +# openstack_object_storage_disk '/dev/sdb' do +# part([ +# { type: "xfs", size: swift_disk::ONE_GIG*4 }, +# { type: "xfs", size: swift_disk::remaining } +# ]) +# action :ensure_exists +# end actions :ensure_exists @@ -36,9 +35,9 @@ def initialize(*args) @action = :ensure_exists end -attribute :name, :kind_of => String -attribute :size, :kind_of => Integer -attribute :blocks, :kind_of => Integer -attribute :device, :kind_of => String -attribute :part, :kind_of => Array -attribute :status, :kind_of => Symbol +attribute :name, kind_of: String +attribute :size, kind_of: Integer +attribute :blocks, kind_of: Integer +attribute :device, kind_of: String +attribute :part, kind_of: Array +attribute :status, kind_of: Symbol diff --git a/resources/mounts.rb b/resources/mounts.rb index 9121ff6..8ec53f7 100644 --- a/resources/mounts.rb +++ b/resources/mounts.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Cookbook Name:: openstack-object-storage # Resource:: mounts @@ -19,43 +20,40 @@ # Author: Ron Pedde # -=begin - Ensure that swift mounts are strongly enforced. This - will ensure specified drives are mounted, and unspecified - drives are not mounted. In addition, if there is a stale - mountpoint (from disk failure, maybe?), then that mountpoint - will try to be unmounted +# Ensure that swift mounts are strongly enforced. This +# will ensure specified drives are mounted, and unspecified +# drives are not mounted. In addition, if there is a stale +# mountpoint (from disk failure, maybe?), then that mountpoint +# will try to be unmounted +# +# Sample use: +# +# openstack_object_storage_mounts '/srv/node' do +# devices [ 'sdb1', 'sdc1' ] +# action :ensure_exists +# ip '10.1.1.1' +# end - Sample use: +# It will force mounts based on fs uuid (mangled to remove +# dashes) and return a structure that describes the disks +# mounted. - openstack_object_storage_mounts "/srv/node" do - devices [ "sdb1", "sdc1" ] - action :ensure_exists - ip "10.1.1.1" - end +# As this is expected to be consumed for the purposes of +# swift, the ip address should be the address that gets +# embedded into the ring (i.e. the listen port of the storage server) - It will force mounts based on fs uuid (mangled to remove - dashes) and return a structure that describes the disks - mounted. +# Example return structure: - As this is expected to be consumed for the purposes of - swift, the ip address should be the address that gets - embedded into the ring (i.e. the listen port of the storage server) - - Example return structure: - - { "2a9452c5-d929-43d9-9631-4340ace45279": { - "device": "sdb1", - "ip": "10.1.1.1", - "mounted": "true", - "mountpoint": "2a9452c5d92943d996314340ace45279", - "size": 1022 (in 1k increments) - "uuid": "2a9452c5-d929-43d9-9631-4340ace45279" - }, - ... - } - -=end +# { '2a9452c5-d929-43d9-9631-4340ace45279': { +# 'device': 'sdb1', +# 'ip': '10.1.1.1', +# 'mounted': 'true', +# 'mountpoint': '2a9452c5d92943d996314340ace45279', +# 'size': 1022 (in 1k increments) +# 'uuid': '2a9452c5-d929-43d9-9631-4340ace45279' +# }, +# ... +# } actions :ensure_exists @@ -64,8 +62,8 @@ def initialize(*args) @action = :ensure_exists end -attribute :name, :kind_of => String -attribute :devices, :kind_of => Array -attribute :ip, :kind_of => String, :default => "127.0.0.1" -attribute :publish_attributes, :kind_of => String, :default => nil -attribute :format, :kind_of => String, :default => "xfs" +attribute :name, kind_of: String +attribute :devices, kind_of: Array +attribute :ip, kind_of: String, default: '127.0.0.1' +attribute :publish_attributes, kind_of: String, default: nil +attribute :format, kind_of: String, default: 'xfs' diff --git a/resources/ring_script.rb b/resources/ring_script.rb index 9a6ad30..66f2d81 100644 --- a/resources/ring_script.rb +++ b/resources/ring_script.rb @@ -1,3 +1,4 @@ +# encoding: UTF-8 # # Copyright 2012, Rackspace US, Inc. # @@ -16,19 +17,16 @@ # Author: Ron Pedde # -=begin - Build a proposed ring-building script - Sample use: - - openstack_object_storage_ring_script "/tmp/build-rings.sh" do - owner "root" - group "swift" - mode "0700" - ring_path "/etc/swift/ring-workspace" - action :ensure_exists - end - -=end +# Build a proposed ring-building script +# Sample use: +# +# openstack_object_storage_ring_script '/tmp/build-rings.sh' do +# owner 'root' +# group 'swift' +# mode '0700' +# ring_path '/etc/swift/ring-workspace' +# action :ensure_exists +# end actions :ensure_exists @@ -37,8 +35,8 @@ def initialize(*args) @action = :ensure_exists end -attribute :name, :kind_of => String -attribute :owner, :kind_of => String, :default => "root" -attribute :group, :kind_of => String, :default => "root" -attribute :mode, :kind_of => String, :default => "0600" -attribute :ring_path, :kind_of => String, :default => "/etc/swift" +attribute :name, kind_of: String +attribute :owner, kind_of: String, default: 'root' +attribute :group, kind_of: String, default: 'root' +attribute :mode, kind_of: String, default: '0600' +attribute :ring_path, kind_of: String, default: '/etc/swift'