skyline/src/resources/zun/container.js
xusongfu 317a81acc4 feature: support search filters and fix image in zun ui
1. support search filters to capsules
2. support search filters to containers
3. support search filters to hosts
4. support search filters to services
5. because the glance image's name can be repeated, change params from name to id if use glance image

Change-Id: If3ceed8d0027f230afd72784c48161048fe61faf
2023-01-10 19:10:26 +08:00

117 lines
2.9 KiB
JavaScript

// Copyright 2022 99cloud
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
export const containerStatus = {
Creating: t('Creating'),
Created: t('Created'),
Running: t('Running'),
Stopped: t('Stopped'),
Paused: t('Paused'),
Restarting: t('Restarting'),
Deleting: t('Deleting'),
Error: t('Error'),
Unknown: t('Unknown'),
Rebuilding: t('Rebuilding'),
};
export const containerTaskStatus = {
free: t('No Task'),
container_creating: t('Container Creating'),
container_starting: t('Container Starting'),
container_stopping: t('Container Stopping'),
container_rebooting: t('Container Rebooting'),
container_deleting: t('Container Deleting'),
container_rebuilding: t('Container Rebuilding'),
container_killing: t('Container Killing'),
};
const states = {
ERROR: 'Error',
RUNNING: 'Running',
STOPPED: 'Stopped',
PAUSED: 'Paused',
UNKNOWN: 'Unknown',
CREATING: 'Creating',
CREATED: 'Created',
DELETED: 'Deleted',
DELETING: 'Deleting',
REBUILDING: 'Rebuilding',
DEAD: 'Dead',
RESTARTING: 'Restarting',
};
const validStates = {
update: [states.CREATED, states.RUNNING, states.STOPPED, states.PAUSED],
start: [states.CREATED, states.STOPPED, states.ERROR],
stop: [states.RUNNING],
reboot: [states.CREATED, states.RUNNING, states.STOPPED, states.ERROR],
rebuild: [states.CREATED, states.RUNNING, states.STOPPED, states.ERROR],
pause: [states.RUNNING],
unpause: [states.PAUSED],
execute: [states.RUNNING],
kill: [states.RUNNING],
delete: [
states.CREATED,
states.ERROR,
states.STOPPED,
states.DELETED,
states.DEAD,
],
delete_force: [
states.CREATED,
states.CREATING,
states.ERROR,
states.RUNNING,
states.STOPPED,
states.UNKNOWN,
states.DELETED,
states.DEAD,
states.RESTARTING,
states.REBUILDING,
states.DELETING,
],
delete_stop: [
states.RUNNING,
states.CREATED,
states.ERROR,
states.STOPPED,
states.DELETED,
states.DEAD,
],
manage_security_groups: [
states.CREATED,
states.RUNNING,
states.STOPPED,
states.PAUSED,
],
};
export const checkItemAction = (item, actionName) => {
if (!item) return false;
const { status } = item;
return validStates[actionName].includes(status);
};
export const imageDrivers = {
docker: t('Docker Hub'),
glance: t('Glance Image'),
};
export const exitPolicies = {
no: t('No'),
'on-failure': t('On failure'),
always: t('Always'),
'unless-stopped': t('Unless Stopped'),
};