Model out the rest of the CSI Plugin properties

This commit is contained in:
Michael Lange
2020-05-02 21:31:17 -07:00
parent 6c262ddeba
commit 5d3438193a
3 changed files with 26 additions and 3 deletions

View File

@@ -1,13 +1,30 @@
import { computed } from '@ember/object';
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import { fragmentArray } from 'ember-data-model-fragments/attributes';
export default Model.extend({
plainId: attr('string'),
topologies: attr(),
provider: attr('string'),
version: attr('string'),
controllerRequired: attr('boolean'),
controllers: fragmentArray('storage-controller', { defaultValue: () => [] }),
nodes: fragmentArray('storage-node', { defaultValue: () => [] }),
controllerRequired: attr('boolean'),
controllersHealthy: attr('number'),
controllersExpected: attr('number'),
controllersHealthyProportion: computed('controllersHealthy', 'controllersExpected', function() {
return this.controllersHealthy / this.controllersExpected;
}),
nodesHealthy: attr('number'),
nodesExpected: attr('number'),
nodesHealthyProportion: computed('nodesHealthy', 'nodesExpected', function() {
return this.nodesHealthy / this.nodesExpected;
}),
});

View File

@@ -14,7 +14,7 @@ const unmap = (hash, propKey) =>
export default ApplicationSerializer.extend({
normalize(typeHash, hash) {
hash.PlainID = hash.ID;
hash.PlainId = hash.ID;
// TODO This shouldn't hardcode `csi/` as part of the ID,
// but it is necessary to make the correct find request and the

View File

@@ -13,8 +13,14 @@ export default Factory.extend({
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);
},
// Internal property to determine whether or not this plugin
// Should create one or two Jobs to represent Node and
@@ -52,7 +58,7 @@ export default Factory.extend({
});
if (plugin.createVolumes) {
server.createList('csi-volume', faker.random.number(5), {
server.createList('csi-volume', faker.random.number({ min: 1, max: 5 }), {
plugin,
provider: plugin.provider,
});