seiso-import_chef 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +3 -2
- data/bin/seiso-import-chef +33 -4
- data/lib/seiso/import_chef.rb +1 -2
- data/lib/seiso/import_chef/chef_machine_mapper.rb +47 -47
- data/refresh +2 -0
- data/seiso-import_chef.gemspec +1 -1
- data/test/test_chef_machine_mapper.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmM4ODJmMmJhZGY5MjRkMjU1YWE1YTE5ZTJjODRjM2MzZWU3ZWRiZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDIxYWU0Y2Y4NTJlMWNiYTU2ZTZkYTZkM2JhNDhkMDU3NTgxYTVjOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzA4MmE5NmVkY2RmMGQyYzU1NmZjNGUxMDI1OGM5YzliNjk3YTA0ZDZiZDU2
|
10
|
+
ZjFkMzMyMzJjNTY4ZjdlYzU0NTI3NTNiNTRiYmY5YmMzNTY0ODdhMDJmNTk3
|
11
|
+
ZWFlMDg2ZDRkZDJmYmExZWQ1NGJjOTk5NzJjMDc0MjJiYmFiOWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmRkNzhlYzZkYTk1NTZjOWQ5YWIwZGQ1OGVkMzM2YTE4YmUyYTBkZTk5ZDYz
|
14
|
+
YTRiNjFhZjU2ZmQyMjE4OTdiYjJiZDE1MzhlZWUxM2I3OGFkNWM3NTU1MDJh
|
15
|
+
MjA0OGRjYTI4NzczMjI2MDZjOGFjMDY2ZDY4MWNmNzc4MTZjMDk=
|
data/README.md
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# Seiso::ImportChef
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/seiso-import_chef)
|
3
4
|
[](https://travis-ci.org/ExpediaDotCom/seiso-import_chef)
|
4
5
|
[](http://inch-ci.org/github/ExpediaDotCom/seiso-import_chef)
|
5
6
|
|
6
|
-
Imports Chef data into Seiso.
|
7
|
+
Imports Chef data into Seiso. See [Integrate Chef Server Data Using Seiso](http://seiso.io/guides/integrate-chef-server-data-using-seiso/) for more details.
|
7
8
|
|
8
9
|
## Installation
|
9
10
|
|
@@ -33,4 +34,4 @@ Or install it yourself as:
|
|
33
34
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
35
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
36
|
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
-
5. Create a new
|
37
|
+
5. Create a new pull request.
|
data/bin/seiso-import-chef
CHANGED
@@ -2,16 +2,45 @@
|
|
2
2
|
# -*- mode: ruby -*-
|
3
3
|
# vi: set ft=ruby :
|
4
4
|
|
5
|
+
require 'optparse'
|
5
6
|
require 'seiso/import_chef'
|
6
7
|
require 'yaml'
|
7
8
|
|
8
9
|
# Imports Chef Server nodes into Seiso as machines.
|
9
10
|
#
|
10
|
-
# Author:: Willie Wheeler
|
11
|
+
# Author:: Willie Wheeler
|
11
12
|
# Copyright:: Copyright (c) 2014-2015 Expedia, Inc.
|
12
13
|
# License:: Apache 2.0
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
options = {}
|
16
|
+
option_parser = OptionParser.new do |opts|
|
17
|
+
executable_name = File.basename $PROGRAM_NAME
|
18
|
+
opts.banner = "Import Chef server nodes into Seiso as machines.
|
19
|
+
|
20
|
+
Usage: #{executable_name} [options]"
|
21
|
+
options[:chef_settings_path] = "#{Dir.home}/.seiso-importers/chef.yml"
|
22
|
+
opts.on("--chef CHEF_SETTINGS_PATH", "Path to Chef server settings file") do |path|
|
23
|
+
options[:chef_settings_path] = path
|
24
|
+
end
|
25
|
+
|
26
|
+
options[:seiso_settings_path] = "#{Dir.home}/.seiso-importers/seiso.yml"
|
27
|
+
opts.on("--seiso SEISO_SETTINGS_PATH", "Path to Seiso API settings file") do |path|
|
28
|
+
options[:seiso_settings_path] = path
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-h", "--help", "Display this screen") do
|
32
|
+
puts opts
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
option_parser.parse!
|
38
|
+
|
39
|
+
puts ("Using: #{options[:chef_settings_path]}")
|
40
|
+
puts ("Using: #{options[:seiso_settings_path]}")
|
41
|
+
|
42
|
+
chef_settings = YAML.load_file(options[:chef_settings_path])
|
43
|
+
seiso_settings = YAML.load_file(options[:seiso_settings_path])
|
44
|
+
|
16
45
|
importer = Seiso::ImportChef.new(chef_settings, seiso_settings)
|
17
|
-
importer.import_all
|
46
|
+
#importer.import_all
|
data/lib/seiso/import_chef.rb
CHANGED
@@ -11,7 +11,6 @@ module Seiso
|
|
11
11
|
# Author:: Willie Wheeler (mailto:wwheeler@expedia.com)
|
12
12
|
# Copyright:: Copyright (c) 2014-2015 Expedia, Inc.
|
13
13
|
# License:: Apache 2.0
|
14
|
-
|
15
14
|
class ImportChef
|
16
15
|
|
17
16
|
# Batch size for putting nodes into Seiso.
|
@@ -23,7 +22,7 @@ module Seiso
|
|
23
22
|
"#{chef_settings['client_name']}",
|
24
23
|
"#{chef_settings['signing_key']}")
|
25
24
|
@seiso = Seiso::Connector.new seiso_settings
|
26
|
-
@mapper = Seiso::ChefMachineMapper.new
|
25
|
+
@mapper = Seiso::ImportChef::ChefMachineMapper.new
|
27
26
|
end
|
28
27
|
|
29
28
|
# Imports all nodes from the Chef server into Seiso.
|
@@ -1,53 +1,53 @@
|
|
1
|
-
# Seiso namespace module
|
2
1
|
module Seiso
|
3
|
-
|
4
|
-
# Maps Chef nodes to Seiso machines.
|
5
|
-
#
|
6
|
-
# Author:: Willie Wheeler (mailto:wwheeler@expedia.com)
|
7
|
-
# Copyright:: Copyright (c) 2014-2015
|
8
|
-
# License:: Apache 2.0
|
9
|
-
|
10
|
-
class ChefMachineMapper
|
2
|
+
class ImportChef
|
11
3
|
|
12
|
-
# Maps
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
seiso_machines
|
20
|
-
end
|
21
|
-
|
22
|
-
def map_one(chef_node)
|
23
|
-
return nil if chef_node.nil?
|
24
|
-
{
|
25
|
-
# FIXME Not sure which field Chef uses as the key here, so we'll just set that externally for now.
|
26
|
-
# "name" => cleanup(chef_node["name"]),
|
27
|
-
"fqdn" => cleanup(chef_node["fqdn"]),
|
28
|
-
"hostname" => cleanup(chef_node["hostname"]),
|
29
|
-
"domain" => cleanup(chef_node["domain"]),
|
30
|
-
|
31
|
-
# TODO For the nodes so far, this is a single IP address. Not sure whether Chef supports multiple IPv4 addresses,
|
32
|
-
# or what it returns in that case. Need to look into it.
|
33
|
-
"ipAddress" => cleanup(chef_node["ipaddress"]),
|
34
|
-
|
35
|
-
# FIXME Commenting this out for now, as it generates arrays where Seiso expects a single value. Not sure why
|
36
|
-
# Chef uses a single value for IPv4 but an array for IPv6.
|
37
|
-
# "ip6Address" => cleanup(chef_node["ip6address"]),
|
38
|
-
|
39
|
-
"macAddress" => cleanup(chef_node["macaddress"]),
|
40
|
-
"platform" => cleanup(chef_node["platform"]),
|
41
|
-
"platformVersion" => cleanup(chef_node["platform_version"]),
|
42
|
-
"os" => cleanup(chef_node["os"]),
|
43
|
-
"osVersion" => cleanup(chef_node["os_version"])
|
44
|
-
}
|
45
|
-
end
|
4
|
+
# Maps Chef nodes to Seiso machines.
|
5
|
+
#
|
6
|
+
# Author:: Willie Wheeler (mailto:wwheeler@expedia.com)
|
7
|
+
# Copyright:: Copyright (c) 2014-2015
|
8
|
+
# License:: Apache 2.0
|
9
|
+
class ChefMachineMapper
|
46
10
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
11
|
+
# Maps a list of Chef nodes to a list of Seiso machines.
|
12
|
+
def map_all(chef_nodes)
|
13
|
+
return nil if chef_nodes.nil?
|
14
|
+
seiso_machines = []
|
15
|
+
chef_nodes.each do |n|
|
16
|
+
seiso_machines << map_one(n)
|
17
|
+
end
|
18
|
+
seiso_machines
|
19
|
+
end
|
20
|
+
|
21
|
+
def map_one(chef_node)
|
22
|
+
return nil if chef_node.nil?
|
23
|
+
{
|
24
|
+
# FIXME Not sure which field Chef uses as the key here, so we'll just set that externally for now.
|
25
|
+
# "name" => cleanup(chef_node["name"]),
|
26
|
+
"fqdn" => cleanup(chef_node["fqdn"]),
|
27
|
+
"hostname" => cleanup(chef_node["hostname"]),
|
28
|
+
"domain" => cleanup(chef_node["domain"]),
|
29
|
+
|
30
|
+
# TODO For the nodes so far, this is a single IP address. Not sure whether Chef supports multiple IPv4 addresses,
|
31
|
+
# or what it returns in that case. Need to look into it.
|
32
|
+
"ipAddress" => cleanup(chef_node["ipaddress"]),
|
33
|
+
|
34
|
+
# FIXME Commenting this out for now, as it generates arrays where Seiso expects a single value. Not sure why
|
35
|
+
# Chef uses a single value for IPv4 but an array for IPv6.
|
36
|
+
# "ip6Address" => cleanup(chef_node["ip6address"]),
|
37
|
+
|
38
|
+
"macAddress" => cleanup(chef_node["macaddress"]),
|
39
|
+
"platform" => cleanup(chef_node["platform"]),
|
40
|
+
"platformVersion" => cleanup(chef_node["platform_version"]),
|
41
|
+
"os" => cleanup(chef_node["os"]),
|
42
|
+
"osVersion" => cleanup(chef_node["os_version"])
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def cleanup(s)
|
49
|
+
s.nil? ? nil : s.strip.downcase
|
50
|
+
end
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
data/refresh
ADDED
data/seiso-import_chef.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "seiso-import_chef"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.2"
|
8
8
|
spec.authors = ["Willie Wheeler"]
|
9
9
|
spec.email = ["wwheeler@expedia.com"]
|
10
10
|
spec.summary = "Imports Chef data into Seiso."
|
@@ -8,7 +8,7 @@ require "seiso/import_chef/chef_machine_mapper"
|
|
8
8
|
class TestChefMachineMapper < MiniTest::Unit::TestCase
|
9
9
|
|
10
10
|
def setup
|
11
|
-
@mapper = Seiso::ChefMachineMapper.new
|
11
|
+
@mapper = Seiso::ImportChef::ChefMachineMapper.new
|
12
12
|
@chef_node = {
|
13
13
|
"fqdn" => "my-fqdn",
|
14
14
|
"hostname" => "my-hostname",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seiso-import_chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willie Wheeler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- bin/seiso-import-chef
|
84
84
|
- lib/seiso/import_chef.rb
|
85
85
|
- lib/seiso/import_chef/chef_machine_mapper.rb
|
86
|
+
- refresh
|
86
87
|
- sample_conf/chef.yml.sample
|
87
88
|
- sample_conf/seiso.yml.sample
|
88
89
|
- seiso-import_chef.gemspec
|