Class: Ruboty::Handlers::Niftycloud
- Inherits:
-
Base
- Object
- Base
- Ruboty::Handlers::Niftycloud
- Defined in:
- lib/ruboty/handlers/niftycloud.rb
Constant Summary collapse
- NIFTYCLOUD =
"(?:niftycloud|nc)"
- ACCOUNT =
"(?:account|a)"
- COMPUTING =
"(?:computing|c)"
- RDB =
"(?:rdb|r)"
- INSTANCE =
"(?:instance|i)"
- KEY_PAIR =
"(?:key_pair|kp)"
- SECURITY_GROUP =
"(?:security_group|sg)"
- VOLUME =
"(?:volume|v)"
- IMAGE =
"(?:image)"
- LOAD_BALANCER =
"(?:load_balancer|lb)"
- ADDRESS =
"(?:address)"
- SSL_CERTIFICATE =
"(?:ssl_certificate|ssl)"
- AVAILABILITY_ZONE =
"(?:availability_zone|zone)"
- DB_INSTANCE =
"(?:db_instance|i)"
- LIST =
"(?:list|l)"
Instance Attribute Summary collapse
-
#prev ⇒ Object
Returns the value of attribute prev.
Instance Method Summary collapse
- #account_list(message) ⇒ Object
- #account_use(message) ⇒ Object
- #computing_address_list(message) ⇒ Object
- #computing_availability_zone_list(message) ⇒ Object
- #computing_image_list(message) ⇒ Object
- #computing_image_show(message) ⇒ Object
- #computing_instance_list(message) ⇒ Object
- #computing_instance_show(message) ⇒ Object
- #computing_key_pair_list(message) ⇒ Object
- #computing_key_pair_show(message) ⇒ Object
- #computing_load_balancer_list(message) ⇒ Object
- #computing_load_balancer_show(message) ⇒ Object
- #computing_region_list(message) ⇒ Object
- #computing_region_use(message) ⇒ Object
- #computing_security_group_list(message) ⇒ Object
- #computing_security_group_show(message) ⇒ Object
- #computing_ssl_certificate_list(message) ⇒ Object
- #computing_ssl_certificate_show(message) ⇒ Object
- #computing_volume_list(message) ⇒ Object
- #computing_volume_show(message) ⇒ Object
- #event_watch(message) ⇒ Object
-
#initialize(robot) ⇒ Niftycloud
constructor
A new instance of Niftycloud.
- #rdb_db_instance_list(message) ⇒ Object
- #rdb_db_instance_show(message) ⇒ Object
Constructor Details
#initialize(robot) ⇒ Niftycloud
Returns a new instance of Niftycloud.
7 8 9 10 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 7 def initialize(robot) super(robot) @prev = {} end |
Instance Attribute Details
#prev ⇒ Object
Returns the value of attribute prev.
5 6 7 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 5 def prev @prev end |
Instance Method Details
#account_list(message) ⇒ Object
175 176 177 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 175 def account_list() Ruboty::Niftycloud::Actions::AccountList.new().call end |
#account_use(message) ⇒ Object
179 180 181 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 179 def account_use() Ruboty::Niftycloud::Actions::AccountUse.new().call end |
#computing_address_list(message) ⇒ Object
215 216 217 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 215 def computing_address_list() Ruboty::Niftycloud::Actions::ComputingAddressList.new().call end |
#computing_availability_zone_list(message) ⇒ Object
219 220 221 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 219 def computing_availability_zone_list() Ruboty::Niftycloud::Actions::ComputingAvailabilityZoneList.new().call end |
#computing_image_list(message) ⇒ Object
223 224 225 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 223 def computing_image_list() Ruboty::Niftycloud::Actions::ComputingImageList.new().call end |
#computing_image_show(message) ⇒ Object
227 228 229 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 227 def computing_image_show() Ruboty::Niftycloud::Actions::ComputingImageShow.new().call end |
#computing_instance_list(message) ⇒ Object
183 184 185 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 183 def computing_instance_list() Ruboty::Niftycloud::Actions::ComputingInstanceList.new().call end |
#computing_instance_show(message) ⇒ Object
187 188 189 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 187 def computing_instance_show() Ruboty::Niftycloud::Actions::ComputingInstanceShow.new().call end |
#computing_key_pair_list(message) ⇒ Object
231 232 233 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 231 def computing_key_pair_list() Ruboty::Niftycloud::Actions::ComputingKeyPairList.new().call end |
#computing_key_pair_show(message) ⇒ Object
235 236 237 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 235 def computing_key_pair_show() Ruboty::Niftycloud::Actions::ComputingKeyPairShow.new().call end |
#computing_load_balancer_list(message) ⇒ Object
207 208 209 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 207 def computing_load_balancer_list() Ruboty::Niftycloud::Actions::ComputingLoadBalancerList.new().call end |
#computing_load_balancer_show(message) ⇒ Object
211 212 213 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 211 def computing_load_balancer_show() Ruboty::Niftycloud::Actions::ComputingLoadBalancerShow.new().call end |
#computing_region_list(message) ⇒ Object
255 256 257 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 255 def computing_region_list() Ruboty::Niftycloud::Actions::ComputingRegionList.new().call end |
#computing_region_use(message) ⇒ Object
259 260 261 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 259 def computing_region_use() Ruboty::Niftycloud::Actions::ComputingRegionUse.new().call end |
#computing_security_group_list(message) ⇒ Object
191 192 193 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 191 def computing_security_group_list() Ruboty::Niftycloud::Actions::ComputingSecurityGroupList.new().call end |
#computing_security_group_show(message) ⇒ Object
195 196 197 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 195 def computing_security_group_show() Ruboty::Niftycloud::Actions::ComputingSecurityGroupShow.new().call end |
#computing_ssl_certificate_list(message) ⇒ Object
239 240 241 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 239 def computing_ssl_certificate_list() Ruboty::Niftycloud::Actions::ComputingSslCertificateList.new().call end |
#computing_ssl_certificate_show(message) ⇒ Object
243 244 245 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 243 def computing_ssl_certificate_show() Ruboty::Niftycloud::Actions::ComputingSslCertificateShow.new().call end |
#computing_volume_list(message) ⇒ Object
199 200 201 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 199 def computing_volume_list() Ruboty::Niftycloud::Actions::ComputingVolumeList.new().call end |
#computing_volume_show(message) ⇒ Object
203 204 205 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 203 def computing_volume_show() Ruboty::Niftycloud::Actions::ComputingVolumeShow.new().call end |
#event_watch(message) ⇒ Object
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 263 def event_watch() return if @thread .reply "started to watch events" @thread = Thread.new do base = Ruboty::Niftycloud::Actions::Base.new() loop do base.accounts.each do |account| base.current_account(account[:name]) base.computing.regions.each do |region| base.current_region(region['regionName']) resources = { %w(computing volumes) => {id: 'volumeId', label: 'ディスク'}, %w(computing key_pairs) => {id: 'keyName', label: 'SSH キー'}, %w(computing images) => {id: 'imageId', label: 'イメージ'}, %w(computing ssl_certificates) => {id: 'fqdnId', label: 'SSL 証明書'}, %w(computing addresses) => {id: ['publicIp', 'privateIpAddress'], label: '付替 IP アドレス'}, %w(computing uploads) => {id: 'conversionTaskId', label: 'アップロード'}, %w(computing instances) => {id: 'instanceId', label: 'サーバー'}, %w(rdb db_instances) => {id: 'DBInstanceIdentifier', label: 'DB サーバー'}, %w(rdb db_snapshots) => {id: 'instanceId', label: 'DB スナップショット'}, %w(computing security_groups) => {id: 'groupName', ignore: 'ipPermissions', label: 'ファイアウォールグループ'}, %w(rdb db_security_groups) => {id: 'DBSecurityGroupName', ignore: ['EC2SecurityGroups', 'IPRanges'], label: 'DB ファイアウォールグループ'}, %w(rdb db_parameter_groups) => {id: 'DBParameterGroupName', label: 'DB パラメーターグループ'}, } resources.each do |, d2e| begin service, resource = key = [account[:name], region['regionName'], resource].join(':') prev = @prev[key] curr = base.send(service).send(resource) if prev events = D2E.new(d2e).d2e(prev, curr) events.each do |event| ja = case event['type'] when 'create'; '作成' when 'delete'; '削除' when 'update'; '更新' end if event['type'] == 'create' || event['type'] == 'delete' table = Table(event['item'].keys) table << event['item'].values .reply [ "#{account[:name]} (#{account[:description]}) の #{region['regionName']} で下記#{d2e[:label]}が#{ja}されました", table.to_s ] else table = Table(event['diff'].keys) table << event['diff'].values.map {|val| "#{val[0]} -> #{val[1]}" } .reply [ "#{account[:name]} (#{account[:description]}) の #{region['regionName']} で下記#{d2e[:label]}(#{event['id']})が#{ja}されました", table.to_s ].join("\n") end end end @prev[key] = curr rescue StandardError => e .reply "Error: #{e}" end end end end sleep 5 end end.run end |
#rdb_db_instance_list(message) ⇒ Object
247 248 249 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 247 def rdb_db_instance_list() Ruboty::Niftycloud::Actions::RdbDbInstanceList.new().call end |
#rdb_db_instance_show(message) ⇒ Object
251 252 253 |
# File 'lib/ruboty/handlers/niftycloud.rb', line 251 def rdb_db_instance_show() Ruboty::Niftycloud::Actions::RdbDbInstanceShow.new().call end |