diff --git a/src/stores/nova/instance.js b/src/stores/nova/instance.js index b9859d35..17ccdce9 100644 --- a/src/stores/nova/instance.js +++ b/src/stores/nova/instance.js @@ -16,6 +16,7 @@ import { action, observable } from 'mobx'; import { get } from 'lodash'; import client from 'client'; import Base from 'stores/base'; +import { mapperRule } from 'resources/security-group-rule'; import { RecycleBinStore } from '../skyline/recycle-server'; export class ServerStore extends Base { @@ -61,6 +62,16 @@ export class ServerStore extends Base { }; } + get mapperSecurityGroupRule() { + return (data) => { + const { security_group_rules = [] } = data; + return { + ...data, + security_group_rules: security_group_rules.map(mapperRule), + }; + }; + } + listFetchByClient(params) { return this.skylineClient.extension.servers(params); } @@ -209,7 +220,9 @@ export class ServerStore extends Base { const result = await Promise.all( sgIds.map((it) => this.sgClient.show(it)) ); - sgItems = result.map((it) => it.security_group); + sgItems = result.map((it) => + this.mapperSecurityGroupRule(it.security_group) + ); } catch (e) {} this.securityGroups = { data: sgItems || [],