fix: fix the rebuild container and ports of zun

1. Determine whether the image resource exists when rebuild container

2. Filter out ports already in use when create container

Change-Id: I6de2ef8d2fc25c0553067e6a0c35edaf4a3f2a10
This commit is contained in:
xusongfu 2023-02-16 15:31:19 +08:00
parent 01ea21d118
commit 635f829217
4 changed files with 28 additions and 2 deletions

View File

@ -2342,6 +2342,7 @@
"The host name of this container": "The host name of this container",
"The http_proxy address to use for nodes in cluster": "The http_proxy address to use for nodes in cluster",
"The https_proxy address to use for nodes in cluster": "The https_proxy address to use for nodes in cluster",
"The image is not existed": "The image is not existed",
"The instance architecture diagram mainly shows the overall architecture composition of the instance. If you need to view the network topology of the instance, please go to: ": "The instance architecture diagram mainly shows the overall architecture composition of the instance. If you need to view the network topology of the instance, please go to: ",
"The instance deleted immediately cannot be restored": "The instance deleted immediately cannot be restored",
"The instance has been locked. If you want to do more, please unlock it first.": "The instance has been locked. If you want to do more, please unlock it first.",

View File

@ -2342,6 +2342,7 @@
"The host name of this container": "容器的主机名",
"The http_proxy address to use for nodes in cluster": "用于集群中节点的HTTP代理地址",
"The https_proxy address to use for nodes in cluster": "用于集群中节点的HTTPS代理地址",
"The image is not existed": "镜像资源不存在",
"The instance architecture diagram mainly shows the overall architecture composition of the instance. If you need to view the network topology of the instance, please go to: ": "云主机架构图主要展示云主机的总体架构组成。如果需要查看云主机的网络拓扑,请转到:",
"The instance deleted immediately cannot be restored": "立即删除的云主机无法恢复",
"The instance has been locked. If you want to do more, please unlock it first.": "该云主机已被锁定。如果要做更多操作,请先解锁。",

View File

@ -14,6 +14,7 @@ import { inject, observer } from 'mobx-react';
import { ModalAction } from 'containers/Action';
import globalContainersStore from 'src/stores/zun/containers';
import { checkItemAction } from 'resources/zun/container';
import { ImageStore } from 'stores/glance/image';
export class RebuildContainer extends ModalAction {
static id = 'rebuild';
@ -58,6 +59,16 @@ export class RebuildContainer extends ModalAction {
type: 'input',
placeholder: t('Name or ID og the container image'),
required: true,
validator: (rule, value) => {
return new ImageStore()
.fetchDetail({ id: value })
.then(() => {
return Promise.resolve(true);
})
.catch(() => {
return Promise.reject(new Error(t('The image is not existed')));
});
},
},
{
name: 'image_driver',

View File

@ -15,6 +15,7 @@ import { SecurityGroupStore } from 'stores/neutron/security-group';
import { PortStore } from 'stores/neutron/port-extension';
import Base from 'components/Form';
import { inject, observer } from 'mobx-react';
import { toJS } from 'mobx';
import { portColumns, portFilters } from 'src/resources/neutron/port';
import {
securityGroupColumns,
@ -26,6 +27,7 @@ export class StepNetworks extends Base {
init() {
this.portStore = new PortStore();
this.securityGroupStore = new SecurityGroupStore();
this.getPorts();
}
get title() {
@ -36,6 +38,17 @@ export class StepNetworks extends Base {
return t('Networks');
}
getPorts() {
this.portStore.fetchList({
project_id: this.currentProjectId,
status: 'DOWN',
});
}
get ports() {
return (toJS(this.portStore.list.data) || []).filter((it) => !it.device_id);
}
get formItems() {
const { networks = [] } = this.state;
const {
@ -58,8 +71,8 @@ export class StepNetworks extends Base {
name: 'ports',
type: 'select-table',
label: t('Ports'),
extraParams: { project_id: this.currentProjectId, status: 'DOWN' },
backendPageStore: this.portStore,
data: this.ports,
isLoading: this.portStore.list.isLoading,
isMulti: true,
header: t(
'Ports provide extra communication channels to your instances. You can select ports instead of networks or a mix of both (The port executes its own security group rules by default).'