Class: Fog::Rackspace::Monitoring::Mock

Inherits:
Service
  • Object
show all
Defined in:
lib/fog/rackspace/monitoring.rb,
lib/fog/rackspace/requests/monitoring/get_agent.rb,
lib/fog/rackspace/requests/monitoring/get_alarm.rb,
lib/fog/rackspace/requests/monitoring/get_check.rb,
lib/fog/rackspace/requests/monitoring/get_entity.rb,
lib/fog/rackspace/requests/monitoring/list_agents.rb,
lib/fog/rackspace/requests/monitoring/list_alarms.rb,
lib/fog/rackspace/requests/monitoring/list_checks.rb,
lib/fog/rackspace/requests/monitoring/create_alarm.rb,
lib/fog/rackspace/requests/monitoring/create_check.rb,
lib/fog/rackspace/requests/monitoring/delete_alarm.rb,
lib/fog/rackspace/requests/monitoring/delete_check.rb,
lib/fog/rackspace/requests/monitoring/list_metrics.rb,
lib/fog/rackspace/requests/monitoring/update_alarm.rb,
lib/fog/rackspace/requests/monitoring/update_check.rb,
lib/fog/rackspace/requests/monitoring/create_entity.rb,
lib/fog/rackspace/requests/monitoring/delete_entity.rb,
lib/fog/rackspace/requests/monitoring/get_cpus_info.rb,
lib/fog/rackspace/requests/monitoring/list_entities.rb,
lib/fog/rackspace/requests/monitoring/list_overview.rb,
lib/fog/rackspace/requests/monitoring/update_entity.rb,
lib/fog/rackspace/requests/monitoring/get_disks_info.rb,
lib/fog/rackspace/requests/monitoring/get_agent_token.rb,
lib/fog/rackspace/requests/monitoring/get_memory_info.rb,
lib/fog/rackspace/requests/monitoring/get_system_info.rb,
lib/fog/rackspace/requests/monitoring/get_notification.rb,
lib/fog/rackspace/requests/monitoring/list_check_types.rb,
lib/fog/rackspace/requests/monitoring/list_data_points.rb,
lib/fog/rackspace/requests/monitoring/list_agent_tokens.rb,
lib/fog/rackspace/requests/monitoring/create_agent_token.rb,
lib/fog/rackspace/requests/monitoring/delete_agent_token.rb,
lib/fog/rackspace/requests/monitoring/get_processes_info.rb,
lib/fog/rackspace/requests/monitoring/list_notifications.rb,
lib/fog/rackspace/requests/monitoring/get_filesystems_info.rb,
lib/fog/rackspace/requests/monitoring/get_logged_in_user_info.rb,
lib/fog/rackspace/requests/monitoring/list_notification_plans.rb,
lib/fog/rackspace/requests/monitoring/get_network_interfaces_info.rb

Instance Method Summary collapse

Methods inherited from Service

#authenticate, #endpoint_uri, #region, #request_without_retry, #service_name, #service_net?

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



116
117
# File 'lib/fog/rackspace/monitoring.rb', line 116

def initialize(options={})
end

Instance Method Details

#create_agent_token(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/rackspace/requests/monitoring/create_agent_token.rb', line 18

def create_agent_token(options = {})

   = Fog::Mock.random_numbers(6).to_s
  token = Fog::Mock.random_letters(50).to_s
  
  if options == -1
    raise TypeError
  end

  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Location"              => "https://monitoring.api.rackspacecloud.com/v1.0/" +  + "/agent_tokens/" + token,
    "X-Object-ID"           => token,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "oknwowevown9330wneviniv",
    "X-LB"                  => "ord1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain",
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#create_alarm(entity_id, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/rackspace/requests/monitoring/create_alarm.rb', line 18

def create_alarm(entity_id, options = {})

  alarm_id = Fog::Mock.random_letters(10)
   = Fog::Mock.random_numbers(6).to_s

  if options[:type]
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Location"              => "https://monitoring.api.rackspacecloud.com/v1.0/" +  + "/entities/" + entity_id.to_s + "/alarms/" + alarm_id,
    "X-Object-ID"           => alarm_id,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "47877",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "laolsgggopnnsv",
    "X-LB"                  => "dfw1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response

end

#create_check(entity_id, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/rackspace/requests/monitoring/create_check.rb', line 18

def create_check(entity_id, options = {})

   = Fog::Mock.random_numbers(6).to_s
  mock_id = Fog::Mock.random_letters(10).to_s
  
  if options[:type] == ""
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Location"              => "https://monitoring.api.rackspacecloud.com/v1.0/" +  + "/" + entity_id + "/checks/" + mock_id,
    "X-Object-ID"           => mock_id,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "knvlknvosnd20038hgouwvn9nv",
    "X-LB"                  => "ord1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain",
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#create_entity(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/fog/rackspace/requests/monitoring/create_entity.rb', line 19

def create_entity(options = {})

   = Fog::Mock.random_numbers(6).to_s
  entity_id = Fog::Mock.random_letters(10)

  if options[:label] == ""  
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Location"              => "https://monitoring.api.rackspacecloud.com/v1.0/" +  + "/entities/" + entity_id,
    "X-Object-ID"           => entity_id,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "47877",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "lakbngf9bgewkgb39sobnsv",
    "X-LB"                  => "dfw1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#delete_agent_token(options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/rackspace/requests/monitoring/delete_agent_token.rb', line 16

def delete_agent_token(options = {})

   = Fog::Mock.random_numbers(6).to_s
  token = Fog::Mock.random_letters(50).to_s

  if options == -1
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 201
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Location"              => "https://monitoring.api.rackspacecloud.com/v1.0/" +  + "/agent_tokens/" + token,
    "X-Object-ID"           => token,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "lsknvnslnv2083ovnsdbno00",
    "X-LB"                  => "ord1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain",
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#delete_alarm(entity_id, alarm_id) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/rackspace/requests/monitoring/delete_alarm.rb', line 17

def delete_alarm(entity_id, alarm_id)

  if entity_id == -1 || alarm_id == -1
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 204
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "38687",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "pomsbnio93gm3030fm303.mmowd",
    "X-LB"                  => "ord1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Content-Length"        => "0"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#delete_check(entity_id, check_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/rackspace/requests/monitoring/delete_check.rb', line 16

def delete_check(entity_id, check_id)
  
  if entity_id == -1 || check_id == -1
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 204
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => ".rh-lHJL.h-ord1-maas-prod-api1.r-AGRIH406.c-4085336.ts-1377785008661.v-e602877",
    "X-LB"                  => "ord1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain",
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#delete_entity(entity_id) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/rackspace/requests/monitoring/delete_entity.rb', line 17

def delete_entity(entity_id)

  if entity_id == -1
   raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 204
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "47877",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "lakgnnnf9bgewkgb39sobnsv",
    "X-LB"                  => "ord1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#get_agent(agent_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/fog/rackspace/requests/monitoring/get_agent.rb', line 15

def get_agent(agent_id)

  if agent_id == -1
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
        "id"              => Fog::Rackspace::MockData.uuid,  
        "last_connected"  => Time.now.to_i - 100,
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#get_agent_token(id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/rackspace/requests/monitoring/get_agent_token.rb', line 16

def get_agent_token(id)

  token = Fog::Mock.random_letters(50).to_s

  if id == -1
    raise TypeError
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "id"      => token,
    "token"   => token,
    "label"   => "mock_token"
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "47903",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "kvnsdonvosnv92989vbvbob",
    "X-LB"                  => "ord1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#get_alarm(entity_id, alarm_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/rackspace/requests/monitoring/get_alarm.rb', line 18

def get_alarm(entity_id, alarm_id)

  if entity_id == -1 || alarm_id == -1
   raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "id"                    => alarm_id,
    "label"                 => nil,
    "check_id"              => Fog::Mock.random_letters(10),
    "criteria"              => nil,
    "disabled"              => false,
    "notification_plan_id"  => "npTechnicalContactsEmail",
    "metadata"              => nil,
    "created_at"            => Time.now.to_i - 1,
    "updated_at"            => Time.now.to_i
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "38687",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "pomkondbno93gm3030fm303.mmowd",
    "X-LB"                  => "ord1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#get_check(entity_id, check_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fog/rackspace/requests/monitoring/get_check.rb', line 16

def get_check(entity_id, check_id)

  if entity_id == -1 || check_id == -1
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "id"                    => check_id,
    "label"                 => nil, 
    "type"                  => "remote.ping", 
    "details"               => {"count"=>5}, 
    "monitoring_zones_poll" => ["mzord", "mzdfw", "mziad"], 
    "timeout"               => 10, 
    "period"                => 30, 
    "target_alias"          => nil, 
    "target_hostname"       => "1.1.1.1", 
    "target_resolver"       => "IPv4", 
    "disabled"              => false, 
    "metadata"              => nil, 
    "created_at"            => Time.now.to_i - 1,
    "updated_at"            => Time.now.to_i
  },
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8", 
    "X-RateLimit-Limit"     => "50000", 
    "X-RateLimit-Remaining" => "44676", 
    "X-RateLimit-Window"    => "24 hours", 
    "X-RateLimit-Type"      => "global", 
    "X-Response-Id"         => "jdnbono34090934nggn", 
    "X-LB"                  => "ord1-maas-prod-api0", 
    "Vary"                  => "Accept-Encoding", 
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#get_cpus_info(agent_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fog/rackspace/requests/monitoring/get_cpus_info.rb', line 16

def get_cpus_info(agent_id)

  if agent_id == -1
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "info"  => [
      {
        "name"            => "cpu.0",
        "vendor"          => "AMD",
        "model"           => "Opteron",
        "mhz"             => Fog::Mock.random_numbers(4).to_i,
        "idle"            => Fog::Mock.random_numbers(10).to_i,
        "irq"             => Fog::Mock.random_numbers(5).to_i,
        "soft_irq"        => Fog::Mock.random_numbers(7).to_i,
        "nice"            => Fog::Mock.random_numbers(9).to_i,
        "stolen"          => Fog::Mock.random_numbers(7).to_i,
        "sys"             => Fog::Mock.random_numbers(7).to_i,
        "user"            => Fog::Mock.random_numbers(9).to_i,
        "wait"            => Fog::Mock.random_numbers(7).to_i,  
        "total"           => Fog::Mock.random_numbers(11).to_i,
        "total_cores"     => 1,
        "total_sockets"   => 1
      }
    ]
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#get_disks_info(agent_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fog/rackspace/requests/monitoring/get_disks_info.rb', line 16

def get_disks_info(agent_id)

  if agent_id == -1
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "info"  => [
      {
        "read_bytes"      => Fog::Mock.random_numbers(10).to_i,
        "reads"           => Fog::Mock.random_numbers(6).to_i,
        "rtime"           => Fog::Mock.random_numbers(6).to_i,
        "write_bytes"     => Fog::Mock.random_numbers(10).to_i,
        "writes"          => Fog::Mock.random_numbers(8).to_i,
        "wtime"           => Fog::Mock.random_numbers(9).to_i,
        "time"            => Fog::Mock.random_numbers(7).to_i,
        "name"            => "/dev/xvda1"
      }
    ]
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#get_entity(entity_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/rackspace/requests/monitoring/get_entity.rb', line 18

def get_entity(entity_id)

   = Fog::Mock.random_numbers(6).to_s
  server_id = Fog::Rackspace::MockData.uuid
  entity_label = Fog::Mock.random_letters(10)

  if entity_id == -1
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "id"            => entity_id,
    "label"         => entity_label,
     "metadata"     => nil,
     "managed"      => false,
     "uri"          => "https://ord.servers.api.rackspacecloud.com/" +  + "/servers/" + server_id,
     "agent_id"     => nil,
     "created_at"   => Time.now.to_i - 1,
     "updated_at"   => Time.now.to_i

  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlkgmngjl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#get_filesystems_info(agent_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/fog/rackspace/requests/monitoring/get_filesystems_info.rb', line 16

def get_filesystems_info(agent_id)

  if agent_id == -1
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "info"  => [
      {
        "dir_name"        => "/",
        "dev_name"        => "/dev/xvda1",
        "sys_type_name"   => "ext4",
        "options"         => "rw,noatime,acl,errors=remount-ro,barrier=0",
        "free"            => Fog::Mock.random_numbers(8).to_i,
        "used"            => Fog::Mock.random_numbers(5).to_i,
        "avail"           => Fog::Mock.random_numbers(7).to_i,
        "total"           => Fog::Mock.random_numbers(9).to_i,
        "files"           => Fog::Mock.random_numbers(6).to_i,
        "free_files"      => Fog::Mock.random_numbers(6).to_i,
      },
      {
        "dir_name"        => "/proc",
        "dev_name"        => "proc",
        "sys_type_name"    => "ext4",
        "options"         => "rw",
      }
    ]
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#get_logged_in_user_info(agent_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fog/rackspace/requests/monitoring/get_logged_in_user_info.rb', line 16

def (agent_id)

  if agent_id == -1
    raise Fog::Rackspace::Monitoring::BadRequest
  end
  
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "info"  => [
      {
        "user"      => "root",
        "device"    => "pts/1",
        "time"      => Time.now.to_i - 100,
        "host"      => "somehost1.company.local"
      },
      {
        "user"      => "user123",
        "device"    => "pts/2",
        "time"      => Time.now.to_i - 50,
        "host"      => "somehost2.company.local"
      }              
    ]
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#get_memory_info(agent_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/fog/rackspace/requests/monitoring/get_memory_info.rb', line 16

def get_memory_info(agent_id)

  if agent_id == -1
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "info"  => [
      {
        "actual_free"     => Fog::Mock.random_numbers(9).to_i,
        "actual_used"     => Fog::Mock.random_numbers(8).to_i,
        "free"            => Fog::Mock.random_numbers(7).to_i,
        "used"            => Fog::Mock.random_numbers(9).to_i,
        "total"           => Fog::Mock.random_numbers(10).to_i,
        "ram"           => Fog::Mock.random_numbers(4).to_i,
        "swap_total"      => Fog::Mock.random_numbers(10).to_i,
        "swap_used"       => Fog::Mock.random_numbers(8).to_i,
        "swap_free"       => Fog::Mock.random_numbers(10).to_i,                
        "swap_page_in"    => Fog::Mock.random_numbers(3).to_i,
        "swap_page_out"   => Fog::Mock.random_numbers(3).to_i,
      }
    ]
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#get_network_interfaces_info(agent_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/fog/rackspace/requests/monitoring/get_network_interfaces_info.rb', line 16

def get_network_interfaces_info(agent_id)

  if agent_id == -1
    raise Fog::Rackspace::Monitoring::BadRequest
  end
  
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "info"  => [
      {
        "name"        => "lo",
        "type"        => "Local Loopback",
        "address"     => Fog::Mock.random_ip({:version => :v4}),
        "netmask"     => "255.0.0.0",
        "address6"    => "::1",
        "broadcast"   => "0.0.0.0.0",
        "hwaddr"      => "00:00:00:00:00:00",
        "mtu"         => Fog::Mock.random_numbers(4).to_i,
        "rx_packets"  => Fog::Mock.random_numbers(3).to_i,
        "rx_bytes"    => Fog::Mock.random_numbers(4).to_i,
        "tx_packets"  => Fog::Mock.random_numbers(3).to_i,
        "tx_bytes"    => Fog::Mock.random_numbers(4).to_i,
        "flags"       => Fog::Mock.random_numbers(2).to_i,
      },
      {
        "name"        => "eth0",
        "type"        => "Ethernet",
        "address"     => Fog::Mock.random_ip({:version => :v4}),
        "netmask"     => "255.255.255.0",
        "address6"    => Fog::Mock.random_ip({:version => :v6}),
        "broadcast"   => Fog::Mock.random_ip({:version => :v4}),
        "hwaddr"      => "A1:B2:C3:D4:E5:F6",
        "mtu"         => "1500",
        "rx_packets"  => Fog::Mock.random_numbers(7).to_i,
        "rx_bytes"    => Fog::Mock.random_numbers(9).to_i,
        "tx_packets"  => Fog::Mock.random_numbers(7).to_i,
        "tx_bytes"    => Fog::Mock.random_numbers(9).to_i,
        "flags"       => Fog::Mock.random_numbers(4).to_i,
      },
      {
        "name"        => "eth1",
        "type"        => "Ethernet",
        "address"     => Fog::Mock.random_ip({:version => :v4}),
        "netmask"     => "255.255.128.0",
        "address6"    => Fog::Mock.random_ip({:version => :v6}),
        "broadcast"   => Fog::Mock.random_ip({:version => :v4}),
        "hwaddr"      => "A2:B3:C4:D5:E6:F7",
        "mtu"         => "1500",
        "rx_packets"  => Fog::Mock.random_numbers(7).to_i,
        "rx_bytes"    => Fog::Mock.random_numbers(9).to_i,
        "tx_packets"  => Fog::Mock.random_numbers(7).to_i,
        "tx_bytes"    => Fog::Mock.random_numbers(9).to_i,
        "flags"       => Fog::Mock.random_numbers(4).to_i,
      }              
    ]
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#get_notification(notification_id) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/rackspace/requests/monitoring/get_notification.rb', line 17

def get_notification(notification_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
      "created_at" => 1378783452067,
      "details" => {
          "address" => "[email protected]"
      },
      "id" => "ntnJN3MQrA",
      "label" => "my email update test",
      "type" => "email",
      "updated_at" => 1378784136307
  }
  
  response.headers = {
    "Date"=> Time.now.utc.to_s,
    "Content-Type"=>"application/json; charset=UTF-8",
    "X-RateLimit-Limit"=>"50000",
    "X-RateLimit-Remaining"=>"49627",
    "X-RateLimit-Window"=>"24 hours",
    "X-RateLimit-Type"=>"global",
    "X-Response-Id"=>"j23jlk234jl2j34j",
    "X-LB"=>"dfw1-maas-prod-api0",
    "Vary"=>"Accept-Encoding",
    "Transfer-Encoding"=>"chunked"
  }
  response
end

#get_processes_info(agent_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fog/rackspace/requests/monitoring/get_processes_info.rb', line 16

def get_processes_info(agent_id)

  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::BadRequest
  end
  
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "info"  => [
      {
        "pid"             => Fog::Mock.random_numbers(4).to_i,
        "exe_name"        => "/usr/share/nova-agent/0.0.1.38/sbin/nova-agent",
        "exe_cwd"         => "/",
        "exe_root"        => "/",
        "time_total"      => Fog::Mock.random_numbers(3).to_i,
        "time_sys"        => Fog::Mock.random_numbers(2).to_i,
        "time_user"       => Fog::Mock.random_numbers(2).to_i,
        "time_start_time" => Time.now.utc.to_i - 10000,
        "state_name"      => "nova-agent",
        "state_ppid"      => Fog::Mock.random_numbers(3).to_i,
        "state_priority"  => "15",
        "state_threads"   => Fog::Mock.random_numbers(1).to_i,
        "memory_size"     => Fog::Mock.random_numbers(9).to_i,
        "memory_resident" => Fog::Mock.random_numbers(7).to_i,
        "memory_share"    => Fog::Mock.random_numbers(6).to_i,
        "memory_major_faults"    => memory_major_faults.to_i,
        "memory_minor_faults"    => memory_minor_faults.to_i,
        "memory_page_faults"     => memory_page_faults.to_i,
        "cred_user"       => "root",
        "cred_group"      => "root"
      }
    ]
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#get_system_info(agent_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/fog/rackspace/requests/monitoring/get_system_info.rb', line 16

def get_system_info(agent_id)

  if agent_id == -1
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "info"  => [
      {
        "name"            => "Linux",
        "arch"            => "x86_64",
        "version"         => "2.6.18-308.el5xen",
        "vendor"          => "CentOS",
        "vendor_version"  => "5.10"
      }
    ]
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#list_agent_tokens(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/rackspace/requests/monitoring/list_agent_tokens.rb', line 18

def list_agent_tokens(options={})
  token = Fog::Mock.random_letters(50).to_s

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values"=> [
      {
        "id"      => token,
        "token"   => token,
        "label"   => "mock_token"
      }
    ],
    "metadata" => {
       "count"       => 1,
       "limit"       => 100,
       "marker"      => nil,
       "next_marker" => nil,
       "next_href"   => nil
    }
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         =>" j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#list_agentsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/rackspace/requests/monitoring/list_agents.rb', line 15

def list_agents

  response = Excon::Response.new
  response.status = 200
  response.body = {
  "values"=>[
  {
  	"id"		=> Fog::Rackspace::MockData.uuid,
  	"last_connected"  => Time.now.to_i - 100
  },
  {
  	"id"		=> Fog::Rackspace::MockData.uuid,
  	"last_connected"  => Time.now.to_i - 110
  },
  {
  	"id"		=> Fog::Rackspace::MockData.uuid,
  	"last_connected"  => Time.now.to_i - 120
  }
],
            
   "metadata" => {
     "count"       => 1,
     "limit"       => 100,
     "marker"      => nil,
     "next_marker" => nil,
     "next_href"   => nil
    }
  }          
  
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Mock.random_ip({:version => :v4})
  response
end

#list_alarms(entity_id) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/fog/rackspace/requests/monitoring/list_alarms.rb', line 18

def list_alarms(entity_id)

  if entity_id == -1
   raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values" => [
     {
      "id"                    => Fog::Mock.random_letters(10),
      "label"                 => nil,
      "check_id"              => Fog::Mock.random_letters(10),
      "criteria"              => nil,
      "disabled"              => false,
      "notification_plan_id"  => "npTechnicalContactsEmail",
      "metadata"              => nil,
      "created_at"            => Time.now.to_i - 1,
      "updated_at"            => Time.now.to_i
     }
    ],
      "metadata" =>
      {
        "count"       =>1,
        "limit"       =>100,
        "marker"      =>nil,
        "next_marker" =>nil,
        "next_href"   =>nil
      }
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "38687",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "pomegmgm3030fm303.mmowd",
    "X-LB"                  => "ord1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#list_check_typesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/fog/rackspace/requests/monitoring/list_check_types.rb', line 16

def list_check_types
  response = Excon::Response.new
  response.status = 200
  response.body = {

    "values" => [
      {
        "type"   => "remote",
        "id"     => "remote.dns",
        "channel"=> "stable",
        "fields" => [
          {
            "name"       => "port",
            "description"=> "Port number (default: 53)",
            "optional"   => true
          },
          { 
            "name"       => "query",
            "description"=> "DNS Query",
            "optional"   => false
          },
          {
            "name"        => "record_type",
            "description" => "DNS Record Type",
            "optional"    => false
          }
        ],              
        "category" => "remote"
      },

      {
        "type"    => "agent",
        "id"      => "agent.memory",
        "channel" =>"stable",
        "fields"  => [],
        "supported_platforms" => [
          "Linux",
          "Windows"
        ],
        "category" => "agent_system"
      }
    ],


  
    "metadata" => {
      "count"       => 2,
      "limit"       => 100,
      "marker"      => nil,
      "next_marker" => nil,
      "next_href"   => nil
    }

  }

response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "zsdvasdtrq345",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
response.remote_ip = Fog::Rackspace::MockData.ipv4_address
response
end

#list_checks(entity_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/rackspace/requests/monitoring/list_checks.rb', line 16

def list_checks(entity_id)

  check_id = Fog::Mock.random_letters(10)

  if entity_id == -1
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values"  => [
      {
        "id"              => check_id,
        "label"           => "load",
        "type"            => "agent.load_average",
        "details"         => {},
        "monitoring_zones_poll" => nil,
        "timeout"         => 10,
        "period"          => 30,
        "target_alias"    => nil,
        "target_hostname" => nil,
        "target_resolver" => nil,
        "disabled"        => false,
        "metadata"        => nil,
        "created_at"      => Time.now.to_i - 1,
        "updated_at"      => Time.now.to_i
      }
    ],
    "metadata" => {
      "count"       => 1,
      "limit"       => 100,
      "marker"      => nil,
      "next_marker" => nil,
      "next_href"   => nil
    }
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#list_data_points(entity_id, check_id, metric_name, options) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fog/rackspace/requests/monitoring/list_data_points.rb', line 19

def list_data_points(entity_id, check_id, metric_name, options)

  if entity_id == -1 || check_id == -1 || metric_name == -1 || options == -1
    raise Fog::Rackspace::Monitoring::BadRequest
  end

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values"  => [],
    "metadata"=> {
      "count"       =>0,
      "limit"       =>nil,
      "marker"      =>nil,
      "next_marker" =>nil,
      "next_href"   =>nil
    }
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "slknbnsodb9830unvnve",
    "X-LB"                  => "ord1-maas-prod-api1",
    "Content-Type"          => "application/json; charset=UTF-8",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#list_entities(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/rackspace/requests/monitoring/list_entities.rb', line 17

def list_entities(options={})
   = Fog::Mock.random_numbers(6).to_s
  server_id = Fog::Rackspace::MockData.uuid
  entity_id = Fog::Mock.random_letters(10)
  entity_label = Fog::Mock.random_letters(10)

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values"=> [
      {
        "id"           => entity_id,
        "label"        => entity_label,
        "ip_addresses" => {
          "access_ip0_v6" => Fog::Rackspace::MockData.ipv6_address,
          "public0_v4"    => Fog::Rackspace::MockData.ipv4_address,
          "public1_v6"    => Fog::Rackspace::MockData.ipv6_address,
          "access_ip1_v4" => Fog::Rackspace::MockData.ipv4_address,
          "private0_v4"   => Fog::Rackspace::MockData.ipv4_address
        },
        "metadata"     => nil,
        "managed"      => false,
        "uri"          => "https://ord.servers.api.rackspacecloud.com/" +  + "/servers/" + server_id,
        "agent_id"     => nil,
        "created_at"   => Time.now.to_i - 1,
        "updated_at"   => Time.now.to_i
      }
  ],
    "metadata" => {
       "count"       => 1,
       "limit"       => 100,
       "marker"      => nil,
       "next_marker" => nil,
       "next_href"   => nil
    }
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#list_metrics(entity_id, check_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/fog/rackspace/requests/monitoring/list_metrics.rb', line 16

def list_metrics(entity_id, check_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values" => [
      {
        "name" => "idle_percent_average",
        "unit" => "percent"
      },
      { "name" => "irq_percent_average",
        "unit" => "percent"
      },
      { "name" => "max_cpu_usage",
        "unit" => "percent"
      },
      { "name" => "min_cpu_usage",
        "unit" => "percent"
      },
      { "name" => "stolen_percent_average",
        "unit" => "percent"
      },
      { "name" => "sys_percent_average",
        "unit" => "percent"
      },
      {
        "name" => "usage_average",
        "unit" => "percent"
      },
      { "name" => "user_percent_average",
        "unit" => "percent"
      },
      { "name" => "wait_percent_average",
        "unit" => "percent"
      }
    ],

    "metadata" => {
      "count"       => 9,
      "limit"       => nil,
      "marker"      => nil,
      "next_marker" => nil,
      "next_href"   => nil
    }

}

response.headers = {
  "Date"                  => Time.now.utc.to_s,
  "Content-Type"          => "application/json; charset=UTF-8",
  "X-RateLimit-Limit"     => "50000",
  "X-RateLimit-Remaining" => "49627",
  "X-RateLimit-Window"    => "24 hours",
  "X-RateLimit-Type"      => "global",
  "X-Response-Id"         => "zsdvasdtrq345",
  "X-LB"                  => "dfw1-maas-prod-api0",
  "Vary"                  => "Accept-Encoding",
  "Transfer-Encoding"     => "chunked"
}

response.remote_ip = Fog::Rackspace::MockData.ipv4_address
response
end

#list_notification_plansObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/rackspace/requests/monitoring/list_notification_plans.rb', line 16

def list_notification_plans
  notification_id   = Fog::Mock.random_letters(10)

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values" => [
      {
        "id"    => "npTechnicalContactsEmail",
        "label" => "Technical Contacts - Email",
        "critical_state" => [],
        "warning_state"  => [],
        "ok_state" => []
      },

      {
        "id"             => "notification_id",
        "label"          => "mock_label",
        "critical_state" => nil,
        "warning_state"  => nil,
        "ok_state"       => nil,
        "created_at"     => Time.now.to_i - 2,
        "updated_at"     => Time.now.to_i - 1
      }
    ],

    "metadata" => {
      "count"       => 2,
      "limit"       => 100,
      "marker"      => nil,
      "next_marker" => nil,
      "next_href"   => nil
    }

  }

  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         =>" zsdvasdtrq345",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }

  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#list_notifications(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/rackspace/requests/monitoring/list_notifications.rb', line 18

def list_notifications(options={})
   = Fog::Mock.random_numbers(6).to_s
  server_id = Fog::Rackspace::MockData.uuid
  entity_id = Fog::Mock.random_letters(10)
  entity_label = Fog::Mock.random_letters(10)

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values"=> [
      {
          "created_at"=>1378783452067,
          "details"=>{
              "address"=>"[email protected]"
          },
          "id"=>"ntnJN3MQrA",
          "label"=>"my email update test",
          "type"=>"email",
          "updated_at"=>1378784136307
      }
  ],
    "metadata" => {
       "count"       => 1,
       "limit"       => 100,
       "marker"      => nil,
       "next_marker" => nil,
       "next_href"   => nil
    }
  }
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "j23jlk234jl2j34j",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#list_overview(options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/fog/rackspace/requests/monitoring/list_overview.rb', line 17

def list_overview(options={})

  alarm_id   = Fog::Mock.random_letters(10)
  check_id   = Fog::Mock.random_letters(10)
  entity_id  = Fog::Mock.random_letters(10)
   = Fog::Mock.random_numbers(6).to_s
  server_id  = Fog::Rackspace::MockData.uuid

  response = Excon::Response.new
  response.status = 200
  response.body = {
    "values" => [
      {
        "entity" => {
          "id"           => entity_id,
          "label"        => "mock_entity",
          "ip_addresses" => { 
            "access_ip0_v6" => Fog::Rackspace::MockData.ipv6_address,
            "public0_v4"    => Fog::Rackspace::MockData.ipv4_address,
            "public1_v6"    => Fog::Rackspace::MockData.ipv6_address,
            "access_ip1_v4" => Fog::Rackspace::MockData.ipv4_address,
            "private0_v4"   => Fog::Rackspace::MockData.ipv4_address
          },
          "metadata" => {
            "testing" => "Bar"
          },
          "managed"    => false,
          "uri"        => "https://ord.servers.api.rackspacecloud.com/" +  + "/servers/" + server_id,
          "agent_id"   => nil,
          "created_at" => Time.now.to_i - 1,
          "updated_at" => Time.now.to_i
        },
        "checks"              => [
          {
            "id"              => check_id,
            "label"           => "mock",
            "type"            => "remote.mock",
            "details"         => {},
            "monitoring_zones_poll" => nil,
            "timeout"         => 10,
            "period"          => 30,
            "target_alias"    => nil,
            "target_hostname" => nil,
            "target_resolver" => nil,
            "disabled       " => false,
            "metadata"        => nil,
            "created_at"      => Time.now.to_i - 1,
            "updated_at"      => Time.now.to_i
          }
        ],
        "alarms" => [
          {
            "id"         => alarm_id,
            "label"      => nil,
            "check_id"   => check_id,
            "criteria"   => nil,
            "disabled"   => false,
            "notification_plan_id" => "npTechnicalContactsEmail",
            "metadata"   => nil,
            "created_at" => Time.now.to_i - 1,
            "updated_at" => Time.now.to_i
          }
        ],
        "latest_alarm_states" => []
      }
    ],
  
    "metadata" => {
      "count"       => 1,
      "limit"       => 100,
      "marker"      => nil,
      "next_marker" => nil,
      "next_href"   => nil
    }

  }

  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Content-Type"          => "application/json; charset=UTF-8",
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         =>" zsdvasdtrq345",
    "X-LB"                  => "dfw1-maas-prod-api0",
    "Vary"                  => "Accept-Encoding",
    "Transfer-Encoding"     => "chunked"
  }

  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#request(params) ⇒ Object



119
120
121
# File 'lib/fog/rackspace/monitoring.rb', line 119

def request(params)
  Fog::Mock.not_implemented
end

#update_alarm(entity_id, alarm_id, options) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/rackspace/requests/monitoring/update_alarm.rb', line 18

def update_alarm(entity_id, alarm_id, options)

   = Fog::Mock.random_numbers(6).to_s

  if entity_id == -1 || alarm_id == -1 || options[:testing]
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 204
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Location"              => "https://monitoring.api.rackspacecloud.com/v1.0/" +  + "/entities/" + entity_id.to_s + "/alarms/" + alarm_id,
    "X-Object-ID"           => alarm_id,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "47877",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "laolsgggopsnfksdovnsv",
    "X-LB"                  => "dfw1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#update_check(entity_id, check_id, options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fog/rackspace/requests/monitoring/update_check.rb', line 17

def update_check(entity_id, check_id, options)

    = Fog::Mock.random_numbers(6).to_s

  if entity_id == -1 || check_id == -1 || options[:testing]
    raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 204
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Location"              => "https://monitoring.api.rackspacecloud.com/v1.0/" +  + "/entities/" + entity_id + "/checks/" + check_id,
    "X-Object-ID"           => check_id,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "49627",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "owbgowb989wno73ubgvw89",
    "X-LB"                  => "ord1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain",
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end

#update_entity(entity_id, options) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/rackspace/requests/monitoring/update_entity.rb', line 18

def update_entity(entity_id, options)

   = Fog::Mock.random_numbers(6).to_s

  if entity_id == -1
   raise Fog::Rackspace::Monitoring::NotFound
  end

  response = Excon::Response.new
  response.status = 204
  response.body = ""
  response.headers = {
    "Date"                  => Time.now.utc.to_s,
    "Location"              => "https://monitoring.api.rackspacecloud.com/v1.0/" +  + "/entities/" + entity_id.to_s,
    "X-Object-ID"           => entity_id.to_s,
    "X-RateLimit-Limit"     => "50000",
    "X-RateLimit-Remaining" => "47877",
    "X-RateLimit-Window"    => "24 hours",
    "X-RateLimit-Type"      => "global",
    "X-Response-Id"         => "lakbngf9bsgkn69gb39sobnsv",
    "X-LB"                  => "dfw1-maas-prod-api1",
    "Content-Length"        => "0",
    "Content-Type"          => "text/plain"
  }
  response.remote_ip = Fog::Rackspace::MockData.ipv4_address
  response
end