netid-tools 0.5.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source "http://rubygems.org"
3
3
  gem "nokogiri"
4
4
  gem "colored"
5
5
  gem "net-ssh"
6
+ gem 'terminal-table'
6
7
  group :development do
7
8
  gem "shoulda", ">= 0"
8
9
  gem "rdoc", "~> 3.12"
data/README.md CHANGED
@@ -143,6 +143,14 @@ The NetID you want to check
143
143
  Version History
144
144
  ===============
145
145
 
146
+ ## 0.5.4
147
+
148
+ * Switch table formatting on ua_check binary
149
+
150
+ ## 0.5.3
151
+
152
+ * Remove debug function
153
+
146
154
  ## 0.5.2
147
155
 
148
156
  * Expand cluster paths if available in quota output
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.4
data/bin/ua_check CHANGED
@@ -3,6 +3,7 @@ require 'net/ssh'
3
3
  require 'colored'
4
4
  require 'netid-tools'
5
5
  require 'optparse'
6
+ require 'terminal-table'
6
7
 
7
8
  options = {}
8
9
  OptionParser.new do |opts|
@@ -78,9 +79,18 @@ user.each do |netid|
78
79
 
79
80
  unless options[:concise]
80
81
  puts "\n"
81
- checkr.check_quota.each do |l|
82
- puts l.join(" ")
82
+ raw_quota = checkr.check_quota
83
+ headers = raw_quota.rotate!.pop
84
+ table = Terminal::Table.new do |t|
85
+ t.headings = headers
86
+ raw_quota.each do |line|
87
+ if line[1].to_f > line[2].to_f
88
+ line[1] = "#{line[1]} (Over Quota!)"
89
+ end
90
+ t << line
91
+ end
83
92
  end
93
+ puts table
84
94
  end
85
95
  puts "\n"
86
96
  end
data/lib/netid-tools.rb CHANGED
@@ -47,7 +47,7 @@ class Netid
47
47
  if /no such user/i =~ run_remote_command("id #{netid}",host)
48
48
  result = nil
49
49
  else
50
- result = run_remote_command("ps -F --user=#{netid}",host).lines
50
+ result = run_remote_command("ps -F --user=#{netid}",host).lines.map{|l| l.chomp}
51
51
  result = remove_extra_processes(result)
52
52
  end
53
53
  if result.nil? || result.count == 1
@@ -119,7 +119,6 @@ class Netid
119
119
  asking_cluster_string = line.first
120
120
 
121
121
  search = clusters.find_index do |c|
122
- puts "searching for #{asking_cluster_string} in #{c}"
123
122
  c =~ /#{asking_cluster_string}/
124
123
  end
125
124
 
@@ -132,7 +131,7 @@ class Netid
132
131
  if user_clusters
133
132
  user_clusters
134
133
  else
135
- command = "gpw -D | sed '1d' | sed 'N;$!P;$!D;$d' | sort | uniq"
134
+ command = "gpw -D #{netid} | sed '1d' | sed 'N;$!P;$!D;$d' | sort | uniq"
136
135
  run_remote_command(command,single_host).split("\n").map do |line|
137
136
  line.chomp
138
137
  end
@@ -1,14 +1,6 @@
1
1
  module SystemConnect
2
2
 
3
- # def initialize_ssh_connections
4
- # connections = []
5
- # systems.each do |host|
6
- # puts "Attempting connection for #{system_user}@#{host}"
7
- # connections << SystemSSH.new(host,connect(host, system_user))
8
- # puts "Connection successful for #{host}"
9
- # end
10
- # @connections = connections
11
- # end
3
+ private
12
4
 
13
5
  def connect(host,user)
14
6
  Net::SSH.start(host,user,{auth_methods: %w(publickey)})
@@ -17,21 +9,24 @@ module SystemConnect
17
9
  def run_remote_command(command, host)
18
10
  connection = find_connection_for_host(host)
19
11
  connection.exec!(command)
20
- # if connection
21
- # connection.exec(command) do |ch, stream, data|
22
- # unless stream == :stderr
23
- # puts data
24
- # end
25
- # end
26
- # else
27
- # puts "No connection found for host: #{host}"
28
- # end
29
12
  end
30
13
 
31
14
  def loop
32
15
  connection.loop
33
16
  end
34
17
 
18
+ def queue_multithreaded_command(command,host)
19
+ if connection
20
+ connection.exec(command) do |ch, stream, data|
21
+ unless stream == :stderr
22
+ puts data
23
+ end
24
+ end
25
+ else
26
+ puts "No connection found for host: #{host}"
27
+ end
28
+ end
29
+
35
30
  def find_connection_for_host(host)
36
31
  @connections ||= []
37
32
  unless @connections.select{ |conn| conn.hostname == host}.empty?
data/netid-tools.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "netid-tools"
8
- s.version = "0.5.2"
8
+ s.version = "0.5.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nikky Southerland"]
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
45
45
  s.add_runtime_dependency(%q<colored>, [">= 0"])
46
46
  s.add_runtime_dependency(%q<net-ssh>, [">= 0"])
47
+ s.add_runtime_dependency(%q<terminal-table>, [">= 0"])
47
48
  s.add_development_dependency(%q<shoulda>, [">= 0"])
48
49
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
49
50
  s.add_development_dependency(%q<bundler>, [">= 0"])
@@ -55,6 +56,7 @@ Gem::Specification.new do |s|
55
56
  s.add_dependency(%q<nokogiri>, [">= 0"])
56
57
  s.add_dependency(%q<colored>, [">= 0"])
57
58
  s.add_dependency(%q<net-ssh>, [">= 0"])
59
+ s.add_dependency(%q<terminal-table>, [">= 0"])
58
60
  s.add_dependency(%q<shoulda>, [">= 0"])
59
61
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
60
62
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -67,6 +69,7 @@ Gem::Specification.new do |s|
67
69
  s.add_dependency(%q<nokogiri>, [">= 0"])
68
70
  s.add_dependency(%q<colored>, [">= 0"])
69
71
  s.add_dependency(%q<net-ssh>, [">= 0"])
72
+ s.add_dependency(%q<terminal-table>, [">= 0"])
70
73
  s.add_dependency(%q<shoulda>, [">= 0"])
71
74
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
72
75
  s.add_dependency(%q<bundler>, [">= 0"])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netid-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: terminal-table
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  - !ruby/object:Gem::Dependency
63
79
  name: shoulda
64
80
  requirement: !ruby/object:Gem::Requirement
@@ -207,7 +223,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
207
223
  version: '0'
208
224
  segments:
209
225
  - 0
210
- hash: -1308523131387062882
226
+ hash: 2601252175228595680
211
227
  required_rubygems_version: !ruby/object:Gem::Requirement
212
228
  none: false
213
229
  requirements: