morpheus-cli 3.3.2.6.1 → 3.3.2.6.2

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: a1b8cab856aa48299dcdee9d248286e84e82d98d
4
- data.tar.gz: dcbedabff74562525087fe4412607288915bab98
3
+ metadata.gz: 03a7254c914049f6b4127d9ec18d0dbf6a0f1ad4
4
+ data.tar.gz: 28d72f20987f22f85ed34182cf42196d1d0c3427
5
5
  SHA512:
6
- metadata.gz: 69bbcebda49f660d9560374d18b12824035e519927a259293e72edb38442a1a9d00e4ea7c90a0af7e47d161d302aa490bfa960d6dd55b09fa4583aa46a543667
7
- data.tar.gz: a40841aa668a7721989aefa9f9b9d49bb0b033d4eef4acff9a7363e143a5bd1df5e805eb3456c4effac78930c286880da8b22aea5ef509bec1716232fc577605
6
+ metadata.gz: 2296878eb4b01319eb354818bc36b98e47a96494c624a9bce32c136f21e69c31a20a9b1a73e37527f0fe675515f0e6ce9e0f265c652d5ecb1b11a24e02f564cf
7
+ data.tar.gz: 00b9bc18a789978e4e765835d6cd163de81a69b03105cfbfc6a4f90516a4898ffaf552423b949afd2375f04172a50072b60779bc9aa0d0534dae2a0b7cb0f0ae
@@ -283,8 +283,8 @@ class Morpheus::APIClient
283
283
  Morpheus::LibraryContainerTemplatesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
284
284
  end
285
285
 
286
- def library_packages
287
- Morpheus::LibraryPackagesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
286
+ def packages
287
+ Morpheus::PackagesInterface.new(@access_token, @refresh_token, @expires_at, @base_url)
288
288
  end
289
289
 
290
290
  end
@@ -0,0 +1,92 @@
1
+ require 'morpheus/api/api_client'
2
+
3
+ class Morpheus::PackagesInterface < Morpheus::APIClient
4
+ def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
5
+ @access_token = access_token
6
+ @refresh_token = refresh_token
7
+ @base_url = base_url
8
+ @expires_at = expires_at
9
+ end
10
+
11
+ # def get(id)
12
+ # raise "#{self.class}.get() passed a blank id!" if id.to_s == ''
13
+ # url = "#{@base_url}/api/packages/#{id}"
14
+ # headers = { params: {}, authorization: "Bearer #{@access_token}" }
15
+ # opts = {method: :get, url: url, headers: headers}
16
+ # execute(opts)
17
+ # end
18
+
19
+ def list(params={})
20
+ url = "#{@base_url}/api/packages"
21
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
22
+ headers[:params].merge!(params)
23
+ opts = {method: :get, url: url, headers: headers}
24
+ execute(opts)
25
+ end
26
+
27
+ def search(params={})
28
+ url = "#{@base_url}/api/packages/search"
29
+ headers = { params: {}, authorization: "Bearer #{@access_token}" }
30
+ headers[:params].merge!(params)
31
+ opts = {method: :get, url: url, headers: headers}
32
+ execute(opts)
33
+ end
34
+
35
+ def install(payload)
36
+ url = "#{@base_url}/api/packages/install"
37
+ headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
38
+ opts = {method: :post, url: url, headers: headers, payload: payload.to_json}
39
+ execute(opts)
40
+ end
41
+
42
+ def update(id, payload)
43
+ url = "#{@base_url}/api/packages/update/#{id}"
44
+ headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
45
+ opts = {method: :put, url: url, headers: headers, payload: payload.to_json}
46
+ execute(opts)
47
+ end
48
+
49
+ def destroy(id)
50
+ url = "#{@base_url}/api/packages/#{id}"
51
+ headers = { :params => {}, :authorization => "Bearer #{@access_token}", 'Content-Type' => 'application/json' }
52
+ opts = {method: :delete, url: url, headers: headers}
53
+ execute(opts)
54
+ end
55
+
56
+ def export(params, outfile)
57
+ url = "#{@base_url}/api/packages/export"
58
+ headers = { params: params, authorization: "Bearer #{@access_token}" }
59
+ opts = {method: :post, url: url, headers: headers}
60
+ # execute(opts, false)
61
+ if Dir.exists?(outfile)
62
+ raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
63
+ end
64
+ # if @verify_ssl == false
65
+ # opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
66
+ # end
67
+ if @dry_run
68
+ return opts
69
+ end
70
+ http_response = nil
71
+ bad_body = nil
72
+ File.open(outfile, 'w') {|f|
73
+ block = proc { |response|
74
+ if response.code.to_i == 200
75
+ response.read_body do |chunk|
76
+ #puts "writing to #{outfile} ..."
77
+ f.write chunk
78
+ end
79
+ else
80
+ # puts_error (#{response.inspect}) #{chunk} ..."
81
+ bad_body = response.body.to_s
82
+ end
83
+ }
84
+ opts[:block_response] = block
85
+ http_response = RestClient::Request.new(opts).execute
86
+ # RestClient::Request.execute(opts)
87
+ }
88
+ return http_response, bad_body
89
+ end
90
+
91
+
92
+ end
data/lib/morpheus/cli.rb CHANGED
@@ -115,7 +115,7 @@ module Morpheus
115
115
  load 'morpheus/cli/library_container_templates_command.rb'
116
116
  load 'morpheus/cli/library_option_types_command.rb'
117
117
  load 'morpheus/cli/library_option_lists_command.rb'
118
- load 'morpheus/cli/library_packages_command.rb'
118
+ load 'morpheus/cli/packages_command.rb'
119
119
 
120
120
  load 'morpheus/cli/version_command.rb'
121
121
  load 'morpheus/cli/alias_command.rb'
@@ -155,7 +155,7 @@ class Morpheus::Cli::Instances
155
155
  }
156
156
  row
157
157
  }
158
- columns = [:id, :name, :group, :cloud, :type, :version, :environment, :nodes, {:connection => {max_width: 30}}, :status]
158
+ columns = [:id, {:name => {:max_width => 50}}, :group, :cloud, :type, :version, :environment, :nodes, {:connection => {:max_width => 30}}, :status]
159
159
  term_width = current_terminal_width()
160
160
  if term_width > 190
161
161
  columns += [:cpu, :memory, :storage]
@@ -6,9 +6,9 @@ class Morpheus::Cli::LibraryPackagesCommand
6
6
  include Morpheus::Cli::CliCommand
7
7
  include Morpheus::Cli::LibraryHelper
8
8
 
9
- set_command_name :'library-packages'
10
- register_subcommands :download
11
- # register_subcommands :upload
9
+ set_command_name :'packages'
10
+ # register_subcommands :list, :get, :install, :update, :remove, :export
11
+ register_subcommands :export
12
12
 
13
13
  # hide until this is released
14
14
  set_command_hidden
@@ -19,17 +19,36 @@ class Morpheus::Cli::LibraryPackagesCommand
19
19
 
20
20
  def connect(opts)
21
21
  @api_client = establish_remote_appliance_connection(opts)
22
- @library_packages_interface = @api_client.library_packages
23
- @library_instance_types_interface = @api_client.library_instance_types
22
+ @packages_interface = @api_client.packages
24
23
  end
25
24
 
26
25
  def handle(args)
27
26
  handle_subcommand(args)
28
27
  end
29
28
 
29
+ def list(args)
30
+ raise "not yet implemented"
31
+ end
32
+
33
+ def get(args)
34
+ raise "not yet implemented"
35
+ end
36
+
37
+ def install(args)
38
+ raise "not yet implemented"
39
+ end
40
+
41
+ def update(args)
42
+ raise "not yet implemented"
43
+ end
44
+
45
+ def remove(args)
46
+ raise "not yet implemented"
47
+ end
48
+
30
49
  # generate a new .morpkg file
31
- def download(args)
32
- full_command_string = "#{command_name} download #{args.join(' ')}".strip
50
+ def export(args)
51
+ full_command_string = "#{command_name} export #{args.join(' ')}".strip
33
52
  options = {}
34
53
  params = {}
35
54
  instance_type_codes = nil
@@ -69,12 +88,23 @@ class Morpheus::Cli::LibraryPackagesCommand
69
88
  do_overwrite = true
70
89
  do_mkdir = true
71
90
  end
72
- opts.on( '--open PROG', String, "Unzip the package and open the expanded directory with the specified program." ) do |val|
91
+ opts.on( '--open [PROG]', String, "Unzip the package and open the expanded directory with the specified program." ) do |val|
73
92
  unzip_and_open = true
74
- open_prog = val.to_s
93
+ if val.to_s.empty?
94
+ open_prog = val.to_s
95
+ else
96
+ open_prog = val.to_s
97
+ end
98
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
99
+ open_prog = "start"
100
+ elsif RbConfig::CONFIG['host_os'] =~ /darwin/
101
+ open_prog = "open"
102
+ elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/
103
+ open_prog = "xdg-open"
104
+ end
75
105
  end
76
106
  build_common_options(opts, options, [:dry_run, :quiet])
77
- opts.footer = "Download one or many instance types as a morpheus library package (.morpkg) file.\n" +
107
+ opts.footer = "Export one or many instance types as a morpheus library package (.morpkg) file.\n" +
78
108
  "[instance-type] is required. This is the instance type code." +
79
109
  "--instance-types can bv. This is a list of instance type codes."
80
110
  end
@@ -82,7 +112,7 @@ class Morpheus::Cli::LibraryPackagesCommand
82
112
 
83
113
  if args.count != 1 && !instance_type_codes && !params['all']
84
114
  print_error Morpheus::Terminal.angry_prompt
85
- puts_error "#{command_name} download expects 1 argument and received #{args.count}: #{args.join(' ')}\n#{optparse}"
115
+ puts_error "#{command_name} export expects 1 argument and received #{args.count}: #{args.join(' ')}\n#{optparse}"
86
116
  return 1
87
117
  end
88
118
  connect(options)
@@ -137,14 +167,14 @@ class Morpheus::Cli::LibraryPackagesCommand
137
167
  end
138
168
 
139
169
  if options[:dry_run]
140
- print_dry_run @library_packages_interface.dry.download(params, outfile), full_command_string
170
+ print_dry_run @packages_interface.dry.export(params, outfile), full_command_string
141
171
  return 1
142
172
  end
143
173
  if !options[:quiet]
144
174
  print cyan + "Downloading morpheus package file #{outfile} ... "
145
175
  end
146
176
 
147
- http_response, bad_body = @library_packages_interface.download(params, outfile)
177
+ http_response, bad_body = @packages_interface.export(params, outfile)
148
178
 
149
179
  # FileUtils.chmod(0600, outfile)
150
180
  success = http_response.code.to_i == 200
@@ -190,12 +220,6 @@ class Morpheus::Cli::LibraryPackagesCommand
190
220
  end
191
221
  end
192
222
 
193
-
194
- def upload
195
- raise "not yet implemented"
196
- end
197
-
198
-
199
223
  private
200
224
 
201
225
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "3.3.2.6.1"
4
+ VERSION = "3.3.2.6.2"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morpheus-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2.6.1
4
+ version: 3.3.2.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Estes
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-06-05 00:00:00.000000000 Z
14
+ date: 2018-06-06 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -171,7 +171,6 @@ files:
171
171
  - lib/morpheus/api/library_container_upgrades_interface.rb
172
172
  - lib/morpheus/api/library_instance_types_interface.rb
173
173
  - lib/morpheus/api/library_layouts_interface.rb
174
- - lib/morpheus/api/library_packages_interface.rb
175
174
  - lib/morpheus/api/license_interface.rb
176
175
  - lib/morpheus/api/load_balancers_interface.rb
177
176
  - lib/morpheus/api/logs_interface.rb
@@ -191,6 +190,7 @@ files:
191
190
  - lib/morpheus/api/option_type_lists_interface.rb
192
191
  - lib/morpheus/api/option_types_interface.rb
193
192
  - lib/morpheus/api/options_interface.rb
193
+ - lib/morpheus/api/packages_interface.rb
194
194
  - lib/morpheus/api/policies_interface.rb
195
195
  - lib/morpheus/api/power_scheduling_interface.rb
196
196
  - lib/morpheus/api/provision_types_interface.rb
@@ -246,7 +246,6 @@ files:
246
246
  - lib/morpheus/cli/library_layouts_command.rb
247
247
  - lib/morpheus/cli/library_option_lists_command.rb
248
248
  - lib/morpheus/cli/library_option_types_command.rb
249
- - lib/morpheus/cli/library_packages_command.rb
250
249
  - lib/morpheus/cli/library_upgrades_command.rb
251
250
  - lib/morpheus/cli/license.rb
252
251
  - lib/morpheus/cli/load_balancers.rb
@@ -275,6 +274,7 @@ files:
275
274
  - lib/morpheus/cli/networks_command.rb
276
275
  - lib/morpheus/cli/option_parser.rb
277
276
  - lib/morpheus/cli/option_types.rb
277
+ - lib/morpheus/cli/packages_command.rb
278
278
  - lib/morpheus/cli/policies_command.rb
279
279
  - lib/morpheus/cli/power_scheduling_command.rb
280
280
  - lib/morpheus/cli/preseed_scripts_command.rb
@@ -1,50 +0,0 @@
1
- require 'morpheus/api/api_client'
2
-
3
- class Morpheus::LibraryPackagesInterface < Morpheus::APIClient
4
- def initialize(access_token, refresh_token,expires_at = nil, base_url=nil)
5
- @access_token = access_token
6
- @refresh_token = refresh_token
7
- @base_url = base_url
8
- @expires_at = expires_at
9
- end
10
-
11
- def download(params, outfile)
12
- url = "#{@base_url}/api/library/packages/download"
13
- headers = { params: params, authorization: "Bearer #{@access_token}" }
14
- opts = {method: :get, url: url, headers: headers}
15
- # execute(opts, false)
16
- if Dir.exists?(outfile)
17
- raise "outfile is invalid. It is the name of an existing directory: #{outfile}"
18
- end
19
- # if @verify_ssl == false
20
- # opts[:verify_ssl] = OpenSSL::SSL::VERIFY_NONE
21
- # end
22
- if @dry_run
23
- return opts
24
- end
25
- http_response = nil
26
- bad_body = nil
27
- File.open(outfile, 'w') {|f|
28
- block = proc { |response|
29
- if response.code.to_i == 200
30
- response.read_body do |chunk|
31
- #puts "writing to #{outfile} ..."
32
- f.write chunk
33
- end
34
- else
35
- # puts_error (#{response.inspect}) #{chunk} ..."
36
- bad_body = response.body.to_s
37
- end
38
- }
39
- opts[:block_response] = block
40
- http_response = RestClient::Request.new(opts).execute
41
- # RestClient::Request.execute(opts)
42
- }
43
- return http_response, bad_body
44
- end
45
-
46
- def upload(file, params={})
47
- raise "implement this"
48
- end
49
-
50
- end