Merge "feat: show back-end storage pools of manila"

This commit is contained in:
Zuul 2022-08-29 09:51:34 +00:00 committed by Gerrit Code Review
commit f16c1e4922
7 changed files with 105 additions and 10 deletions

View File

@ -178,6 +178,11 @@ export class ManilaClient extends Base {
key: 'share-servers',
responseKey: 'share_server',
},
{
name: 'pools',
key: 'scheduler-stats/pools/detail',
responseKey: 'pool',
},
];
}
}

View File

@ -561,6 +561,13 @@ const renderMenu = (t) => {
},
],
},
{
path: '/share/storage-admin',
name: t('Storage Backends'),
key: 'shareStorageBackendAdmin',
level: 1,
children: [],
},
],
},
{

View File

@ -0,0 +1,36 @@
// Copyright 2021 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.
import { observer, inject } from 'mobx-react';
import { Storage as Base } from 'pages/storage/containers/Storage';
import globalPoolStore from 'stores/manila/pool';
import { poolColumns } from 'resources/cinder/cinder-pool';
export class Storage extends Base {
init() {
this.store = globalPoolStore;
}
get policy() {
return 'scheduler_stats:pools:detail';
}
getColumns = () => {
const columns = [...poolColumns];
columns[2].dataIndex = 'share_backend_name';
return columns;
};
}
export default inject('rootStore')(observer(Storage));

View File

@ -29,6 +29,7 @@ import ShareDetail from '../containers/Share/Detail';
import ShareCreate from '../containers/Share/actions/Create';
import ShareServer from '../containers/ShareServer';
import ShareServerDetail from '../containers/ShareServer/Detail';
import Storage from '../containers/Storage';
const PATH = '/share';
export default [
@ -137,6 +138,7 @@ export default [
component: ShareServerDetail,
exact: true,
},
{ path: `${PATH}/storage-admin`, component: Storage, exact: true },
{ path: '*', component: E404 },
],
},

View File

@ -33,16 +33,21 @@ export const poolColumns = [
title: t('Storage Capacity(GiB)'),
dataIndex: 'usedGBPercent',
isHideable: true,
render: (value, record) => (
render: (value, record) =>
value ? (
<Progress
value={value}
label={`${record.usedGB} / ${record.total_capacity_gb}`}
/>
) : (
'-'
),
stringify: (value, record) =>
`${value}% (${t('Used')}: ${record.usedGB} / ${t('Total')}: ${
value
? `${value}% (${t('Used')}: ${record.usedGB} / ${t('Total')}: ${
record.total_capacity_gb
})`,
})`
: '-',
},
];

View File

@ -73,7 +73,7 @@ export const policyMap = {
],
zun: ['capsule:', 'container:', 'host:get'],
panko: ['segregation', 'telemetry:events:index'],
manila: ['share:', 'share_'],
manila: ['share:', 'share_', 'scheduler_stats:pools'],
trove: [
'instance:create',
'instance:delete',

40
src/stores/manila/pool.js Normal file
View File

@ -0,0 +1,40 @@
// Copyright 2021 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.
import { isNumber } from 'lodash';
import client from 'client';
import Base from 'stores/base';
export class PoolStore extends Base {
get client() {
return client.manila.pools;
}
get mapper() {
return (data) => {
const { name, capabilities = {} } = data;
const newItem = { name, ...capabilities };
const { total_capacity_gb, free_capacity_gb } = capabilities;
if (isNumber(total_capacity_gb) && isNumber(free_capacity_gb)) {
newItem.usedGB = (total_capacity_gb - free_capacity_gb).toFixed(2);
newItem.usedGBPercent =
(newItem.usedGB / total_capacity_gb).toFixed(2) * 100;
}
return newItem;
};
}
}
const globalPoolStore = new PoolStore();
export default globalPoolStore;