1bd6a69067
Closes #7197 #7199 Note: Test coverage is limited to adapter and serializer unit tests. All acceptance tests have been stubbed and all features have been manually tested end-to-end. This represents Phase 1 of #6993 which is the core workflow of CSI in the UI. It includes a couple new pages for viewing all external volumes as well as the allocations associated with each. It also updates existing volume related views on job and allocation pages to handle both Host Volumes and CSI Volumes.
62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
import { Factory } from 'ember-cli-mirage';
|
|
import faker from 'nomad-ui/mirage/faker';
|
|
import { pickOne } from '../utils';
|
|
import { STORAGE_PROVIDERS } from '../common';
|
|
|
|
const ACCESS_MODES = ['multi-node-single-writer'];
|
|
const ATTACHMENT_MODES = ['file-system'];
|
|
|
|
export default Factory.extend({
|
|
id: i => `${faker.hacker.noun().dasherize()}-${i}`.toLowerCase(),
|
|
name() {
|
|
return this.id;
|
|
},
|
|
|
|
externalId: () => `vol-${faker.random.uuid().split('-')[0]}`,
|
|
|
|
// Topologies is currently unused by the UI. This should
|
|
// eventually become dynamic.
|
|
topologies: () => [{ foo: 'bar' }],
|
|
|
|
accessMode: faker.helpers.randomize(ACCESS_MODES),
|
|
attachmentMode: faker.helpers.randomize(ATTACHMENT_MODES),
|
|
|
|
schedulable: faker.random.boolean,
|
|
provider: faker.helpers.randomize(STORAGE_PROVIDERS),
|
|
version: '1.0.1',
|
|
controllerRequired: faker.random.boolean,
|
|
controllersHealthy: () => faker.random.number(10),
|
|
controllersExpected() {
|
|
return this.controllersHealthy + faker.random.number(10);
|
|
},
|
|
nodesHealthy: () => faker.random.number(10),
|
|
nodesExpected() {
|
|
return this.nodesHealthy + faker.random.number(10);
|
|
},
|
|
|
|
afterCreate(volume, server) {
|
|
if (!volume.namespaceId) {
|
|
const namespace = server.db.namespaces.length ? pickOne(server.db.namespaces).id : null;
|
|
volume.update({
|
|
namespace,
|
|
namespaceId: namespace,
|
|
});
|
|
} else {
|
|
volume.update({
|
|
namespace: volume.namespaceId,
|
|
});
|
|
}
|
|
|
|
if (!volume.plugin) {
|
|
const plugin = server.db.csiPlugins.length ? pickOne(server.db.csiPlugins) : null;
|
|
volume.update({
|
|
PluginId: plugin && plugin.id,
|
|
});
|
|
} else {
|
|
volume.update({
|
|
PluginId: volume.plugin.id,
|
|
});
|
|
}
|
|
},
|
|
});
|