morpheus-cli 3.3.2.6.2 → 3.3.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/morpheus/api/api_client.rb +4 -0
  3. data/lib/morpheus/api/cloud_datastores_interface.rb +47 -0
  4. data/lib/morpheus/api/virtual_images_interface.rb +2 -2
  5. data/lib/morpheus/cli.rb +1 -0
  6. data/lib/morpheus/cli/app_templates.rb +5 -15
  7. data/lib/morpheus/cli/cli_command.rb +5 -1
  8. data/lib/morpheus/cli/cloud_datastores_command.rb +399 -0
  9. data/lib/morpheus/cli/containers_command.rb +2 -8
  10. data/lib/morpheus/cli/hosts.rb +10 -21
  11. data/lib/morpheus/cli/instance_types.rb +4 -10
  12. data/lib/morpheus/cli/instances.rb +14 -34
  13. data/lib/morpheus/cli/library_container_scripts_command.rb +5 -12
  14. data/lib/morpheus/cli/library_container_templates_command.rb +4 -10
  15. data/lib/morpheus/cli/library_container_types_command.rb +4 -10
  16. data/lib/morpheus/cli/library_instance_types_command.rb +4 -10
  17. data/lib/morpheus/cli/library_layouts_command.rb +4 -10
  18. data/lib/morpheus/cli/library_option_types_command.rb +2 -5
  19. data/lib/morpheus/cli/library_upgrades_command.rb +4 -10
  20. data/lib/morpheus/cli/load_balancers.rb +4 -16
  21. data/lib/morpheus/cli/monitoring_apps_command.rb +5 -14
  22. data/lib/morpheus/cli/monitoring_checks_command.rb +13 -33
  23. data/lib/morpheus/cli/monitoring_contacts_command.rb +10 -11
  24. data/lib/morpheus/cli/monitoring_groups_command.rb +19 -38
  25. data/lib/morpheus/cli/monitoring_incidents_command.rb +37 -66
  26. data/lib/morpheus/cli/network_domains_command.rb +7 -16
  27. data/lib/morpheus/cli/network_groups_command.rb +6 -16
  28. data/lib/morpheus/cli/network_pool_servers_command.rb +6 -16
  29. data/lib/morpheus/cli/network_pools_command.rb +6 -16
  30. data/lib/morpheus/cli/network_proxies_command.rb +6 -16
  31. data/lib/morpheus/cli/network_services_command.rb +4 -11
  32. data/lib/morpheus/cli/networks_command.rb +6 -16
  33. data/lib/morpheus/cli/packages_command.rb +148 -13
  34. data/lib/morpheus/cli/policies_command.rb +6 -16
  35. data/lib/morpheus/cli/power_scheduling_command.rb +6 -24
  36. data/lib/morpheus/cli/recent_activity_command.rb +19 -19
  37. data/lib/morpheus/cli/remote.rb +7 -8
  38. data/lib/morpheus/cli/storage_providers_command.rb +6 -16
  39. data/lib/morpheus/cli/tasks.rb +4 -12
  40. data/lib/morpheus/cli/user_groups_command.rb +7 -25
  41. data/lib/morpheus/cli/user_sources_command.rb +9 -21
  42. data/lib/morpheus/cli/users.rb +6 -17
  43. data/lib/morpheus/cli/version.rb +1 -1
  44. data/lib/morpheus/cli/workflows.rb +4 -12
  45. metadata +4 -2
@@ -56,16 +56,10 @@ class Morpheus::Cli::ContainersCommand
56
56
  #return 1 if container.nil?
57
57
  json_response = @containers_interface.get(arg.to_i)
58
58
  if options[:json]
59
- if options[:include_fields]
60
- json_response = {"container" => filter_data(json_response["container"], options[:include_fields]) }
61
- end
62
- puts as_json(json_response, options)
59
+ puts as_json(json_response, options, "container")
63
60
  return 0
64
61
  elsif options[:yaml]
65
- if options[:include_fields]
66
- json_response = {"container" => filter_data(json_response["container"], options[:include_fields]) }
67
- end
68
- puts as_yaml(json_response, options)
62
+ puts as_yaml(json_response, options, "container")
69
63
  return 0
70
64
  end
71
65
 
@@ -108,16 +108,12 @@ class Morpheus::Cli::Hosts
108
108
  json_response = @servers_interface.list(params)
109
109
 
110
110
  if options[:json]
111
- if options[:include_fields]
112
- json_response = {"servers" => filter_data(json_response["servers"], options[:include_fields]) }
113
- end
114
- puts as_json(json_response, options)
111
+ json_response.delete('stats') if options[:include_fields]
112
+ puts as_json(json_response, options, "servers")
115
113
  return 0
116
114
  elsif options[:yaml]
117
- if options[:include_fields]
118
- json_response = {"servers" => filter_data(json_response["servers"], options[:include_fields]) }
119
- end
120
- puts as_yaml(json_response, options)
115
+ json_response.delete('stats') if options[:include_fields]
116
+ puts as_yaml(json_response, options, "servers")
121
117
  return 0
122
118
  elsif options[:csv]
123
119
  # merge stats to be nice here..
@@ -263,16 +259,12 @@ class Morpheus::Cli::Hosts
263
259
  server = find_host_by_name_or_id(arg)
264
260
  json_response = @servers_interface.get(server['id'])
265
261
  if options[:json]
266
- if options[:include_fields]
267
- json_response = {"server" => filter_data(json_response["server"], options[:include_fields]) }
268
- end
269
- puts as_json(json_response, options)
262
+ json_response.delete('stats') if options[:include_fields]
263
+ puts as_json(json_response, options, "server")
270
264
  return 0
271
265
  elsif options[:yaml]
272
- if options[:include_fields]
273
- json_response = {"server" => filter_data(json_response["server"], options[:include_fields]) }
274
- end
275
- puts as_yaml(json_response, options)
266
+ json_response.delete('stats') if options[:include_fields]
267
+ puts as_yaml(json_response, options, "server")
276
268
  return 0
277
269
  end
278
270
  if options[:csv]
@@ -343,13 +335,10 @@ class Morpheus::Cli::Hosts
343
335
  server = find_host_by_name_or_id(arg)
344
336
  json_response = @servers_interface.get(server['id'])
345
337
  if options[:json]
346
- print JSON.pretty_generate(json_response), "\n"
338
+ puts as_json(json_response, options, "stats")
347
339
  return 0
348
340
  elsif options[:yaml]
349
- if options[:include_fields]
350
- json_response = {"stats" => filter_data(json_response["stats"], options[:include_fields]) }
351
- end
352
- puts as_yaml(json_response, options)
341
+ puts as_yaml(json_response, options, "stats")
353
342
  return 0
354
343
  elsif options[:csv]
355
344
  puts records_as_csv([json_response['stats']], options)
@@ -60,18 +60,15 @@ class Morpheus::Cli::InstanceTypes
60
60
  # do it
61
61
  json_response = @instance_types_interface.list(params)
62
62
  instance_types = json_response['instanceTypes']
63
- if options[:include_fields]
64
- json_response = {"instanceTypes" => filter_data(json_response["instanceTypes"], options[:include_fields]) }
65
- end
66
63
  # print result and return output
67
64
  if options[:json]
68
- puts as_json(json_response, options)
65
+ puts as_json(json_response, options, "instanceTypes")
69
66
  return 0
70
67
  elsif options[:csv]
71
68
  puts records_as_csv(json_response['instanceTypes'], options)
72
69
  return 0
73
70
  elsif options[:yaml]
74
- puts as_yaml(json_response, options)
71
+ puts as_yaml(json_response, options, "instanceTypes")
75
72
  return 0
76
73
  end
77
74
  instance_types = json_response['instanceTypes']
@@ -134,14 +131,11 @@ class Morpheus::Cli::InstanceTypes
134
131
  instance_type = json_response['instanceType']
135
132
  end
136
133
 
137
- if options[:include_fields]
138
- json_response = {"instanceType" => filter_data(json_response["instanceType"], options[:include_fields]) }
139
- end
140
134
  if options[:json]
141
- puts as_json(json_response, options)
135
+ puts as_json(json_response, options, "instanceType")
142
136
  return 0
143
137
  elsif options[:yaml]
144
- puts as_yaml(json_response, options)
138
+ puts as_yaml(json_response, options, "instanceType")
145
139
  return 0
146
140
  elsif options[:csv]
147
141
  puts records_as_csv([json_response['instanceType']], options)
@@ -83,16 +83,12 @@ class Morpheus::Cli::Instances
83
83
  end
84
84
  json_response = @instances_interface.list(params)
85
85
  if options[:json]
86
- if options[:include_fields]
87
- json_response = {"instances" => filter_data(json_response["instances"], options[:include_fields]) }
88
- end
89
- puts as_json(json_response, options)
86
+ json_response.delete('stats') if options[:include_fields]
87
+ puts as_json(json_response, options, "instances")
90
88
  return 0
91
89
  elsif options[:yaml]
92
- if options[:include_fields]
93
- json_response = {"instances" => filter_data(json_response["instances"], options[:include_fields]) }
94
- end
95
- puts as_yaml(json_response, options)
90
+ json_response.delete('stats') if options[:include_fields]
91
+ puts as_yaml(json_response, options, "instances")
96
92
  return 0
97
93
  elsif options[:csv]
98
94
  # merge stats to be nice here..
@@ -467,13 +463,10 @@ class Morpheus::Cli::Instances
467
463
  end
468
464
  json_response = @instances_interface.get(instance['id'])
469
465
  if options[:json]
470
- puts as_json(json_response, options)
466
+ puts as_json(json_response, options, "stats")
471
467
  return 0
472
468
  elsif options[:yaml]
473
- if options[:include_fields]
474
- json_response = {"stats" => filter_data(json_response["stats"], options[:include_fields]) }
475
- end
476
- puts as_yaml(json_response, options)
469
+ puts as_yaml(json_response, options, "stats")
477
470
  return 0
478
471
  end
479
472
  instance = json_response['instance']
@@ -648,16 +641,12 @@ class Morpheus::Cli::Instances
648
641
  instance = find_instance_by_name_or_id(arg)
649
642
  json_response = @instances_interface.get(instance['id'])
650
643
  if options[:json]
651
- if options[:include_fields]
652
- json_response = {"instance" => filter_data(json_response["instance"], options[:include_fields]) }
653
- end
654
- puts as_json(json_response, options)
644
+ json_response.delete('stats') if options[:include_fields]
645
+ puts as_json(json_response, options, "instance")
655
646
  return 0
656
647
  elsif options[:yaml]
657
- if options[:include_fields]
658
- json_response = {"instance" => filter_data(json_response["instance"], options[:include_fields]) }
659
- end
660
- puts as_yaml(json_response, options)
648
+ json_response.delete('stats') if options[:include_fields]
649
+ puts as_yaml(json_response, options, "instance")
661
650
  return 0
662
651
  end
663
652
 
@@ -839,16 +828,10 @@ class Morpheus::Cli::Instances
839
828
  end
840
829
  json_response = @instances_interface.containers(instance['id'])
841
830
  if options[:json]
842
- if options[:include_fields]
843
- json_response = {"containers" => filter_data(json_response["containers"], options[:include_fields]) }
844
- end
845
- puts as_json(json_response, options)
831
+ puts as_json(json_response, options, "containers")
846
832
  return 0
847
833
  elsif options[:yaml]
848
- if options[:include_fields]
849
- json_response = {"containers" => filter_data(json_response["containers"], options[:include_fields]) }
850
- end
851
- puts as_yaml(json_response, options)
834
+ puts as_yaml(json_response, options, "containers")
852
835
  return 0
853
836
  end
854
837
 
@@ -2006,14 +1989,11 @@ class Morpheus::Cli::Instances
2006
1989
  return 0
2007
1990
  end
2008
1991
  json_response = @instances_interface.threshold(instance['id'])
2009
- if options[:include_fields]
2010
- json_response = {"instanceThreshold" => filter_data(json_response["instanceThreshold"], options[:include_fields]) }
2011
- end
2012
1992
  if options[:json]
2013
- puts as_json(json_response, options)
1993
+ puts as_json(json_response, options, "instanceThreshold")
2014
1994
  return 0
2015
1995
  elsif options[:yaml]
2016
- puts as_yaml(json_response, options)
1996
+ puts as_yaml(json_response, options, "instanceThreshold")
2017
1997
  return 0
2018
1998
  elsif options[:csv]
2019
1999
  puts records_as_csv([json_response['instanceThreshold']], options)
@@ -41,19 +41,15 @@ class Morpheus::Cli::LibraryContainerScriptsCommand
41
41
  end
42
42
  # do it
43
43
  json_response = @container_scripts_interface.list(params)
44
- container_scripts = json_response['containerScripts']
45
- if options[:include_fields]
46
- json_response = {"containerScripts" => filter_data(json_response["containerScripts"], options[:include_fields]) }
47
- end
48
44
  # print result and return output
49
45
  if options[:json]
50
- puts as_json(json_response, options)
46
+ puts as_json(json_response, options, "containerScripts")
51
47
  return 0
52
48
  elsif options[:csv]
53
49
  puts records_as_csv(json_response['containerScripts'], options)
54
50
  return 0
55
51
  elsif options[:yaml]
56
- puts as_yaml(json_response, options)
52
+ puts as_yaml(json_response, options, "containerScripts")
57
53
  return 0
58
54
  end
59
55
  container_scripts = json_response['containerScripts']
@@ -107,17 +103,14 @@ class Morpheus::Cli::LibraryContainerScriptsCommand
107
103
  container_script = json_response['containerScript']
108
104
  instances = json_response['instances'] || []
109
105
  servers = json_response['servers'] || []
110
- if options[:include_fields]
111
- json_response = {"containerScript" => filter_data(json_response["containerScript"], options[:include_fields]) }
112
- end
113
106
  if options[:json]
114
- puts as_json(json_response, options)
107
+ puts as_json(json_response, options, "containerScript")
115
108
  return 0
116
109
  elsif options[:yaml]
117
- puts as_yaml(json_response, options)
110
+ puts as_yaml(json_response, options, "containerScript")
118
111
  return 0
119
112
  elsif options[:csv]
120
- puts records_as_csv([json_response['containerScript']], options)
113
+ puts records_as_csv([json_response["containerScript"]], options)
121
114
  return 0
122
115
  end
123
116
 
@@ -38,17 +38,14 @@ class Morpheus::Cli::LibraryContainerTemplatesCommand
38
38
  end
39
39
 
40
40
  json_response = @container_templates_interface.list(params)
41
- if options[:include_fields]
42
- json_response = {"containerTemplates" => filter_data(json_response["containerTemplates"], options[:include_fields]) }
43
- end
44
41
  if options[:json]
45
- puts as_json(json_response, options)
42
+ puts as_json(json_response, options, "containerTemplates")
46
43
  return 0
47
44
  elsif options[:csv]
48
45
  puts records_as_csv(json_response['containerTemplates'], options)
49
46
  return 0
50
47
  elsif options[:yaml]
51
- puts as_yaml(json_response, options)
48
+ puts as_yaml(json_response, options, "containerTemplates")
52
49
  return 0
53
50
  end
54
51
  container_templates = json_response['containerTemplates']
@@ -111,14 +108,11 @@ class Morpheus::Cli::LibraryContainerTemplatesCommand
111
108
  container_template = json_response['containerTemplate']
112
109
  instances = json_response['instances'] || []
113
110
  servers = json_response['servers'] || []
114
- if options[:include_fields]
115
- json_response = {"containerTemplate" => filter_data(json_response["containerTemplate"], options[:include_fields]) }
116
- end
117
111
  if options[:json]
118
- puts as_json(json_response, options)
112
+ puts as_json(json_response, options, "containerTemplate")
119
113
  return 0
120
114
  elsif options[:yaml]
121
- puts as_yaml(json_response, options)
115
+ puts as_yaml(json_response, options, "containerTemplate")
122
116
  return 0
123
117
  elsif options[:csv]
124
118
  puts records_as_csv([json_response['containerTemplate']], options)
@@ -65,19 +65,16 @@ class Morpheus::Cli::LibraryContainerTypesCommand
65
65
  end
66
66
  # do it
67
67
  json_response = @library_container_types_interface.list(layout_id, params)
68
- if options[:include_fields]
69
- json_response = {"containerTypes" => filter_data(json_response["containerTypes"], options[:include_fields]) }
70
- end
71
68
  # print and/or return result
72
69
  # return 0 if options[:quiet]
73
70
  if options[:json]
74
- puts as_json(json_response, options)
71
+ puts as_json(json_response, options, "containerTypes")
75
72
  return 0
76
73
  elsif options[:csv]
77
74
  puts records_as_csv(json_response['containerTypes'], options)
78
75
  return 0
79
76
  elsif options[:yaml]
80
- puts as_yaml(json_response, options)
77
+ puts as_yaml(json_response, options, "containerTypes")
81
78
  return 0
82
79
  end
83
80
  container_types = json_response['containerTypes']
@@ -140,14 +137,11 @@ class Morpheus::Cli::LibraryContainerTypesCommand
140
137
  #json_response = @library_container_types_interface.get(layout_id, container_type['id'])
141
138
  json_response = {'containerType' => container_type}
142
139
  #container_type = json_response['containerType']
143
- if options[:include_fields]
144
- json_response = {"containerType" => filter_data(json_response["containerType"], options[:include_fields]) }
145
- end
146
140
  if options[:json]
147
- puts as_json(json_response, options)
141
+ puts as_json(json_response, options, "containerType")
148
142
  return 0
149
143
  elsif options[:yaml]
150
- puts as_yaml(json_response, options)
144
+ puts as_yaml(json_response, options, "containerType")
151
145
  return 0
152
146
  elsif options[:csv]
153
147
  puts records_as_csv([json_response['containerType']], options)
@@ -62,17 +62,14 @@ class Morpheus::Cli::LibraryInstanceTypesCommand
62
62
  end
63
63
  # do it
64
64
  json_response = @library_instance_types_interface.list(params)
65
- if options[:include_fields]
66
- json_response = {"instanceTypes" => filter_data(json_response["instanceTypes"], options[:include_fields]) }
67
- end
68
65
  if options[:json]
69
- puts as_json(json_response, options)
66
+ puts as_json(json_response, options, "instanceTypes")
70
67
  return 0
71
68
  elsif options[:csv]
72
69
  puts records_as_csv(json_response['instanceTypes'], options)
73
70
  return 0
74
71
  elsif options[:yaml]
75
- puts as_yaml(json_response, options)
72
+ puts as_yaml(json_response, options, "instanceTypes")
76
73
  return 0
77
74
  end
78
75
  instance_types = json_response['instanceTypes']
@@ -131,14 +128,11 @@ class Morpheus::Cli::LibraryInstanceTypesCommand
131
128
  instance_type = json_response['instanceType']
132
129
  end
133
130
 
134
- if options[:include_fields]
135
- json_response = {"instanceType" => filter_data(json_response["instanceType"], options[:include_fields]) }
136
- end
137
131
  if options[:json]
138
- puts as_json(json_response, options)
132
+ puts as_json(json_response, options, "instanceType")
139
133
  return 0
140
134
  elsif options[:yaml]
141
- puts as_yaml(json_response, options)
135
+ puts as_yaml(json_response, options, "instanceType")
142
136
  return 0
143
137
  elsif options[:csv]
144
138
  puts records_as_csv([json_response['instanceType']], options)
@@ -70,17 +70,14 @@ class Morpheus::Cli::LibraryLayoutsCommand
70
70
  end
71
71
 
72
72
  json_response = @library_layouts_interface.list(instance_type_id, params)
73
- if options[:include_fields]
74
- json_response = {"instanceTypeLayouts" => filter_data(json_response["instanceTypeLayouts"], options[:include_fields]) }
75
- end
76
73
  if options[:json]
77
- puts as_json(json_response, options)
74
+ puts as_json(json_response, options, "instanceTypeLayouts")
78
75
  return 0
79
76
  elsif options[:csv]
80
77
  puts records_as_csv(json_response['instanceTypeLayouts'], options)
81
78
  return 0
82
79
  elsif options[:yaml]
83
- puts as_yaml(json_response, options)
80
+ puts as_yaml(json_response, options, "instanceTypeLayouts")
84
81
  return 0
85
82
  end
86
83
  layouts = json_response['instanceTypeLayouts']
@@ -142,14 +139,11 @@ class Morpheus::Cli::LibraryLayoutsCommand
142
139
  #json_response = @library_layouts_interface.get(instance_type_id, layout['id'])
143
140
  json_response = {'instanceTypeLayout' => layout}
144
141
  #layout = json_response['instanceTypeLayout']
145
- if options[:include_fields]
146
- json_response = {"instanceTypeLayout" => filter_data(json_response["instanceTypeLayout"], options[:include_fields]) }
147
- end
148
142
  if options[:json]
149
- puts as_json(json_response, options)
143
+ puts as_json(json_response, options, "instanceTypeLayout")
150
144
  return 0
151
145
  elsif options[:yaml]
152
- puts as_yaml(json_response, options)
146
+ puts as_yaml(json_response, options, "instanceTypeLayout")
153
147
  return 0
154
148
  elsif options[:csv]
155
149
  puts records_as_csv([json_response['instanceTypeLayout']], options)
@@ -120,14 +120,11 @@ class Morpheus::Cli::LibraryOptionTypesCommand
120
120
  option_type = find_option_type_by_name_or_id(id)
121
121
  exit 1 if option_type.nil?
122
122
 
123
- if options[:include_fields]
124
- json_response = {"optionType" => filter_data(json_response["optionType"], options[:include_fields]) }
125
- end
126
123
  if options[:json]
127
- puts as_json(json_response, options)
124
+ puts as_json(json_response, options, "optionType")
128
125
  return 0
129
126
  elsif options[:yaml]
130
- puts as_yaml(json_response, options)
127
+ puts as_yaml(json_response, options, "optionType")
131
128
  return 0
132
129
  elsif options[:csv]
133
130
  puts records_as_csv([json_response['optionType']], options)
@@ -75,17 +75,14 @@ class Morpheus::Cli::LibraryUpgradesCommand
75
75
  end
76
76
 
77
77
  json_response = @library_container_upgrades_interface.list(instance_type_id, params)
78
- if options[:include_fields]
79
- json_response = {"upgrades" => filter_data(json_response["upgrades"], options[:include_fields]) }
80
- end
81
78
  if options[:json]
82
- puts as_json(json_response, options)
79
+ puts as_json(json_response, options, "upgrades")
83
80
  return 0
84
81
  elsif options[:csv]
85
82
  puts records_as_csv(json_response['upgrades'], options)
86
83
  return 0
87
84
  elsif options[:yaml]
88
- puts as_yaml(json_response, options)
85
+ puts as_yaml(json_response, options, "upgrades")
89
86
  return 0
90
87
  end
91
88
  upgrades = json_response['upgrades']
@@ -151,14 +148,11 @@ class Morpheus::Cli::LibraryUpgradesCommand
151
148
  #json_response = @library_container_upgrades_interface.get(instance_type_id, upgrade['id'])
152
149
  json_response = {'upgrade' => upgrade}
153
150
  #upgrade = json_response['upgrade']
154
- if options[:include_fields]
155
- json_response = {"upgrade" => filter_data(json_response["upgrade"], options[:include_fields]) }
156
- end
157
151
  if options[:json]
158
- puts as_json(json_response, options)
152
+ puts as_json(json_response, options, "upgrade")
159
153
  return 0
160
154
  elsif options[:yaml]
161
- puts as_yaml(json_response, options)
155
+ puts as_yaml(json_response, options, "upgrade")
162
156
  return 0
163
157
  elsif options[:csv]
164
158
  puts records_as_csv([json_response['upgrade']], options)