Merge "fix: Fix the permission of QosPolicy"

This commit is contained in:
Zuul 2021-10-11 02:13:51 +00:00 committed by Gerrit Code Review
commit 6b1f119db7
10 changed files with 87 additions and 24 deletions

View File

@ -67,6 +67,7 @@ export const octaviaBase = () => getOpenstackEndpoint('octavia');
export const ironicOriginEndpoint = () => getOriginEndpoint('ironic');
export const vpnEndpoint = () => getOriginEndpoint('neutron_vpn');
export const lbEndpoint = () => getOriginEndpoint('octavia');
export const qosEndpoint = () => getOriginEndpoint('neutron_qos');
export const apiVersionMaps = {
nova: {

View File

@ -21,6 +21,7 @@ import globalProjectStore from 'stores/keystone/project';
import globalSubnetStore from 'stores/neutron/subnet';
import { QoSPolicyStore } from 'stores/neutron/qos-policy';
import { getQoSPolicyTabs } from 'resources/qos-policy';
import { qosEndpoint } from 'client/client/constants';
export class Allocate extends ModalAction {
static id = 'allocate';
@ -32,11 +33,15 @@ export class Allocate extends ModalAction {
}
static get modalSize() {
return 'large';
return qosEndpoint() ? 'large' : 'small';
}
getModalSize() {
return 'large';
return qosEndpoint() ? 'large' : 'small';
}
get qosEndpoint() {
return qosEndpoint();
}
init() {
@ -221,6 +226,7 @@ export class Allocate extends ModalAction {
isMulti: false,
tip: t('Choosing a QoS policy can limit bandwidth and DSCP'),
onChange: this.onQosChange,
display: !!this.qosEndpoint,
},
];
}

View File

@ -17,6 +17,7 @@ import { ModalAction } from 'containers/Action';
import globalFloatingIpsStore from 'stores/neutron/floatingIp';
import { getQoSPolicyTabs } from 'resources/qos-policy';
import { QoSPolicyStore } from 'stores/neutron/qos-policy';
import { qosEndpoint } from 'client/client/constants';
export class Edit extends ModalAction {
static id = 'edit-floating-ip';
@ -24,11 +25,15 @@ export class Edit extends ModalAction {
static policy = 'update_floatingip';
static get modalSize() {
return 'large';
return qosEndpoint() ? 'large' : 'small';
}
getModalSize() {
return 'large';
return qosEndpoint() ? 'large' : 'small';
}
get qosEndpoint() {
return qosEndpoint();
}
init() {
@ -39,17 +44,21 @@ export class Edit extends ModalAction {
const { item } = this.props;
return {
description: this.item.description,
qos_policy_id: {
selectedRowKeys: item.qos_policy_id ? [item.qos_policy_id] : [],
selectedRows: item.qos_policy_id
? [
{
id: item.qos_policy_id,
name: item.qos_policy_id,
},
]
: [],
},
...(this.qosEndpoint
? {
qos_policy_id: {
selectedRowKeys: item.qos_policy_id ? [item.qos_policy_id] : [],
selectedRows: item.qos_policy_id
? [
{
id: item.qos_policy_id,
name: item.qos_policy_id,
},
]
: [],
},
}
: {}),
};
}
@ -86,6 +95,7 @@ export class Edit extends ModalAction {
tabs: getQoSPolicyTabs.call(this),
isMulti: false,
tip: t('Choosing a QoS policy can limit bandwidth and DSCP'),
display: !!this.qosEndpoint,
},
];
}

View File

@ -21,6 +21,7 @@ import { Link } from 'react-router-dom';
import { emptyActionConfig } from 'utils/constants';
import { Col, Popover, Row } from 'antd';
import { FileTextOutlined } from '@ant-design/icons';
import { qosEndpoint } from 'client/client/constants';
import styles from './styles.less';
import actionConfigs from './actions';
@ -30,6 +31,10 @@ export class FloatingIps extends Base {
this.downloadStore = new FloatingIpStore();
}
get qosEndpoint() {
return qosEndpoint();
}
get isFilterByBackend() {
return true;
}
@ -128,6 +133,7 @@ export class FloatingIps extends Base {
{value}
</Link>
),
hidden: !this.qosEndpoint,
},
{
title: t('Project ID/Name'),

View File

@ -14,6 +14,7 @@
import { inject, observer } from 'mobx-react';
import Base from 'containers/BaseDetail';
import { qosEndpoint } from 'client/client/constants';
@inject('rootStore')
@observer
@ -23,6 +24,10 @@ export default class BaseDetail extends Base {
return cards;
}
get qosEndpoint() {
return qosEndpoint();
}
get baseInfoCard() {
const options = [
{
@ -55,17 +60,19 @@ export default class BaseDetail extends Base {
label: t('Segmentation ID'),
dataIndex: 'provider:segmentation_id',
},
{
label: t('QoS Policy'),
dataIndex: 'qos_policy_id',
render: (data) => data || '-',
},
{
label: t('Port Security Enabled'),
dataIndex: 'port_security_enabled',
valueRender: 'yesNo',
},
];
if (this.qosEndpoint) {
options.push({
label: t('QoS Policy'),
dataIndex: 'qos_policy_id',
render: (data) => data || '-',
});
}
return {
title: t('Base Info'),
options,

View File

@ -16,6 +16,7 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List';
import { QoSPolicyStore } from 'stores/neutron/qos-policy';
import { getQosPolicyColumns, getQosPolicyFilters } from 'resources/qos-policy';
import { qosEndpoint } from 'client/client/constants';
import actionConfigs from './actions';
export class QoSPolicy extends Base {
@ -29,6 +30,14 @@ export class QoSPolicy extends Base {
all_projects: this.tabKey === 'allQoSPolicy' || this.isAdminPage,
});
get checkEndpoint() {
return true;
}
get endpoint() {
return qosEndpoint();
}
get policy() {
return 'get_policy';
}

View File

@ -14,11 +14,20 @@
import { observer, inject } from 'mobx-react';
import Base from 'containers/TabList';
import { qosEndpoint } from 'client/client/constants';
import QoSPolicyComponent from './QoSPolicy';
@inject('rootStore')
@observer
export default class QoSPolicy extends Base {
get checkEndpoint() {
return true;
}
get endpoint() {
return qosEndpoint();
}
get tabs() {
const tabs = [
{

View File

@ -17,6 +17,7 @@ import { Link } from 'react-router-dom';
import { inject, observer } from 'mobx-react';
import Base from 'containers/BaseDetail';
import { bindingTypes } from 'resources/port';
import { qosEndpoint } from 'client/client/constants';
@inject('rootStore')
@observer
@ -25,6 +26,10 @@ export default class BaseDetail extends Base {
return [this.baseInfoCard];
}
get qosEndpoint() {
return qosEndpoint();
}
get baseInfoCard() {
const options = [
{
@ -57,7 +62,9 @@ export default class BaseDetail extends Base {
dataIndex: 'binding:vnic_type',
render: (value) => bindingTypes[value] || '-',
},
{
];
if (this.qosEndpoint) {
options.push({
label: t('QoS Policy'),
dataIndex: 'qos_policy_id',
copyable: false,
@ -67,8 +74,8 @@ export default class BaseDetail extends Base {
) : (
'-'
),
},
];
});
}
return {
title: t('Base Info'),
options,

View File

@ -24,6 +24,7 @@ import globalVirtualAdapterStore from 'stores/neutron/virtual-adapter';
import globalProjectStore from 'stores/keystone/project';
import { SubnetStore } from 'stores/neutron/subnet';
import { getQoSPolicyTabs } from 'resources/qos-policy';
import { qosEndpoint } from 'client/client/constants';
const portTypes =
'normal,macvtap,direct,baremetal,direct-physical,virtio-forwarder,smart-nic';
@ -33,6 +34,10 @@ export class CreateAction extends ModalAction {
static title = t('Create Virtual Adapter');
get qosEndpoint() {
return qosEndpoint();
}
init() {
this.networkStore = new NetworkStore();
this.securityGroupStore = new SecurityGroupStore();
@ -312,6 +317,7 @@ export class CreateAction extends ModalAction {
});
},
hidden: !more,
display: !!this.qosEndpoint,
},
{
name: 'qos_policy_id',
@ -322,6 +328,7 @@ export class CreateAction extends ModalAction {
required: enableQosPolicy,
tip: t('Choosing a QoS policy can limit bandwidth and DSCP'),
hidden: !(more && enableQosPolicy),
display: !!this.qosEndpoint,
},
{
name: 'bindingProfile',

View File

@ -18,6 +18,7 @@ import { ModalAction } from 'containers/Action';
import { QoSPolicyStore } from 'stores/neutron/qos-policy';
import globalVirtualAdapterStore from 'stores/neutron/virtual-adapter';
import { getQoSPolicyTabs } from 'resources/qos-policy';
import { qosEndpoint } from 'client/client/constants';
export class ModifyQoS extends ModalAction {
static id = 'modify_qos';
@ -87,7 +88,7 @@ export class ModifyQoS extends ModalAction {
static policy = 'update_port';
static allowed = () => Promise.resolve(true);
static allowed = () => Promise.resolve(!!qosEndpoint());
onSubmit = (values) => {
const { id } = this.item;