rubocop 2
This commit is contained in:
13
.rubocop.yml
13
.rubocop.yml
@@ -1,5 +1,16 @@
|
||||
AllCops:
|
||||
Excludes:
|
||||
- vendor/**
|
||||
|
||||
AlignParameters:
|
||||
Enabled: false
|
||||
Encoding:
|
||||
Enabled: false
|
||||
HashSyntax:
|
||||
Enabled: false
|
||||
StringLiterals:
|
||||
Enabled: false
|
||||
|
||||
LineLength:
|
||||
Enabled: false
|
||||
MethodLength:
|
||||
Max: 30
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
default["ceph"]["radosgw"]["api_fqdn"] = "localhost"
|
||||
default["ceph"]["radosgw"]["admin_email"] = "admin@example.com"
|
||||
default["ceph"]["radosgw"]["rgw_addr"] = "*:80"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'ipaddr'
|
||||
require 'json'
|
||||
|
||||
def is_crowbar?()
|
||||
return defined?(Chef::Recipe::Barclamp) != nil
|
||||
def is_crowbar?
|
||||
!defined?(Chef::Recipe::Barclamp).nil?
|
||||
end
|
||||
|
||||
def get_mon_nodes(extra_search=nil)
|
||||
@@ -16,11 +16,10 @@ def get_mon_nodes(extra_search=nil)
|
||||
search_string = "role:ceph-mon AND chef_environment:#{node.chef_environment}"
|
||||
end
|
||||
|
||||
if not extra_search.nil?
|
||||
unless extra_search.nil?
|
||||
search_string = "(#{search_string}) AND (#{extra_search})"
|
||||
end
|
||||
mons = search(:node, search_string)
|
||||
return mons
|
||||
search(:node, search_string)
|
||||
end
|
||||
|
||||
# If public_network is specified
|
||||
@@ -64,21 +63,19 @@ def find_node_ip_in_network(network, nodeish=nil)
|
||||
nil
|
||||
end
|
||||
|
||||
def get_mon_addresses()
|
||||
def get_mon_addresses
|
||||
mon_ips = []
|
||||
|
||||
if File.exists?("/var/run/ceph/ceph-mon.#{node['hostname']}.asok")
|
||||
mon_ips = get_quorum_members_ips()
|
||||
mon_ips = get_quorum_members_ips
|
||||
else
|
||||
mons = []
|
||||
# make sure if this node runs ceph-mon, it's always included even if
|
||||
# search is laggy; put it first in the hopes that clients will talk
|
||||
# primarily to local node
|
||||
if node['roles'].include? 'ceph-mon'
|
||||
mons << node
|
||||
end
|
||||
mons << node if node['roles'].include?('ceph-mon')
|
||||
|
||||
mons += get_mon_nodes()
|
||||
mons += get_mon_nodes
|
||||
if is_crowbar?
|
||||
mon_ips = mons.map { |node| Chef::Recipe::Barclamp::Inventory.get_network_by_type(node, "admin").address }
|
||||
else
|
||||
@@ -89,24 +86,24 @@ def get_mon_addresses()
|
||||
end
|
||||
end
|
||||
end
|
||||
mon_ips = mon_ips.reject{|m|m.nil?}
|
||||
return mon_ips.uniq
|
||||
mon_ips.reject { |m| m.nil? }.uniq
|
||||
end
|
||||
|
||||
def get_quorum_members_ips()
|
||||
def get_quorum_members_ips
|
||||
mon_ips = []
|
||||
mon_status = %x[ceph --admin-daemon /var/run/ceph/ceph-mon.#{node['hostname']}.asok mon_status]
|
||||
raise 'getting quorum members failed' unless $?.exitstatus == 0
|
||||
cmd = Mixlib::ShellOut.new("ceph --admin-daemon /var/run/ceph/ceph-mon.#{node['hostname']}.asok mon_status")
|
||||
cmd.run_command
|
||||
cmd.error!
|
||||
|
||||
mons = JSON.parse(mon_status)['monmap']['mons']
|
||||
mons = JSON.parse(cmd.stdout)['monmap']['mons']
|
||||
mons.each do |k|
|
||||
mon_ips.push(k['addr'][0..-3])
|
||||
end
|
||||
return mon_ips
|
||||
mon_ips
|
||||
end
|
||||
|
||||
QUORUM_STATES = ['leader', 'peon']
|
||||
def have_quorum?()
|
||||
QUORUM_STATES = %w(leader, peon)
|
||||
def have_quorum?
|
||||
# "ceph auth get-or-create-key" would hang if the monitor wasn't
|
||||
# in quorum yet, which is highly likely on the first run. This
|
||||
# helper lets us delay the key generation into the next
|
||||
@@ -116,8 +113,11 @@ def have_quorum?()
|
||||
# in the ceph tool, this exits immediately if the ceph-mon is not
|
||||
# running for any reason; trying to connect via TCP/IP would wait
|
||||
# for a relatively long timeout.
|
||||
mon_status = %x[ceph --admin-daemon /var/run/ceph/ceph-mon.#{node['hostname']}.asok mon_status]
|
||||
raise 'getting monitor state failed' unless $?.exitstatus == 0
|
||||
state = JSON.parse(mon_status)['state']
|
||||
return QUORUM_STATES.include?(state)
|
||||
|
||||
cmd = Mixlib::ShellOut.new("ceph --admin-daemon /var/run/ceph/ceph-mon.#{node['hostname']}.asok mon_status")
|
||||
cmd.run_command
|
||||
cmd.error!
|
||||
|
||||
state = JSON.parse(cmd.stdout)['state']
|
||||
QUORUM_STATES.include?(state)
|
||||
end
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
include_recipe "apt"
|
||||
|
||||
branch = node['ceph']['branch']
|
||||
|
||||
@@ -59,11 +59,11 @@ else
|
||||
# TODO: cluster name
|
||||
cluster = 'ceph'
|
||||
|
||||
osd_secret = if node['ceph']['encrypted_data_bags']
|
||||
if node['ceph']['encrypted_data_bags']
|
||||
secret = Chef::EncryptedDataBagItem.load_secret(node["ceph"]["osd"]["secret_file"])
|
||||
Chef::EncryptedDataBagItem.load("ceph", "osd", secret)["secret"]
|
||||
osd_secret = Chef::EncryptedDataBagItem.load("ceph", "osd", secret)["secret"]
|
||||
else
|
||||
mons[0]["ceph"]["bootstrap_osd_key"]
|
||||
osd_secret = mons[0]["ceph"]["bootstrap_osd_key"]
|
||||
end
|
||||
|
||||
execute "format as keyring" do
|
||||
|
||||
Reference in New Issue
Block a user