Parameterize generateResources to enable property overrides
This commit is contained in:
parent
d3b41b0d69
commit
f9864930ce
|
@ -27,10 +27,10 @@ export const STORAGE_PROVIDERS = ['ebs', 'zfs', 'nfs', 'cow', 'moo'];
|
|||
|
||||
export function generateResources(options = {}) {
|
||||
return {
|
||||
CPU: faker.helpers.randomize(CPU_RESERVATIONS),
|
||||
MemoryMB: faker.helpers.randomize(MEMORY_RESERVATIONS),
|
||||
DiskMB: faker.helpers.randomize(DISK_RESERVATIONS),
|
||||
IOPS: faker.helpers.randomize(IOPS_RESERVATIONS),
|
||||
CPU: options.CPU || faker.helpers.randomize(CPU_RESERVATIONS),
|
||||
MemoryMB: options.MemoryMB || faker.helpers.randomize(MEMORY_RESERVATIONS),
|
||||
DiskMB: options.DiskMB || faker.helpers.randomize(DISK_RESERVATIONS),
|
||||
IOPS: options.IOPS || faker.helpers.randomize(IOPS_RESERVATIONS),
|
||||
Networks: generateNetworks(options.networks),
|
||||
Ports: generatePorts(options.networks),
|
||||
};
|
||||
|
@ -73,15 +73,17 @@ export function generateNetworks(options = {}) {
|
|||
}
|
||||
|
||||
export function generatePorts(options = {}) {
|
||||
return Array(faker.random.number({
|
||||
min: options.minPorts != null ? options.minPorts : 0,
|
||||
max: options.maxPorts != null ? options.maxPorts : 2
|
||||
}))
|
||||
return Array(
|
||||
faker.random.number({
|
||||
min: options.minPorts != null ? options.minPorts : 0,
|
||||
max: options.maxPorts != null ? options.maxPorts : 2,
|
||||
})
|
||||
)
|
||||
.fill(null)
|
||||
.map(() => ({
|
||||
Label: faker.hacker.noun(),
|
||||
Value: faker.random.number({ min: 5000, max: 60000 }),
|
||||
To: faker.random.number({ min: 5000, max: 60000 }),
|
||||
HostIP: faker.random.boolean() ? faker.internet.ip() : faker.internet.ipv6(),
|
||||
}))
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue