From 9b510f14a2966cd0638aab8f30a3d9bb81069263 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Mon, 27 Sep 2021 17:39:57 +0800 Subject: [PATCH] fix: Fix the system classsification of image Fix image os to be others when image has no os_distro metadata or the os_distro is is inconsistent with classification Closes-Bug: #1945152 Change-Id: Ia9e0d3126732d931933cd1ef00281d971943b21f --- src/stores/glance/image.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/stores/glance/image.js b/src/stores/glance/image.js index 2002ee28..8d8ef868 100644 --- a/src/stores/glance/image.js +++ b/src/stores/glance/image.js @@ -15,6 +15,7 @@ import { action, observable } from 'mobx'; import client from 'client'; import Base from 'stores/base'; +import { imageOS } from 'resources/image'; export class ImageStore extends Base { @observable @@ -65,6 +66,17 @@ export class ImageStore extends Base { }; } + get mapper() { + return (data) => { + const { os_distro } = data; + const os = imageOS[os_distro] ? os_distro : 'others'; + return { + ...data, + os_distro: os, + }; + }; + } + @action async uploadImage(imageId, file, conf) { return this.client.uploadFile(imageId, file, conf);