ceph-crush-location 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CONTRIBUTING.md +17 -0
- data/Gemfile +4 -0
- data/README.md +67 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ceph-crush-location.gemspec +27 -0
- data/exe/crush-location.rb +3 -0
- data/lib/ceph/crush/location.rb +20 -0
- data/lib/ceph/crush/location/bucket.rb +97 -0
- data/lib/ceph/crush/location/logger.rb +28 -0
- data/lib/ceph/crush/location/node_info/parser.rb +17 -0
- data/lib/ceph/crush/location/options/parser.rb +109 -0
- data/lib/ceph/crush/location/osd.rb +137 -0
- data/lib/ceph/crush/location/version.rb +7 -0
- metadata +147 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3ce20f8f342c0b2a09c41c7ab5a2915ed5f47310
|
4
|
+
data.tar.gz: df72c8eda7b4803e273f8787c8aa891e20b30309
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 004ae1ccbfd2844e14cb8292aff17da7e3d1aea69a495b9157d497d495e177ec88715a4cad69c19d58e667fdfe5b9d4456678c3d6258e1c2ffa2b53b7d77c140
|
7
|
+
data.tar.gz: bbead56a581722574c8d5318355828422493e397b091cd1f96184deb36f32e0dd5a38bb4b786548628c589fd2f9b9ce6daf44403028f611d841475af0e9be786
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
When contributing to this repository, please first discuss the change you wish to make via issue,
|
4
|
+
email, or any other method with the owners of this repository before making a change.
|
5
|
+
|
6
|
+
Please note we have a code of conduct, please follow it in all your interactions with the project.
|
7
|
+
|
8
|
+
## Pull Request Process
|
9
|
+
|
10
|
+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
|
11
|
+
build.
|
12
|
+
2. Update the README.md with details of changes to the interface, this includes new environment
|
13
|
+
variables, exposed ports, useful file locations and container parameters.
|
14
|
+
3. Increase the version numbers in any examples files and the README.md to the new version that this
|
15
|
+
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
|
16
|
+
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
|
17
|
+
do not have permission to do that, you may request the second reviewer to merge it for you.
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Ceph::Crush::Location
|
2
|
+
|
3
|
+
This module is designed as an assistent to the [Ceph OSD](https://ceph.com) daemon.
|
4
|
+
On starting a Ceph OSD, the daemon will invoke an executable as detailed in the config.
|
5
|
+
|
6
|
+
```ini
|
7
|
+
[osd]
|
8
|
+
osd_crush_location_hook = /path/to/crush/location/bin
|
9
|
+
```
|
10
|
+
|
11
|
+
Ceph invokes this executable with the following options:
|
12
|
+
--cluster CLUSTER
|
13
|
+
--id ID
|
14
|
+
--type DAEMON_TYPE
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Install it yourself as:
|
19
|
+
|
20
|
+
$ gem install ceph-crush-location
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
This file takes information about the node from a file called `/etc/nodeinfo/info.json`. This can contain information about what datacenter, row, rack and chassis a host is in.
|
25
|
+
This is useful for maintaining redundancy of data.
|
26
|
+
|
27
|
+
the json file can take the following format
|
28
|
+
```json
|
29
|
+
{
|
30
|
+
"datacenter": "dc",
|
31
|
+
"row": "1",
|
32
|
+
"rack": "rackname",
|
33
|
+
"chassis": "chassis-name"
|
34
|
+
}
|
35
|
+
```
|
36
|
+
|
37
|
+
Should this file not be available from this location, you can specify the location using `ENV['NODE_INFO']`
|
38
|
+
|
39
|
+
Beyond that there are three lower types provided which are derived as follows:
|
40
|
+
root # Crush root, either default, or read from /path/to/osd/crush_root
|
41
|
+
disk_chassis # JBOD level of redundancy read from /path/to/osd/disk_chassis
|
42
|
+
enclosure # Enclosure/backplane read from /path/to/osd/enclosure
|
43
|
+
|
44
|
+
If any of the crush bucket information items are not retrievable (or not provided), they will be ommitted.
|
45
|
+
|
46
|
+
Each bucket is maintained as unique by concatenating all higher level bucket names to the lower one, thus if you ignore a bucket layer in the middle, the disk will fall potentially into a different bucket from what you are expecting.
|
47
|
+
|
48
|
+
Your crush ruleset will require the following types to use this gem:
|
49
|
+
type 0 osd
|
50
|
+
type 1 enclosure
|
51
|
+
type 2 disk_chassis
|
52
|
+
type 3 host
|
53
|
+
type 4 chassis
|
54
|
+
type 5 rack
|
55
|
+
type 6 row
|
56
|
+
type 7 datacenter
|
57
|
+
type 8 root
|
58
|
+
## Development
|
59
|
+
|
60
|
+
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.
|
61
|
+
|
62
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/essjayhch/ceph-crush-location.
|
67
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'ceph/crush/location'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require 'pry'
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ceph/crush/location/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ceph-crush-location'
|
8
|
+
spec.version = Ceph::Crush::Location::VERSION
|
9
|
+
spec.authors = ['Stuart Harland']
|
10
|
+
spec.email = ['s.harland@livelinktechnology.net']
|
11
|
+
|
12
|
+
spec.summary = 'Manage where OSDs are found in crush map'
|
13
|
+
spec.homepage = 'https://github.com/essjayhch/ceph-crush-location'
|
14
|
+
spec.licenses = ['MIT']
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
spec.add_runtime_dependency 'activesupport'
|
22
|
+
spec.add_runtime_dependency 'json'
|
23
|
+
spec.add_runtime_dependency 'logger'
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Ruby module for code to do with Ceph
|
2
|
+
module Ceph
|
3
|
+
# Ruby Module to do with Crush Maps
|
4
|
+
module Crush
|
5
|
+
# Code to handle where to inject OSDs into the Crush Map
|
6
|
+
module Location
|
7
|
+
require 'rubygems'
|
8
|
+
require 'active_support'
|
9
|
+
mattr_accessor :nodeinfo, :logger, :options
|
10
|
+
require 'ceph/crush/location/version'
|
11
|
+
require 'ceph/crush/location/logger'
|
12
|
+
Ceph::Crush::Location::Logger.send('Load')
|
13
|
+
require 'ceph/crush/location/options/parser'
|
14
|
+
require 'ceph/crush/location/node_info/parser'
|
15
|
+
require 'ceph/crush/location/osd'
|
16
|
+
require 'ceph/crush/location/bucket'
|
17
|
+
Ceph::Crush::Location::Logger.send('Loaded')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Ceph
|
2
|
+
module Crush
|
3
|
+
module Location
|
4
|
+
# Derives a Bucket line for Crush
|
5
|
+
class Bucket
|
6
|
+
def initialize
|
7
|
+
Ceph::Crush::Location::Logger.send('Bucket.initialize')
|
8
|
+
@osd = OSD.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
Ceph::Crush::Location::Logger.send('Bucket.to_s')
|
13
|
+
[root_bucket, datacenter_bucket,
|
14
|
+
row_bucket, rack_bucket, chassis_bucket,
|
15
|
+
host_bucket, disk_chassis_bucket, enclosure_bucket].join('')
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def root_bucket
|
21
|
+
Ceph::Crush::Location::Logger.send('Bucket.root_bucket')
|
22
|
+
"root=#{@osd.root}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def datacenter_bucket
|
26
|
+
Ceph::Crush::Location::Logger.send('Bucket.datacenter_bucket')
|
27
|
+
" datacenter=#{datacenter}" if @osd.knows_datacenter?
|
28
|
+
end
|
29
|
+
|
30
|
+
def datacenter
|
31
|
+
Ceph::Crush::Location::Logger.send('Bucket.datacenter')
|
32
|
+
@osd.root_artifact(@osd.datacenter)
|
33
|
+
end
|
34
|
+
|
35
|
+
def row_bucket
|
36
|
+
Ceph::Crush::Location::Logger.send('Bucket.row_bucket')
|
37
|
+
" row=#{row}" if @osd.knows_row?
|
38
|
+
end
|
39
|
+
|
40
|
+
def row
|
41
|
+
Ceph::Crush::Location::Logger.send('Bucket.row')
|
42
|
+
@osd.datacenter_artifact(@osd.row)
|
43
|
+
end
|
44
|
+
|
45
|
+
def rack_bucket
|
46
|
+
Ceph::Crush::Location::Logger.send('Bucket.rack_bucket')
|
47
|
+
" rack=#{rack}" if @osd.knows_rack?
|
48
|
+
end
|
49
|
+
|
50
|
+
def rack
|
51
|
+
Ceph::Crush::Location::Logger.send('Bucket.rack')
|
52
|
+
@osd.row_artifact(@osd.rack)
|
53
|
+
end
|
54
|
+
|
55
|
+
def chassis_bucket
|
56
|
+
Ceph::Crush::Location::Logger.send('Bucket.chassis_bucket')
|
57
|
+
" chassis=#{chassis}" if @osd.knows_chassis?
|
58
|
+
end
|
59
|
+
|
60
|
+
def chassis
|
61
|
+
Ceph::Crush::Location::Logger.send('Bucket.chassis')
|
62
|
+
@osd.rack_artifact(@osd.chassis)
|
63
|
+
end
|
64
|
+
|
65
|
+
def host_bucket
|
66
|
+
Ceph::Crush::Location::Logger.send('Bucket.host_bucket')
|
67
|
+
" host=#{host}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def host
|
71
|
+
Ceph::Crush::Location::Logger.send('Bucket.host')
|
72
|
+
@osd.chassis_artifact(@osd.hostname)
|
73
|
+
end
|
74
|
+
|
75
|
+
def disk_chassis_bucket
|
76
|
+
Ceph::Crush::Location::Logger.send('Bucket.disk_chassis_bucket')
|
77
|
+
" disk_chassis=#{disk_chassis}" if @osd.knows_disk_chassis?
|
78
|
+
end
|
79
|
+
|
80
|
+
def disk_chassis
|
81
|
+
Ceph::Crush::Location::Logger.send('Bucket.disk_chassis')
|
82
|
+
@osd.host_artifact(@osd.disk_chassis)
|
83
|
+
end
|
84
|
+
|
85
|
+
def enclosure_bucket
|
86
|
+
Ceph::Crush::Location::Logger.send('Bucket.enclosure_bucket')
|
87
|
+
" enclosure=#{enclosure}" if @osd.knows_enclosure?
|
88
|
+
end
|
89
|
+
|
90
|
+
def enclosure
|
91
|
+
Ceph::Crush::Location::Logger.send('Bucket.enclosure')
|
92
|
+
@osd.disk_chassis_artifact(@osd.enclosure)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Ceph
|
2
|
+
module Crush
|
3
|
+
module Location
|
4
|
+
# Logs things
|
5
|
+
module Logger
|
6
|
+
mattr_accessor :loggers
|
7
|
+
|
8
|
+
def self.add_logger_instance(logger)
|
9
|
+
loggers << logger
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.send(message, level = ::Logger::INFO)
|
13
|
+
return unless loggers
|
14
|
+
loggers.each do |l|
|
15
|
+
send_log_message(message, l, level)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.send_log_message(message, logger, level = ::Logger::INFO)
|
20
|
+
return logger.info(message) if level == ::Logger::INFO
|
21
|
+
return logger.error(message) if level == ::Logger::ERR
|
22
|
+
return logger.warn(message) if level == ::Logger::WARN
|
23
|
+
logger.debug(message)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Ceph
|
2
|
+
module Crush
|
3
|
+
module Location
|
4
|
+
# This Module loads information about this node from a json file
|
5
|
+
module NodeInfo
|
6
|
+
def self.load
|
7
|
+
Ceph::Crush::Location::Logger.send('loading node info')
|
8
|
+
require 'json'
|
9
|
+
Ceph::Crush::Location.nodeinfo = JSON.parse(
|
10
|
+
::File.read(Ceph::Crush::Location.options[:nodeinfo])
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
Ceph::Crush::Location::NodeInfo.load
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
module Ceph
|
3
|
+
module Crush
|
4
|
+
module Location
|
5
|
+
# Holds options
|
6
|
+
module Options
|
7
|
+
def self.parse!
|
8
|
+
Parser.parse!
|
9
|
+
end
|
10
|
+
|
11
|
+
# Parses it
|
12
|
+
class Parser
|
13
|
+
class << self
|
14
|
+
def parse!
|
15
|
+
::Ceph::Crush::Location::Logger.send('parsing attributes')
|
16
|
+
::Ceph::Crush::Location.options = {}
|
17
|
+
grab!
|
18
|
+
validate!
|
19
|
+
default_env
|
20
|
+
env!
|
21
|
+
::Ceph::Crush::Location.options.freeze
|
22
|
+
rescue OptionParser::MissingArgument => e
|
23
|
+
report e
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_env
|
27
|
+
Ceph::Crush::Location::Logger.send('Options::Parser.default_env')
|
28
|
+
::Ceph::Crush::Location.options[:nodeinfo] =
|
29
|
+
'/etc/nodeinfo/info.json'
|
30
|
+
end
|
31
|
+
|
32
|
+
def env!
|
33
|
+
Ceph::Crush::Location::Logger.send('Options::Parser.env!')
|
34
|
+
return unless ENV['NODE_INFO']
|
35
|
+
::Ceph::Crush::Location.options[:nodeinfo] = ENV['NODE_INFO']
|
36
|
+
end
|
37
|
+
|
38
|
+
def report(e)
|
39
|
+
::Ceph::Crush::Location.log(e, Logger::ERROR)
|
40
|
+
STDERR.puts "#{$PROGRAM_NAME}: #{e}"
|
41
|
+
exit(-1)
|
42
|
+
end
|
43
|
+
|
44
|
+
def usage(opts)
|
45
|
+
Ceph::Crush::Location::Logger.send('Options::Parser.usage')
|
46
|
+
opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
|
47
|
+
opts.separator ''
|
48
|
+
opts.separator 'Specific options:'
|
49
|
+
end
|
50
|
+
|
51
|
+
def options(opts)
|
52
|
+
Ceph::Crush::Location::Logger.send('Options::Parser.options')
|
53
|
+
opts.on('-c', '--cluster CLUSTER', 'Specify Cluster Name') do |c|
|
54
|
+
::Ceph::Crush::Location.options[:cluster] = c
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on('-t', '--type TYPE', 'Specify Daemon Type') do |t|
|
58
|
+
::Ceph::Crush::Location.options[:type] = t
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on('-i', '--id ID', 'Specify Daemon ID') do |i|
|
62
|
+
::Ceph::Crush::Location.options[:id] = i
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def tail
|
67
|
+
Ceph::Crush::Location::Logger.send('Options::Parser.tail')
|
68
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
69
|
+
puts opts
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
|
73
|
+
opts.on_tail('--version', 'Show version') do
|
74
|
+
puts Ceph::Crush::Location::VERSION
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def grab!
|
80
|
+
Ceph::Crush::Location::Logger.send('Options::Parser.grab!')
|
81
|
+
OptionParser.new do |opts|
|
82
|
+
usage(opts)
|
83
|
+
|
84
|
+
options(opts)
|
85
|
+
|
86
|
+
opts.separator ''
|
87
|
+
opts.separator 'Common options:'
|
88
|
+
end.parse!(ARGV)
|
89
|
+
end
|
90
|
+
|
91
|
+
def validate!
|
92
|
+
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
|
+
::Ceph::Crush::Location.options.fetch(:id) do
|
97
|
+
raise OptionParser::MissingArgument, 'no \'id\' provided'
|
98
|
+
end
|
99
|
+
::Ceph::Crush::Location.options.fetch(:type) do
|
100
|
+
raise OptionParser::MissingArgument, 'no \'type\' provided'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
Ceph::Crush::Location::Options.parse!
|
@@ -0,0 +1,137 @@
|
|
1
|
+
require 'socket'
|
2
|
+
module Ceph
|
3
|
+
module Crush
|
4
|
+
module Location
|
5
|
+
# This class stores metadata about this OSD
|
6
|
+
class OSD
|
7
|
+
attr_accessor :id, :cluster
|
8
|
+
CEPH_OSD_ROOT_PATH = '/var/lib/ceph/osd'.freeze
|
9
|
+
def initialize
|
10
|
+
Ceph::Crush::Location::Logger.send('OSD.initialize')
|
11
|
+
self.id = Ceph::Crush::Location.options[:id]
|
12
|
+
self.cluster = Ceph::Crush::Location.options[:cluster]
|
13
|
+
end
|
14
|
+
|
15
|
+
def osd_directory
|
16
|
+
Ceph::Crush::Location::Logger.send('OSD.osd_directory')
|
17
|
+
::File.join CEPH_OSD_ROOT_PATH, "#{cluster}-#{id}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_root?
|
21
|
+
!::File.exist? root_path
|
22
|
+
end
|
23
|
+
|
24
|
+
def root_path
|
25
|
+
@root_path ||= ::File.join(osd_directory, 'crush_root')
|
26
|
+
end
|
27
|
+
|
28
|
+
def root
|
29
|
+
return 'default' if default_root?
|
30
|
+
::File.read root_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def disk_chassis_path
|
34
|
+
Ceph::Crush::Location::Logger.send('OSD.disk_chassis_path')
|
35
|
+
@disk_chassis_path ||= ::File.join(osd_directory, 'disk_chassis')
|
36
|
+
end
|
37
|
+
|
38
|
+
def knows_disk_chassis?
|
39
|
+
::File.exist? disk_chassis_path
|
40
|
+
end
|
41
|
+
|
42
|
+
def disk_chassis
|
43
|
+
::File.read disk_chassis_path if knows_disk_chassis?
|
44
|
+
end
|
45
|
+
|
46
|
+
def enclosure_path
|
47
|
+
Ceph::Crush::Location::Logger.send('OSD.enclosure_path')
|
48
|
+
@enclosure_path ||= ::File.join(osd_directory, 'enclosure')
|
49
|
+
end
|
50
|
+
|
51
|
+
def knows_enclosure?
|
52
|
+
::File.exist? enclosure_path
|
53
|
+
end
|
54
|
+
|
55
|
+
def enclosure
|
56
|
+
::File.read enclosure_path if knows_enclosure?
|
57
|
+
end
|
58
|
+
|
59
|
+
def knows_chassis?
|
60
|
+
!chassis.nil?
|
61
|
+
end
|
62
|
+
|
63
|
+
def chassis
|
64
|
+
Ceph::Crush::Location::Logger.send('OSD.chassis')
|
65
|
+
@chassis ||= Ceph::Crush::Location.nodeinfo['chassis']
|
66
|
+
end
|
67
|
+
|
68
|
+
def knows_rack?
|
69
|
+
!rack.nil?
|
70
|
+
end
|
71
|
+
|
72
|
+
def rack
|
73
|
+
@rack ||= Ceph::Crush::Location.nodeinfo['rack']
|
74
|
+
end
|
75
|
+
|
76
|
+
def knows_row?
|
77
|
+
!row.nil?
|
78
|
+
end
|
79
|
+
|
80
|
+
def row
|
81
|
+
@row ||= Ceph::Crush::Location.nodeinfo['row']
|
82
|
+
end
|
83
|
+
|
84
|
+
def knows_datacenter?
|
85
|
+
!datacenter.nil?
|
86
|
+
end
|
87
|
+
|
88
|
+
def datacenter
|
89
|
+
Ceph::Crush::Location::Logger.send('OSD.datacenter')
|
90
|
+
@datacenter ||= Ceph::Crush::Location.nodeinfo['datacenter']
|
91
|
+
end
|
92
|
+
|
93
|
+
def hostname
|
94
|
+
Socket.gethostname.strip.split('.').first
|
95
|
+
end
|
96
|
+
|
97
|
+
def root_artifact(append = '')
|
98
|
+
"#{root}_#{append}"
|
99
|
+
end
|
100
|
+
|
101
|
+
def datacenter_artifact(append = '')
|
102
|
+
return root_artifact("#{datacenter}_#{append}") if knows_datacenter?
|
103
|
+
root_artifact(append)
|
104
|
+
end
|
105
|
+
|
106
|
+
def row_artifact(append = '')
|
107
|
+
return datacenter_artifact("#{row}_#{append}") if knows_row?
|
108
|
+
datacenter_artifact(append)
|
109
|
+
end
|
110
|
+
|
111
|
+
def rack_artifact(append = '')
|
112
|
+
return row_artifact("#{rack}_#{append}") if knows_rack?
|
113
|
+
row_artifact(append)
|
114
|
+
end
|
115
|
+
|
116
|
+
def chassis_artifact(append = '')
|
117
|
+
return rack_artifact("#{chassis}_#{append}") if knows_chassis?
|
118
|
+
rack_artifact(append)
|
119
|
+
end
|
120
|
+
|
121
|
+
def host_artifact(append = '')
|
122
|
+
chassis_artifact("#{hostname}_#{append}")
|
123
|
+
end
|
124
|
+
|
125
|
+
def disk_chassis_artifact(append = '')
|
126
|
+
return host_artifact(append) unless knows_disk_chassis?
|
127
|
+
host_artifact("#{disk_chassis}_#{append}")
|
128
|
+
end
|
129
|
+
|
130
|
+
def enclosure_artifact(append = '')
|
131
|
+
return disk_chassis_artifact(append) unless knows_enclosure?
|
132
|
+
disk_chassis_artifact("#{enclosure}_#{append}")
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
metadata
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ceph-crush-location
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stuart Harland
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: logger
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.12'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- s.harland@livelinktechnology.net
|
100
|
+
executables:
|
101
|
+
- crush-location.rb
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CONTRIBUTING.md
|
109
|
+
- Gemfile
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- ceph-crush-location.gemspec
|
115
|
+
- exe/crush-location.rb
|
116
|
+
- lib/ceph/crush/location.rb
|
117
|
+
- lib/ceph/crush/location/bucket.rb
|
118
|
+
- lib/ceph/crush/location/logger.rb
|
119
|
+
- lib/ceph/crush/location/node_info/parser.rb
|
120
|
+
- lib/ceph/crush/location/options/parser.rb
|
121
|
+
- lib/ceph/crush/location/osd.rb
|
122
|
+
- lib/ceph/crush/location/version.rb
|
123
|
+
homepage: https://github.com/essjayhch/ceph-crush-location
|
124
|
+
licenses:
|
125
|
+
- MIT
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.6.11
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Manage where OSDs are found in crush map
|
147
|
+
test_files: []
|