mms-api 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -8
- data/lib/mms.rb +5 -5
- data/lib/mms/agent.rb +87 -11
- data/lib/mms/cache.rb +2 -7
- data/lib/mms/cli.rb +36 -74
- data/lib/mms/client.rb +22 -13
- data/lib/mms/config.rb +15 -44
- data/lib/mms/errors.rb +2 -10
- data/lib/mms/resource.rb +20 -23
- data/lib/mms/resource/alert.rb +3 -7
- data/lib/mms/resource/backup_config.rb +0 -3
- data/lib/mms/resource/cluster.rb +9 -15
- data/lib/mms/resource/group.rb +13 -15
- data/lib/mms/resource/host.rb +7 -12
- data/lib/mms/resource/metric.rb +5 -7
- data/lib/mms/resource/restore_job.rb +7 -9
- data/lib/mms/resource/snapshot.rb +10 -13
- data/lib/mms/resource/snapshot_schedule.rb +9 -12
- data/lib/mms/version.rb +1 -1
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 522bb6499771a5d35e3775dc983f503c17213531
|
4
|
+
data.tar.gz: c1a3b629f19493576070783dfa937d0611195169
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0feb735e81520656658e134e5fccbd5a46af4e192862b4072aae6a431c4e0796e7d4bb1f688c962a661d0445da7bcc4f4e477cf9d99874aa57963215de1b30b2
|
7
|
+
data.tar.gz: 7bbbf7c6f5d75db491d175aa11f9b6a5774b3a862bf1400c37fac9e75b83a7491facd32651bb1d6e7326ba34b8d891298681259a9e9cc4a942b9e8f784f2ba0b
|
data/README.md
CHANGED
@@ -14,14 +14,20 @@ The MMS Public API follows the principles of the REST architectural style to exp
|
|
14
14
|
|
15
15
|
|Resource |Get All |Get One |Create |Update |Delete |
|
16
16
|
|:--------------|:------:|:------:|:-----:|:-----:|:-----:|
|
17
|
-
|Groups | + | + |
|
18
|
-
|Hosts | + | + |
|
19
|
-
|Clusters | + | + |
|
20
|
-
|Snapshots | + | + |
|
21
|
-
|Alerts | + | + |
|
22
|
-
|Restore Jobs | + | + | + |
|
23
|
-
|Backup Configs | + | + |
|
24
|
-
|Metrics | + | + |
|
17
|
+
|Groups | + | + | - | - | - |
|
18
|
+
|Hosts | + | + | + | + | + |
|
19
|
+
|Clusters | + | + | x | + | x |
|
20
|
+
|Snapshots | + | + | x | x | - |
|
21
|
+
|Alerts | + | + | x | - | x |
|
22
|
+
|Restore Jobs | + | + | + | x | x |
|
23
|
+
|Backup Configs | + | + | x | - | x |
|
24
|
+
|Metrics | + | + | x | x | x |
|
25
|
+
|
26
|
+
```
|
27
|
+
+ : supported by gem
|
28
|
+
- : not supported by gem
|
29
|
+
x : not supported by MMS
|
30
|
+
```
|
25
31
|
|
26
32
|
Library usage
|
27
33
|
-------------
|
data/lib/mms.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module MMS
|
2
|
-
require 'rubygems'
|
2
|
+
require 'rubygems' # For ruby < 1.9
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
4
|
+
require 'uri'
|
5
|
+
require 'json'
|
6
|
+
require 'cgi'
|
7
|
+
require 'net/http'
|
8
8
|
require 'net/http/digest_auth'
|
9
9
|
require 'terminal-table'
|
10
10
|
require 'pathname'
|
data/lib/mms/agent.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
module MMS
|
2
|
-
|
3
2
|
class Agent
|
4
|
-
|
5
3
|
attr_accessor :client
|
6
4
|
|
7
5
|
# @param [MMS::Client] client
|
@@ -10,7 +8,7 @@ module MMS
|
|
10
8
|
end
|
11
9
|
|
12
10
|
# @param [String] apiurl
|
13
|
-
def
|
11
|
+
def apiurl(apiurl)
|
14
12
|
@client.url = apiurl
|
15
13
|
end
|
16
14
|
|
@@ -19,8 +17,8 @@ module MMS
|
|
19
17
|
group_list = []
|
20
18
|
client.get('/groups').each do |group|
|
21
19
|
g = MMS::Resource::Group.new
|
22
|
-
g.
|
23
|
-
g.
|
20
|
+
g.client(client)
|
21
|
+
g.data(group)
|
24
22
|
|
25
23
|
group_list.push g
|
26
24
|
end
|
@@ -36,6 +34,72 @@ module MMS
|
|
36
34
|
host_list
|
37
35
|
end
|
38
36
|
|
37
|
+
# @param [String] groupid
|
38
|
+
# @param [String] hostname
|
39
|
+
# @param [Integer] port
|
40
|
+
# @option options [String] username Required if authMechanismName is MONGODB_CR. Otherwise illegal.
|
41
|
+
# @option options [String] password Required if authMechanismName is MONGODB_CR. Otherwise illegal.
|
42
|
+
# @option options [TrueClass, FalseClass] sslEnabled Must be true if the authMechanismName is MONGODB_X509. Default is false if omitted.
|
43
|
+
# @option options [TrueClass, FalseClass] logsEnabled Default is false if omitted.
|
44
|
+
# @option options [TrueClass, FalseClass] alertsEnabled Default is true if omitted.
|
45
|
+
# @option options [TrueClass, FalseClass] profilerEnabled Default is false if omitted.
|
46
|
+
# @option options [Integer] muninPort Default is 0 and Munin stats are not collected if omitted.
|
47
|
+
# @option options [String] authMechanismName Default is NONE if omitted. If set to MONGODB_CR then you must provide the username and password.
|
48
|
+
# @return [<MMS::Resource::Host>]
|
49
|
+
def host_create(groupid, hostname, port, options = {})
|
50
|
+
data = {}
|
51
|
+
data[:hostname] = hostname
|
52
|
+
data[:port] = port
|
53
|
+
data[:username] = options[:username] || nil
|
54
|
+
data[:password] = options[:password] || nil
|
55
|
+
data[:sslEnabled] = options[:sslEnabled] || false
|
56
|
+
data[:logsEnabled] = options[:logsEnabled] || false
|
57
|
+
data[:alertsEnabled] = options[:alertsEnabled] || true
|
58
|
+
data[:profilerEnabled] = options[:profilerEnabled] || false
|
59
|
+
data[:muninPort] = options[:muninPort] || 0
|
60
|
+
data[:authMechanismName] = options[:authMechanismName] || nil
|
61
|
+
ret_host = client.post("/groups/#{groupid}/hosts", data)
|
62
|
+
host = MMS::Resource::Host.new
|
63
|
+
host._from_hash(ret_host)
|
64
|
+
host
|
65
|
+
end
|
66
|
+
|
67
|
+
# @param [String] groupid
|
68
|
+
# @param [String] hostid
|
69
|
+
# @option options [String] username Required if authMechanismName is MONGODB_CR. Otherwise illegal.
|
70
|
+
# @option options [String] password Required if authMechanismName is MONGODB_CR. Otherwise illegal.
|
71
|
+
# @option options [TrueClass, FalseClass] sslEnabled Must be true if the authMechanismName is MONGODB_X509. Default is false if omitted.
|
72
|
+
# @option options [TrueClass, FalseClass] logsEnabled Default is false if omitted.
|
73
|
+
# @option options [TrueClass, FalseClass] alertsEnabled Default is true if omitted.
|
74
|
+
# @option options [TrueClass, FalseClass] profilerEnabled Default is false if omitted.
|
75
|
+
# @option options [Integer] muninPort Default is 0 and Munin stats are not collected if omitted.
|
76
|
+
# @option options [String] authMechanismName Default is NONE if omitted. If set to MONGODB_CR then you must provide the username and password.
|
77
|
+
# @return [<MMS::Resource::Host>]
|
78
|
+
def host_update(groupid, hostid, options = {})
|
79
|
+
data = {}
|
80
|
+
data[:username] = options[:username] if options.include?(:username)
|
81
|
+
data[:password] = options[:password] if options.include?(:password)
|
82
|
+
data[:sslEnabled] = options[:sslEnabled] if options.include?(:sslEnabled)
|
83
|
+
data[:logsEnabled] = options[:logsEnabled] if options.include?(:logsEnabled)
|
84
|
+
data[:alertsEnabled] = options[:alertsEnabled] if options.include?(:alertsEnabled)
|
85
|
+
data[:profilerEnabled] = options[:profilerEnabled] if options.include?(:profilerEnabled)
|
86
|
+
data[:muninPort] = options[:muninPort] if options.include?(:muninPort)
|
87
|
+
data[:authMechanismName] = options[:authMechanismName] if options.include?(:authMechanismName)
|
88
|
+
ret_host = client.patch("/groups/#{groupid}/hosts/#{hostid}", data)
|
89
|
+
host = MMS::Resource::Host.new
|
90
|
+
host._from_hash(ret_host)
|
91
|
+
host
|
92
|
+
end
|
93
|
+
|
94
|
+
# @param [String] groupid
|
95
|
+
# @param [String] hostid
|
96
|
+
# @return [TrueClass, FalseClass]
|
97
|
+
def host_delete(groupid, hostid)
|
98
|
+
client.delete("/groups/#{groupid}/hosts/#{hostid}")
|
99
|
+
host = client.delete("/groups/#{groupid}/hosts/#{hostid}")
|
100
|
+
host == {} ? true : false
|
101
|
+
end
|
102
|
+
|
39
103
|
# @return [Array<MMS::Resource::Cluster>]
|
40
104
|
def clusters
|
41
105
|
cluster_list = []
|
@@ -45,13 +109,25 @@ module MMS
|
|
45
109
|
cluster_list
|
46
110
|
end
|
47
111
|
|
112
|
+
# @param [String] groupid
|
113
|
+
# @param [String] clusterid
|
114
|
+
# @param [String] name
|
115
|
+
# @return [<MMS::Resource::Cluster>]
|
116
|
+
def cluster_update(groupid, clusterid, name)
|
117
|
+
data = { clusterName: name }
|
118
|
+
ret_cluster = client.patch("/groups/#{groupid}/clusters/#{clusterid}", data)
|
119
|
+
cluster = MMS::Resource::Cluster.new
|
120
|
+
cluster._from_hash(ret_cluster)
|
121
|
+
cluster
|
122
|
+
end
|
123
|
+
|
48
124
|
# @return [Array<MMS::Resource::Snapshot>]
|
49
125
|
def snapshots
|
50
126
|
snapshot_list = []
|
51
127
|
clusters.each do |cluster|
|
52
128
|
snapshot_list.concat cluster.snapshots
|
53
129
|
end
|
54
|
-
snapshot_list.sort_by
|
130
|
+
snapshot_list.sort_by(&:created_date).reverse
|
55
131
|
end
|
56
132
|
|
57
133
|
# @return [Array<MMS::Resource::Alert>]
|
@@ -60,7 +136,7 @@ module MMS
|
|
60
136
|
groups.each do |group|
|
61
137
|
alert_list.concat group.alerts
|
62
138
|
end
|
63
|
-
alert_list.sort_by
|
139
|
+
alert_list.sort_by(&:created).reverse
|
64
140
|
end
|
65
141
|
|
66
142
|
# @return [Array<MMS::Resource::RestoreJob>]
|
@@ -69,7 +145,7 @@ module MMS
|
|
69
145
|
clusters.each do |cluster|
|
70
146
|
restorejob_list.concat cluster.restorejobs
|
71
147
|
end
|
72
|
-
restorejob_list.sort_by
|
148
|
+
restorejob_list.sort_by(&:created).reverse
|
73
149
|
end
|
74
150
|
|
75
151
|
# @param [String] type_value
|
@@ -79,8 +155,9 @@ module MMS
|
|
79
155
|
def restorejob_create(type_value, group_id, cluster_id)
|
80
156
|
if type_value.length == 24
|
81
157
|
find_group(group_id).cluster(cluster_id).snapshot(type_value).create_restorejob
|
82
|
-
|
83
|
-
|
158
|
+
else
|
159
|
+
datetime = (type_value == 'now' ? DateTime.now : DateTime.parse(type_value))
|
160
|
+
fail('Invalid datetime. Correct `YYYY-MM-RRTH:m:sZ`') if datetime.nil?
|
84
161
|
datetime_string = [[datetime.year, datetime.month, datetime.day].join('-'), 'T', [datetime.hour, datetime.minute, datetime.second].join(':'), 'Z'].join
|
85
162
|
find_group(group_id).cluster(cluster_id).create_restorejob(datetime_string)
|
86
163
|
end
|
@@ -110,6 +187,5 @@ module MMS
|
|
110
187
|
def find_group(id)
|
111
188
|
MMS::Resource::Group.find(@client, id)
|
112
189
|
end
|
113
|
-
|
114
190
|
end
|
115
191
|
end
|
data/lib/mms/cache.rb
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
require 'singleton'
|
2
2
|
|
3
3
|
module MMS
|
4
|
-
|
5
4
|
class Cache
|
6
|
-
|
7
5
|
include Singleton
|
8
6
|
|
9
7
|
attr_accessor :storage
|
8
|
+
attr_reader :storage
|
10
9
|
|
11
10
|
def initialize
|
12
|
-
@storage = Hash.new {|hash, key| hash[key] = nil }
|
11
|
+
@storage = Hash.new { |hash, key| hash[key] = nil }
|
13
12
|
end
|
14
13
|
|
15
14
|
# @param [String] key
|
@@ -32,9 +31,5 @@ module MMS
|
|
32
31
|
def clear
|
33
32
|
initialize
|
34
33
|
end
|
35
|
-
|
36
|
-
def storage
|
37
|
-
@storage
|
38
|
-
end
|
39
34
|
end
|
40
35
|
end
|
data/lib/mms/cli.rb
CHANGED
@@ -2,11 +2,8 @@ require 'clamp'
|
|
2
2
|
require 'parseconfig'
|
3
3
|
|
4
4
|
module MMS
|
5
|
-
|
6
5
|
class CLI
|
7
|
-
|
8
6
|
class MMS::CLI::Command < Clamp::Command
|
9
|
-
|
10
7
|
attr_accessor :app_name
|
11
8
|
attr_accessor :config
|
12
9
|
|
@@ -25,7 +22,7 @@ module MMS
|
|
25
22
|
@config.apiurl = u
|
26
23
|
end
|
27
24
|
|
28
|
-
option ['-v', '--version'], :flag, 'Version' do |
|
25
|
+
option ['-v', '--version'], :flag, 'Version' do |_v|
|
29
26
|
puts "mms-api v#{MMS::VERSION}"
|
30
27
|
exit
|
31
28
|
end
|
@@ -43,28 +40,28 @@ module MMS
|
|
43
40
|
parse_user_home_config
|
44
41
|
end
|
45
42
|
|
46
|
-
option ['-i', '--ignore'], :flag, 'Ignore flag of --group-id and -cluster-id', :
|
43
|
+
option ['-i', '--ignore'], :flag, 'Ignore flag of --group-id and -cluster-id', default: false
|
47
44
|
|
48
|
-
option ['-j', '--json'], :flag, 'Print JSON output', :
|
45
|
+
option ['-j', '--json'], :flag, 'Print JSON output', default: false
|
49
46
|
|
50
47
|
option ['-l', '--limit'], '<integer>', 'Limit for result items' do |l|
|
51
48
|
@config.limit = Integer(l)
|
52
49
|
end
|
53
50
|
|
54
|
-
def initialize(
|
51
|
+
def initialize(_invocation_path, _context = {}, _parent_attribute_values = {})
|
55
52
|
@config ||= MMS::Config.new
|
56
53
|
end
|
57
54
|
|
58
55
|
def parse_user_home_config
|
59
|
-
|
56
|
+
fail(MMS::ConfigError.new('Config file path is not set!')) if @config.config_path.nil?
|
60
57
|
config_file = Pathname.new(@config.config_path)
|
61
|
-
|
58
|
+
fail(MMS::ConfigError.new("Config file `#{config_file}` does not exist")) unless config_file.exist?
|
62
59
|
|
63
60
|
config = ParseConfig.new(config_file)
|
64
61
|
config.params.map do |key, value|
|
65
62
|
begin
|
66
63
|
@config.send("#{key}=", value)
|
67
|
-
rescue Exception =>
|
64
|
+
rescue Exception => _e
|
68
65
|
raise MMS::ConfigError.new("Config option `#{key}` from file `#{config_file}` is not allowed!")
|
69
66
|
end
|
70
67
|
end
|
@@ -92,13 +89,13 @@ module MMS
|
|
92
89
|
end
|
93
90
|
|
94
91
|
# @param [String] heading
|
95
|
-
# @param [Array<MMS::Resource>]
|
92
|
+
# @param [Array<MMS::Resource>] resource_list
|
96
93
|
def print(heading, resource_list)
|
97
94
|
json? ? print_json(resource_list) : print_human(heading, resource_list)
|
98
95
|
end
|
99
96
|
|
100
97
|
# @param [String] heading
|
101
|
-
# @param [Array<MMS::Resource>]
|
98
|
+
# @param [Array<MMS::Resource>] resource_list
|
102
99
|
def print_human(heading, resource_list)
|
103
100
|
rows = []
|
104
101
|
|
@@ -106,12 +103,12 @@ module MMS
|
|
106
103
|
rows += resource.table_section
|
107
104
|
end
|
108
105
|
|
109
|
-
puts Terminal::Table.new :
|
106
|
+
puts Terminal::Table.new headings: (heading.nil? ? [] : heading), rows: rows
|
110
107
|
|
111
108
|
print_tips unless ignore?
|
112
109
|
end
|
113
110
|
|
114
|
-
# @param [Array<MMS::Resource>]
|
111
|
+
# @param [Array<MMS::Resource>] resource_list
|
115
112
|
def print_json(resource_list)
|
116
113
|
rows = []
|
117
114
|
|
@@ -126,127 +123,100 @@ module MMS
|
|
126
123
|
puts 'Default group: ' + @config.default_group_id unless @config.default_group_id.nil?
|
127
124
|
puts 'Default cluster: ' + @config.default_cluster_id unless @config.default_cluster_id.nil?
|
128
125
|
|
129
|
-
if !@config.default_group_id.nil?
|
126
|
+
if !@config.default_group_id.nil? || !@config.default_cluster_id.nil?
|
130
127
|
puts "Add flag --ignore or update --default-group-id, --default-cluster-id or update your `#{@config.config_path}` to see all resources"
|
131
128
|
end
|
132
129
|
end
|
133
130
|
|
134
|
-
|
135
131
|
# @param [Array] arguments
|
136
132
|
def run(arguments)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
raise(["Resource #{e.resource.class.name} problem:", e.message].join("\n"))
|
148
|
-
end
|
133
|
+
parse_user_home_config
|
134
|
+
super
|
135
|
+
rescue Clamp::HelpWanted => _e
|
136
|
+
raise(help)
|
137
|
+
rescue Clamp::UsageError => e
|
138
|
+
raise([e.message, help].join("\n"))
|
139
|
+
rescue MMS::AuthError => _e
|
140
|
+
raise('Authorisation problem. Please check you credential!')
|
141
|
+
rescue MMS::ResourceError => e
|
142
|
+
raise(["Resource #{e.resource.class.name} problem:", e.message].join("\n"))
|
149
143
|
end
|
150
144
|
end
|
151
145
|
|
152
146
|
class MMS::CLI::Command::Groups < MMS::CLI::Command
|
153
|
-
|
154
147
|
subcommand 'list', 'Group list' do
|
155
|
-
|
156
148
|
def execute
|
157
149
|
print(MMS::Resource::Group.table_header, groups)
|
158
150
|
end
|
159
151
|
end
|
160
|
-
|
161
152
|
end
|
162
153
|
|
163
154
|
class MMS::CLI::Command::Hosts < MMS::CLI::Command
|
164
|
-
|
165
155
|
subcommand 'list', 'Host list' do
|
166
|
-
|
167
156
|
def execute
|
168
|
-
host_list = groups.collect!
|
157
|
+
host_list = groups.collect!(&:hosts).flatten
|
169
158
|
print(MMS::Resource::Host.table_header, host_list)
|
170
159
|
end
|
171
160
|
end
|
172
|
-
|
173
161
|
end
|
174
162
|
|
175
163
|
class MMS::CLI::Command::Clusters < MMS::CLI::Command
|
176
|
-
|
177
164
|
subcommand 'list', 'Cluster list' do
|
178
|
-
|
179
165
|
def execute
|
180
166
|
print(MMS::Resource::Cluster.table_header, clusters)
|
181
167
|
end
|
182
168
|
end
|
183
169
|
|
184
170
|
subcommand 'snapshot-schedule', 'Cluster snapshot schedule config' do
|
185
|
-
|
186
171
|
def execute
|
187
|
-
snapshot_schedule_list = clusters.collect!
|
172
|
+
snapshot_schedule_list = clusters.collect!(&:snapshot_schedule).flatten
|
188
173
|
print(MMS::Resource::SnapshotSchedule.table_header, snapshot_schedule_list)
|
189
174
|
end
|
190
175
|
end
|
191
|
-
|
192
176
|
end
|
193
177
|
|
194
|
-
|
195
178
|
class MMS::CLI::Command::Alerts < MMS::CLI::Command
|
196
|
-
|
197
179
|
subcommand 'list', 'Alerts list' do
|
198
|
-
|
199
180
|
def execute
|
200
|
-
alert_list = groups.collect!
|
181
|
+
alert_list = groups.collect!(&:alerts).flatten
|
201
182
|
print(MMS::Resource::Alert.table_header, alert_list)
|
202
183
|
end
|
203
|
-
|
204
184
|
end
|
205
185
|
|
206
186
|
subcommand 'ack', 'Acknowledge alert' do
|
207
|
-
|
208
|
-
parameter '[
|
209
|
-
parameter '[
|
210
|
-
parameter '[timestamp]', 'Postpone to timestamp', :default => 'forever'
|
187
|
+
parameter '[alert-id]', 'Alert ID', default: 'all'
|
188
|
+
parameter '[group-id]', 'Group ID', default: '--default-group-id'
|
189
|
+
parameter '[timestamp]', 'Postpone to timestamp', default: 'forever'
|
211
190
|
|
212
191
|
def execute
|
213
192
|
g_id = group_id == '--default-group-id' ? @config.default_group_id : group_id
|
214
193
|
agent.alert_ack(alert_id, timestamp, g_id)
|
215
194
|
puts 'Done.'
|
216
195
|
end
|
217
|
-
|
218
196
|
end
|
219
|
-
|
220
197
|
end
|
221
198
|
|
222
199
|
class MMS::CLI::Command::Snapshots < MMS::CLI::Command
|
223
|
-
|
224
200
|
subcommand 'list', 'Snapshot list' do
|
225
|
-
|
226
201
|
def execute
|
227
|
-
snapshot_list = clusters.collect!
|
202
|
+
snapshot_list = clusters.collect!(&:snapshots).flatten.sort_by(&:created_date).reverse
|
228
203
|
print(MMS::Resource::Snapshot.table_header, snapshot_list)
|
229
204
|
end
|
230
205
|
end
|
231
|
-
|
232
206
|
end
|
233
207
|
|
234
208
|
class MMS::CLI::Command::RestoreJobs < MMS::CLI::Command
|
235
|
-
|
236
209
|
subcommand 'list', 'Restorejob list' do
|
237
|
-
|
238
210
|
def execute
|
239
|
-
restorejob_list = clusters.collect!
|
211
|
+
restorejob_list = clusters.collect!(&:restorejobs).flatten.sort_by(&:created).reverse
|
240
212
|
print(MMS::Resource::RestoreJob.table_header, restorejob_list)
|
241
213
|
end
|
242
|
-
|
243
214
|
end
|
244
215
|
|
245
216
|
subcommand 'create', 'Restorejob create' do
|
246
|
-
|
247
|
-
parameter '[
|
248
|
-
parameter '[
|
249
|
-
parameter '[cluster-id]', 'Cluster ID', :default => '--default-cluster-id'
|
217
|
+
parameter '[snapshot-source]', 'Restore from source. Options: now | timestamp | snapshot-id', default: 'now'
|
218
|
+
parameter '[group-id]', 'Group ID', default: '--default-group-id'
|
219
|
+
parameter '[cluster-id]', 'Cluster ID', default: '--default-cluster-id'
|
250
220
|
|
251
221
|
def execute
|
252
222
|
g_id = group_id == '--default-group-id' ? @config.default_group_id : group_id
|
@@ -256,19 +226,14 @@ module MMS
|
|
256
226
|
|
257
227
|
puts 'Done.'
|
258
228
|
end
|
259
|
-
|
260
229
|
end
|
261
|
-
|
262
230
|
end
|
263
231
|
|
264
232
|
class MMS::CLI::CommandManager < MMS::CLI::Command
|
265
|
-
|
266
233
|
def run(arguments)
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
abort(e.message.empty? ? 'Unknown error/Interrupt' : e.message)
|
271
|
-
end
|
234
|
+
super
|
235
|
+
rescue Exception => e
|
236
|
+
abort(e.message.empty? ? 'Unknown error/Interrupt' : e.message)
|
272
237
|
end
|
273
238
|
|
274
239
|
subcommand 'groups', 'Groups ', MMS::CLI::Command::Groups
|
@@ -277,9 +242,6 @@ module MMS
|
|
277
242
|
subcommand 'alerts', 'Alerts', MMS::CLI::Command::Alerts
|
278
243
|
subcommand 'snapshots', 'Snapshots', MMS::CLI::Command::Snapshots
|
279
244
|
subcommand 'restorejobs', 'Restorejobs', MMS::CLI::Command::RestoreJobs
|
280
|
-
|
281
245
|
end
|
282
|
-
|
283
246
|
end
|
284
|
-
|
285
247
|
end
|