fix: Fix virtual resource about compute
Use Nova service api to get the correct count of compute Change-Id: I6a2bd8797e219d31f899f86e338acb5c56fd2707
This commit is contained in:
parent
633fcdec63
commit
99d839a24f
@ -83,7 +83,7 @@ const volumeColors = {
|
|||||||
|
|
||||||
export class virtualResourceInfo extends Component {
|
export class virtualResourceInfo extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.store.getVirtualResource();
|
this.props.store.getVirtualResourceOverview();
|
||||||
}
|
}
|
||||||
|
|
||||||
get card() {
|
get card() {
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Row, Col, Card, Descriptions, Progress, Avatar } from 'antd';
|
import { Row, Col, Card, Descriptions, Progress, Avatar } from 'antd';
|
||||||
import { inject, observer } from 'mobx-react';
|
import { inject, observer } from 'mobx-react';
|
||||||
import globalHypervisorStore from 'stores/nova/hypervisor';
|
|
||||||
import styles from '../style.less';
|
import styles from '../style.less';
|
||||||
|
|
||||||
export const resourceCircle = [
|
export const resourceCircle = [
|
||||||
@ -38,13 +37,8 @@ export const color = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class ResourceCircle extends Component {
|
export class ResourceCircle extends Component {
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.store = globalHypervisorStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.store.getOverview();
|
this.props.store.getVirtualResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
get resourceCircle() {
|
get resourceCircle() {
|
||||||
@ -56,7 +50,7 @@ export class ResourceCircle extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderCircle = (item, index) => {
|
renderCircle = (item, index) => {
|
||||||
const { overview } = this.store;
|
const { overview } = this.props.store;
|
||||||
const resource = overview[item.resource];
|
const resource = overview[item.resource];
|
||||||
|
|
||||||
const used = overview[item.used];
|
const used = overview[item.used];
|
||||||
@ -114,7 +108,7 @@ export class ResourceCircle extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { isLoading } = this.store;
|
const { isLoading } = this.props.store;
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
|
@ -16,6 +16,8 @@ import React, { Component } from 'react';
|
|||||||
import { observer } from 'mobx-react';
|
import { observer } from 'mobx-react';
|
||||||
import { Row, Col } from 'antd';
|
import { Row, Col } from 'antd';
|
||||||
import OverviewAdminStore from 'stores/overview-admin';
|
import OverviewAdminStore from 'stores/overview-admin';
|
||||||
|
import globalServerStore from 'stores/nova/server';
|
||||||
|
import globalHypervisorStore from 'stores/nova/hypervisor';
|
||||||
import styles from './style.less';
|
import styles from './style.less';
|
||||||
import PlatformInfo from './components/PlatformInfo';
|
import PlatformInfo from './components/PlatformInfo';
|
||||||
import ComputeService from './components/ComputeService';
|
import ComputeService from './components/ComputeService';
|
||||||
@ -34,11 +36,11 @@ export class Overview extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
renderVirtualResource() {
|
renderVirtualResource() {
|
||||||
return <VirtualResource store={this.adminStore} />;
|
return <VirtualResource store={globalHypervisorStore} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderResourceOverview() {
|
renderResourceOverview() {
|
||||||
return <ResourceOverview store={this.adminStore} />;
|
return <ResourceOverview store={globalServerStore} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderComputeService() {
|
renderComputeService() {
|
||||||
|
@ -139,7 +139,7 @@ export class HypervisorStore extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
getOverview = async () => {
|
getVirtualResource = async () => {
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
const hypervisorResult = await this.client.listDetail();
|
const hypervisorResult = await this.client.listDetail();
|
||||||
const { hypervisors } = hypervisorResult;
|
const { hypervisors } = hypervisorResult;
|
||||||
|
111
src/stores/nova/server.js
Normal file
111
src/stores/nova/server.js
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
// 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 { action, extendObservable } from 'mobx';
|
||||||
|
import client from 'client';
|
||||||
|
import Base from 'stores/base';
|
||||||
|
import globalRootStore from 'stores/root';
|
||||||
|
|
||||||
|
export class ServerStore extends Base {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
extendObservable(this, {
|
||||||
|
virtualResource: {},
|
||||||
|
virtualResourceLoading: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
get client() {
|
||||||
|
return client.nova.servers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
async getVirtualResourceOverview() {
|
||||||
|
this.virtualResourceLoading = true;
|
||||||
|
const promiseArray = [
|
||||||
|
this.requestListAllByLimit({ all_tenants: true }, 1000),
|
||||||
|
this.requestListAllByLimit({ all_tenants: true, status: 'ACTIVE' }, 1000),
|
||||||
|
this.requestListAllByLimit({ all_tenants: true, status: 'ERROR' }, 1000),
|
||||||
|
this.requestListAllByLimit(
|
||||||
|
{ all_tenants: true, status: 'SHUTOFF' },
|
||||||
|
1000
|
||||||
|
),
|
||||||
|
];
|
||||||
|
if (globalRootStore.checkEndpoint('cinder')) {
|
||||||
|
const volumeResource = [
|
||||||
|
client.skyline.extension.volumes({ limit: 10, all_projects: true }),
|
||||||
|
client.skyline.extension.volumes({
|
||||||
|
limit: 10,
|
||||||
|
all_projects: true,
|
||||||
|
status: 'in-use',
|
||||||
|
}),
|
||||||
|
client.skyline.extension.volumes({
|
||||||
|
limit: 10,
|
||||||
|
all_projects: true,
|
||||||
|
status: 'error',
|
||||||
|
}),
|
||||||
|
client.skyline.extension.volumes({
|
||||||
|
limit: 10,
|
||||||
|
all_projects: true,
|
||||||
|
status: 'available',
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
promiseArray.push(...volumeResource);
|
||||||
|
}
|
||||||
|
const [
|
||||||
|
allServers,
|
||||||
|
activeServers,
|
||||||
|
errorServers,
|
||||||
|
shutoffServers,
|
||||||
|
allVolumes,
|
||||||
|
attachVolumes,
|
||||||
|
errorVolumes,
|
||||||
|
availableVolumes,
|
||||||
|
] = await Promise.all(promiseArray);
|
||||||
|
const allServersCount = allServers.length;
|
||||||
|
const activeServersCount = activeServers.length;
|
||||||
|
const errorServersCount = errorServers.length;
|
||||||
|
const shutoffServersCount = shutoffServers.length;
|
||||||
|
const serviceNum = {
|
||||||
|
all: allServersCount,
|
||||||
|
active: activeServersCount,
|
||||||
|
error: errorServersCount,
|
||||||
|
shutoff: shutoffServersCount,
|
||||||
|
other:
|
||||||
|
allServersCount -
|
||||||
|
(activeServersCount + errorServersCount + shutoffServersCount),
|
||||||
|
};
|
||||||
|
this.virtualResource = { serviceNum };
|
||||||
|
if (globalRootStore.checkEndpoint('cinder')) {
|
||||||
|
const { count: allVolumesCount } = allVolumes;
|
||||||
|
const { count: attachVolumesCount } = attachVolumes;
|
||||||
|
const { count: errorVolumesCount } = errorVolumes;
|
||||||
|
const { count: availableVolumesCount } = availableVolumes;
|
||||||
|
const volumeNum = {
|
||||||
|
all: allVolumesCount,
|
||||||
|
active: attachVolumesCount,
|
||||||
|
error: errorVolumesCount,
|
||||||
|
available: availableVolumesCount,
|
||||||
|
other:
|
||||||
|
allVolumesCount -
|
||||||
|
(attachVolumesCount + errorVolumesCount + availableVolumesCount),
|
||||||
|
};
|
||||||
|
this.virtualResource.volumeNum = volumeNum;
|
||||||
|
}
|
||||||
|
this.virtualResourceLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const globalServerStore = new ServerStore();
|
||||||
|
export default globalServerStore;
|
@ -14,41 +14,21 @@
|
|||||||
|
|
||||||
import { extendObservable, action } from 'mobx';
|
import { extendObservable, action } from 'mobx';
|
||||||
import client from 'client';
|
import client from 'client';
|
||||||
import globalRootStore from 'stores/root';
|
|
||||||
|
|
||||||
export default class OverviewStore {
|
export default class OverviewStore {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.reset(true);
|
extendObservable(this, {
|
||||||
}
|
|
||||||
|
|
||||||
get initValue() {
|
|
||||||
return {
|
|
||||||
projectInfoLoading: true,
|
projectInfoLoading: true,
|
||||||
computeServiceLoading: true,
|
computeServiceLoading: true,
|
||||||
networkServiceLoading: true,
|
networkServiceLoading: true,
|
||||||
virtualResourceLoading: true,
|
|
||||||
computeService: [],
|
computeService: [],
|
||||||
networkService: [],
|
networkService: [],
|
||||||
virtualResource: {},
|
|
||||||
platformNum: {
|
platformNum: {
|
||||||
projectNum: 0,
|
projectNum: 0,
|
||||||
userNum: 0,
|
userNum: 0,
|
||||||
nodeNum: 0,
|
nodeNum: 0,
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
|
||||||
reset(init) {
|
|
||||||
const state = this.initValue;
|
|
||||||
|
|
||||||
if (init) {
|
|
||||||
extendObservable(this, state);
|
|
||||||
} else {
|
|
||||||
Object.keys(state).forEach((key) => {
|
|
||||||
this[key] = state[key];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
@ -71,91 +51,6 @@ export default class OverviewStore {
|
|||||||
this.projectInfoLoading = false;
|
this.projectInfoLoading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
|
||||||
async getVirtualResource() {
|
|
||||||
this.virtualResourceLoading = true;
|
|
||||||
const promiseArray = [
|
|
||||||
client.skyline.extension.servers({ limit: 10, all_projects: true }),
|
|
||||||
client.skyline.extension.servers({
|
|
||||||
limit: 10,
|
|
||||||
all_projects: true,
|
|
||||||
status: 'ACTIVE',
|
|
||||||
}),
|
|
||||||
client.skyline.extension.servers({
|
|
||||||
limit: 10,
|
|
||||||
all_projects: true,
|
|
||||||
status: 'ERROR',
|
|
||||||
}),
|
|
||||||
client.skyline.extension.servers({
|
|
||||||
limit: 10,
|
|
||||||
all_projects: true,
|
|
||||||
status: 'SHUTOFF',
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
if (globalRootStore.checkEndpoint('cinder')) {
|
|
||||||
const volumeResource = [
|
|
||||||
client.skyline.extension.volumes({ limit: 10, all_projects: true }),
|
|
||||||
client.skyline.extension.volumes({
|
|
||||||
limit: 10,
|
|
||||||
all_projects: true,
|
|
||||||
status: 'in-use',
|
|
||||||
}),
|
|
||||||
client.skyline.extension.volumes({
|
|
||||||
limit: 10,
|
|
||||||
all_projects: true,
|
|
||||||
status: 'error',
|
|
||||||
}),
|
|
||||||
client.skyline.extension.volumes({
|
|
||||||
limit: 10,
|
|
||||||
all_projects: true,
|
|
||||||
status: 'available',
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
promiseArray.push(...volumeResource);
|
|
||||||
}
|
|
||||||
const [
|
|
||||||
allServers,
|
|
||||||
activeServers,
|
|
||||||
errorServers,
|
|
||||||
shutoffServers,
|
|
||||||
allVolumes,
|
|
||||||
attachVolumes,
|
|
||||||
errorVolumes,
|
|
||||||
availableVolumes,
|
|
||||||
] = await Promise.all(promiseArray);
|
|
||||||
const { count: allServersCount } = allServers;
|
|
||||||
const { count: activeServersCount } = activeServers;
|
|
||||||
const { count: errorServersCount } = errorServers;
|
|
||||||
const { count: shutoffServersCount } = shutoffServers;
|
|
||||||
const serviceNum = {
|
|
||||||
all: allServersCount,
|
|
||||||
active: activeServersCount,
|
|
||||||
error: errorServersCount,
|
|
||||||
shutoff: shutoffServersCount,
|
|
||||||
other:
|
|
||||||
allServersCount -
|
|
||||||
(activeServersCount + errorServersCount + shutoffServersCount),
|
|
||||||
};
|
|
||||||
this.virtualResource = { serviceNum };
|
|
||||||
if (globalRootStore.checkEndpoint('cinder')) {
|
|
||||||
const { count: allVolumesCount } = allVolumes;
|
|
||||||
const { count: attachVolumesCount } = attachVolumes;
|
|
||||||
const { count: errorVolumesCount } = errorVolumes;
|
|
||||||
const { count: availableVolumesCount } = availableVolumes;
|
|
||||||
const volumeNum = {
|
|
||||||
all: allVolumesCount,
|
|
||||||
active: attachVolumesCount,
|
|
||||||
error: errorVolumesCount,
|
|
||||||
available: availableVolumesCount,
|
|
||||||
other:
|
|
||||||
allVolumesCount -
|
|
||||||
(attachVolumesCount + errorVolumesCount + availableVolumesCount),
|
|
||||||
};
|
|
||||||
this.virtualResource.volumeNum = volumeNum;
|
|
||||||
}
|
|
||||||
this.virtualResourceLoading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
async getComputeService() {
|
async getComputeService() {
|
||||||
this.computeServiceLoading = true;
|
this.computeServiceLoading = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user