smartos-manager 1.2.5 → 1.3.0

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: 137ad132fca39b6b0324020fa234dfe5f6ce27e0
4
- data.tar.gz: 14abd66feaf04836cae4d34446776b82b8e0a399
3
+ metadata.gz: 08f6ffdaa4b9f3b88435b5a74308f1cba0a2e4ee
4
+ data.tar.gz: 61baf7480b232b6bfbbb01d7c8171a76dc991733
5
5
  SHA512:
6
- metadata.gz: c8276fb6b3155b61d3f5776a4a97a4500c261e5954668ad57db7ad0539130949d31501e3200dfd731255a03d0a369b7a12e5f285a7d5d43fb2f60da48e99d7ea
7
- data.tar.gz: 21dc78194fe6fa6334016ce4dbb5ff798e4d543aeec808fe91a2697939af0c72afe0a2137fcb6a5f9d1802ba39fabdb4f28a39aba9362fdda84450538b7441df
6
+ metadata.gz: e0bfa73b194c133bf34bb9ad9daa21119361f4a2a03e139de1674cc6e0662bf1b75c5d1376f3db7cdbb0bbd5f1ce9eb2faa9d5d5ca671d67af678ecf4553587d
7
+ data.tar.gz: c60ae132875b71575055084541742fee98bf5519f1b33b3d4a6db16936f6b966f0445eb42562c26cabed1dd9e27a7bf44aff50d726201968399c4a5be00ae41e
@@ -8,7 +8,7 @@ class ColorPicker
8
8
 
9
9
  def initialize
10
10
  @colors = {}
11
- @available_colors = %w(green yellow cyan magenta blue red)
11
+ @available_colors = %w(green yellow cyan magenta blue red gray white)
12
12
  end
13
13
 
14
14
  def get(str)
@@ -18,6 +18,24 @@ class ColorPicker
18
18
  end
19
19
 
20
20
  class AppCLI < Thor
21
+
22
+ desc "list_images", "List images available"
23
+ def list_images
24
+ registry = HostRegistry.new('smartos_hosts.toml')
25
+ ret = registry.list_images()
26
+
27
+ rev_colors = ColorPicker.new
28
+ p_img_list("UUID", "Name", "Version", "OS")
29
+
30
+ ret.each do |host, images|
31
+ puts "\n#{host.name} - #{host.address}"
32
+ images.each do |img|
33
+ # color = rev_colors.get(img.uuid)
34
+ p_img_list( img.uuid, img.name, img.version, img.os)
35
+ end
36
+ end
37
+ end
38
+
21
39
  desc "list", "List all vms"
22
40
  def list
23
41
  registry = HostRegistry.new('smartos_hosts.toml')
@@ -84,6 +102,11 @@ class AppCLI < Thor
84
102
  str
85
103
  end
86
104
 
105
+ # (uuid name version os)
106
+ def p_img_list(uuid, name, version, os)
107
+ puts " [ #{uuid.ljust(37)}] #{name.ljust(30)} #{version.ljust(6)} #{os}"
108
+ end
109
+
87
110
  def p_vm_list(size, name, type, uuid, state, admin_ip, disk_label, *user_columns)
88
111
  tmp = user_columns.map{|val| "[ #{format_generic(val).to_s.ljust(15).cyan} ]" }.join('')
89
112
 
@@ -4,6 +4,7 @@ require 'net/ssh/multi'
4
4
  require 'net/ssh/gateway'
5
5
  require 'toml'
6
6
  require 'size_units'
7
+ require 'json'
7
8
 
8
9
 
9
10
  class SSHHost
@@ -63,6 +64,18 @@ class VirtualMachine
63
64
  end
64
65
  end
65
66
 
67
+
68
+ class Image
69
+ attr_reader :uuid, :name, :version, :os
70
+
71
+ def initialize(data = {})
72
+ @uuid = data.delete('uuid')
73
+ @name = data.delete('name')
74
+ @version = data.delete('version')
75
+ @os = data.delete('os')
76
+ end
77
+ end
78
+
66
79
  class HostRegistry
67
80
  attr_reader :user_columns
68
81
 
@@ -144,6 +157,26 @@ class HostRegistry
144
157
 
145
158
  end
146
159
 
160
+
161
+ def list_images
162
+ ret = {}
163
+
164
+ columns = %w(uuid name version os)
165
+
166
+ images = run_on_all("imgadm list -j")
167
+ images.each do |host, data|
168
+
169
+ json = JSON.parse(data)
170
+
171
+ ret[host] = json.map do |img_data|
172
+ Image.new( img_data['manifest'] )
173
+ end
174
+ end
175
+
176
+ ret
177
+ end
178
+
179
+
147
180
  def diag
148
181
  ret = {}
149
182
 
@@ -1,3 +1,3 @@
1
1
  module SmartosManager
2
- VERSION = "1.2.5"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartos-manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Ammous
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toml-rb