ruboty-niftycloud 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/ruboty/handlers/niftycloud.rb +46 -21
- data/lib/ruboty/niftycloud.rb +1 -0
- data/lib/ruboty/niftycloud/version.rb +1 -1
- data/ruboty-niftycloud.gemspec +1 -0
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2fbaea4da6186886970574cccbe543fdcbd5bd0
|
4
|
+
data.tar.gz: 5f4de5c82986028326b02500b786cdb9bb773b03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d38adba0d69534049f5b9660e7c97907407ff11477de024e3e92ef156cc96f3c666a8151818c990daae1e2b9e550bd1086c083aa4b8cd084cb6c5d25bbad549b
|
7
|
+
data.tar.gz: 33f7218e3c80464c30a033e9b6e4bcff4798a152a248676cec8004ba85ae6e9dfbce674a1ca4cc599df6278d65765a5cd8098adf457d1361cf1b87fb162c1fd0
|
data/README.md
CHANGED
@@ -14,6 +14,8 @@ gem "ruboty-niftycloud"
|
|
14
14
|
```
|
15
15
|
@ruboty niftycloud account list - list accounts
|
16
16
|
@ruboty niftycloud account use <account or number> - use account
|
17
|
+
@ruboty niftycloud event watch - watch events
|
18
|
+
@ruboty niftycloud event unwatch - unwatch events
|
17
19
|
@ruboty niftycloud computing region list - list computing regions
|
18
20
|
@ruboty niftycloud computing region use - use computing region
|
19
21
|
@ruboty niftycloud computing availability zone list - list computing availability zones
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding:utf-8
|
1
2
|
module Ruboty
|
2
3
|
module Handlers
|
3
4
|
class Niftycloud < Base
|
@@ -261,6 +262,7 @@ module Ruboty
|
|
261
262
|
|
262
263
|
def event_watch(message)
|
263
264
|
return if @thread
|
265
|
+
message.reply "started to watch events"
|
264
266
|
@thread = Thread.new do
|
265
267
|
base = Ruboty::Niftycloud::Actions::Base.new(message)
|
266
268
|
loop do
|
@@ -271,30 +273,50 @@ module Ruboty
|
|
271
273
|
base.current_region(region['regionName'])
|
272
274
|
|
273
275
|
resources = {
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
276
|
+
%w(computing volumes) => {id: 'volumeId', label: 'ディスク'},
|
277
|
+
%w(computing key_pairs) => {id: 'keyName', label: 'SSH キー'},
|
278
|
+
%w(computing images) => {id: 'imageId', label: 'イメージ'},
|
279
|
+
%w(computing ssl_certificates) => {id: 'fqdnId', label: 'SSL 証明書'},
|
280
|
+
%w(computing addresses) => {id: ['publicIp', 'privateIpAddress'], label: '付替 IP アドレス'},
|
281
|
+
%w(computing uploads) => {id: 'conversionTaskId', label: 'アップロード'},
|
282
|
+
%w(computing instances) => {id: 'instanceId', label: 'サーバー'},
|
283
|
+
%w(rdb db_instances) => {id: 'DBInstanceIdentifier', label: 'DB サーバー'},
|
284
|
+
%w(rdb db_snapshots) => {id: 'instanceId', label: 'DB スナップショット'},
|
285
|
+
%w(computing security_groups) => {id: 'groupName', ignore: 'ipPermissions', label: 'ファイアウォールグループ'},
|
286
|
+
%w(rdb db_security_groups) => {id: 'DBSecurityGroupName', ignore: ['EC2SecurityGroups', 'IPRanges'], label: 'DB ファイアウォールグループ'},
|
287
|
+
%w(rdb db_parameter_groups) => {id: 'DBParameterGroupName', label: 'DB パラメーターグループ'},
|
281
288
|
}
|
282
|
-
resources.each do |
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
289
|
+
resources.each do |options, d2e|
|
290
|
+
begin
|
291
|
+
service, resource = options
|
292
|
+
key = [account[:name], region['regionName'], resource].join(':')
|
293
|
+
prev = @prev[key]
|
294
|
+
curr = base.send(service).send(resource)
|
295
|
+
if prev
|
296
|
+
events = D2E.new(d2e).d2e(prev, curr)
|
297
|
+
events.each do |event|
|
298
|
+
ja = case event['type']
|
299
|
+
when 'create'; '作成'
|
300
|
+
when 'delete'; '削除'
|
301
|
+
when 'update'; '更新'
|
302
|
+
end
|
303
|
+
if event['type'] == 'create' || event['type'] == 'delete'
|
304
|
+
robot.say body: "#{account[:name]} (#{account[:description]}) の #{region['regionName']} で下記#{d2e[:label]}が#{ja}されました"
|
305
|
+
table = Table(event['item'].keys)
|
306
|
+
table << event['item'].values
|
307
|
+
robot.say body: table.to_s
|
308
|
+
else
|
309
|
+
robot.say body: "#{account[:name]} (#{account[:description]}) の #{region['regionName']} で下記#{d2e[:label]}(#{event['id']})が#{ja}されました"
|
310
|
+
table = Table(event['diff'].keys)
|
311
|
+
table << event['diff'].values.map {|val| "#{val[0]} -> #{val[1]}" }
|
312
|
+
robot.say body: table.to_s
|
313
|
+
end
|
294
314
|
end
|
295
315
|
end
|
316
|
+
@prev[key] = curr
|
317
|
+
rescue StandardError => e
|
318
|
+
robot.say "Error: #{e}"
|
296
319
|
end
|
297
|
-
@prev[key] = curr
|
298
320
|
end
|
299
321
|
end
|
300
322
|
end
|
@@ -305,7 +327,10 @@ module Ruboty
|
|
305
327
|
end
|
306
328
|
|
307
329
|
def event_unwatch(message)
|
308
|
-
|
330
|
+
return if @thread.nil
|
331
|
+
@thread.kill
|
332
|
+
@thread = nil
|
333
|
+
message.reply "stopped to watch events"
|
309
334
|
end
|
310
335
|
end
|
311
336
|
end
|
data/lib/ruboty/niftycloud.rb
CHANGED
data/ruboty-niftycloud.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-niftycloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tily
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: ruport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description: Manage NIFTYCloud via Ruboty
|
98
112
|
email:
|
99
113
|
- tily05@gmail.com
|