Создай массив из 11 подобных элементов { host: 'client-host-1', ip: '1.1.1.1', iqn:…
- User
Создай массив из 11 подобных элементов { host: 'client-host-1', ip: '1.1.1.1', iqn: 'iqn.1993-08.org.debian:01:24587eabe6d', chapType: 'none', authKey: 'none', images: 20, iscsiGateways: ['uStor-1:1', 'uStor-2:2', 'uStor-1:2', 'uStor-4:1'], }, { host: 'client-host-2', ip: '1.2.1.1', iqn: 'iqn.1993-08.org.debian:01:24587eabe6d', chapType: 'one-way', authKey: '1', images: 1, iscsiGateways: ['uStor-1:1', 'uStor-2:2', 'uStor-1:2', 'uStor-4:1'], },
Интерфейс interface SingleHost { host: string; ip: string; iqn: string; chap: ChapTypes; authKey: string; images: number; iscsiGateways: string[]; // Список iSCSI Gateway:Portal_ID }
- Assistant
- User
{ host: 'client-host-1', ip: '1.1.1.1', iqn: 'iqn.1993-08.org.debian:01:24587eabe6d', chap: 'none', authKey: 'none', images: 20, iscsiGateways: ['uStor-1:1', 'uStor-2uStor-2:2', 'uStor-1:2', 'uSt23131or-4:1'], }, Сделай 100 iscsiGateways у этого объекта
- Assistant
Конечно! Вот обновленный объект с 100 элементами в массиве
iscsiGateways. Я использую шаблонные строки для генерации значений:typescriptconst singleHostWithManyGateways = { host: 'client-host-1', ip: '1.1.1.1', iqn: 'iqn.1993-08.org.debian:01:24587eabe6d', chap: 'none', authKey: 'none', images: 20, iscsiGateways: Array.from({ length: 100 }, (_, index) => `uStor-${Math.floor(index / 10) + 1}:${index + 1}`), };В этом примере:
- Я использовал метод
Array.from()для генерации массива длиной 100. - Значение
uStor-${Math.floor(index / 10) + 1}:${index + 1}динамически формирует строки. Первый элемент будетuStor-1:1, второй —uStor-1:2, ..., десятый —uStor-1:10, а начиная с 11-го элемента добавитсяuStor-2, и так далее.
Таким образом, можно будет создать 100 уникальных
iscsiGateways, распределенных междуuStor-1,uStor-2и т.д. - Я использовал метод