gogetit 0.1.18 → 0.1.19

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: 82fb5713fad52b472d154eab5830a5696a2ac5d3
4
- data.tar.gz: 63bb2a42d787401965222e72c09eeac25b3aeabd
3
+ metadata.gz: 69a041470a02b35929805777c4c591c2b748fbf8
4
+ data.tar.gz: 3a1be3d51b36f9be2ebc96eac14a67529f2e92d2
5
5
  SHA512:
6
- metadata.gz: d2e43782f172ee97bdf3b8fe0d3c0bd65b2fe4fb1a93818a162698b950bb31b5a5b4f9ad8329651648e24b71c5c3541c4b8c8a546c666644ff26ee1034a09ce8
7
- data.tar.gz: ff932ec49672bcb2a828a4337df3daf052be6aa5c274fa4849a6caba224c96f6027d31e27fa9540ee05ef895ae9571b4277a002825ef728ed65eb98354acb20e
6
+ metadata.gz: 1dec3d7518f34f4b973cf7eba4542b9a9f37ece0d94013318a511c1da3916a4d83c9463b4486c2e954c0f7427eaece90cd1b5f611c977b661ef1d65e411f52bd
7
+ data.tar.gz: 92907d8e36b55819124bd4c1733c7d995c1e4543421c946c3f1117a4553d9dd0952e9f28f6c4fd114ce3cd2f04a6949835249cb421e19e1905e858dc58399d81
data/.gitignore CHANGED
@@ -8,6 +8,6 @@
8
8
  /spec/reports/
9
9
  /tmp/
10
10
  .idea/
11
-
11
+ mkmf.log
12
12
  # rspec failure tracking
13
13
  .rspec_status
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Gogetit
2
2
 
3
- Libraries with a CLI tool for dealing with things like MAAS, LXD and Libvirt.
3
+ Libraries with a CLI tool for dealing with things which I am working on such as MAAS, LXD, Libvirt and Chef.
4
+ Using this, you will get to use them all together in automated and efficient way.
4
5
 
5
6
  ## Installation
6
7
 
@@ -12,6 +13,8 @@ sudo apt install -y build-essential lxd-client libvirt-dev libvirt-bin
12
13
  # to remove default network(virbr0)
13
14
  virsh net-destroy default
14
15
  virsh net-undefine default
16
+
17
+ # chefdk environment
15
18
  ```
16
19
 
17
20
  ### install
@@ -24,7 +27,15 @@ $ gem install gogetit --no-ri --no-rdoc
24
27
  gogetit list
25
28
  gogetit create lxd lxd01
26
29
  gogetit create libvirt kvm01
30
+
27
31
  gogetit destroy lxd01
32
+ gogetit rebuild kvm01
33
+
34
+ # to create a container bootstrapping as a chef node
35
+ gogetit create --chef chef01
36
+
37
+ # to destroy a container deleting corresponding chef node and client
38
+ gogetit destroy --chef chef01
28
39
  ```
29
40
 
30
41
  ```ruby
@@ -32,7 +43,8 @@ require 'gogetit'
32
43
  ```
33
44
 
34
45
  ## TODO
35
- - Add allocating static IP
46
+ - Network subnets and space aware via MAAS
47
+ - Static IP allocation
36
48
 
37
49
  ## Development and Contributing
38
50
  Clone and then execute followings:
data/gogetit.gemspec CHANGED
@@ -35,7 +35,7 @@ Gem::Specification.new do |spec|
35
35
  #spec.add_runtime_dependency 'etcd-rb', '~> 1.1.0'
36
36
  spec.add_runtime_dependency 'json', '~> 2.1.0'
37
37
  spec.add_runtime_dependency 'hyperkit', '~> 1.1.0'
38
- spec.add_runtime_dependency 'maas-client', '~> 0.1.23'
38
+ spec.add_runtime_dependency 'maas-client', '~> 0.1.24'
39
39
  spec.add_runtime_dependency 'ruby-libvirt', '~> 0.7.0'
40
40
  spec.add_runtime_dependency 'oga', '~> 2.10'
41
41
  spec.add_runtime_dependency 'net-ssh', '~> 4.1.0'
@@ -1,6 +1,6 @@
1
1
  # https://gist.github.com/ryanlecompte/1283413
2
2
  module Gogetit
3
- module Gogetit::ExecutionHooks
3
+ module ExecutionHooks
4
4
  # this method is invoked whenever a new instance method is added to a class
5
5
  def method_added(method_name)
6
6
  # do nothing if the method that was added was an actual hook method, or
data/lib/gogetit.rb CHANGED
@@ -1,89 +1,17 @@
1
- require 'executionhooks'
2
1
  require 'gogetit/version'
3
- require 'maas'
4
- require 'multilogger'
2
+ require 'gogetit/config'
3
+ require 'gogetit/maas'
5
4
  require 'providers/lxd'
6
5
  require 'providers/libvirt'
7
- require 'yaml'
8
- require 'logger'
9
- require 'util'
10
6
 
11
7
  module Gogetit
12
- extend Gogetit::Util
13
8
 
14
9
  class << self
15
- attr_reader :config, :maas, :lxd, :libvirt, :logger
16
- end
17
-
18
- # TODO: It might be needed to disable one of logging devices according to satiation.
19
- STDOUT.sync = true
20
- log_to_stdout = Logger.new(STDOUT)
21
- @logger = Gogetit::MultiLogger.new(:loggers => log_to_stdout)
22
- logger.debug('Instantiate main objects..')
23
-
24
- @config = {}
25
-
26
- logger.debug('Defining home directory..')
27
- user_gogetit_home = Dir.home + '/.gogetit'
28
- config[:user_gogetit_home] = user_gogetit_home
29
- if not File.directory?(user_gogetit_home)
30
- logger.debug('Creating home directory..')
31
- FileUtils.mkdir(user_gogetit_home)
32
- end
33
-
34
- # TODO: It can be used to provide different behavior according to consumer.
35
- logger.debug('Defining default consumer..')
36
- config[:consumer] = 'gogetit_cli'
37
-
38
- logger.debug('Defining log directory..')
39
- log_dir = user_gogetit_home + '/log'
40
- config[:log_dir] = log_dir
41
- if not File.directory?(log_dir)
42
- logger.debug('Creating log directory..')
43
- FileUtils.mkdir(log_dir)
44
- end
45
-
46
- logger.debug('Define file log devices..')
47
- log_file = File.open(log_dir + '/debug.log', 'a')
48
- log_file.sync = true
49
- log_to_file = Logger.new(log_file)
50
- logger.add_logger(log_to_file)
51
-
52
- logger.debug('Defining logger..')
53
- # logger.datetime_format = "%Y-%m-%d %H:%M:%S"
54
- logger.progname = 'GoGetIt'
55
-
56
- lib_dir = File.dirname(__FILE__)
57
-
58
- config[:lib_dir] = lib_dir
59
- logger.debug('Loading GoGetIt default configuration..')
60
- conf_file = user_gogetit_home + '/gogetit.yml'
61
- if not File.exists?(conf_file)
62
- src = File.new(lib_dir + '/sample_conf/gogetit.yml')
63
- dst = Dir.new(user_gogetit_home)
64
- logger.debug('Copying GoGetIt default configuration..')
65
- FileUtils.cp(src, dst)
66
- abort('Please define default configuration for GoGetIt at ~/.gogetit/gogetit.yml.')
67
- end
68
- config.merge!(symbolize_keys(YAML.load_file(conf_file)))
69
-
70
- logger.debug('Define provider configuration directory..')
71
- provider_conf_dir = user_gogetit_home + '/conf'
72
- config[:provider_conf_dir] = provider_conf_dir
73
- default_provider_conf_file = provider_conf_dir + '/default.yml'
74
- config[:default_provider_conf_file] = default_provider_conf_file
75
- if not File.exists?(default_provider_conf_file)
76
- if not File.directory?(provider_conf_dir)
77
- logger.debug('Creating provider configuration directory..')
78
- FileUtils.mkdir(provider_conf_dir)
79
- end
80
- src = File.new(lib_dir + '/sample_conf/default.yml')
81
- dst = Dir.new(provider_conf_dir)
82
- logger.debug('Copying provider configuration file..')
83
- FileUtils.cp(src, dst)
84
- abort('Please define default configuration for providers at ~/.gogetit/conf/default.yml.')
10
+ attr_reader :config, :logger, :maas, :lxd, :libvirt
85
11
  end
86
12
 
13
+ @config = Gogetit::Config.config
14
+ @logger = Gogetit::Config.logger
87
15
  @maas = Gogetit::GogetMAAS.new(config, logger)
88
16
  @lxd = Gogetit::GogetLXD.new(config, maas, logger)
89
17
  @libvirt = Gogetit::GogetLibvirt.new(config, maas, logger)
data/lib/gogetit/cli.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'thor'
2
2
  require 'gogetit'
3
- require 'util'
3
+ require 'gogetit/util'
4
4
 
5
5
  module Gogetit
6
6
  class CLI < Thor
@@ -17,6 +17,7 @@ module Gogetit
17
17
  end
18
18
 
19
19
  desc 'create (TYPE) NAME', 'Create either a container or KVM domain.'
20
+ method_option :chef, :type => :boolean, :desc => "Enable chef awareness."
20
21
  def create(type='lxd', name)
21
22
  case type
22
23
  when 'lxd'
@@ -27,12 +28,13 @@ module Gogetit
27
28
  abort('Invalid argument entered.')
28
29
  end
29
30
  # post-tasks
30
- knife_bootstrap(name, type, Gogetit.config)
31
+ knife_bootstrap(name, type, Gogetit.config) if options[:chef]
31
32
  Gogetit.config[:default][:user] ||= ENV['USER']
32
33
  puts "ssh #{Gogetit.config[:default][:user]}@#{name}"
33
34
  end
34
35
 
35
36
  desc 'destroy NAME', 'Destroy either a container or KVM domain.'
37
+ method_option :chef, :type => :boolean, :desc => "Enable chef awareness."
36
38
  def destroy(name)
37
39
  type = Gogetit.get_provider_of(name)
38
40
  if type
@@ -46,7 +48,7 @@ module Gogetit
46
48
  end
47
49
  end
48
50
  # post-tasks
49
- knife_remove(name)
51
+ knife_remove(name) if options[:chef]
50
52
  end
51
53
 
52
54
  desc 'rebuild NAME', 'Destroy and create either a container or KVM domain again.'
@@ -0,0 +1,83 @@
1
+ require 'yaml'
2
+ require 'logger'
3
+ require 'gogetit/util'
4
+ require 'gogetit/multilogger'
5
+
6
+ module Gogetit
7
+ module Config
8
+ extend Gogetit::Util
9
+ class << self
10
+ attr_reader :config, :logger
11
+ end
12
+
13
+ # TODO: It might be needed to disable one of logging devices according to satiation.
14
+ STDOUT.sync = true
15
+ log_to_stdout = Logger.new(STDOUT)
16
+ @logger = Gogetit::MultiLogger.new(:loggers => log_to_stdout)
17
+ logger.debug('Instantiate main objects..')
18
+
19
+ @config = {}
20
+
21
+ logger.debug('Defining home directory..')
22
+ user_gogetit_home = Dir.home + '/.gogetit'
23
+ config[:user_gogetit_home] = user_gogetit_home
24
+ if not File.directory?(user_gogetit_home)
25
+ logger.debug('Creating home directory..')
26
+ FileUtils.mkdir(user_gogetit_home)
27
+ end
28
+
29
+ # TODO: It can be used to provide different behavior according to consumer.
30
+ logger.debug('Defining default consumer..')
31
+ config[:consumer] = 'gogetit_cli'
32
+
33
+ logger.debug('Defining log directory..')
34
+ log_dir = user_gogetit_home + '/log'
35
+ config[:log_dir] = log_dir
36
+ if not File.directory?(log_dir)
37
+ logger.debug('Creating log directory..')
38
+ FileUtils.mkdir(log_dir)
39
+ end
40
+
41
+ logger.debug('Define file log devices..')
42
+ log_file = File.open(log_dir + '/debug.log', 'a')
43
+ log_file.sync = true
44
+ log_to_file = Logger.new(log_file)
45
+ logger.add_logger(log_to_file)
46
+
47
+ logger.debug('Defining logger..')
48
+ # logger.datetime_format = "%Y-%m-%d %H:%M:%S"
49
+ logger.progname = 'GoGetIt'
50
+
51
+ lib_dir = Gem::Specification.find_by_name('gogetit').gem_dir + '/lib'
52
+
53
+ config[:lib_dir] = lib_dir
54
+ logger.debug('Loading GoGetIt default configuration..')
55
+ conf_file = user_gogetit_home + '/gogetit.yml'
56
+ if not File.exists?(conf_file)
57
+ src = File.new(lib_dir + '/sample_conf/gogetit.yml')
58
+ dst = Dir.new(user_gogetit_home)
59
+ logger.debug('Copying GoGetIt default configuration..')
60
+ FileUtils.cp(src, dst)
61
+ abort('Please define default configuration for GoGetIt at ~/.gogetit/gogetit.yml.')
62
+ end
63
+ config.merge!(symbolize_keys(YAML.load_file(conf_file)))
64
+
65
+ logger.debug('Define provider configuration directory..')
66
+ provider_conf_dir = user_gogetit_home + '/conf'
67
+ config[:provider_conf_dir] = provider_conf_dir
68
+ default_provider_conf_file = provider_conf_dir + '/default.yml'
69
+ config[:default_provider_conf_file] = default_provider_conf_file
70
+ if not File.exists?(default_provider_conf_file)
71
+ if not File.directory?(provider_conf_dir)
72
+ logger.debug('Creating provider configuration directory..')
73
+ FileUtils.mkdir(provider_conf_dir)
74
+ end
75
+ src = File.new(lib_dir + '/sample_conf/default.yml')
76
+ dst = Dir.new(provider_conf_dir)
77
+ logger.debug('Copying provider configuration file..')
78
+ FileUtils.cp(src, dst)
79
+ abort('Please define default configuration for providers at ~/.gogetit/conf/default.yml.')
80
+ end
81
+
82
+ end
83
+ end
File without changes
File without changes
@@ -15,6 +15,8 @@ module Gogetit
15
15
  --ssh-user ubuntu \
16
16
  --sudo \
17
17
  --bootstrap-install-command \"#{install_cmd}\""
18
+ puts 'Bootstrapping..'
19
+ puts knife_cmd
18
20
  system(knife_cmd)
19
21
  end
20
22
  end
@@ -1,3 +1,3 @@
1
1
  module Gogetit
2
- VERSION = "0.1.18"
2
+ VERSION = "0.1.19"
3
3
  end
@@ -2,13 +2,13 @@ require 'libvirt'
2
2
  require 'securerandom'
3
3
  require 'oga'
4
4
  require 'rexml/document'
5
- require 'util'
5
+ require 'gogetit/util'
6
6
 
7
7
  module Gogetit
8
8
  class GogetLibvirt
9
9
  include Gogetit::Util
10
10
 
11
- attr_reader :config, :conn, :maas, :logger
11
+ attr_reader :config, :logger, :conn, :maas
12
12
 
13
13
  def initialize(conf, maas, logger)
14
14
  @config = conf
data/lib/providers/lxd.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require 'hyperkit'
2
- require 'util'
2
+ require 'gogetit/util'
3
3
 
4
4
  module Gogetit
5
5
  class GogetLXD
6
6
  include Gogetit::Util
7
7
 
8
- attr_reader :config, :conn, :maas, :logger
8
+ attr_reader :config, :logger, :conn, :maas
9
9
 
10
10
  def initialize(conf, maas, logger)
11
11
  @config = conf
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gogetit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Draper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-25 00:00:00.000000000 Z
11
+ date: 2017-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.1.23
117
+ version: 0.1.24
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.1.23
124
+ version: 0.1.24
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: ruby-libvirt
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -208,9 +208,11 @@ files:
208
208
  - lib/executionhooks.rb
209
209
  - lib/gogetit.rb
210
210
  - lib/gogetit/cli.rb
211
+ - lib/gogetit/config.rb
212
+ - lib/gogetit/maas.rb
213
+ - lib/gogetit/multilogger.rb
214
+ - lib/gogetit/util.rb
211
215
  - lib/gogetit/version.rb
212
- - lib/maas.rb
213
- - lib/multilogger.rb
214
216
  - lib/providers/libvirt.rb
215
217
  - lib/providers/lxd.rb
216
218
  - lib/sample_conf/ceph.yml
@@ -220,7 +222,6 @@ files:
220
222
  - lib/template/domain.xml
221
223
  - lib/template/nic.xml
222
224
  - lib/template/volume.xml
223
- - lib/util.rb
224
225
  homepage: https://github.com/itisnotdone/gogetit.git
225
226
  licenses:
226
227
  - MIT