seiso-import_chef 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzI4MGI0MTMwMDM2YWZhODg5OTEwNTk3YzE3Zjg3NDI1MzI2ODQ5Mw==
4
+ YmM4ODJmMmJhZGY5MjRkMjU1YWE1YTE5ZTJjODRjM2MzZWU3ZWRiZQ==
5
5
  data.tar.gz: !binary |-
6
- ZGM1MjhiYjUzN2FlOTY5MDY4NjQyMWY4NDIwZDdiMDg0NTE1NTFkOA==
6
+ MDIxYWU0Y2Y4NTJlMWNiYTU2ZTZkYTZkM2JhNDhkMDU3NTgxYTVjOQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmQ3MmI5NmUyMjIxMmExOWMyZjRjODc2ZjE2ZmU3NjA1OWNiMWQ1YzEwM2U2
10
- ZjJjOWNkYjBjMTlmZWMxOWNhMDg1YjQxYTFhZWM3M2U3MzVkNmRlMWEyYmNh
11
- ZTY2NzdhODllMjM5ZDQ1ZDNlYzkwYzdlNGRkNDM0ZDI2OTJlYmM=
9
+ YzA4MmE5NmVkY2RmMGQyYzU1NmZjNGUxMDI1OGM5YzliNjk3YTA0ZDZiZDU2
10
+ ZjFkMzMyMzJjNTY4ZjdlYzU0NTI3NTNiNTRiYmY5YmMzNTY0ODdhMDJmNTk3
11
+ ZWFlMDg2ZDRkZDJmYmExZWQ1NGJjOTk5NzJjMDc0MjJiYmFiOWI=
12
12
  data.tar.gz: !binary |-
13
- MjkyODdjNWQ5YTNjNGI5ODBiNmY4YjJmYWJlYWM0ZmE3OTFlZjYwZDA4MmM4
14
- NWFkMjZjZDZjNzViNmZhOWE3ZTc3ZTgxMDc2MDE1MDAxNjVkOWYyMTkxYjhl
15
- ZjM2NjE4Njg2ZTQ2NDY4ZWRkYWRmMWNiODc5MDcyN2Y4YjBjYWY=
13
+ YmRkNzhlYzZkYTk1NTZjOWQ5YWIwZGQ1OGVkMzM2YTE4YmUyYTBkZTk5ZDYz
14
+ YTRiNjFhZjU2ZmQyMjE4OTdiYjJiZDE1MzhlZWUxM2I3OGFkNWM3NTU1MDJh
15
+ MjA0OGRjYTI4NzczMjI2MDZjOGFjMDY2ZDY4MWNmNzc4MTZjMDk=
data/README.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # Seiso::ImportChef
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/seiso-import_chef.svg)](http://badge.fury.io/rb/seiso-import_chef)
3
4
  [![Build Status](https://travis-ci.org/ExpediaDotCom/seiso-import_chef.svg)](https://travis-ci.org/ExpediaDotCom/seiso-import_chef)
4
5
  [![Inline docs](http://inch-ci.org/github/ExpediaDotCom/seiso-import_chef.svg?branch=master)](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 Pull Request
37
+ 5. Create a new pull request.
@@ -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 (mailto:wwheeler@expedia.com)
11
+ # Author:: Willie Wheeler
11
12
  # Copyright:: Copyright (c) 2014-2015 Expedia, Inc.
12
13
  # License:: Apache 2.0
13
14
 
14
- chef_settings = YAML.load_file "#{Dir.home}/.seiso-importers/chef.yml"
15
- seiso_settings = YAML.load_file "#{Dir.home}/.seiso-importers/seiso.yml"
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
@@ -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 a list of Chef nodes to a list of Seiso machines.
13
- def map_all(chef_nodes)
14
- return nil if chef_nodes.nil?
15
- seiso_machines = []
16
- chef_nodes.each do |n|
17
- seiso_machines << map_one(n)
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
- private
48
-
49
- def cleanup(s)
50
- s.nil? ? nil : s.strip.downcase
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
@@ -0,0 +1,2 @@
1
+ gem build seiso-import_chef.gemspec
2
+ gem install seiso-import_chef-*.gem
@@ -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.1"
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.1
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: 2014-12-16 00:00:00.000000000 Z
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