ruboty-niftycloud 0.0.2 → 0.0.3

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: 6523e45228397bc507035936b667128a7526f023
4
- data.tar.gz: e1b8b5e226f2f7ec0277ab13ea44187824762f6d
3
+ metadata.gz: bf5afa3cf305d41677d68c153ac5bae57ca1dad2
4
+ data.tar.gz: 56f2612995b3a6864d215164175cfd453c18306d
5
5
  SHA512:
6
- metadata.gz: e20ff19e9a77f8c91d546eae3569142ec75b0fa1977d75c2c5e130359b7c2624a8b36b77175d5a1269bee13853e9756b746ca51e93dc029d88219489eaf275ae
7
- data.tar.gz: 2cbdfdf54d69eafd591e01e66f49e982942e8beb91ecbd620d46178061cec95bdd91ea98f3b97b485641fa4dd188f1c8a5562476373b5f7ea4e52b73699a3984
6
+ metadata.gz: 154297170fdede2cf6050d27dd811f99ed312880f02876f5ecd8439fbdeeffee6797004ed428adb783323d31ffd8b69359119645609d701951659899192bd1de
7
+ data.tar.gz: a20509044adafb99623764caa38067d8bce01a912a3ac1e49de00eb508af7da414b3d5015390f230622c09b4f55465bc53f7694fa2e898e0077497318bebfdf5
data/README.md CHANGED
@@ -20,8 +20,8 @@ gem "ruboty-niftycloud"
20
20
  @ruboty niftycloud computing instance list - list computing instances
21
21
  @ruboty niftycloud computing instance show <instance_id> - show computing instance
22
22
  @ruboty niftycloud computing key_pair list - list computing key pairs
23
- @ruboty niftycloud computing security group list - list computing security groups
24
- @ruboty niftycloud computing security group show <group name> - show computing security group
23
+ @ruboty niftycloud computing security_group list - list computing security groups
24
+ @ruboty niftycloud computing security_group show <group name> - show computing security group
25
25
  @ruboty niftycloud computing volume list - list computing volumes
26
26
  @ruboty niftycloud computing volume show <volume id> - show computing volume
27
27
  @ruboty niftycloud computing load_balancer list - list computing load balancers
@@ -29,8 +29,8 @@ gem "ruboty-niftycloud"
29
29
  @ruboty niftycloud computing address list - list computing addresses
30
30
  @ruboty niftycloud computing image list - list computing images
31
31
  @ruboty niftycloud computing image show <image id> - show computing image
32
- @ruboty niftycloud computing ssl certificate list - list computing ssl certificates
33
- @ruboty niftycloud computing ssl certificate show <fqdn id> - show computing ssl certificate
32
+ @ruboty niftycloud computing ssl_certificate list - list computing ssl certificates
33
+ @ruboty niftycloud computing ssl_certificate show <fqdn id> - show computing ssl certificate
34
34
  @ruboty niftycloud rdb db_instance list - list rdb db instances
35
35
  @ruboty niftycloud rdb db_instance show <db_instance_id> - show rdb db instance
36
36
  ```
@@ -1,6 +1,13 @@
1
1
  module Ruboty
2
2
  module Handlers
3
3
  class Niftycloud < Base
4
+ attr_accessor :prev
5
+
6
+ def initialize(robot)
7
+ super(robot)
8
+ @prev = {}
9
+ end
10
+
4
11
  NIFTYCLOUD = "(?:niftycloud|nc)"
5
12
 
6
13
  ACCOUNT = "(?:account|a)"
@@ -32,6 +39,18 @@ module Ruboty
32
39
  description: 'use niftycloud account',
33
40
  )
34
41
 
42
+ on(
43
+ /#{NIFTYCLOUD} event watch/,
44
+ name: 'event_watch',
45
+ description: 'watch niftycloud events',
46
+ )
47
+
48
+ on(
49
+ /#{NIFTYCLOUD} event unwatch/,
50
+ name: 'event_unwatch',
51
+ description: 'unwatch niftycloud events',
52
+ )
53
+
35
54
  on(
36
55
  /#{NIFTYCLOUD} #{COMPUTING} #{INSTANCE} #{LIST}/,
37
56
  name: 'computing_instance_list',
@@ -239,6 +258,54 @@ module Ruboty
239
258
  def computing_region_use(message)
240
259
  Ruboty::Niftycloud::Actions::ComputingRegionUse.new(message).call
241
260
  end
261
+
262
+ def event_watch(message)
263
+ return if @thread
264
+ @thread = Thread.new do
265
+ base = Ruboty::Niftycloud::Actions::Base.new(message)
266
+ loop do
267
+ base.accounts.each do |account|
268
+ base.current_account(account[:name])
269
+
270
+ base.computing.regions.each do |region|
271
+ base.current_region(region['regionName'])
272
+
273
+ resources = {
274
+ 'volumes' => 'volumeId',
275
+ 'key_pairs' => 'keyName',
276
+ 'images' => 'imageId',
277
+ 'ssl_certificates' => 'fqdnId',
278
+ 'addresses' => ['publicIp', 'privateIpAddress'],
279
+ 'uploads' => ['conversionTaskId'],
280
+ 'instances' => ['instanceId'],
281
+ }
282
+ resources.each do |resource, id|
283
+ key = [account[:name], region['regionName'], resource].join(':')
284
+ prev = @prev[key]
285
+ curr = base.computing.send(resource)
286
+ if prev
287
+ events = D2E.new(id: id).d2e(prev, curr)
288
+ events.each do |event|
289
+ robot.say body: "#{account[:name]}(#{account[:description]}) の #{region['regionName']} で下記 #{resource} が #{event['type']} されました"
290
+ if event['type'] == 'create' || event['type'] == 'delete'
291
+ robot.say body: event['item']
292
+ else
293
+ robot.say body: event
294
+ end
295
+ end
296
+ end
297
+ @prev[key] = curr
298
+ end
299
+ end
300
+ end
301
+ sleep 5
302
+ end
303
+ end.run
304
+ end
305
+ end
306
+
307
+ def event_unwatch(message)
308
+ @thread.kill if @thread
242
309
  end
243
310
  end
244
311
  end
@@ -1,5 +1,5 @@
1
1
  module Ruboty
2
2
  module Niftycloud
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -24,4 +24,5 @@ require "ruboty/niftycloud/actions/rdb_db_instance_show"
24
24
  require "ruboty/niftycloud/version"
25
25
  require "ruboty/handlers/niftycloud"
26
26
 
27
+ require 'd2e'
27
28
  require "ace-client"
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_dependency "ruboty"
25
25
  spec.add_dependency "ace-client"
26
26
  spec.add_dependency "ace-client-ext"
27
+ spec.add_dependency "d2e"
27
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-niftycloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tily
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-22 00:00:00.000000000 Z
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: d2e
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Manage NIFTYCloud via Ruboty
84
98
  email:
85
99
  - tily05@gmail.com