diff --git a/lib/fog/rackspace/monitoring.rb b/lib/fog/rackspace/monitoring.rb index 8ca248607..32572a61a 100644 --- a/lib/fog/rackspace/monitoring.rb +++ b/lib/fog/rackspace/monitoring.rb @@ -61,6 +61,7 @@ module Fog request_path 'fog/rackspace/requests/monitoring' request :list_agent_tokens + request :list_agents request :list_alarms request :list_alarm_examples request :list_checks @@ -72,6 +73,7 @@ module Fog request :list_notification_plans request :list_notifications + request :get_agent request :get_agent_token request :get_alarm request :get_alarm_example diff --git a/lib/fog/rackspace/requests/monitoring/get_cpus_info.rb b/lib/fog/rackspace/requests/monitoring/get_cpus_info.rb index ac0f61d1c..34dd52155 100644 --- a/lib/fog/rackspace/requests/monitoring/get_cpus_info.rb +++ b/lib/fog/rackspace/requests/monitoring/get_cpus_info.rb @@ -15,10 +15,8 @@ module Fog class Mock def get_cpus_info(agent_id) - agent_id = Fog::Rackspace::MockData.uuid - if agent_id == -1 - raise Fog::Rackspace::Monitoring::NotFound + raise Fog::Rackspace::Monitoring::BadRequest end response = Excon::Response.new diff --git a/lib/fog/rackspace/requests/monitoring/get_disks_info.rb b/lib/fog/rackspace/requests/monitoring/get_disks_info.rb index 8282c90b8..761adb6c0 100644 --- a/lib/fog/rackspace/requests/monitoring/get_disks_info.rb +++ b/lib/fog/rackspace/requests/monitoring/get_disks_info.rb @@ -15,10 +15,8 @@ module Fog class Mock def get_disks_info(agent_id) - agent_id = Fog::Rackspace::MockData.uuid - if agent_id == -1 - raise Fog::Rackspace::Monitoring::NotFound + raise Fog::Rackspace::Monitoring::BadRequest end response = Excon::Response.new diff --git a/lib/fog/rackspace/requests/monitoring/get_filesystems_info.rb b/lib/fog/rackspace/requests/monitoring/get_filesystems_info.rb index 08c5b825d..81358d5c6 100644 --- a/lib/fog/rackspace/requests/monitoring/get_filesystems_info.rb +++ b/lib/fog/rackspace/requests/monitoring/get_filesystems_info.rb @@ -15,10 +15,8 @@ module Fog class Mock def get_filesystems_info(agent_id) - agent_id = Fog::Rackspace::MockData.uuid - if agent_id == -1 - raise Fog::Rackspace::Monitoring::NotFound + raise Fog::Rackspace::Monitoring::BadRequest end response = Excon::Response.new diff --git a/lib/fog/rackspace/requests/monitoring/get_logged_in_user_info.rb b/lib/fog/rackspace/requests/monitoring/get_logged_in_user_info.rb index 98cb11ba5..7ff36f4c1 100644 --- a/lib/fog/rackspace/requests/monitoring/get_logged_in_user_info.rb +++ b/lib/fog/rackspace/requests/monitoring/get_logged_in_user_info.rb @@ -15,10 +15,8 @@ module Fog class Mock def get_logged_in_user_info(agent_id) - agent_id = Fog::Rackspace::MockData.uuid - if agent_id == -1 - raise Fog::Rackspace::Monitoring::NotFound + raise Fog::Rackspace::Monitoring::BadRequest end response = Excon::Response.new diff --git a/lib/fog/rackspace/requests/monitoring/get_memory_info.rb b/lib/fog/rackspace/requests/monitoring/get_memory_info.rb index 07f6f6b3d..98a866383 100644 --- a/lib/fog/rackspace/requests/monitoring/get_memory_info.rb +++ b/lib/fog/rackspace/requests/monitoring/get_memory_info.rb @@ -15,10 +15,8 @@ module Fog class Mock def get_memory_info(agent_id) - agent_id = Fog::Rackspace::MockData.uuid - if agent_id == -1 - raise Fog::Rackspace::Monitoring::NotFound + raise Fog::Rackspace::Monitoring::BadRequest end response = Excon::Response.new diff --git a/lib/fog/rackspace/requests/monitoring/get_network_interfaces_info.rb b/lib/fog/rackspace/requests/monitoring/get_network_interfaces_info.rb index 8610fa659..04efd4b29 100644 --- a/lib/fog/rackspace/requests/monitoring/get_network_interfaces_info.rb +++ b/lib/fog/rackspace/requests/monitoring/get_network_interfaces_info.rb @@ -15,10 +15,8 @@ module Fog class Mock def get_network_interfaces_info(agent_id) - agent_id = Fog::Rackspace::MockData.uuid - if agent_id == -1 - raise Fog::Rackspace::Monitoring::NotFound + raise Fog::Rackspace::Monitoring::BadRequest end response = Excon::Response.new diff --git a/lib/fog/rackspace/requests/monitoring/get_processes_info.rb b/lib/fog/rackspace/requests/monitoring/get_processes_info.rb index 3e5934182..d2f4d5496 100644 --- a/lib/fog/rackspace/requests/monitoring/get_processes_info.rb +++ b/lib/fog/rackspace/requests/monitoring/get_processes_info.rb @@ -15,13 +15,12 @@ module Fog class Mock def get_processes_info(agent_id) - agent_id = Fog::Rackspace::MockData.uuid memory_major_faults = Fog::Mock.random_numbers(1).to_i memory_minor_faults = Fog::Mock.random_numbers(3).to_i memory_page_faults = memory_major_faults+memory_minor_faults if agent_id == -1 - raise Fog::Rackspace::Monitoring::NotFound + raise Fog::Rackspace::Monitoring::BadRequest end response = Excon::Response.new diff --git a/lib/fog/rackspace/requests/monitoring/get_system_info.rb b/lib/fog/rackspace/requests/monitoring/get_system_info.rb index c3c650f37..ed3a5a132 100644 --- a/lib/fog/rackspace/requests/monitoring/get_system_info.rb +++ b/lib/fog/rackspace/requests/monitoring/get_system_info.rb @@ -15,10 +15,8 @@ module Fog class Mock def get_system_info(agent_id) - agent_id = Fog::Rackspace::MockData.uuid - if agent_id == -1 - raise Fog::Rackspace::Monitoring::NotFound + raise Fog::Rackspace::Monitoring::BadRequest end response = Excon::Response.new diff --git a/tests/rackspace/requests/monitoring/agent_tests.rb b/tests/rackspace/requests/monitoring/agent_tests.rb index 51ddf96f3..d81640c95 100644 --- a/tests/rackspace/requests/monitoring/agent_tests.rb +++ b/tests/rackspace/requests/monitoring/agent_tests.rb @@ -3,6 +3,11 @@ Shindo.tests('Fog::Rackspace::Monitoring | agent_tests', ['rackspace','rackspace account = Fog::Rackspace::Monitoring.new agent_token = nil options = { "label" => "Bar" } + values_format = Hash +# values_format = { +# 'info' => Fog::Nullable::Hash +# } + tests('success') do tests('#create new agent token').formats(DATA_FORMAT) do response = account.create_agent_token(options).data @@ -12,13 +17,47 @@ Shindo.tests('Fog::Rackspace::Monitoring | agent_tests', ['rackspace','rackspace tests('#list agent tokens').formats(LIST_HEADERS_FORMAT) do account.list_agent_tokens().data[:headers] end + tests("#list_agents") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.list_agents.body } + end + tests("#get_agent") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_agent("agent_id").body } + end + + tests('#get agent token').formats(LIST_HEADERS_FORMAT) do account.get_agent_token(agent_token).data[:headers] end tests('#delete agent token').formats(DELETE_HEADERS_FORMAT) do account.delete_agent_token(agent_token).data[:headers] end + tests("#get_cpus_info") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_cpus_info("agent_id").body } + end + tests("#get_disks_info") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_disks_info("agent_id").body } + end + tests("#get_filesystems_info") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_filesystems_info("agent_id").body } + end + tests("#get_logged_in_user_info") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_logged_in_user_info("agent_id").body } + end + tests("#get_memory_info") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_memory_info("agent_id").body } + end + tests("#get_network_interfaces_info") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_network_interfaces_info("agent_id").body } + end + tests("#get_processes_info") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_processes_info("agent_id").body } + end + tests("#get_system_info") do + data_matches_schema(values_format, {:allow_extra_keys => true}) { account.get_system_info("agent_id").body } + end + end + tests('failure') do tests('#fail to create agent token(-1)').raises(TypeError) do account.create_agent_token(-1) @@ -29,5 +68,11 @@ Shindo.tests('Fog::Rackspace::Monitoring | agent_tests', ['rackspace','rackspace tests('#fail to delete agent token(-1)').raises(Fog::Rackspace::Monitoring::NotFound) do account.delete_agent_token(-1) end + tests('#fail to connect to agent(-1)').raises(Fog::Rackspace::Monitoring::BadRequest) do + account.get_cpus_info(-1) + end + tests('#fail to get agent (-1)').raises(Fog::Rackspace::Monitoring::NotFound) do + account.get_agent(-1) + end end end