mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[stormondemand|monitoring] Add a new Monitoring service and add/move load/bandwidth/service APIs
This commit is contained in:
parent
3de8f5c9c4
commit
55d0925de1
20 changed files with 336 additions and 54 deletions
24
lib/fog/monitoring.rb
Normal file
24
lib/fog/monitoring.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
module Fog
|
||||
module Monitoring
|
||||
|
||||
def self.[](provider)
|
||||
self.new(:provider => provider)
|
||||
end
|
||||
|
||||
def self.new(attributes)
|
||||
attributes = attributes.dup
|
||||
provider = attributes.delete(:provider).to_s.downcase.to_sym
|
||||
if provider == :stormondemand
|
||||
require 'fog/storm_on_demand/billing'
|
||||
Fog::Monitoring::StormOnDemand.new(attributes)
|
||||
else
|
||||
raise ArgumentError.new("#{provider} has no monitoring service")
|
||||
end
|
||||
end
|
||||
|
||||
def self.providers
|
||||
Fog.services[:monitoring]
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -9,6 +9,7 @@ module Fog
|
|||
service(:storage, 'storm_on_demand/storage', 'Storage')
|
||||
service(:dns, 'storm_on_demand/dns', 'DNS')
|
||||
service(:billing, 'storm_on_demand/billing', 'Billing')
|
||||
service(:monitoring, 'storm_on_demand/monitoring', 'Monitoring')
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,8 +30,6 @@ module Fog
|
|||
collection :pools
|
||||
model :zone
|
||||
collection :zones
|
||||
model :stat
|
||||
collection :stats
|
||||
model :template
|
||||
collection :templates
|
||||
model :product
|
||||
|
@ -80,9 +78,6 @@ module Fog
|
|||
request :update_image
|
||||
request :restore_image
|
||||
|
||||
request :get_stats
|
||||
request :get_stats_graph
|
||||
|
||||
request :list_private_ips
|
||||
request :get_private_ip
|
||||
request :attach_server_to_private_ip
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storm_on_demand/models/compute/stat'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
class StormOnDemand
|
||||
|
||||
class Stats < Fog::Collection
|
||||
model Fog::Compute::StormOnDemand::Stat
|
||||
|
||||
def get(options)
|
||||
data = service.get_stats(options).body
|
||||
load(data)
|
||||
rescue Excon::Errors::Forbidden
|
||||
nil
|
||||
end
|
||||
|
||||
def graph(options)
|
||||
service.get_stats_graph(options).body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/storm_on_demand/models/monitoring/bandwidth.rb
Normal file
23
lib/fog/storm_on_demand/models/monitoring/bandwidth.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
|
||||
class Bandwidth < Fog::Model
|
||||
attribute :actual
|
||||
attribute :averages
|
||||
attribute :cost
|
||||
attribute :domain
|
||||
attribute :pricing
|
||||
attribute :projected
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
23
lib/fog/storm_on_demand/models/monitoring/bandwidths.rb
Normal file
23
lib/fog/storm_on_demand/models/monitoring/bandwidths.rb
Normal file
|
@ -0,0 +1,23 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storm_on_demand/models/monitoring/bandwidth'
|
||||
|
||||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
|
||||
class Bandwidths < Fog::Collection
|
||||
model Fog::Monitoring::StormOnDemand::Bandwidth
|
||||
|
||||
def graph(options)
|
||||
service.get_bandwidth_graph(options).body
|
||||
end
|
||||
|
||||
def stats(uniq_id)
|
||||
bw = service.get_bandwidth_stats(:uniq_id => uniq_id).body
|
||||
new(bw)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,15 +1,15 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Compute
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
|
||||
class Stat < Fog::Model
|
||||
class Load < Fog::Model
|
||||
attribute :disk
|
||||
attribute :domain
|
||||
attribute :loadavg
|
||||
attribute :memory
|
||||
attribute :proc
|
||||
attribute :domain
|
||||
attribute :disk
|
||||
attribute :uptime
|
||||
|
||||
def initialize(attributes={})
|
24
lib/fog/storm_on_demand/models/monitoring/loads.rb
Normal file
24
lib/fog/storm_on_demand/models/monitoring/loads.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storm_on_demand/models/monitoring/load'
|
||||
|
||||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
|
||||
class Loads < Fog::Collection
|
||||
model Fog::Monitoring::StormOnDemand::Load
|
||||
|
||||
def graph(options)
|
||||
service.get_load_graph(options).body
|
||||
end
|
||||
|
||||
def stats(uniq_id)
|
||||
load = service.get_load_stats(:uniq_id => uniq_id).body
|
||||
new(load)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
22
lib/fog/storm_on_demand/models/monitoring/monitor_service.rb
Normal file
22
lib/fog/storm_on_demand/models/monitoring/monitor_service.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
require 'fog/core/model'
|
||||
|
||||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
|
||||
class MonitorService < Fog::Model
|
||||
attribute :can_monitor
|
||||
attribute :enabled
|
||||
attribute :services
|
||||
attribute :uniq_id
|
||||
attribute :unmonitored
|
||||
|
||||
def initialize(attributes={})
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
require 'fog/core/collection'
|
||||
require 'fog/storm_on_demand/models/monitoring/monitor_service'
|
||||
|
||||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
|
||||
class MonitorServices < Fog::Collection
|
||||
model Fog::Monitoring::StormOnDemand::MonitorService
|
||||
|
||||
def get(uniq_id)
|
||||
status = service.get_service(:uniq_id => uniq_id).body
|
||||
new(status)
|
||||
end
|
||||
|
||||
def monitoring_ips
|
||||
service.monitoring_ips.body['ips']
|
||||
end
|
||||
|
||||
def status(uniq_id)
|
||||
service.get_service_status(:uniq_id => uniq_id).body
|
||||
end
|
||||
|
||||
def update(options)
|
||||
status = service.update_service(options).body
|
||||
new(status)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
68
lib/fog/storm_on_demand/monitoring.rb
Normal file
68
lib/fog/storm_on_demand/monitoring.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
require 'fog/storm_on_demand'
|
||||
require 'fog/monitoring'
|
||||
require 'fog/storm_on_demand/shared'
|
||||
|
||||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand < Fog::Service
|
||||
|
||||
requires :storm_on_demand_username, :storm_on_demand_password
|
||||
recognizes :storm_on_demand_auth_url
|
||||
|
||||
model_path 'fog/storm_on_demand/models/monitoring'
|
||||
model :load
|
||||
collection :loads
|
||||
model :bandwidth
|
||||
collection :bandwidths
|
||||
model :monitor_service
|
||||
collection :monitor_services
|
||||
|
||||
request_path 'fog/storm_on_demand/requests/monitoring'
|
||||
request :get_load_graph
|
||||
request :get_load_stats
|
||||
request :get_bandwidth_graph
|
||||
request :get_bandwidth_stats
|
||||
request :get_service
|
||||
request :monitoring_ips
|
||||
request :get_service_status
|
||||
request :update_service
|
||||
|
||||
|
||||
class Mock
|
||||
|
||||
def self.data
|
||||
@data ||= Hash.new
|
||||
end
|
||||
|
||||
def self.reset
|
||||
@data = nil
|
||||
end
|
||||
|
||||
def self.reset_data(keys=data.keys)
|
||||
for key in [*keys]
|
||||
data.delete(key)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(options={})
|
||||
@storm_on_demand_username = options[:storm_on_demand_username]
|
||||
end
|
||||
|
||||
def data
|
||||
self.class.data[@storm_on_demand_username]
|
||||
end
|
||||
|
||||
def reset_data
|
||||
self.class.data.delete(@storm_on_demand_username)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Real
|
||||
|
||||
include Fog::StormOnDemand::RealShared
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,16 +0,0 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_stats(options = {})
|
||||
request(
|
||||
:path => "/Monitoring/Load/stats",
|
||||
:body => Fog::JSON.encode({:params => options})
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_bandwidth_graph(options={})
|
||||
request(
|
||||
:path => '/Monitoring/Bandwidth/graph',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_bandwidth_stats(options={})
|
||||
request(
|
||||
:path => '/Monitoring/Bandwidth/stats',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,9 +1,9 @@
|
|||
module Fog
|
||||
module Compute
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_stats_graph(options={})
|
||||
def get_load_graph(options={})
|
||||
request(
|
||||
:path => '/Monitoring/Load/graph',
|
||||
:body => Fog::JSON.encode(:params => options)
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_load_stats(options={})
|
||||
request(
|
||||
:path => '/Monitoring/Load/stats',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/storm_on_demand/requests/monitoring/get_service.rb
Normal file
16
lib/fog/storm_on_demand/requests/monitoring/get_service.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_service(options={})
|
||||
request(
|
||||
:path => '/Monitoring/Services/get',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def get_service_status(options={})
|
||||
request(
|
||||
:path => '/Monitoring/Services/status',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def monitoring_ips(options={})
|
||||
request(
|
||||
:path => '/Monitoring/Services/monitoringIps',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Monitoring
|
||||
class StormOnDemand
|
||||
class Real
|
||||
|
||||
def update_service(options={})
|
||||
request(
|
||||
:path => '/Monitoring/Services/update',
|
||||
:body => Fog::JSON.encode(:params => options)
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue