smartos-manager 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smartos-manager/cli.rb +17 -1
- data/lib/smartos-manager/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b04069d628efefa65d69c71179bf5637d3de581f
|
4
|
+
data.tar.gz: 60457d3566a9a510afd5fbe107def4dbbaea4baf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ce603d565b809a4386e542a355437780e2ed1afd1ecaf0be5e14b4ca1fca165aa7f0028953bd5a3508b86586696060c3560a6a93d2e8d5ee6b306ea284b4c1
|
7
|
+
data.tar.gz: 903447464addafc64449bbc87148e773095bf9620fdb408f852db5e15337905bcd0950ce23c8b567d3f96a79099ea8f0f9fd22046df58b9e777dc50d011a1916
|
data/lib/smartos-manager/cli.rb
CHANGED
@@ -3,12 +3,28 @@ require File.expand_path('../core', __FILE__)
|
|
3
3
|
require 'thor'
|
4
4
|
require 'colored'
|
5
5
|
|
6
|
+
|
7
|
+
class ColorPicker
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@colors = {}
|
11
|
+
@available_colors = %w(green yellow red cyan magenta blue)
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(str)
|
15
|
+
@colors[str] ||= @available_colors.shift()
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
6
20
|
class AppCLI < Thor
|
7
21
|
desc "list", "List all vms"
|
8
22
|
def list
|
9
23
|
registry = HostRegistry.new('smartos_hosts.toml')
|
10
24
|
ret = registry.list_vms()
|
11
25
|
|
26
|
+
rev_colors = ColorPicker.new
|
27
|
+
|
12
28
|
sysinfos = registry.sysinfo()
|
13
29
|
|
14
30
|
user_columns = registry.user_columns.keys.map{|s| humanize(s) }
|
@@ -23,7 +39,7 @@ class AppCLI < Thor
|
|
23
39
|
avail = (mem - vm_memory) - (20 * mem/100.0)
|
24
40
|
|
25
41
|
rev = sysinfos[host][:smartos_version]
|
26
|
-
puts "\n#{host.name} [SmartOS: #{rev.
|
42
|
+
puts "\n#{host.name} [SmartOS: #{rev.send(rev_colors.get(rev))}] (#{host.address}) (#{vms.size} vms) (Total RAM: #{mem.human_size(1).green}, Avail: #{avail.human_size(1).magenta})"
|
27
43
|
vms.each do |vm|
|
28
44
|
user_columns = registry.user_columns.values.map{|key| vm[key] }
|
29
45
|
p_vm_list(vm.memory.human_size(1), vm.name, vm.type, vm.uuid, printable_state(vm.state), vm.admin_ip, *user_columns)
|