2020-03-25 12:51:26 +00:00
|
|
|
import { Factory } from 'ember-cli-mirage';
|
|
|
|
import faker from 'nomad-ui/mirage/faker';
|
|
|
|
import { STORAGE_PROVIDERS } from '../common';
|
|
|
|
const REF_TIME = new Date();
|
|
|
|
|
|
|
|
export default Factory.extend({
|
|
|
|
provider: faker.helpers.randomize(STORAGE_PROVIDERS),
|
|
|
|
providerVersion: '1.0.1',
|
|
|
|
|
|
|
|
healthy: faker.random.boolean,
|
|
|
|
healthDescription() {
|
|
|
|
this.healthy ? 'healthy' : 'unhealthy';
|
|
|
|
},
|
|
|
|
|
2020-05-05 04:35:58 +00:00
|
|
|
updateTime: () => faker.date.past(2 / 365, REF_TIME),
|
2020-03-25 12:51:26 +00:00
|
|
|
|
|
|
|
requiresControllerPlugin: true,
|
|
|
|
requiresTopologies: true,
|
|
|
|
|
2020-05-08 00:29:42 +00:00
|
|
|
shallow: false,
|
|
|
|
|
2020-03-25 12:51:26 +00:00
|
|
|
nodeInfo: () => ({
|
|
|
|
MaxVolumes: 51,
|
|
|
|
AccessibleTopology: {
|
|
|
|
key: 'value',
|
|
|
|
},
|
|
|
|
RequiresNodeStageVolume: true,
|
|
|
|
}),
|
|
|
|
|
|
|
|
afterCreate(storageNode, server) {
|
|
|
|
const alloc = server.create('allocation', {
|
|
|
|
jobId: storageNode.job.id,
|
2020-05-05 04:35:58 +00:00
|
|
|
modifyTime: storageNode.updateTime * 1000000,
|
2020-05-08 00:29:42 +00:00
|
|
|
shallow: storageNode.shallow,
|
2020-03-25 12:51:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
storageNode.update({
|
2020-05-04 19:20:16 +00:00
|
|
|
allocID: alloc.id,
|
2020-03-25 12:51:26 +00:00
|
|
|
nodeId: alloc.nodeId,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|