feat(xo-server,xo-web): allow setting remote syslog host (#2958)
Fixes #2900
This commit is contained in:
committed by
Pierre Donias
parent
d45265b180
commit
873b40cc70
@@ -76,6 +76,21 @@ export { restartAgent as restart_agent } // eslint-disable-line camelcase
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
export function setRemoteSyslogHost ({ host, syslogDestination }) {
|
||||
return this.getXapi(host).setRemoteSyslogHost(host._xapiId, syslogDestination)
|
||||
}
|
||||
|
||||
setRemoteSyslogHost.params = {
|
||||
id: { type: 'string' },
|
||||
syslogDestination: { type: 'string' },
|
||||
}
|
||||
|
||||
setRemoteSyslogHost.resolve = {
|
||||
host: ['id', 'host', 'administrate'],
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
export function start ({ host }) {
|
||||
return this.getXapi(host).powerOnHost(host._xapiId)
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ const TRANSFORMS = {
|
||||
license_params: obj.license_params,
|
||||
license_server: obj.license_server,
|
||||
license_expiry: toTimestamp(obj.license_params.expiry),
|
||||
logging: obj.logging,
|
||||
name_description: obj.name_description,
|
||||
name_label: obj.name_label,
|
||||
memory: (function () {
|
||||
|
||||
@@ -426,6 +426,14 @@ export default class Xapi extends XapiBase {
|
||||
await this.call('host.restart_agent', this.getObject(hostId).$ref)
|
||||
}
|
||||
|
||||
async setRemoteSyslogHost (hostId, syslogDestination) {
|
||||
const host = this.getObject(hostId)
|
||||
await this.call('host.set_logging', host.$ref, {
|
||||
syslog_destination: syslogDestination,
|
||||
})
|
||||
await this.call('host.syslog_reconfigure', host.$ref)
|
||||
}
|
||||
|
||||
async shutdownHost (hostId, force = false) {
|
||||
const host = this.getObject(hostId)
|
||||
|
||||
|
||||
@@ -598,11 +598,15 @@ const messages = {
|
||||
vmsTabName: 'Vms',
|
||||
srsTabName: 'Srs',
|
||||
// ----- Pool advanced tab -----
|
||||
poolEditAll: 'Edit all',
|
||||
poolEditRemoteSyslog: 'Edit remote syslog for all hosts',
|
||||
poolHaStatus: 'High Availability',
|
||||
poolHaEnabled: 'Enabled',
|
||||
poolHaDisabled: 'Disabled',
|
||||
setpoolMaster: 'Master',
|
||||
poolGpuGroups: 'GPU groups',
|
||||
poolRemoteSyslogPlaceHolder: 'Logging host',
|
||||
setpoolMaster: 'Master',
|
||||
syslogRemoteHost: 'Remote syslog host',
|
||||
// ----- Pool host tab -----
|
||||
hostNameLabel: 'Name',
|
||||
hostDescription: 'Description',
|
||||
@@ -682,6 +686,7 @@ const messages = {
|
||||
hostLicenseType: 'Type',
|
||||
hostLicenseSocket: 'Socket',
|
||||
hostLicenseExpiry: 'Expiry',
|
||||
hostRemoteSyslog: 'Remote syslog',
|
||||
supplementalPacks: 'Installed supplemental packs',
|
||||
supplementalPackNew: 'Install new supplemental pack',
|
||||
supplementalPackPoolNew: 'Install supplemental pack on every host',
|
||||
|
||||
@@ -576,6 +576,15 @@ export const editHost = (host, props) =>
|
||||
export const fetchHostStats = (host, granularity) =>
|
||||
_call('host.stats', { host: resolveId(host), granularity })
|
||||
|
||||
export const setRemoteSyslogHost = (host, syslogDestination) =>
|
||||
_call('host.setRemoteSyslogHost', {
|
||||
id: resolveId(host),
|
||||
syslogDestination,
|
||||
})
|
||||
|
||||
export const setRemoteSyslogHosts = (hosts, syslogDestination) =>
|
||||
Promise.all(map(hosts, host => setRemoteSyslogHost(host, syslogDestination)))
|
||||
|
||||
export const restartHost = (host, force = false) =>
|
||||
confirm({
|
||||
title: _('restartHostModalTitle'),
|
||||
|
||||
@@ -5,20 +5,22 @@ import React from 'react'
|
||||
import TabButton from 'tab-button'
|
||||
import SelectFiles from 'select-files'
|
||||
import Upgrade from 'xoa-upgrade'
|
||||
import { compareVersions, connectStore } from 'utils'
|
||||
import { Text } from 'editable'
|
||||
import { Toggle } from 'form'
|
||||
import { compareVersions, connectStore } from 'utils'
|
||||
import { FormattedRelative, FormattedTime } from 'react-intl'
|
||||
import { Container, Row, Col } from 'grid'
|
||||
import { forEach, map, noop } from 'lodash'
|
||||
import { createGetObjectsOfType, createSelector } from 'selectors'
|
||||
import {
|
||||
enableHost,
|
||||
detachHost,
|
||||
disableHost,
|
||||
forgetHost,
|
||||
setRemoteSyslogHost,
|
||||
restartHost,
|
||||
installSupplementalPack,
|
||||
} from 'xo'
|
||||
import { FormattedRelative, FormattedTime } from 'react-intl'
|
||||
import { Container, Row, Col } from 'grid'
|
||||
import { createGetObjectsOfType, createSelector } from 'selectors'
|
||||
import { forEach, map, noop } from 'lodash'
|
||||
|
||||
const ALLOW_INSTALL_SUPP_PACK = process.env.XOA_PLAN > 1
|
||||
|
||||
@@ -66,6 +68,7 @@ export default class extends Component {
|
||||
return uniqPacks
|
||||
}
|
||||
)
|
||||
_setRemoteSyslogHost = value => setRemoteSyslogHost(this.props.host, value)
|
||||
|
||||
render () {
|
||||
const { host, pcis, pgpus } = this.props
|
||||
@@ -182,6 +185,15 @@ export default class extends Component {
|
||||
<th>{_('hostIscsiName')}</th>
|
||||
<Copiable tagName='td'>{host.iSCSI_name}</Copiable>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{_('hostRemoteSyslog')}</th>
|
||||
<td>
|
||||
<Text
|
||||
value={host.logging.syslog_destination || ''}
|
||||
onChange={this._setRemoteSyslogHost}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
import React from 'react'
|
||||
|
||||
import _ from 'intl'
|
||||
import _, { messages } from 'intl'
|
||||
import ActionButton from 'action-button'
|
||||
import ActionRowButton from 'action-row-button'
|
||||
import Component from 'base-component'
|
||||
import Copiable from 'copiable'
|
||||
import renderXoItem from 'render-xo-item'
|
||||
import SelectFiles from 'select-files'
|
||||
import Upgrade from 'xoa-upgrade'
|
||||
import { connectStore } from 'utils'
|
||||
import { createGetObjectsOfType } from 'selectors'
|
||||
import { XoSelect } from 'editable'
|
||||
import { installSupplementalPackOnAllHosts, setPoolMaster } from 'xo'
|
||||
import { map } from 'lodash'
|
||||
import { connectStore } from 'utils'
|
||||
import { injectIntl } from 'react-intl'
|
||||
import { createGetObjectsOfType } from 'selectors'
|
||||
import { Text, XoSelect } from 'editable'
|
||||
import { Container, Row, Col } from 'grid'
|
||||
import {
|
||||
installSupplementalPackOnAllHosts,
|
||||
setPoolMaster,
|
||||
setRemoteSyslogHost,
|
||||
setRemoteSyslogHosts,
|
||||
} from 'xo'
|
||||
|
||||
@connectStore(() => ({
|
||||
master: createGetObjectsOfType('host').find((_, { pool }) => ({
|
||||
@@ -39,56 +47,128 @@ class PoolMaster extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default connectStore({
|
||||
@injectIntl
|
||||
@connectStore({
|
||||
hosts: createGetObjectsOfType('host')
|
||||
.filter((_, { pool }) => ({ $pool: pool.id }))
|
||||
.sort(),
|
||||
gpuGroups: createGetObjectsOfType('gpuGroup'),
|
||||
})(({ gpuGroups, pool }) => (
|
||||
<div>
|
||||
<h3 className='mb-1'>{_('xenSettingsLabel')}</h3>
|
||||
<Container>
|
||||
<Row>
|
||||
<Col size={3}>
|
||||
<strong>{_('uuid')}</strong>
|
||||
</Col>
|
||||
<Col size={9}>
|
||||
<Copiable tagName='div'>{pool.uuid}</Copiable>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col size={3}>
|
||||
<strong>{_('poolHaStatus')}</strong>
|
||||
</Col>
|
||||
<Col size={9}>
|
||||
{pool.HA_enabled ? _('poolHaEnabled') : _('poolHaDisabled')}
|
||||
</Col>
|
||||
</Row>
|
||||
<Row>
|
||||
<Col size={3}>
|
||||
<strong>{_('setpoolMaster')}</strong>
|
||||
</Col>
|
||||
<Col size={9}>
|
||||
<PoolMaster pool={pool} />
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
<h3 className='mt-1 mb-1'>{_('poolGpuGroups')}</h3>
|
||||
<Container>
|
||||
<Row>
|
||||
<Col size={9}>
|
||||
<ul className='list-group'>
|
||||
{map(gpuGroups, gpuGroup => (
|
||||
<li key={gpuGroup.id} className='list-group-item'>
|
||||
{renderXoItem(gpuGroup)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
<h3 className='mt-1 mb-1'>{_('supplementalPackPoolNew')}</h3>
|
||||
<Upgrade place='poolSupplementalPacks' required={2}>
|
||||
<SelectFiles
|
||||
onChange={file => installSupplementalPackOnAllHosts(pool, file)}
|
||||
/>
|
||||
</Upgrade>
|
||||
</div>
|
||||
))
|
||||
})
|
||||
export default class TabAdvanced extends Component {
|
||||
_setRemoteSyslogHosts = () =>
|
||||
setRemoteSyslogHosts(this.props.hosts, this.state.syslogDestination).then(
|
||||
() => this.setState({ editRemoteSyslog: false, syslogDestination: '' })
|
||||
)
|
||||
|
||||
render () {
|
||||
const { hosts, gpuGroups, pool } = this.props
|
||||
const { state } = this
|
||||
const { editRemoteSyslog } = state
|
||||
return (
|
||||
<div>
|
||||
<Container>
|
||||
<Row>
|
||||
<Col>
|
||||
<h3>{_('xenSettingsLabel')}</h3>
|
||||
<table className='table'>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>{_('uuid')}</th>
|
||||
<Copiable tagName='td'>{pool.uuid}</Copiable>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{_('poolHaStatus')}</th>
|
||||
<td>
|
||||
{pool.HA_enabled
|
||||
? _('poolHaEnabled')
|
||||
: _('poolHaDisabled')}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{_('setpoolMaster')}</th>
|
||||
<td>
|
||||
<PoolMaster pool={pool} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{_('syslogRemoteHost')}</th>
|
||||
<td>
|
||||
<ul className='pl-0'>
|
||||
{map(hosts, host => (
|
||||
<li key={host.id}>
|
||||
<span>{`${host.name_label}: `}</span>
|
||||
<Text
|
||||
value={host.logging.syslog_destination || ''}
|
||||
onChange={value =>
|
||||
setRemoteSyslogHost(host, value)
|
||||
}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<ActionRowButton
|
||||
btnStyle={editRemoteSyslog ? 'info' : 'primary'}
|
||||
handler={this.toggleState('editRemoteSyslog')}
|
||||
icon='edit'
|
||||
>
|
||||
{_('poolEditAll')}
|
||||
</ActionRowButton>
|
||||
{editRemoteSyslog && (
|
||||
<form
|
||||
id='formRemoteSyslog'
|
||||
className='form-inline mt-1'
|
||||
>
|
||||
<div className='form-group'>
|
||||
<input
|
||||
className='form-control'
|
||||
onChange={this.linkState('syslogDestination')}
|
||||
placeholder={this.props.intl.formatMessage(
|
||||
messages.poolRemoteSyslogPlaceHolder
|
||||
)}
|
||||
type='text'
|
||||
value={state.syslogDestination}
|
||||
/>
|
||||
</div>
|
||||
<div className='form-group ml-1'>
|
||||
<ActionButton
|
||||
btnStyle='primary'
|
||||
form='formRemoteSyslog'
|
||||
handler={this._setRemoteSyslogHosts}
|
||||
icon='save'
|
||||
>
|
||||
{_('confirmOk')}
|
||||
</ActionButton>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
<h3 className='mt-1 mb-1'>{_('poolGpuGroups')}</h3>
|
||||
<Container>
|
||||
<Row>
|
||||
<Col size={9}>
|
||||
<ul className='list-group'>
|
||||
{map(gpuGroups, gpuGroup => (
|
||||
<li key={gpuGroup.id} className='list-group-item'>
|
||||
{renderXoItem(gpuGroup)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Col>
|
||||
</Row>
|
||||
</Container>
|
||||
<h3 className='mt-1 mb-1'>{_('supplementalPackPoolNew')}</h3>
|
||||
<Upgrade place='poolSupplementalPacks' required={2}>
|
||||
<SelectFiles
|
||||
onChange={file => installSupplementalPackOnAllHosts(pool, file)}
|
||||
/>
|
||||
</Upgrade>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user