rouster 0.68 → 0.69

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: f2922e8289682a6859c9e8425df652eb5af74b93
4
- data.tar.gz: 2862b48d598fd179b986458f214232f65ca483cf
3
+ metadata.gz: 7b0d2cb460b4d6fad86880726845308f77c14cf8
4
+ data.tar.gz: 66319f2e227a7bbb4d51458ca3f6628ef281ddf0
5
5
  SHA512:
6
- metadata.gz: 34ce58498c46e4eccc008177db64cefdfc5e1f4ae66df0e7a34cd1abbac60b2bd12929f6b60e31b418153deb7c9a946c6c955f0d210c6fc3d9851a9dbc319485
7
- data.tar.gz: 40599a85f744aea565ce406870890b8ad92620cc7aba21f02e4eb721aa3368d80208c176790e003a650e4e00f7afdb268cf0b167fa22732900bed1ba8e10b85c
6
+ metadata.gz: c6854485af207e64f012b3d45a79e9f90844cf403b0dfbfa41915b6832e9678004e0b6d5b98fd6bdd6dd73da802de36490e7d06715a704d8a34c701b8428f1d2
7
+ data.tar.gz: 93b7c1a6577ced94ed8cc9bd31341ee90af333aa4a8759c73a5b418ef1281b548326640d1f1cb81ab47c4c777719d670cdb03314fad38d33fedf0bf5be9476b5
data/.reek ADDED
@@ -0,0 +1,63 @@
1
+ ---
2
+
3
+ Attribute:
4
+ enabled: false
5
+
6
+ # so judgy.. and without context
7
+ BooleanParameter:
8
+ enabled: false
9
+
10
+ ControlParameter:
11
+ enabled: false
12
+
13
+ DataClump:
14
+ min_clump_size: 4
15
+
16
+ DuplicateMethodCall:
17
+ enabled: false
18
+
19
+ # this is not a real thing
20
+ FeatureEnvy:
21
+ enabled: false
22
+
23
+ # this should have understanding of non-required parameters
24
+ LongParameterList:
25
+ max_params: 5
26
+
27
+ NestedIterators:
28
+ max_allowed_nesting: 3
29
+
30
+ # you don't know my life
31
+ NilCheck:
32
+ enabled: false
33
+
34
+ # more lacking context judgement - when _would_ you be ok with '!' ?
35
+ PrimaDonnaMethod:
36
+ enabled: false
37
+
38
+ # this feels a bit arbitrary.. maybe would make more sense if was an average
39
+ TooManyStatements:
40
+ max_statements: 30
41
+
42
+ # see above
43
+ TooManyInstanceVariables:
44
+ max_instance_variables: 20
45
+
46
+ # see above
47
+ TooManyMethods:
48
+ max_methods: 20
49
+
50
+ # i don't name my exceptions specifically. that doesn't make me a bad person.
51
+ UncommunicativeVariableName:
52
+ accept: /^[a|b|e|f|g|h|i|j|k|l|m|p|r|s|u|v]$/
53
+
54
+ # or my comparators in ~sort() functions
55
+ ## https://github.com/troessner/reek/issues/886
56
+ UncommunicativeParameterName:
57
+ accept:
58
+ - a
59
+ - b
60
+
61
+ # got dinged for using class variables.. how else would you use self.startup?
62
+ exclude_paths:
63
+ - test/
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+
6
+ notifications:
7
+ email: false
8
+
9
+ bundler_args: --without test --jobs 3 --retry 3
10
+ script: bundle exec rake test:unit build
11
+
data/Gemfile CHANGED
@@ -6,9 +6,11 @@ gem 'json'
6
6
  gem 'log4r', '~> 1.1.9'
7
7
  gem 'net-scp'
8
8
  gem 'net-ssh'
9
+ gem 'rake', '= 10.4.2'
9
10
 
10
11
  group :development do
11
12
  gem 'test-unit', '~> 3.0.0'
13
+ gem 'reek', '= 3.10.2'
12
14
  end
13
15
 
14
16
  gem 'fog', '= 1.24.0', :groups => [:aws, :openstack]
data/Gemfile.lock CHANGED
@@ -1,7 +1,19 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
+ ast (2.3.0)
5
+ axiom-types (0.1.1)
6
+ descendants_tracker (~> 0.0.4)
7
+ ice_nine (~> 0.11.0)
8
+ thread_safe (~> 0.3, >= 0.3.1)
4
9
  builder (3.2.2)
10
+ codeclimate-engine-rb (0.3.1)
11
+ virtus (~> 1.0)
12
+ coercible (1.0.0)
13
+ descendants_tracker (~> 0.0.1)
14
+ descendants_tracker (0.0.4)
15
+ thread_safe (~> 0.3, >= 0.3.1)
16
+ equalizer (0.0.11)
5
17
  excon (0.40.0)
6
18
  fog (1.24.0)
7
19
  fog-brightbox
@@ -39,6 +51,7 @@ GEM
39
51
  fog-core
40
52
  nokogiri (~> 1.5, >= 1.5.11)
41
53
  formatador (0.2.5)
54
+ ice_nine (0.11.2)
42
55
  inflecto (0.0.2)
43
56
  ipaddress (0.8.0)
44
57
  json (1.8.1)
@@ -51,17 +64,39 @@ GEM
51
64
  net-ssh (2.9.1)
52
65
  nokogiri (1.6.3.1)
53
66
  mini_portile (= 0.6.0)
67
+ parser (2.3.3.0)
68
+ ast (~> 2.2)
54
69
  power_assert (0.1.4)
70
+ rainbow (2.1.0)
71
+ rake (10.4.2)
72
+ reek (3.10.2)
73
+ codeclimate-engine-rb (~> 0.3.1)
74
+ parser (~> 2.3, >= 2.3.0.6)
75
+ rainbow (~> 2.0)
55
76
  test-unit (3.0.2)
56
77
  power_assert
78
+ thread_safe (0.3.5)
79
+ virtus (1.0.5)
80
+ axiom-types (~> 0.1)
81
+ coercible (~> 1.0)
82
+ descendants_tracker (~> 0.0, >= 0.0.3)
83
+ equalizer (~> 0.0, >= 0.0.9)
57
84
 
58
85
  PLATFORMS
59
86
  ruby
60
87
 
61
88
  DEPENDENCIES
62
- fog
89
+ fog (= 1.24.0)
63
90
  json
64
91
  log4r (~> 1.1.9)
65
92
  net-scp
66
93
  net-ssh
94
+ rake (= 10.4.2)
95
+ reek (= 3.10.2)
67
96
  test-unit (~> 3.0.0)
97
+
98
+ RUBY VERSION
99
+ ruby 2.0.0p648
100
+
101
+ BUNDLED WITH
102
+ 1.13.6
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Rouster
2
2
  ======
3
3
 
4
+ [![build status](https://travis-ci.org/chorankates/rouster.svg)](https://travis-ci.org/chorankates/rouster) [![Gem Version](https://badge.fury.io/rb/rouster.svg)](https://rubygems.org/gems/rouster)
5
+
4
6
  ```rb
5
7
  Rouster.is_a?('abstraction layer for controlling Vagrant virtual machines')
6
8
  => true
@@ -61,9 +63,6 @@ irb(main):001:0> require 'rouster'
61
63
 
62
64
  ### pre-built gem installation (stable)
63
65
 
64
- [RubyGems](http://rubygems.org/gems/rouster)
65
- [![Gem Version](https://badge.fury.io/rb/rouster.png)](http://badge.fury.io/rb/rouster)
66
-
67
66
  ```sh
68
67
  gem install rouster
69
68
  ```
data/Rakefile CHANGED
@@ -1,11 +1,14 @@
1
1
  require sprintf('%s/%s', File.dirname(File.expand_path(__FILE__)), 'path_helper')
2
2
  require 'rubygems'
3
3
  require 'rake/testtask'
4
+ require 'reek/rake/task'
4
5
 
5
- task :buildgem do
6
+ desc 'build the gem'
7
+ task :build do
6
8
  sh 'gem build rouster.gemspec'
7
9
  end
8
10
 
11
+ desc 'cleanup environment'
9
12
  task :clean do
10
13
  sh 'rm /tmp/rouster-*'
11
14
  end
@@ -14,56 +17,67 @@ task :default do
14
17
  sh 'ruby test/basic.rb'
15
18
  end
16
19
 
20
+ desc 'run the example demo'
17
21
  task :demo do
18
22
  sh 'ruby examples/demo.rb'
19
23
  end
20
24
 
25
+ desc 'rdoc generation'
21
26
  task :doc do
22
27
  sh 'rdoc --line-numbers lib/*'
23
28
  end
24
29
 
25
30
  task :examples do
26
31
  Dir['examples/**/*.rb'].each do |example|
27
- sh "ruby #{example}"
28
- end
32
+ sh "ruby #{example}"
33
+ end
29
34
  end
30
35
 
36
+ desc 'shortcut to vagrant destroy -f'
31
37
  task :vdestroy do
32
38
  sh 'vagrant destroy -f'
33
39
  end
34
40
 
35
- task :reek do
36
- sh 'reek lib/**/*.rb'
41
+ Reek::Rake::Task.new do |t|
42
+ t.config_file = sprintf('%s/.reek', File.dirname(__FILE__))
43
+ #t.source_files = FileList.new('lib/**/*.rb', 'plugins/**/*.rb')
44
+ t.source_files = FileList.new('lib/**/*.rb')
45
+ t.reek_opts = '--no-wiki-links'
46
+ t.fail_on_error = false
47
+ t.verbose = true
37
48
  end
38
49
 
39
- Rake::TestTask.new(:test => :vdestroy) do |t|
40
- t.libs << 'lib'
41
- t.test_files = FileList['test/**/test_*.rb']
42
- t.verbose = true
43
- end
50
+ namespace :test do
51
+ Rake::TestTask.new(:all => :vdestroy) do |t|
52
+ t.description = 'run all tests'
53
+ t.libs << 'lib'
54
+ t.test_files = FileList['test/**/test_*.rb']
55
+ end
44
56
 
45
- Rake::TestTask.new do |t|
46
- t.name = 'unit'
47
- t.libs << 'lib'
48
- t.test_files = FileList['test/unit/**/test_*.rb']
49
- t.verbose = true
50
- end
57
+ Rake::TestTask.new do |t|
58
+ t.name = 'unit'
59
+ t.description = 'run unit tests'
60
+ t.libs << 'lib'
61
+ t.test_files = FileList['test/unit/**/test_*.rb']
62
+ end
51
63
 
52
- Rake::TestTask.new(:functional => :vdestroy) do |t|
53
- t.libs << 'lib'
54
- t.test_files = FileList['test/functional/**/test_*.rb']
55
- t.verbose = true
56
- end
64
+ Rake::TestTask.new(:functional => :vdestroy) do |t|
65
+ t.description = 'run functional tests'
66
+ t.libs << 'lib'
67
+ t.test_files = FileList['test/functional/**/test_*.rb']
68
+ end
57
69
 
58
- Rake::TestTask.new(:deltas => :vdestroy) do |t|
59
- t.libs << 'lib'
60
- t.test_files = FileList['test/functional/deltas/test_*.rb']
61
- t.verbose = true
62
- end
70
+ Rake::TestTask.new(:deltas => :vdestroy) do |t|
71
+ t.description = 'run delta tests'
72
+ t.libs << 'lib'
73
+ t.test_files = FileList['test/functional/deltas/test_*.rb']
74
+ end
63
75
 
64
- Rake::TestTask.new do |t|
65
- t.name = 'puppet'
66
- t.libs << 'lib'
67
- t.test_files = FileList['test/puppet/test*.rb']
68
- t.verbose = true
76
+ Rake::TestTask.new do |t|
77
+ t.name = 'puppet'
78
+ t.description = 'run puppet tests'
79
+ t.libs << 'lib'
80
+ t.test_files = FileList['test/puppet/test*.rb']
81
+ t.verbose = true
82
+ end
69
83
  end
data/lib/rouster.rb CHANGED
@@ -12,7 +12,7 @@ require 'rouster/vagrant'
12
12
  class Rouster
13
13
 
14
14
  # sporadically updated version number
15
- VERSION = 0.68
15
+ VERSION = 0.69
16
16
 
17
17
  # custom exceptions -- what else do we want them to include/do?
18
18
  class ArgumentError < StandardError; end # thrown by methods that take parameters from users
@@ -144,22 +144,33 @@ class Rouster
144
144
 
145
145
  res = Hash.new()
146
146
 
147
- raw = self.run('cat /etc/group')
147
+ {
148
+ :file => self.run('cat /etc/group'),
149
+ :dynamic => self.run('getent group', [0,127]),
150
+ }.each_pair do |source, raw|
148
151
 
149
- raw.split("\n").each do |line|
150
- next unless line.match(/\w+:\w+:\w+/)
152
+ raw.split("\n").each do |line|
153
+ next unless line.match(/\w+:\w+:\w+/)
154
+
155
+ data = line.split(':')
151
156
 
152
- data = line.split(':')
157
+ group = data[0]
158
+ gid = data[2]
153
159
 
154
- group = data[0]
155
- gid = data[2]
160
+ # this works in some cases, deep functionality picks up the others
161
+ users = data[3].nil? ? ['NONE'] : data[3].split(',')
156
162
 
157
- # this works in some cases, deep functionality picks up the others
158
- users = data[3].nil? ? ['NONE'] : data[3].split(',')
163
+ if res.has_key?(group)
164
+ @logger.debug(sprintf('for[%s] old GID[%s] new GID[%s]', group, gid, res[group][:users])) unless gid.eql?(res[group][:gid])
165
+ @logger.debug(sprintf('for[%s] old users[%s] new users[%s]', group, users)) unless users.eql?(res[group][:users])
166
+ end
167
+
168
+ res[group] = Hash.new() # i miss autovivification
169
+ res[group][:gid] = gid
170
+ res[group][:users] = users
171
+ res[group][:source] = source
172
+ end
159
173
 
160
- res[group] = Hash.new() # i miss autovivification
161
- res[group][:gid] = gid
162
- res[group][:users] = users
163
174
  end
164
175
 
165
176
  groups = res
@@ -755,20 +766,39 @@ class Rouster
755
766
 
756
767
  res = Hash.new()
757
768
 
758
- raw = self.run('cat /etc/passwd')
769
+ {
770
+ :file => self.run('cat /etc/passwd'),
771
+ :dynamic => self.run('getent passwd', [0,127]),
772
+ }.each do |source, raw|
759
773
 
760
- raw.split("\n").each do |line|
761
- next if line.match(/(\w+)(?::\w+){3,}/).nil?
762
-
763
- user = $1
764
- data = line.split(':')
774
+ raw.split("\n").each do |line|
775
+ next if line.match(/(\w+)(?::\w+){3,}/).nil?
776
+
777
+ user = $1
778
+ data = line.split(':')
779
+
780
+ shell = data[-1]
781
+ home = data[-2]
782
+ home_exists = self.is_dir?(data[-2])
783
+ uid = data[2]
784
+ gid = data[3]
785
+
786
+ if res.has_key?(user)
787
+ @logger.info(sprintf('for[%s] old shell[%s], new shell[%s]', res[user][:shell], shell)) unless shell.eql?(res[user][:shell])
788
+ @logger.info(sprintf('for[%s] old home[%s], new home[%s]', res[user][:home], home)) unless home.eql?(res[user][:home])
789
+ @logger.info(sprintf('for[%s] old home_exists[%s], new home_exists[%s]', res[user][:home_exists], home_exists)) unless home_exists.eql?(res[user][:home_exists])
790
+ @logger.info(sprintf('for[%s] old UID[%s], new UID[%s]', res[user][:uid], uid)) unless uid.eql?(res[user][:uid])
791
+ @logger.info(sprintf('for[%s] old GID[%s], new GID[%s]', res[user][:gid], gid)) unless gid.eql?(res[user][:gid])
792
+ end
765
793
 
766
- res[user] = Hash.new()
767
- res[user][:shell] = data[-1]
768
- res[user][:home] = data[-2]
769
- res[user][:home_exists] = self.is_dir?(data[-2])
770
- res[user][:uid] = data[2]
771
- res[user][:gid] = data[3]
794
+ res[user] = Hash.new()
795
+ res[user][:shell] = shell
796
+ res[user][:home] = home
797
+ res[user][:home_exists] = home_exists
798
+ res[user][:uid] = uid
799
+ res[user][:gid] = gid
800
+ res[user][:source] = source
801
+ end
772
802
  end
773
803
 
774
804
  if cache
@@ -48,7 +48,7 @@ class Rouster
48
48
  @logger.info('up()')
49
49
 
50
50
  # don't like putting this here, may be refactored
51
- if self.is_passthrough?
51
+ if self.is_passthrough?
52
52
  if (self.passthrough[:type].equal?(:aws) or self.passthrough[:type].equal?(:raiden))
53
53
  self.aws_up()
54
54
  elsif (self.passthrough[:type].equal?(:openstack))
@@ -87,7 +87,7 @@ class Rouster
87
87
  @logger.info('destroy()')
88
88
 
89
89
  # don't like putting this here, may be refactored
90
- if self.is_passthrough?
90
+ if self.is_passthrough?
91
91
  if (self.passthrough[:type].equal?(:aws) or self.passthrough[:type].equal?(:raiden))
92
92
  self.aws_destroy()
93
93
  elsif self.is_passthrough? and self.passthrough[:type].equal?(:openstack)
@@ -121,7 +121,7 @@ class Rouster
121
121
 
122
122
  # don't like putting this here, may be refactored
123
123
  @logger.info('status()')
124
- if self.is_passthrough?
124
+ if self.is_passthrough?
125
125
  if (self.passthrough[:type].equal?(:aws) or self.passthrough[:type].equal?(:raiden))
126
126
  status = self.aws_status()
127
127
  elsif self.passthrough[:type].equal?(:openstack)
@@ -167,7 +167,7 @@ class Rouster
167
167
  def reload(no_provision = true)
168
168
 
169
169
  if self.is_passthrough?
170
- @logger.warn(sprintf('calling [vagrant reload] on a passthrough host is a noop', face))
170
+ @logger.warn('calling [vagrant reload] on a passthrough host is a noop')
171
171
  return nil
172
172
  end
173
173
 
@@ -326,6 +326,25 @@ class TestParseLsString < Test::Unit::TestCase
326
326
  assert_equal(expectation, res)
327
327
  end
328
328
 
329
+ def test_uid_forced
330
+ uid = 501
331
+ str = "-rw-r--r-- 1 #{uid} root 0 Jun 13 09:35 foo\n"
332
+
333
+ res = @app.exposed_parse_ls_string(str)
334
+
335
+ assert_equal('501', res[:owner])
336
+
337
+ end
338
+
339
+ def test_gid_forced
340
+ gid = 10
341
+ str = "-rw-r--r-- 1 vagrant #{gid} 0 Jun 13 09:35 foo\n"
342
+
343
+ res = @app.exposed_parse_ls_string(str)
344
+
345
+ assert_equal('10', res[:group])
346
+ end
347
+
329
348
  def test_dir_detection
330
349
  dir_str = "drwxrwxrwt 5 root root 4096 May 28 00:26 /tmp/\n"
331
350
  file_str = "-rw-r--r-- 1 root root 906 Oct 2 2012 grub.conf\n"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouster
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.68'
4
+ version: '0.69'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Conor Horan-Kates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-30 00:00:00.000000000 Z
11
+ date: 2017-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -116,6 +116,8 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - .gitignore
119
+ - .reek
120
+ - .travis.yml
119
121
  - Gemfile
120
122
  - Gemfile.lock
121
123
  - LICENSE