ceph-crush-location 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 97aad1320dfffe37fb0c8312741aaab5f4b75994
4
- data.tar.gz: cc35cdba6f0cdafc589d5e49deede2084722faad
3
+ metadata.gz: 8552b18a67fcc67b703bf323699962715fabf08e
4
+ data.tar.gz: 8ec2a6495a3218f7933845d7cafd668b1941be44
5
5
  SHA512:
6
- metadata.gz: 8eec69aa68257f42e9257378374d2b39fa8222d0308280d1e249598bec49abd72e86036ad399eee874ae1d350200906c042c6aa3eabc995acc346f5057246cd8
7
- data.tar.gz: bcf5016a248eba7ccbb2b0650686c761c364f31b379271d23d646eb938e6d331750fe1910e499b2d9aa1f1f8ad42dd814f30e5b3971f6aaf11acc1cba3d88ff6
6
+ metadata.gz: ea17ab665aed4c2d00b012305deb48b8967d8012aba35d956a672139f6ddf5fdd0bb8541aa4eacc81ecc95d6ca3184ccfa1c070dac636b75284143f0c25fa793
7
+ data.tar.gz: 7b3973deeef8835ef4e068cb8a6637d4886b824b52a6d66066885439e2d887c1ce5f87a50a2d3b68fa195073e05d1ab77bb00a6e42b501221cd9794a71bfd01e
data/README.md CHANGED
@@ -36,6 +36,8 @@ the json file can take the following format
36
36
 
37
37
  Should this file not be available from this location, you can specify the location using `ENV['NODE_INFO']`
38
38
 
39
+ Should this file be missing, or if it is corrupted, it will behave as if it was not there and behave as with the defaults
40
+
39
41
  Beyond that there are three lower types provided which are derived as follows:
40
42
  root # Crush root, either default, or read from /path/to/osd/crush_root
41
43
  disk_chassis # JBOD level of redundancy read from /path/to/osd/disk_chassis
@@ -55,6 +57,12 @@ Your crush ruleset will require the following types to use this gem:
55
57
  type 6 row
56
58
  type 7 datacenter
57
59
  type 8 root
60
+
61
+ ### Config crush_location
62
+
63
+ For any daemon, ceph optionally provides a `crush_location` option that can be set in the cluster configuration file on the host this script is invoked. Providing this for will override the operation of this script and return that value instead.
64
+ ie setting it for [osd] will override all OSDSs on this host, setting it for [osd.N] will override for that osd only.
65
+
58
66
  ## Development
59
67
 
60
68
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -8,8 +8,23 @@ module Ceph
8
8
  @osd = OSD.new
9
9
  end
10
10
 
11
+ def from_config
12
+ require 'shellwords'
13
+ ceph_conf_bin = '/usr/bin/ceph-conf'
14
+ cluster = ::Shellwords.escape @osd.cluster
15
+ type = 'osd'
16
+ id = ::Shellwords.escape @osd.id
17
+ location_command = "#{ceph_conf_bin} --cluster=#{cluster} "\
18
+ "--name=#{type}.#{id} --lookup crush_location"
19
+ `#{location_command}`
20
+ rescue
21
+ ''
22
+ end
23
+
11
24
  def to_s
12
25
  Ceph::Crush::Location::Logger.send('Bucket.to_s')
26
+ ceph_location_config = from_config
27
+ return ceph_location_config unless ceph_location_config == ''
13
28
  [root_bucket, datacenter_bucket,
14
29
  row_bucket, rack_bucket, chassis_bucket,
15
30
  host_bucket, disk_chassis_bucket, enclosure_bucket].join('')
@@ -9,6 +9,8 @@ module Ceph
9
9
  Ceph::Crush::Location.nodeinfo = JSON.parse(
10
10
  ::File.read(Ceph::Crush::Location.options[:nodeinfo])
11
11
  )
12
+ rescue
13
+ Ceph::Crush::Location.nodeinfo = {}
12
14
  end
13
15
  end
14
16
  end
@@ -14,6 +14,7 @@ module Ceph
14
14
  def parse!
15
15
  ::Ceph::Crush::Location::Logger.send('parsing attributes')
16
16
  ::Ceph::Crush::Location.options = {}
17
+ ::Ceph::Crush::Location.options[:cluster] = 'ceph'
17
18
  grab!
18
19
  validate!
19
20
  default_env
@@ -36,7 +37,7 @@ module Ceph
36
37
  end
37
38
 
38
39
  def report(e)
39
- ::Ceph::Crush::Location::Logger.send(e, Logger::ERROR)
40
+ ::Ceph::Crush::Location::Logger.send(e, ::Logger::ERROR)
40
41
  STDERR.puts "#{$PROGRAM_NAME}: #{e}"
41
42
  exit(-1)
42
43
  end
@@ -50,7 +51,7 @@ module Ceph
50
51
 
51
52
  def options(opts)
52
53
  Ceph::Crush::Location::Logger.send('Options::Parser.options')
53
- opts.on('-c', '--cluster CLUSTER', 'Specify Cluster Name') do |c|
54
+ opts.on('-c', '--cluster [CLUSTER]', 'Specify Cluster') do |c|
54
55
  ::Ceph::Crush::Location.options[:cluster] = c
55
56
  end
56
57
 
@@ -90,9 +91,6 @@ module Ceph
90
91
 
91
92
  def validate!
92
93
  Ceph::Crush::Location::Logger.send('Options::Parser.validate!')
93
- ::Ceph::Crush::Location.options.fetch(:cluster) do
94
- raise OptionParser::MissingArgument, 'no \'cluster\' provided'
95
- end
96
94
  ::Ceph::Crush::Location.options.fetch(:id) do
97
95
  raise OptionParser::MissingArgument, 'no \'id\' provided'
98
96
  end
@@ -1,7 +1,7 @@
1
1
  module Ceph
2
2
  module Crush
3
3
  module Location
4
- VERSION = '0.1.2'.freeze
4
+ VERSION = '0.1.4'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ceph-crush-location
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Harland
@@ -98,7 +98,7 @@ description:
98
98
  email:
99
99
  - s.harland@livelinktechnology.net
100
100
  executables:
101
- - crush-location.rb
101
+ - ceph-crush-location.rb
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
@@ -112,7 +112,7 @@ files:
112
112
  - bin/console
113
113
  - bin/setup
114
114
  - ceph-crush-location.gemspec
115
- - exe/crush-location.rb
115
+ - exe/ceph-crush-location.rb
116
116
  - lib/ceph/crush/location.rb
117
117
  - lib/ceph/crush/location/bucket.rb
118
118
  - lib/ceph/crush/location/logger.rb