2019-09-26 18:47:07 +00:00
|
|
|
import { Factory } from 'ember-cli-mirage';
|
2019-10-03 14:13:08 +00:00
|
|
|
import faker from 'nomad-ui/mirage/faker';
|
2017-09-19 14:47:10 +00:00
|
|
|
import { provide } from '../utils';
|
|
|
|
import { DATACENTERS } from '../common';
|
|
|
|
|
|
|
|
const UUIDS = provide(100, faker.random.uuid.bind(faker.random));
|
|
|
|
const AGENT_STATUSES = ['alive', 'leaving', 'left', 'failed'];
|
|
|
|
|
|
|
|
export default Factory.extend({
|
|
|
|
id: i => (i / 100 >= 1 ? `${UUIDS[i]}-${i}` : UUIDS[i]),
|
|
|
|
name: () => `nomad@${faker.internet.ip()}`,
|
|
|
|
|
2019-09-30 14:44:22 +00:00
|
|
|
status: () => faker.helpers.randomize(AGENT_STATUSES),
|
|
|
|
serf_port: () => faker.random.number({ min: 4000, max: 4999 }),
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
address() {
|
|
|
|
return this.name.split('@')[1];
|
|
|
|
},
|
|
|
|
|
|
|
|
tags() {
|
|
|
|
const rpcPortCandidate = faker.random.number({ min: 4000, max: 4999 });
|
|
|
|
return {
|
|
|
|
port: rpcPortCandidate === this.serf_port ? rpcPortCandidate + 1 : rpcPortCandidate,
|
2019-09-26 18:47:07 +00:00
|
|
|
dc: faker.helpers.randomize(DATACENTERS),
|
2017-09-19 14:47:10 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|