ruboty-niftycloud 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +2 -0
- data/lib/ruboty/handlers/niftycloud.rb +245 -0
- data/lib/ruboty/niftycloud.rb +27 -0
- data/lib/ruboty/niftycloud/actions/account_list.rb +13 -0
- data/lib/ruboty/niftycloud/actions/account_use.rb +24 -0
- data/lib/ruboty/niftycloud/actions/base.rb +60 -0
- data/lib/ruboty/niftycloud/actions/computing_address_list.rb +14 -0
- data/lib/ruboty/niftycloud/actions/computing_availability_zone_list.rb +14 -0
- data/lib/ruboty/niftycloud/actions/computing_image_list.rb +14 -0
- data/lib/ruboty/niftycloud/actions/computing_image_show.rb +14 -0
- data/lib/ruboty/niftycloud/actions/computing_instance_list.rb +13 -0
- data/lib/ruboty/niftycloud/actions/computing_instance_show.rb +15 -0
- data/lib/ruboty/niftycloud/actions/computing_key_pair_list.rb +13 -0
- data/lib/ruboty/niftycloud/actions/computing_load_balancer_list.rb +13 -0
- data/lib/ruboty/niftycloud/actions/computing_load_balancer_show.rb +14 -0
- data/lib/ruboty/niftycloud/actions/computing_region_list.rb +13 -0
- data/lib/ruboty/niftycloud/actions/computing_region_use.rb +13 -0
- data/lib/ruboty/niftycloud/actions/computing_security_group_list.rb +13 -0
- data/lib/ruboty/niftycloud/actions/computing_security_group_show.rb +14 -0
- data/lib/ruboty/niftycloud/actions/computing_ssl_certificate_list.rb +13 -0
- data/lib/ruboty/niftycloud/actions/computing_ssl_certificate_show.rb +14 -0
- data/lib/ruboty/niftycloud/actions/computing_volume_list.rb +13 -0
- data/lib/ruboty/niftycloud/actions/computing_volume_show.rb +14 -0
- data/lib/ruboty/niftycloud/actions/rdb_db_instance_list.rb +14 -0
- data/lib/ruboty/niftycloud/actions/rdb_db_instance_show.rb +14 -0
- data/lib/ruboty/niftycloud/version.rb +5 -0
- data/ruboty-niftycloud.gemspec +27 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e4e05cb20e4e6eaa24e29d1d7a47c4d581ab8488
|
4
|
+
data.tar.gz: de9d5ced2ff824957bbaef354c6fce27ce52472c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5bb9db657b63536605b677ce6b1e37d38cff1edf99b9d61525d6da11c5c4de5424a12afc41f96417a56b6884fb133b0e6fd30b26d5748ae1915f63daaac77660
|
7
|
+
data.tar.gz: 641e7210f1bb29026bd97623ef54a07602091b158998a2ede7c25f8933e4b111e8e0e176cce68e9181e405690b646de7fa76d410f8bf3fda778db973cbef7b50
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 tily
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Ruboty::Niftycloud
|
2
|
+
|
3
|
+
Manage NIFTYCloud via Ruboty
|
4
|
+
|
5
|
+
## Install
|
6
|
+
|
7
|
+
```
|
8
|
+
# Gemfile
|
9
|
+
gem "ruboty-niftycloud"
|
10
|
+
```
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
```
|
15
|
+
@ruboty niftycloud account list - list accounts
|
16
|
+
@ruboty niftycloud account use <account or number> - use account
|
17
|
+
@ruboty niftycloud computing region list - list computing regions
|
18
|
+
@ruboty niftycloud computing region use - use computing region
|
19
|
+
@ruboty niftycloud computing availability zone list - list computing availability zones
|
20
|
+
@ruboty niftycloud computing instance list - list computing instances
|
21
|
+
@ruboty niftycloud computing instance show <instance_id> - show computing instance
|
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
|
25
|
+
@ruboty niftycloud computing volume list - list computing volumes
|
26
|
+
@ruboty niftycloud computing volume show <volume id> - show computing volume
|
27
|
+
@ruboty niftycloud computing load_balancer list - list computing load balancers
|
28
|
+
@ruboty niftycloud computing load_balancer show <load balancer name> - show computing load balancer
|
29
|
+
@ruboty niftycloud computing address list - list computing addresses
|
30
|
+
@ruboty niftycloud computing image list - list computing images
|
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
|
34
|
+
@ruboty niftycloud rdb db_instance list - list rdb db instances
|
35
|
+
@ruboty niftycloud rdb db_instance show <db_instance_id> - show rdb db instance
|
36
|
+
```
|
37
|
+
|
38
|
+
## ENV
|
39
|
+
|
40
|
+
```
|
41
|
+
NIFTYCLOUD_ACCOUNTS - accounts to use (separated by comma)
|
42
|
+
NIFTYCLOUD_DEFAULT_ACCOUNT - default account
|
43
|
+
NIFTYCLOUD_ACCOUNT_ABC12345_DESCRIPTION - account's description
|
44
|
+
NIFTYCLOUD_ACCOUNT_ABC12345_ACCESS_KEY_ID - account's access key id
|
45
|
+
NIFTYCLOUD_ACCOUNT_ABC12345_SECRET_ACCESS_KEY - account's secret access key
|
46
|
+
```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it ( https://github.com/[my-github-username]/ruboty-niftycloud/fork )
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
p 'handl'
|
2
|
+
module Ruboty
|
3
|
+
module Handlers
|
4
|
+
class Niftycloud < Base
|
5
|
+
NIFTYCLOUD = "(?:niftycloud|nc)"
|
6
|
+
|
7
|
+
ACCOUNT = "(?:account|a)"
|
8
|
+
COMPUTING = "(?:computing|c)"
|
9
|
+
RDB = "(?:rdb|r)"
|
10
|
+
|
11
|
+
INSTANCE = "(?:instance|i)"
|
12
|
+
KEY_PAIR = "(?:key_pair|kp)"
|
13
|
+
SECURITY_GROUP = "(?:security_group|sg)"
|
14
|
+
VOLUME = "(?:volume|v)"
|
15
|
+
IMAGE = "(?:image)"
|
16
|
+
LOAD_BALANCER = "(?:load_balancer|lb)"
|
17
|
+
ADDRESS = "(?:address)"
|
18
|
+
SSL_CERTIFICATE = "(?:ssl_certificate|ssl)"
|
19
|
+
AVAILABILITY_ZONE = "(?:availability_zone|zone)"
|
20
|
+
DB_INSTANCE = "(?:db_instance|i)"
|
21
|
+
|
22
|
+
LIST = "(?:list|l)"
|
23
|
+
|
24
|
+
on(
|
25
|
+
/#{NIFTYCLOUD} #{ACCOUNT} #{LIST}/,
|
26
|
+
name: 'account_list',
|
27
|
+
description: 'list niftycloud accounts',
|
28
|
+
)
|
29
|
+
|
30
|
+
on(
|
31
|
+
/#{NIFTYCLOUD} #{ACCOUNT} use (?<target>.+)/,
|
32
|
+
name: 'account_use',
|
33
|
+
description: 'use niftycloud account',
|
34
|
+
)
|
35
|
+
|
36
|
+
on(
|
37
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{INSTANCE} #{LIST}/,
|
38
|
+
name: 'computing_instance_list',
|
39
|
+
description: 'list computing instances',
|
40
|
+
)
|
41
|
+
|
42
|
+
on(
|
43
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{INSTANCE} show (?<instance_id>.+)/,
|
44
|
+
name: 'computing_instance_show',
|
45
|
+
description: 'show computing instance',
|
46
|
+
)
|
47
|
+
|
48
|
+
on(
|
49
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{SECURITY_GROUP} #{LIST}/,
|
50
|
+
name: 'computing_security_group_list',
|
51
|
+
description: 'list computing security groups',
|
52
|
+
)
|
53
|
+
|
54
|
+
on(
|
55
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{SECURITY_GROUP} show (?<group_name>.+)/,
|
56
|
+
name: 'computing_security_group_show',
|
57
|
+
description: 'show computing security group',
|
58
|
+
)
|
59
|
+
|
60
|
+
on(
|
61
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{VOLUME} #{LIST}/,
|
62
|
+
name: 'computing_volume_list',
|
63
|
+
description: 'list computing volumes',
|
64
|
+
)
|
65
|
+
|
66
|
+
on(
|
67
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{VOLUME} show (?<volume_id>.+)/,
|
68
|
+
name: 'computing_volume_show',
|
69
|
+
description: 'show computing volume',
|
70
|
+
)
|
71
|
+
|
72
|
+
on(
|
73
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{LOAD_BALANCER} #{LIST}/,
|
74
|
+
name: 'computing_load_balancer_list',
|
75
|
+
description: 'list computing load balancers',
|
76
|
+
)
|
77
|
+
|
78
|
+
on(
|
79
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{LOAD_BALANCER} show (?<load_balancer_name>.+)/,
|
80
|
+
name: 'computing_load_balancer_show',
|
81
|
+
description: 'show computing load balancer',
|
82
|
+
)
|
83
|
+
|
84
|
+
on(
|
85
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{ADDRESS} #{LIST}/,
|
86
|
+
name: 'computing_address_list',
|
87
|
+
description: 'list computing addresss',
|
88
|
+
)
|
89
|
+
|
90
|
+
on(
|
91
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{AVAILABILITY_ZONE} #{LIST}/,
|
92
|
+
name: 'computing_availability_zone_list',
|
93
|
+
description: 'list computing availability zones',
|
94
|
+
)
|
95
|
+
|
96
|
+
on(
|
97
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{IMAGE} #{LIST}/,
|
98
|
+
name: 'computing_image_list',
|
99
|
+
description: 'list computing images',
|
100
|
+
)
|
101
|
+
|
102
|
+
on(
|
103
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{IMAGE} show (?<image_id>.+)/,
|
104
|
+
name: 'computing_image_show',
|
105
|
+
description: 'show computing image',
|
106
|
+
)
|
107
|
+
|
108
|
+
on(
|
109
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{KEY_PAIR} #{LIST}/,
|
110
|
+
name: 'computing_key_pair_list',
|
111
|
+
description: 'list computing key pairs',
|
112
|
+
)
|
113
|
+
|
114
|
+
on(
|
115
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{KEY_PAIR} show (?<key_pair_id>.+)/,
|
116
|
+
name: 'computing_key_pair_show',
|
117
|
+
description: 'show computing key pair',
|
118
|
+
)
|
119
|
+
|
120
|
+
on(
|
121
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{SSL_CERTIFICATE} list/,
|
122
|
+
name: 'computing_ssl_certificate_list',
|
123
|
+
description: 'list computing ssl certificates',
|
124
|
+
)
|
125
|
+
|
126
|
+
on(
|
127
|
+
/#{NIFTYCLOUD} #{COMPUTING} #{SSL_CERTIFICATE} show (?<fqdn_id>.+)/,
|
128
|
+
name: 'computing_ssl_certificate_show',
|
129
|
+
description: 'show computing ssl certificate',
|
130
|
+
)
|
131
|
+
|
132
|
+
on(
|
133
|
+
/#{NIFTYCLOUD} #{RDB} #{DB_INSTANCE} #{LIST}/,
|
134
|
+
name: 'rdb_db_instance_list',
|
135
|
+
description: 'list rdb db instances',
|
136
|
+
)
|
137
|
+
|
138
|
+
on(
|
139
|
+
/#{NIFTYCLOUD} #{RDB} #{DB_INSTANCE} show (?<db_instance_id>.+)/,
|
140
|
+
name: 'rdb_db_instance_show',
|
141
|
+
description: 'show rdb db instance',
|
142
|
+
)
|
143
|
+
|
144
|
+
on(
|
145
|
+
/#{NIFTYCLOUD} #{COMPUTING} region #{LIST}/,
|
146
|
+
name: 'computing_region_list',
|
147
|
+
description: 'list computing regions',
|
148
|
+
)
|
149
|
+
|
150
|
+
on(
|
151
|
+
/#{NIFTYCLOUD} #{COMPUTING} region use (?<region>.+)/,
|
152
|
+
name: 'computing_region_use',
|
153
|
+
description: 'use computing region',
|
154
|
+
)
|
155
|
+
|
156
|
+
def account_list(message)
|
157
|
+
Ruboty::Niftycloud::Actions::AccountList.new(message).call
|
158
|
+
end
|
159
|
+
|
160
|
+
def account_use(message)
|
161
|
+
Ruboty::Niftycloud::Actions::AccountUse.new(message).call
|
162
|
+
end
|
163
|
+
|
164
|
+
def computing_instance_list(message)
|
165
|
+
Ruboty::Niftycloud::Actions::ComputingInstanceList.new(message).call
|
166
|
+
end
|
167
|
+
|
168
|
+
def computing_instance_show(message)
|
169
|
+
Ruboty::Niftycloud::Actions::ComputingInstanceShow.new(message).call
|
170
|
+
end
|
171
|
+
|
172
|
+
def computing_security_group_list(message)
|
173
|
+
Ruboty::Niftycloud::Actions::ComputingSecurityGroupList.new(message).call
|
174
|
+
end
|
175
|
+
|
176
|
+
def computing_security_group_show(message)
|
177
|
+
Ruboty::Niftycloud::Actions::ComputingSecurityGroupShow.new(message).call
|
178
|
+
end
|
179
|
+
|
180
|
+
def computing_volume_list(message)
|
181
|
+
Ruboty::Niftycloud::Actions::ComputingVolumeList.new(message).call
|
182
|
+
end
|
183
|
+
|
184
|
+
def computing_volume_show(message)
|
185
|
+
Ruboty::Niftycloud::Actions::ComputingVolumeShow.new(message).call
|
186
|
+
end
|
187
|
+
|
188
|
+
def computing_load_balancer_list(message)
|
189
|
+
Ruboty::Niftycloud::Actions::ComputingLoadBalancerList.new(message).call
|
190
|
+
end
|
191
|
+
|
192
|
+
def computing_load_balancer_show(message)
|
193
|
+
Ruboty::Niftycloud::Actions::ComputingLoadBalancerShow.new(message).call
|
194
|
+
end
|
195
|
+
|
196
|
+
def computing_address_list(message)
|
197
|
+
Ruboty::Niftycloud::Actions::ComputingAddressList.new(message).call
|
198
|
+
end
|
199
|
+
|
200
|
+
def computing_availability_zone_list(message)
|
201
|
+
Ruboty::Niftycloud::Actions::ComputingAvailabilityZoneList.new(message).call
|
202
|
+
end
|
203
|
+
|
204
|
+
def computing_image_list(message)
|
205
|
+
Ruboty::Niftycloud::Actions::ComputingImageList.new(message).call
|
206
|
+
end
|
207
|
+
|
208
|
+
def computing_image_show(message)
|
209
|
+
Ruboty::Niftycloud::Actions::ComputingImageShow.new(message).call
|
210
|
+
end
|
211
|
+
|
212
|
+
def computing_key_pair_list(message)
|
213
|
+
Ruboty::Niftycloud::Actions::ComputingKeyPairList.new(message).call
|
214
|
+
end
|
215
|
+
|
216
|
+
def computing_key_pair_show(message)
|
217
|
+
Ruboty::Niftycloud::Actions::ComputingKeyPairShow.new(message).call
|
218
|
+
end
|
219
|
+
|
220
|
+
def computing_ssl_certificate_list(message)
|
221
|
+
Ruboty::Niftycloud::Actions::ComputingSslCertificateList.new(message).call
|
222
|
+
end
|
223
|
+
|
224
|
+
def computing_ssl_certificate_show(message)
|
225
|
+
Ruboty::Niftycloud::Actions::ComputingSslCertificateShow.new(message).call
|
226
|
+
end
|
227
|
+
|
228
|
+
def rdb_db_instance_list(message)
|
229
|
+
Ruboty::Niftycloud::Actions::RdbDbInstanceList.new(message).call
|
230
|
+
end
|
231
|
+
|
232
|
+
def rdb_db_instance_show(message)
|
233
|
+
Ruboty::Niftycloud::Actions::RdbDbInstanceShow.new(message).call
|
234
|
+
end
|
235
|
+
|
236
|
+
def computing_region_list(message)
|
237
|
+
Ruboty::Niftycloud::Actions::ComputingRegionList.new(message).call
|
238
|
+
end
|
239
|
+
|
240
|
+
def computing_region_use(message)
|
241
|
+
Ruboty::Niftycloud::Actions::ComputingRegionUse.new(message).call
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "ruboty"
|
2
|
+
require "ruboty/niftycloud/actions/base"
|
3
|
+
require "ruboty/niftycloud/actions/account_list"
|
4
|
+
require "ruboty/niftycloud/actions/account_use"
|
5
|
+
require "ruboty/niftycloud/actions/computing_region_list"
|
6
|
+
require "ruboty/niftycloud/actions/computing_region_use"
|
7
|
+
require "ruboty/niftycloud/actions/computing_instance_list"
|
8
|
+
require "ruboty/niftycloud/actions/computing_instance_show"
|
9
|
+
require "ruboty/niftycloud/actions/computing_security_group_list"
|
10
|
+
require "ruboty/niftycloud/actions/computing_security_group_show"
|
11
|
+
require "ruboty/niftycloud/actions/computing_volume_list"
|
12
|
+
require "ruboty/niftycloud/actions/computing_volume_show"
|
13
|
+
require "ruboty/niftycloud/actions/computing_load_balancer_list"
|
14
|
+
require "ruboty/niftycloud/actions/computing_load_balancer_show"
|
15
|
+
require "ruboty/niftycloud/actions/computing_key_pair_list"
|
16
|
+
require "ruboty/niftycloud/actions/computing_image_list"
|
17
|
+
require "ruboty/niftycloud/actions/computing_image_show"
|
18
|
+
require "ruboty/niftycloud/actions/computing_availability_zone_list"
|
19
|
+
require "ruboty/niftycloud/actions/computing_ssl_certificate_list"
|
20
|
+
require "ruboty/niftycloud/actions/computing_ssl_certificate_show"
|
21
|
+
require "ruboty/niftycloud/actions/computing_address_list"
|
22
|
+
require "ruboty/niftycloud/actions/rdb_db_instance_list"
|
23
|
+
require "ruboty/niftycloud/actions/rdb_db_instance_show"
|
24
|
+
require "ruboty/niftycloud/version"
|
25
|
+
require "ruboty/handlers/niftycloud"
|
26
|
+
|
27
|
+
require "ace-client"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class AccountList < Base
|
5
|
+
def call
|
6
|
+
accounts.each_with_index do |account, i|
|
7
|
+
message.reply("#{i} [#{account[:name] == current_account[:name] ? "*" : " "}] #{account[:name]} - #{account[:description]}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class AccountUse < Base
|
5
|
+
def call
|
6
|
+
target = message[:target]
|
7
|
+
|
8
|
+
if target.match(/^\d+$/)
|
9
|
+
account = accounts[target.to_i]
|
10
|
+
else
|
11
|
+
account = accounts.find {|account| account[:name] == target }
|
12
|
+
end
|
13
|
+
|
14
|
+
if !account
|
15
|
+
return message.reply("Error: account not found")
|
16
|
+
end
|
17
|
+
|
18
|
+
current_account(account[:name])
|
19
|
+
message.reply("using: #{account[:name]}")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'ace-client/niftycloud/computing'
|
2
|
+
require 'ace-client/niftycloud/rdb'
|
3
|
+
|
4
|
+
module Ruboty
|
5
|
+
module Niftycloud
|
6
|
+
module Actions
|
7
|
+
class Base
|
8
|
+
NAMESPACE = "niftycloud"
|
9
|
+
|
10
|
+
attr_reader :message
|
11
|
+
|
12
|
+
def initialize(message)
|
13
|
+
@message = message
|
14
|
+
end
|
15
|
+
|
16
|
+
def accounts
|
17
|
+
ENV["NIFTYCLOUD_ACCOUNTS"].split(",").map do |account|
|
18
|
+
{
|
19
|
+
name: account,
|
20
|
+
description: ENV["NIFTYCLOUD_ACCOUNT_#{account}_DESCRIPTION"],
|
21
|
+
access_key_id: ENV["NIFTYCLOUD_ACCOUNT_#{account}_ACCESS_KEY_ID"],
|
22
|
+
secret_access_key: ENV["NIFTYCLOUD_ACCOUNT_#{account}_SECRET_ACCESS_KEY"],
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def current_account(account=nil)
|
28
|
+
message.robot.brain.data[NAMESPACE] ||= {}
|
29
|
+
if account
|
30
|
+
message.robot.brain.data[NAMESPACE]["current_account"] = account
|
31
|
+
else
|
32
|
+
name = message.robot.brain.data[NAMESPACE]["current_account"] || ENV["NIFTYCLOUD_DEFAULT_ACCOUNT"]
|
33
|
+
accounts.find {|account| account[:name] == name }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def current_region(region=nil)
|
38
|
+
message.robot.brain.data[NAMESPACE] ||= {}
|
39
|
+
if region
|
40
|
+
message.robot.brain.data[NAMESPACE]["current_region"] = region
|
41
|
+
else
|
42
|
+
message.robot.brain.data[NAMESPACE]["current_region"] || 'east-1'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def computing
|
47
|
+
AceClient::Niftycloud::Computing.build_client(
|
48
|
+
current_account.merge(endpoint: "#{current_region}.cp.cloud.nifty.com", path: '/api')
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
def rdb
|
53
|
+
AceClient::Niftycloud::Rdb.build_client(
|
54
|
+
current_account.merge(endpoint: "rdb.jp-#{current_region}.api.cloud.nifty.com")
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingAddressList < Base
|
5
|
+
def call
|
6
|
+
computing.addresses.each do |address|
|
7
|
+
# TODO: instance
|
8
|
+
message.reply("#{address['publicIp']} #{address['privateIpAddress']} #{address['description']} #{address['availabilityZone']}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingAvailabilityZoneList < Base
|
5
|
+
def call
|
6
|
+
computing.availability_zones.each do |availability_zone|
|
7
|
+
# TODO: {"zoneName"=>"east-11", "zoneState"=>"available", "regionName"=>"east-1", "messageSet"=>nil, "securityGroupSupported"=>"false", "isDefault"=>"false"}
|
8
|
+
message.reply(availability_zone.values.join(' '))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingImageList < Base
|
5
|
+
def call
|
6
|
+
computing.images.each do |image|
|
7
|
+
# TODO: OS name
|
8
|
+
message.reply("#{image['name']} #{image['imageId']} #{image['architecture']} #{image['imageState']} #{image['imageOwnerAlias']}(#{image['imageOwnerId']}) #{image['description']} #{image['placement'] ? image['placement']['availabilityZone'] : ''}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingImageShow < Base
|
5
|
+
def call
|
6
|
+
image = computing.images.find {|image| image['imageId'] == message[:image_id] }
|
7
|
+
image.each do |k, v|
|
8
|
+
message.reply "#{k}: #{v}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingInstanceList < Base
|
5
|
+
def call
|
6
|
+
computing.instances.each do |instance|
|
7
|
+
message.reply "#{instance['instanceId']} #{instance['instanceType']} #{instance['instanceState']['name']} #{instance['placement']['availabilityZone']} #{instance['ipAddress']} #{instance['description']} #{instance['launchTime']}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingInstanceShow < Base
|
5
|
+
def call
|
6
|
+
instance_id = message[:instance_id]
|
7
|
+
instance = computing.instances.find {|instance| instance['instanceId'] == instance_id }
|
8
|
+
instance.each do |k, v|
|
9
|
+
message.reply "#{k}: #{v}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingLoadBalancerList < Base
|
5
|
+
def call
|
6
|
+
computing.load_balancers.each do |load_balancer|
|
7
|
+
message.reply "#{load_balancer['LoadBalancerName']} #{load_balancer['DNSName']} #{load_balancer['ListenerDescriptions']} #{load_balancer['Instances'] ? [load_balancer['Instances']['member']].flatten.size : ''} #{}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingLoadBalancerShow < Base
|
5
|
+
def call
|
6
|
+
load_balancer = computing.load_balancers.find {|load_balancer| load_balancer['LoadBalancerName'] == message[:load_balancer_name] }
|
7
|
+
load_balancer.each do |k, v|
|
8
|
+
message.reply "#{k}: #{v}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingRegionList < Base
|
5
|
+
def call
|
6
|
+
computing.regions.each do |region|
|
7
|
+
message.reply("#{region['regionName']} #{region['regionEndpoint']} #{region['isDefault']}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingSecurityGroupList < Base
|
5
|
+
def call
|
6
|
+
computing.security_groups.each do |security_group|
|
7
|
+
message.reply("#{security_group['groupName']} #{security_group['ipPermissions'] ? security_group['ipPermissions']['item'].size : 0} #{security_group['groupStatus']} #{security_group['groupDescription']} #{security_group['availabilityZone']}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingSecurityGroupShow < Base
|
5
|
+
def call
|
6
|
+
security_group = computing.security_groups.find {|security_group| security_group['groupName'] == message[:group_name] }
|
7
|
+
security_group.each do |k, v|
|
8
|
+
message.reply "#{k}: #{v}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingSslCertificateShow < Base
|
5
|
+
def call
|
6
|
+
ssl_certificate = computing.ssl_certificates.find {|ssl_certificate| ssl_certificate['fqdnId'] == message[:fqdn_id] }
|
7
|
+
ssl_certificate.each do |k, v|
|
8
|
+
message.reply "#{k}: #{v}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingVolumeList < Base
|
5
|
+
def call
|
6
|
+
computing.volumes.each do |volume|
|
7
|
+
message.reply("#{volume['volumeId']} #{volume['diskType']} #{volume['size']} #{volume['status']} #{volume['attachmentSet'] ? [volume['attachmentSet']['item']].flatten.first['instanceId'] : ''} #{volume['availabilityZone']}")
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class ComputingVolumeShow < Base
|
5
|
+
def call
|
6
|
+
volume = computing.volumes.find {|volume| volume['volumeId'] == message[:volume_id] }
|
7
|
+
volume.each do |k, v|
|
8
|
+
puts "#{k}: #{v}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class RdbDbInstanceList < Base
|
5
|
+
def call
|
6
|
+
rdb.db_instances.each do |db_instance|
|
7
|
+
# TODO: Type(master or replica)
|
8
|
+
message.reply("#{db_instance['DBInstanceIdentifier']} #{db_instance['DBInstanceClass']} #{db_instance['Engine']}#{db_instance['EngineVersion']} #{db_instance['DBInstanceStatus']} #{db_instance['AllocatedStorage']} #{db_instance['AvailabilityZone']} #{db_instance['Endpoint']['Address']} #{db_instance['Endpoint']['NiftyPrivateAddress']}")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Niftycloud
|
3
|
+
module Actions
|
4
|
+
class RdbDbInstanceShow < Base
|
5
|
+
def call
|
6
|
+
db_instance = rdb.db_instances.find {|db_instance| db_instance['DBInstanceIdentifier'] == message[:db_instance_id] }
|
7
|
+
db_instance.each do |k, v|
|
8
|
+
message.reply "#{k}: #{v}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/niftycloud/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruboty-niftycloud"
|
8
|
+
spec.version = Ruboty::Niftycloud::VERSION
|
9
|
+
spec.authors = ["tily"]
|
10
|
+
spec.email = ["tily05@gmail.com"]
|
11
|
+
spec.summary = %q{Manage NIFTYCloud via Ruboty}
|
12
|
+
spec.description = %q{Manage NIFTYCloud via Ruboty}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_dependency "ruboty"
|
25
|
+
spec.add_dependency "ace-client"
|
26
|
+
spec.add_dependency "ace-client-ext"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-niftycloud
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- tily
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruboty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: ace-client
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ace-client-ext
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Manage NIFTYCloud via Ruboty
|
84
|
+
email:
|
85
|
+
- tily05@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE.txt
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- lib/ruboty/handlers/niftycloud.rb
|
96
|
+
- lib/ruboty/niftycloud.rb
|
97
|
+
- lib/ruboty/niftycloud/actions/account_list.rb
|
98
|
+
- lib/ruboty/niftycloud/actions/account_use.rb
|
99
|
+
- lib/ruboty/niftycloud/actions/base.rb
|
100
|
+
- lib/ruboty/niftycloud/actions/computing_address_list.rb
|
101
|
+
- lib/ruboty/niftycloud/actions/computing_availability_zone_list.rb
|
102
|
+
- lib/ruboty/niftycloud/actions/computing_image_list.rb
|
103
|
+
- lib/ruboty/niftycloud/actions/computing_image_show.rb
|
104
|
+
- lib/ruboty/niftycloud/actions/computing_instance_list.rb
|
105
|
+
- lib/ruboty/niftycloud/actions/computing_instance_show.rb
|
106
|
+
- lib/ruboty/niftycloud/actions/computing_key_pair_list.rb
|
107
|
+
- lib/ruboty/niftycloud/actions/computing_load_balancer_list.rb
|
108
|
+
- lib/ruboty/niftycloud/actions/computing_load_balancer_show.rb
|
109
|
+
- lib/ruboty/niftycloud/actions/computing_region_list.rb
|
110
|
+
- lib/ruboty/niftycloud/actions/computing_region_use.rb
|
111
|
+
- lib/ruboty/niftycloud/actions/computing_security_group_list.rb
|
112
|
+
- lib/ruboty/niftycloud/actions/computing_security_group_show.rb
|
113
|
+
- lib/ruboty/niftycloud/actions/computing_ssl_certificate_list.rb
|
114
|
+
- lib/ruboty/niftycloud/actions/computing_ssl_certificate_show.rb
|
115
|
+
- lib/ruboty/niftycloud/actions/computing_volume_list.rb
|
116
|
+
- lib/ruboty/niftycloud/actions/computing_volume_show.rb
|
117
|
+
- lib/ruboty/niftycloud/actions/rdb_db_instance_list.rb
|
118
|
+
- lib/ruboty/niftycloud/actions/rdb_db_instance_show.rb
|
119
|
+
- lib/ruboty/niftycloud/version.rb
|
120
|
+
- ruboty-niftycloud.gemspec
|
121
|
+
homepage: ''
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.3.0
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Manage NIFTYCloud via Ruboty
|
145
|
+
test_files: []
|