consul/ui/javascripts/fixtures.js

301 lines
6.7 KiB
JavaScript
Raw Normal View History

2014-04-23 18:01:42 +00:00
//
// I intentionally am not using ember-data and the fixture
// adapter. I'm not confident the Consul UI API will be compatible
// without a bunch of wrangling, and it's really not enough updating
// of the models to justify the use of such a big component. getJSON
// *should* be enough.
//
window.fixtures = {}
2014-04-24 18:02:26 +00:00
//
2014-04-24 19:33:53 +00:00
// The array route, i.e /ui/<dc>/services, should return _all_ services
2014-04-24 18:02:26 +00:00
// in the DC
//
2014-04-23 18:01:42 +00:00
fixtures.services = [
{
"Name": "vagrant-cloud-http",
"Checks": [
{
"Name": "serfHealth",
"Status": "passing"
},
{
"Name": "fooHealth",
"Status": "critical"
},
{
"Name": "bazHealth",
"Status": "passing"
}
],
"Nodes": [
"node-10-0-1-109",
2014-04-24 19:25:28 +00:00
"node-10-0-1-102"
2014-04-23 18:01:42 +00:00
]
},
{
"Name": "vagrant-share-mux",
"Checks": [
{
"Name": "serfHealth",
"Status": "passing"
},
{
"Name": "fooHealth",
"Status": "passing"
},
{
"Name": "bazHealth",
"Status": "passing"
}
],
"Nodes": [
2014-04-24 19:25:28 +00:00
"node-10-0-1-109",
"node-10-0-1-102"
2014-04-23 18:01:42 +00:00
]
},
]
2014-04-24 18:02:26 +00:00
//
// This one is slightly more complicated to allow more UI interaction.
2014-04-24 19:33:53 +00:00
// It represents the route /ui/<dc>/services/<service> BUT it's what is
2014-04-24 18:02:26 +00:00
// BELOW the top-level key.
//
// So, what is actually returned should be similar to the /catalog/service/<service>
// endpoint.
fixtures.services_full = {
2014-04-24 18:02:26 +00:00
"vagrant-cloud-http":
// This array is what is actually expected from the API.
[
{
"ServicePort": 80,
"ServiceTags": null,
"ServiceName": "vagrant-cloud-http",
"ServiceID": "vagrant-cloud-http",
"Address": "10.0.1.109",
"Node": "node-10-0-1-109",
"Checks": [
{
"ServiceName": "",
"ServiceID": "",
"Notes": "",
"Status": "critical",
"Name": "Serf Health Status",
"CheckID": "serfHealth",
2014-04-24 19:25:28 +00:00
"Node": "node-10-0-1-109"
}
]
},
// A node
{
"ServicePort": 80,
"ServiceTags": null,
"ServiceName": "vagrant-cloud-http",
"ServiceID": "vagrant-cloud-http",
2014-04-24 19:25:28 +00:00
"Address": "10.0.1.102",
"Node": "node-10-0-1-102",
"Checks": [
{
"ServiceName": "",
"ServiceID": "",
"Notes": "",
"Status": "passing",
"Name": "Serf Health Status",
"CheckID": "serfHealth",
2014-04-24 19:25:28 +00:00
"Node": "node-10-0-1-102"
}
]
}
],
"vagrant-share-mux": [
// A node
{
"ServicePort": 80,
"ServiceTags": null,
"ServiceName": "vagrant-share-mux",
"ServiceID": "vagrant-share-mux",
2014-04-24 19:25:28 +00:00
"Address": "10.0.1.102",
"Node": "node-10-0-1-102",
"Checks": [
{
"ServiceName": "vagrant-share-mux",
"ServiceID": "vagrant-share-mux",
"Notes": "",
"Output": "200 ok",
"Status": "passing",
"Name": "Foo Heathly",
"CheckID": "fooHealth",
2014-04-24 19:25:28 +00:00
"Node": "node-10-0-1-102"
}
]
},
// A node
{
"ServicePort": 80,
"ServiceTags": null,
"ServiceName": "vagrant-share-mux",
"ServiceID": "vagrant-share-mux",
2014-04-24 19:25:28 +00:00
"Address": "10.0.1.109",
"Node": "node-10-0-1-109",
"Checks": [
{
"ServiceName": "",
"ServiceID": "",
"Notes": "",
"Output": "foobar baz",
"Status": "passing",
"Name": "Baz Status",
"CheckID": "bazHealth",
2014-04-24 19:25:28 +00:00
"Node": "node-10-0-1-109"
},
{
"ServiceName": "",
"ServiceID": "",
"Notes": "",
"Output": "foobar baz",
"Status": "passing",
"Name": "Serf Health Status",
"CheckID": "serfHealth",
2014-04-24 19:25:28 +00:00
"Node": "node-10-0-1-109"
}
]
}
]
}
2014-04-24 19:33:53 +00:00
//
// /ui/<dc>/nodes
// all the nodes
//
2014-04-24 19:18:11 +00:00
fixtures.nodes = [
{
"Address": "10.0.1.109",
"Name": "node-10-0-1-109",
"Services": [
2014-04-24 19:25:28 +00:00
"vagrant-share-mux",
2014-04-24 19:18:11 +00:00
"vagrant-cloud-http"
],
"Checks": [
{
"Name": "serfHealth",
"status": "passing"
},
{
"Name": "fooHealth",
"status": "critical"
},
{
"Name": "bazHealth",
"status": "passing"
}
]
},
{
"Address": "10.0.1.102",
"Name": "node-10-0-1-102",
"Services": [
2014-04-24 19:25:28 +00:00
"vagrant-share-mux",
2014-04-24 19:18:11 +00:00
"vagrant-cloud-http"
],
"Checks": [
{
"Name": "serfHealth",
"status": "passing"
},
{
"Name": "fooHealth",
"status": "critical"
},
{
"Name": "bazHealth",
"status": "passing"
}
],
}
]
2014-04-24 19:33:53 +00:00
// These are for retrieving individual nodes. Same story as services,
// the top level key is just for the demo.
2014-04-24 19:18:11 +00:00
fixtures.nodes_full = {
2014-04-24 19:33:53 +00:00
"node-10-0-1-109":
// This is what would be returned.
{
2014-04-24 19:18:11 +00:00
"Services": [
{
"Port": 0,
"Tags": null,
"Service": "vagrant-cloud-http",
"ID": "vagrant-cloud-http"
},
{
"Port": 80,
"Tags": null,
"Service": "vagrant-cloud-http",
"ID": "vagrant-cloud-http"
}
],
"Node": {
"Address": "10.0.1.109",
"Node": "node-10-0-1-109"
},
"Checks": [
{
"ServiceName": "",
"ServiceID": "",
"Notes": "Checks the status of the serf agent",
"Status": "passing",
"Name": "Serf Health Status",
"CheckID": "serfHealth",
"Node": "node-10-0-1-109"
}
]
},
"node-10-0-1-102": {
"Services": [
{
"Port": 0,
"Tags": null,
"Service": "vagrant-cloud-http",
"ID": "vagrant-cloud-http"
},
{
"Port": 80,
"Tags": null,
"Service": "vagrant-cloud-http",
"ID": "vagrant-cloud-http"
}
],
"Node": {
"Address": "10.0.1.102",
"Node": "node-10-0-1-102"
},
"Checks": [
{
"ServiceName": "",
"ServiceID": "",
"Notes": "",
"Output": "foobar baz",
"Status": "passing",
"Name": "Baz Status",
"CheckID": "bazHealth",
"Node": "node-10-0-1-102"
},
{
"ServiceName": "",
"ServiceID": "",
"Notes": "",
"Output": "foobar baz",
"Status": "passing",
"Name": "Serf Health Status",
"CheckID": "serfHealth",
"Node": "node-10-0-1-102"
}
]
}
}
2014-04-23 18:01:42 +00:00
fixtures.dcs = ['nyc1', 'sf1', 'sg1']
localStorage.setItem("current_dc", fixtures.dcs[0]);