vpsadmin-client 3.0.0.master.20220121.pre.0.b5a81113 → 3.0.0.master.20221118.pre.0.99dcc6de

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
  SHA256:
3
- metadata.gz: ce5635948bc213752357b413d4e92f8b7f2089306b9a3e02194b76f44f3617c3
4
- data.tar.gz: 4304acd24bbecf0389a954d61ce680fece999e1128651f84e75306cf61889195
3
+ metadata.gz: be8e44144778361fe0bd564030b80f66efcdf734c6b81a1ae13c816c5d6ad853
4
+ data.tar.gz: e6e0ed82d681b2c7f980430a4f141e687e867784a9a941ae66a6901ce6b1e1c6
5
5
  SHA512:
6
- metadata.gz: b3c0c9029f6d14639adb9f901f4b1cc133d1518360be85d8e506e8aa285fa5a1b3e8be5cfa475ae87d8147fadf78dd55bd168593e945f59c1dc237412f714705
7
- data.tar.gz: 35e2c3b730bf246d1a14c0a6a7cdf77c08910efa4d460aeb878a52a9d4a0210058a7450c556c7e30a08199b011464a45b17b155b13d965c2da057e14a3878309
6
+ metadata.gz: 9f5ae2ef0e02b51ada7bc284457f3fb9ffadadcc0636a42ef8c82465642d2bd5c616b333f40769ed49d4ce4ac38db7f16a884ccf62e0abc33f9194e72db1930e
7
+ data.tar.gz: fb68a389dc4602e2891d0b44d3e03556ca523cb2e647094fbedb1d0a069bdb16fee0508deaa7037ed25c708c7b2483a8b3b3d1a722b65cdc0ed9d14988d412f5
@@ -1,15 +1,15 @@
1
1
  require 'curses'
2
2
 
3
3
  module VpsAdmin::CLI::Commands
4
- class IpTrafficTop < BackupDataset
4
+ class NetworkTop < HaveAPI::CLI::Command
5
5
  include Curses
6
6
 
7
7
  REFRESH_RATE = 10
8
- FILTERS = %i(limit ip_address ip_version environment location network ip_range node vps)
8
+ FILTERS = %i(limit user environment location node vps network_interface)
9
9
 
10
- cmd :ip_traffic, :top
10
+ cmd :network, :top
11
11
  args ''
12
- desc 'Live IP traffic monitor'
12
+ desc 'Live network traffic monitor'
13
13
 
14
14
  def options(opts)
15
15
  @opts = {
@@ -24,24 +24,8 @@ module VpsAdmin::CLI::Commands
24
24
  @opts[:limit] = v
25
25
  end
26
26
 
27
- opts.on('--ip-address ADDR', 'ADDR or ID of IP addresses to monitor') do |v|
28
- id = ip_address_id(v)
29
-
30
- if id
31
- @opts[:ip_address] = id
32
-
33
- else
34
- warn "IP address '#{v}' not found"
35
- exit(1)
36
- end
37
- end
38
-
39
- opts.on('--ip-version VER', [4, 6], 'Filter IP addresses by version') do |v|
40
- @opts[:ip_version] = v
41
- end
42
-
43
- (FILTERS - %i(limit ip_address ip_version)).each do |f|
44
- opts.on("--#{f.to_s.gsub(/_/, '-')} ID", Integer, "Filter IP addresses by #{f}") do |v|
27
+ (FILTERS - %i(limit)).each do |f|
28
+ opts.on("--#{f.to_s.gsub(/_/, '-')} ID", Integer, "Filter network interfaces by #{f}") do |v|
45
29
  @opts[f] = v
46
30
  end
47
31
  end
@@ -49,12 +33,13 @@ module VpsAdmin::CLI::Commands
49
33
 
50
34
  def exec(args)
51
35
  if @global_opts[:list_output]
52
- exclude = %i(id ip_address user updated_at delta)
36
+ exclude = %i(id network_interface updated_at delta)
53
37
 
54
- @api.ip_traffic_monitor.actions[:index].params.each_key do |name|
38
+ @api.network_interface_monitor.actions[:index].params.each_key do |name|
55
39
  next if exclude.include?(name)
56
40
  puts name
57
41
  end
42
+
58
43
  exit
59
44
  end
60
45
 
@@ -113,9 +98,8 @@ module VpsAdmin::CLI::Commands
113
98
  def set_global_opts
114
99
  if @global_opts[:output]
115
100
  @params = @global_opts[:output].split(',').map(&:to_sym)
116
-
117
101
  else
118
- @params = %i(bytes_in bytes_out bytes)
102
+ @params = %i(bytes bytes_in bytes_out packets packets_in packets_out)
119
103
  end
120
104
 
121
105
  if @global_opts[:sort]
@@ -158,7 +142,7 @@ module VpsAdmin::CLI::Commands
158
142
  params = {
159
143
  limit: limit > 0 ? limit : 25,
160
144
  order: "#{@sort_desc ? '-' : ''}#{@sort_param}",
161
- meta: {includes: 'ip_address__network_interface'}
145
+ meta: {includes: 'network_interface'},
162
146
  }
163
147
 
164
148
  FILTERS.each do |f|
@@ -167,7 +151,7 @@ module VpsAdmin::CLI::Commands
167
151
  params[f] = @opts[f]
168
152
  end
169
153
 
170
- @data = @api.ip_traffic_monitor.list(params)
154
+ @data = @api.network_interface_monitor.list(params)
171
155
  end
172
156
 
173
157
  def render(t, refresh)
@@ -177,7 +161,7 @@ module VpsAdmin::CLI::Commands
177
161
  end
178
162
 
179
163
  setpos(0, 0)
180
- addstr("#{File.basename($0)} ip_traffic top - #{t.strftime('%H:%M:%S')}, ")
164
+ addstr("#{File.basename($0)} network top - #{t.strftime('%H:%M:%S')}, ")
181
165
  addstr("next update at #{(t + REFRESH_RATE).strftime('%H:%M:%S')}")
182
166
 
183
167
  attron(color_pair(1))
@@ -202,12 +186,12 @@ module VpsAdmin::CLI::Commands
202
186
 
203
187
  def header
204
188
  unless @header
205
- fmt = (['%-30s', '%6s'] + @columns.map { |c| "%#{c[:width]}s" }).join(' ')
189
+ fmt = (['%8s', '%-15s'] + @columns.map { |c| "%#{c[:width]}s" }).join(' ')
206
190
 
207
191
  @header = sprintf(
208
192
  fmt,
209
- 'IP Address',
210
193
  'VPS',
194
+ 'Interface',
211
195
  *@columns.map { |c| c[:title] },
212
196
  )
213
197
 
@@ -219,9 +203,9 @@ module VpsAdmin::CLI::Commands
219
203
 
220
204
  def print_row(data)
221
205
  addstr(sprintf(
222
- '%-30s %6s',
223
- data.ip_address.addr,
224
- data.ip_address.network_interface.vps_id
206
+ '%8s %-15s',
207
+ data.network_interface.vps_id,
208
+ data.network_interface.name,
225
209
  ))
226
210
 
227
211
  @columns.each do |c|
@@ -234,7 +218,7 @@ module VpsAdmin::CLI::Commands
234
218
  end
235
219
 
236
220
  def stats
237
- fields = %i(packets bytes public_bytes private_bytes)
221
+ fields = %i(bytes packets)
238
222
  stats = {}
239
223
  delta_sum = 0
240
224
 
@@ -263,17 +247,15 @@ module VpsAdmin::CLI::Commands
263
247
  setpos(lines-5, 0)
264
248
  addstr('─' * cols)
265
249
 
266
- fmt = '%10s %10s %10s %14s %14s'
250
+ fmt = '%10s %10s %10s'
267
251
  unit = @opts[:unit].to_s.capitalize
268
252
 
269
253
  setpos(lines-4, 0)
270
254
  addstr(sprintf(
271
255
  fmt,
272
256
  '',
273
- 'Packets/s',
274
257
  "#{unit}/s",
275
- "Public#{unit}/s",
276
- "Private#{unit}/s"
258
+ 'Packets/s',
277
259
  ))
278
260
 
279
261
  setpos(lines-3, 0)
@@ -7,8 +7,8 @@ module VpsAdmin::CLI
7
7
  class DownloadError < StandardError ; end
8
8
 
9
9
  class StreamDownloader
10
- def self.download(*args)
11
- new(*args)
10
+ def self.download(*args, **kwargs)
11
+ new(*args, **kwargs)
12
12
  end
13
13
 
14
14
  def initialize(api, dl, io, progress: STDOUT, position: 0, max_rate: nil,
data/lib/vpsadmin/cli.rb CHANGED
@@ -22,4 +22,4 @@ require 'vpsadmin/cli/commands/snapshot_download'
22
22
  require 'vpsadmin/cli/commands/snapshot_send'
23
23
  require 'vpsadmin/cli/commands/backup_dataset'
24
24
  require 'vpsadmin/cli/commands/backup_vps'
25
- require 'vpsadmin/cli/commands/ip_traffic_top'
25
+ require 'vpsadmin/cli/commands/network_top'
@@ -1,5 +1,5 @@
1
1
  module VpsAdmin
2
2
  module Client
3
- VERSION = '3.0.0.master.20220121-0.b5a81113'
3
+ VERSION = '3.0.0.master.20221118-0.99dcc6de'
4
4
  end
5
5
  end
data/shell.nix CHANGED
@@ -17,7 +17,6 @@ in stdenv.mkDerivation rec {
17
17
  mkdir -p /tmp/dev-ruby-gems
18
18
  export GEM_HOME="/tmp/dev-ruby-gems"
19
19
  export GEM_PATH="$GEM_HOME:$PWD/lib"
20
- export PATH="$GEM_HOME/bin:$PATH"
21
20
 
22
21
  BUNDLE="$GEM_HOME/bin/bundle"
23
22
 
@@ -29,5 +28,6 @@ in stdenv.mkDerivation rec {
29
28
  $BUNDLE install
30
29
 
31
30
  export RUBYOPT=-rbundler/setup
31
+ export PATH="$(ruby -e 'puts Gem.bindir'):$PATH"
32
32
  '';
33
33
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpsadmin-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.master.20220121.pre.0.b5a81113
4
+ version: 3.0.0.master.20221118.pre.0.99dcc6de
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jakub Skokan
@@ -100,7 +100,7 @@ files:
100
100
  - lib/vpsadmin/cli/commands/backup_dataset.rb
101
101
  - lib/vpsadmin/cli/commands/backup_vps.rb
102
102
  - lib/vpsadmin/cli/commands/base_download.rb
103
- - lib/vpsadmin/cli/commands/ip_traffic_top.rb
103
+ - lib/vpsadmin/cli/commands/network_top.rb
104
104
  - lib/vpsadmin/cli/commands/snapshot_download.rb
105
105
  - lib/vpsadmin/cli/commands/snapshot_send.rb
106
106
  - lib/vpsadmin/cli/commands/vps_migrate_many.rb