morpheus-cli 3.5.2 → 3.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/morpheus/api/api_client.rb +16 -0
  3. data/lib/morpheus/api/blueprints_interface.rb +84 -0
  4. data/lib/morpheus/api/execution_request_interface.rb +33 -0
  5. data/lib/morpheus/api/instances_interface.rb +21 -0
  6. data/lib/morpheus/api/packages_interface.rb +25 -5
  7. data/lib/morpheus/api/processes_interface.rb +34 -0
  8. data/lib/morpheus/api/roles_interface.rb +7 -0
  9. data/lib/morpheus/api/servers_interface.rb +8 -0
  10. data/lib/morpheus/api/user_settings_interface.rb +76 -0
  11. data/lib/morpheus/cli.rb +5 -1
  12. data/lib/morpheus/cli/alias_command.rb +1 -1
  13. data/lib/morpheus/cli/app_templates.rb +2 -1
  14. data/lib/morpheus/cli/apps.rb +173 -19
  15. data/lib/morpheus/cli/blueprints_command.rb +2134 -0
  16. data/lib/morpheus/cli/cli_command.rb +3 -1
  17. data/lib/morpheus/cli/clouds.rb +4 -10
  18. data/lib/morpheus/cli/coloring_command.rb +14 -8
  19. data/lib/morpheus/cli/containers_command.rb +92 -5
  20. data/lib/morpheus/cli/execution_request_command.rb +313 -0
  21. data/lib/morpheus/cli/hosts.rb +188 -7
  22. data/lib/morpheus/cli/instances.rb +472 -9
  23. data/lib/morpheus/cli/login.rb +1 -1
  24. data/lib/morpheus/cli/mixins/print_helper.rb +8 -0
  25. data/lib/morpheus/cli/mixins/processes_helper.rb +134 -0
  26. data/lib/morpheus/cli/option_types.rb +21 -16
  27. data/lib/morpheus/cli/packages_command.rb +469 -17
  28. data/lib/morpheus/cli/processes_command.rb +313 -0
  29. data/lib/morpheus/cli/remote.rb +20 -9
  30. data/lib/morpheus/cli/roles.rb +186 -6
  31. data/lib/morpheus/cli/shell.rb +10 -1
  32. data/lib/morpheus/cli/tasks.rb +4 -1
  33. data/lib/morpheus/cli/user_settings_command.rb +431 -0
  34. data/lib/morpheus/cli/version.rb +1 -1
  35. data/lib/morpheus/cli/whoami.rb +1 -1
  36. data/lib/morpheus/formatters.rb +14 -0
  37. data/lib/morpheus/morpkg.rb +119 -0
  38. data/morpheus-cli.gemspec +1 -0
  39. metadata +26 -2
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Morpheus
3
3
  module Cli
4
- VERSION = "3.5.2"
4
+ VERSION = "3.5.3"
5
5
  end
6
6
  end
@@ -183,7 +183,7 @@ class Morpheus::Cli::Whoami
183
183
  }
184
184
  print_description_list({
185
185
  "Name" => 'name',
186
- "Url" => 'url',
186
+ "URL" => 'url',
187
187
  "Version" => 'buildVersion'
188
188
  }, appliance_data)
189
189
 
@@ -97,6 +97,17 @@ def format_duration_seconds(seconds, format="human")
97
97
  out
98
98
  end
99
99
 
100
+ def format_duration_milliseconds(milliseconds, format="human", ms_threshold=1000)
101
+ out = ""
102
+ milliseconds = milliseconds.abs.to_i
103
+ if ms_threshold && ms_threshold > milliseconds
104
+ out = "#{milliseconds}ms"
105
+ else
106
+ out = format_duration_seconds((milliseconds.to_f / 1000).floor, format)
107
+ end
108
+ out
109
+ end
110
+
100
111
  # returns a human readable time duration
101
112
  # @param seconds - duration in seconds
102
113
  def format_human_duration(seconds)
@@ -127,6 +138,9 @@ def format_human_duration(seconds)
127
138
  else
128
139
  out << "#{minutes.floor} minutes"
129
140
  end
141
+ elsif seconds > 0 && seconds < 1
142
+ ms = (seconds.to_f * 1000).to_i
143
+ out << "#{ms}ms"
130
144
  else
131
145
  seconds = seconds.floor
132
146
  if seconds == 1
@@ -0,0 +1,119 @@
1
+ require 'zip'
2
+
3
+ module Morpheus
4
+
5
+ # A module for building .morpkg files
6
+ module Morpkg
7
+
8
+ # parse the manifest json data for a package source directory
9
+ def self.parse_package_manifest(source_directory)
10
+ source_directory = File.expand_path(source_directory)
11
+ manifest_filename = File.join(source_directory, "package-manifest.json")
12
+ if !File.exists?(manifest_filename)
13
+ raise "Package manifest file not found: #{manifest_filename}"
14
+ end
15
+ manifest = JSON.parse(File.read(manifest_filename))
16
+ return manifest
17
+ end
18
+
19
+ # write a .morpkg file for a package source directory
20
+ # validates manifest data
21
+ # default outfile is code-version.morpkg
22
+ # returns outfile (filename) or raises exception
23
+ def self.build_package(source_directory, outfile=nil, do_overwrite=false)
24
+ source_directory = File.expand_path(source_directory)
25
+ manifest = self.parse_package_manifest(source_directory)
26
+ code = manifest["code"]
27
+ version = manifest["version"]
28
+ org = manifest["org"] || manifest["organization"]
29
+ type = manifest["type"]
30
+ if code.nil? || code.empty?
31
+ raise "Package manifest data missing: code"
32
+ end
33
+ if version.nil? || version.empty?
34
+ raise "Package manifest data missing: version"
35
+ end
36
+ # if org.nil? || org.empty?
37
+ # raise "Package manifest data missing: org"
38
+ # end
39
+ # if type.nil? || type.empty?
40
+ # raise "Package manifest data missing: type"
41
+ # end
42
+ if outfile.nil? || outfile.empty?
43
+ # outfile = "#{orig_dir}/#{type}-#{code}-#{version}.morpkg"
44
+ # outfile = File.join(File.dirname(source_directory), "#{type}-#{code}-#{version}.morpkg")
45
+ outfile = File.join(File.dirname(source_directory), "#{code}-#{version}.morpkg")
46
+ elsif File.directory?(outfile)
47
+ outfile = File.join(outfile, "#{code}-#{version}.morpkg")
48
+ end
49
+ if Dir.exists?(outfile)
50
+ raise "Invalid package target. #{outfile} is the name of an existing directory."
51
+ end
52
+ if File.exists?(outfile)
53
+ if do_overwrite
54
+ # don't delete, just overwrite.
55
+ # File.delete(outfile)
56
+ else
57
+ raise "Invalid package target. File already exists: #{outfile}"
58
+ end
59
+ end
60
+ # build directories if needed
61
+ if !Dir.exists?(File.dirname(outfile))
62
+ Dir.mkdir(File.dirname(outfile))
63
+ end
64
+
65
+ # write the .morpkg file and return filename
66
+ zf = ZipFileGenerator.new(source_directory, outfile)
67
+ zf.write()
68
+
69
+ return outfile
70
+ end
71
+
72
+ # This is a simple example which uses rubyzip to
73
+ # recursively generate a zip file from the contents of
74
+ # a specified directory. The directory itself is not
75
+ # included in the archive, rather just its contents.
76
+ #
77
+ # Usage:
78
+ # directoryToZip = "/tmp/input"
79
+ # outputFile = "/tmp/out.zip"
80
+ # zf = ZipFileGenerator.new(directoryToZip, outputFile)
81
+ # zf.write()
82
+ class ZipFileGenerator
83
+
84
+ # Initialize with the directory to zip and the location of the output archive.
85
+ def initialize(inputDir, outputFile)
86
+ @inputDir = inputDir
87
+ @outputFile = outputFile
88
+ end
89
+
90
+ # Zip the input directory.
91
+ def write()
92
+ entries = Dir.entries(@inputDir); entries.delete("."); entries.delete("..")
93
+ io = Zip::File.open(@outputFile, Zip::File::CREATE);
94
+ writeEntries(entries, "", io)
95
+ io.close();
96
+ end
97
+
98
+ # A helper method to make the recursion work.
99
+ private
100
+ def writeEntries(entries, path, io)
101
+
102
+ entries.each { |e|
103
+ zipFilePath = path == "" ? e : File.join(path, e)
104
+ diskFilePath = File.join(@inputDir, zipFilePath)
105
+ puts "Deflating " + diskFilePath # remove me
106
+ if File.directory?(diskFilePath)
107
+ io.mkdir(zipFilePath)
108
+ subdir =Dir.entries(diskFilePath); subdir.delete("."); subdir.delete("..")
109
+ writeEntries(subdir, zipFilePath, io)
110
+ else
111
+ io.get_output_stream(zipFilePath) { |f| f.puts(File.open(diskFilePath, "rb").read())}
112
+ end
113
+ }
114
+ end
115
+
116
+ end
117
+
118
+ end
119
+ end
@@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'mime-types'
29
29
  spec.add_dependency "table_print"
30
30
  spec.add_dependency "http"
31
+ spec.add_dependency "rubyzip"
31
32
  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.5.2
4
+ version: 3.5.3
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-10-23 00:00:00.000000000 Z
14
+ date: 2018-12-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -139,6 +139,20 @@ dependencies:
139
139
  - - ">="
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: rubyzip
144
+ requirement: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ type: :runtime
150
+ prerelease: false
151
+ version_requirements: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
142
156
  description: Infrastructure agnostic cloud application management & orchestration
143
157
  CLI for Morpheus. Easily manage and orchestrate VMS on private or public infrastructure
144
158
  and containerized architectures.
@@ -164,6 +178,7 @@ files:
164
178
  - lib/morpheus/api/archive_buckets_interface.rb
165
179
  - lib/morpheus/api/archive_files_interface.rb
166
180
  - lib/morpheus/api/auth_interface.rb
181
+ - lib/morpheus/api/blueprints_interface.rb
167
182
  - lib/morpheus/api/cloud_datastores_interface.rb
168
183
  - lib/morpheus/api/cloud_policies_interface.rb
169
184
  - lib/morpheus/api/clouds_interface.rb
@@ -174,6 +189,7 @@ files:
174
189
  - lib/morpheus/api/deploy_interface.rb
175
190
  - lib/morpheus/api/deployments_interface.rb
176
191
  - lib/morpheus/api/execute_schedules_interface.rb
192
+ - lib/morpheus/api/execution_request_interface.rb
177
193
  - lib/morpheus/api/group_policies_interface.rb
178
194
  - lib/morpheus/api/groups_interface.rb
179
195
  - lib/morpheus/api/image_builder_boot_scripts_interface.rb
@@ -211,6 +227,7 @@ files:
211
227
  - lib/morpheus/api/packages_interface.rb
212
228
  - lib/morpheus/api/policies_interface.rb
213
229
  - lib/morpheus/api/power_schedules_interface.rb
230
+ - lib/morpheus/api/processes_interface.rb
214
231
  - lib/morpheus/api/provision_types_interface.rb
215
232
  - lib/morpheus/api/roles_interface.rb
216
233
  - lib/morpheus/api/security_group_rules_interface.rb
@@ -221,6 +238,7 @@ files:
221
238
  - lib/morpheus/api/task_sets_interface.rb
222
239
  - lib/morpheus/api/tasks_interface.rb
223
240
  - lib/morpheus/api/user_groups_interface.rb
241
+ - lib/morpheus/api/user_settings_interface.rb
224
242
  - lib/morpheus/api/user_sources_interface.rb
225
243
  - lib/morpheus/api/users_interface.rb
226
244
  - lib/morpheus/api/virtual_images_interface.rb
@@ -232,6 +250,7 @@ files:
232
250
  - lib/morpheus/cli/app_templates.rb
233
251
  - lib/morpheus/cli/apps.rb
234
252
  - lib/morpheus/cli/archives_command.rb
253
+ - lib/morpheus/cli/blueprints_command.rb
235
254
  - lib/morpheus/cli/boot_scripts_command.rb
236
255
  - lib/morpheus/cli/cli_command.rb
237
256
  - lib/morpheus/cli/cli_registry.rb
@@ -253,6 +272,7 @@ files:
253
272
  - lib/morpheus/cli/edit_rc_command.rb
254
273
  - lib/morpheus/cli/error_handler.rb
255
274
  - lib/morpheus/cli/execute_schedules_command.rb
275
+ - lib/morpheus/cli/execution_request_command.rb
256
276
  - lib/morpheus/cli/expression_parser.rb
257
277
  - lib/morpheus/cli/groups.rb
258
278
  - lib/morpheus/cli/hosts.rb
@@ -280,6 +300,7 @@ files:
280
300
  - lib/morpheus/cli/mixins/library_helper.rb
281
301
  - lib/morpheus/cli/mixins/monitoring_helper.rb
282
302
  - lib/morpheus/cli/mixins/print_helper.rb
303
+ - lib/morpheus/cli/mixins/processes_helper.rb
283
304
  - lib/morpheus/cli/mixins/provisioning_helper.rb
284
305
  - lib/morpheus/cli/mixins/whoami_helper.rb
285
306
  - lib/morpheus/cli/monitoring_apps_command.rb
@@ -300,6 +321,7 @@ files:
300
321
  - lib/morpheus/cli/policies_command.rb
301
322
  - lib/morpheus/cli/power_schedules_command.rb
302
323
  - lib/morpheus/cli/preseed_scripts_command.rb
324
+ - lib/morpheus/cli/processes_command.rb
303
325
  - lib/morpheus/cli/recent_activity_command.rb
304
326
  - lib/morpheus/cli/remote.rb
305
327
  - lib/morpheus/cli/roles.rb
@@ -313,6 +335,7 @@ files:
313
335
  - lib/morpheus/cli/storage_providers_command.rb
314
336
  - lib/morpheus/cli/tasks.rb
315
337
  - lib/morpheus/cli/user_groups_command.rb
338
+ - lib/morpheus/cli/user_settings_command.rb
316
339
  - lib/morpheus/cli/user_sources_command.rb
317
340
  - lib/morpheus/cli/users.rb
318
341
  - lib/morpheus/cli/version.rb
@@ -324,6 +347,7 @@ files:
324
347
  - lib/morpheus/ext/nil_class.rb
325
348
  - lib/morpheus/formatters.rb
326
349
  - lib/morpheus/logging.rb
350
+ - lib/morpheus/morpkg.rb
327
351
  - lib/morpheus/rest_client.rb
328
352
  - lib/morpheus/terminal.rb
329
353
  - morpheus-cli.gemspec