Compare commits
6 Commits
updateChan
...
feat_s3_st
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d10e261f8 | ||
|
|
84252c3abe | ||
|
|
4fb48e01fa | ||
|
|
516fc3f6ff | ||
|
|
676851ea82 | ||
|
|
a7a64f4281 |
@@ -22,7 +22,7 @@
|
||||
"fuse-native": "^2.2.6",
|
||||
"lru-cache": "^7.14.0",
|
||||
"promise-toolbox": "^0.21.0",
|
||||
"vhd-lib": "^4.6.1"
|
||||
"vhd-lib": "^4.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"postversion": "npm publish --access public"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
|
||||
"dependencies": {
|
||||
"@xen-orchestra/async-map": "^0.1.2",
|
||||
"@xen-orchestra/backups": "^0.43.0",
|
||||
"@xen-orchestra/backups": "^0.42.1",
|
||||
"@xen-orchestra/fs": "^4.1.0",
|
||||
"filenamify": "^6.0.0",
|
||||
"getopts": "^2.2.5",
|
||||
@@ -27,7 +27,7 @@
|
||||
"scripts": {
|
||||
"postversion": "npm publish --access public"
|
||||
},
|
||||
"version": "1.0.13",
|
||||
"version": "1.0.12",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": {
|
||||
"name": "Vates SAS",
|
||||
|
||||
@@ -681,11 +681,13 @@ export class RemoteAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
async outputStream(path, input, { checksum = true, validator = noop } = {}) {
|
||||
async outputStream(path, input, { checksum = true, maxStreamLength, streamLength, validator = noop } = {}) {
|
||||
const container = watchStreamSize(input)
|
||||
await this._handler.outputStream(path, input, {
|
||||
checksum,
|
||||
dirMode: this._dirMode,
|
||||
maxStreamLength,
|
||||
streamLength,
|
||||
async validator() {
|
||||
await input.task
|
||||
return validator.apply(this, arguments)
|
||||
@@ -742,8 +744,15 @@ export class RemoteAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
readFullVmBackup(metadata) {
|
||||
return this._handler.createReadStream(resolve('/', dirname(metadata._filename), metadata.xva))
|
||||
async readFullVmBackup(metadata) {
|
||||
const xvaPath = resolve('/', dirname(metadata._filename), metadata.xva)
|
||||
const stream = await this._handler.createReadStream(xvaPath)
|
||||
try {
|
||||
stream.length = await this._handler.getSize(xvaPath)
|
||||
} catch (error) {
|
||||
warn(`Can't compute length of xva file`, { xvaPath, error })
|
||||
}
|
||||
return stream
|
||||
}
|
||||
|
||||
async readVmBackupMetadata(path) {
|
||||
|
||||
@@ -29,6 +29,8 @@ export const FullRemote = class FullRemoteVmBackupRunner extends AbstractRemote
|
||||
writer =>
|
||||
writer.run({
|
||||
stream: forkStreamUnpipe(stream),
|
||||
// stream is copied and transformed, it's not safe to attach additionnal properties to it
|
||||
streamLength: stream.length,
|
||||
timestamp: metadata.timestamp,
|
||||
vm: metadata.vm,
|
||||
vmSnapshot: metadata.vmSnapshot,
|
||||
|
||||
@@ -35,13 +35,22 @@ export const FullXapi = class FullXapiVmBackupRunner extends AbstractXapi {
|
||||
useSnapshot: false,
|
||||
})
|
||||
)
|
||||
|
||||
const vdis = await exportedVm.$getDisks()
|
||||
let maxStreamLength = 1024 * 1024 // Ovf file and tar headers are a few KB, let's stay safe
|
||||
vdis.forEach(vdiRef => {
|
||||
const vdi = this._xapi.getObject(vdiRef)
|
||||
maxStreamLength += vdi.physical_utilisation ?? 0 // at most the xva will take the physical usage of the disk
|
||||
// it can be smaller due to the smaller block size for xva than vhd, and compression of xcp-ng
|
||||
})
|
||||
|
||||
const sizeContainer = watchStreamSize(stream)
|
||||
|
||||
const timestamp = Date.now()
|
||||
|
||||
await this._callWriters(
|
||||
writer =>
|
||||
writer.run({
|
||||
maxStreamLength,
|
||||
sizeContainer,
|
||||
stream: forkStreamUnpipe(stream),
|
||||
timestamp,
|
||||
|
||||
@@ -31,11 +31,6 @@ export const AbstractXapi = class AbstractXapiVmBackupRunner extends Abstract {
|
||||
throw new Error('cannot backup a VM created by this very job')
|
||||
}
|
||||
|
||||
const currentOperations = Object.values(vm.current_operations)
|
||||
if (currentOperations.some(_ => _ === 'migrate_send' || _ === 'pool_migrate')) {
|
||||
throw new Error('cannot backup a VM currently being migrated')
|
||||
}
|
||||
|
||||
this.config = config
|
||||
this.job = job
|
||||
this.remoteAdapters = remoteAdapters
|
||||
@@ -261,15 +256,7 @@ export const AbstractXapi = class AbstractXapiVmBackupRunner extends Abstract {
|
||||
}
|
||||
|
||||
if (this._writers.size !== 0) {
|
||||
const { pool_migrate = null, migrate_send = null } = this._exportedVm.blocked_operations
|
||||
|
||||
const reason = 'VM migration is blocked during backup'
|
||||
await this._exportedVm.update_blocked_operations({ pool_migrate: reason, migrate_send: reason })
|
||||
try {
|
||||
await this._copy()
|
||||
} finally {
|
||||
await this._exportedVm.update_blocked_operations({ pool_migrate, migrate_send })
|
||||
}
|
||||
await this._copy()
|
||||
}
|
||||
} finally {
|
||||
if (startAfter) {
|
||||
|
||||
@@ -24,7 +24,7 @@ export class FullRemoteWriter extends MixinRemoteWriter(AbstractFullWriter) {
|
||||
)
|
||||
}
|
||||
|
||||
async _run({ timestamp, sizeContainer, stream, vm, vmSnapshot }) {
|
||||
async _run({ maxStreamLength, timestamp, sizeContainer, stream, streamLength, vm, vmSnapshot }) {
|
||||
const settings = this._settings
|
||||
const job = this._job
|
||||
const scheduleId = this._scheduleId
|
||||
@@ -65,6 +65,8 @@ export class FullRemoteWriter extends MixinRemoteWriter(AbstractFullWriter) {
|
||||
|
||||
await Task.run({ name: 'transfer' }, async () => {
|
||||
await adapter.outputStream(dataFilename, stream, {
|
||||
maxStreamLength,
|
||||
streamLength,
|
||||
validator: tmpPath => adapter.isValidXva(tmpPath),
|
||||
})
|
||||
return { size: sizeContainer.size }
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { AbstractWriter } from './_AbstractWriter.mjs'
|
||||
|
||||
export class AbstractFullWriter extends AbstractWriter {
|
||||
async run({ timestamp, sizeContainer, stream, vm, vmSnapshot }) {
|
||||
async run({ maxStreamLength, timestamp, sizeContainer, stream, streamLength, vm, vmSnapshot }) {
|
||||
try {
|
||||
return await this._run({ timestamp, sizeContainer, stream, vm, vmSnapshot })
|
||||
return await this._run({ maxStreamLength, timestamp, sizeContainer, stream, streamLength, vm, vmSnapshot })
|
||||
} finally {
|
||||
// ensure stream is properly closed
|
||||
stream.destroy()
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
||||
},
|
||||
"version": "0.43.0",
|
||||
"version": "0.42.1",
|
||||
"engines": {
|
||||
"node": ">=14.18"
|
||||
},
|
||||
@@ -44,7 +44,7 @@
|
||||
"proper-lockfile": "^4.1.2",
|
||||
"tar": "^6.1.15",
|
||||
"uuid": "^9.0.0",
|
||||
"vhd-lib": "^4.6.1",
|
||||
"vhd-lib": "^4.6.0",
|
||||
"xen-api": "^1.3.6",
|
||||
"yazl": "^2.5.1"
|
||||
},
|
||||
@@ -56,7 +56,7 @@
|
||||
"tmp": "^0.2.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@xen-orchestra/xapi": "^3.2.0"
|
||||
"@xen-orchestra/xapi": "^3.1.0"
|
||||
},
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"author": {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"@aws-sdk/lib-storage": "^3.54.0",
|
||||
"@aws-sdk/middleware-apply-body-checksum": "^3.58.0",
|
||||
"@aws-sdk/node-http-handler": "^3.54.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.421.0",
|
||||
"@sindresorhus/df": "^3.1.1",
|
||||
"@vates/async-each": "^1.0.0",
|
||||
"@vates/coalesce-calls": "^0.1.0",
|
||||
|
||||
@@ -189,7 +189,7 @@ export default class RemoteHandlerAbstract {
|
||||
* @param {number} [options.dirMode]
|
||||
* @param {(this: RemoteHandlerAbstract, path: string) => Promise<undefined>} [options.validator] Function that will be called before the data is commited to the remote, if it fails, file should not exist
|
||||
*/
|
||||
async outputStream(path, input, { checksum = true, dirMode, validator } = {}) {
|
||||
async outputStream(path, input, { checksum = true, dirMode, maxStreamLength, streamLength, validator } = {}) {
|
||||
path = normalizePath(path)
|
||||
let checksumStream
|
||||
|
||||
@@ -201,6 +201,8 @@ export default class RemoteHandlerAbstract {
|
||||
}
|
||||
await this._outputStream(path, input, {
|
||||
dirMode,
|
||||
maxStreamLength,
|
||||
streamLength,
|
||||
validator,
|
||||
})
|
||||
if (checksum) {
|
||||
@@ -624,18 +626,14 @@ export default class RemoteHandlerAbstract {
|
||||
|
||||
const files = await this._list(dir)
|
||||
await asyncEach(files, file =>
|
||||
this._unlink(`${dir}/${file}`).catch(
|
||||
error => {
|
||||
// Unlink dir behavior is not consistent across platforms
|
||||
// https://github.com/nodejs/node-v0.x-archive/issues/5791
|
||||
if (error.code === 'EISDIR' || error.code === 'EPERM') {
|
||||
return this._rmtree(`${dir}/${file}`)
|
||||
}
|
||||
throw error
|
||||
},
|
||||
// real unlink concurrency will be 2**max directory depth
|
||||
{ concurrency: 2 }
|
||||
)
|
||||
this._unlink(`${dir}/${file}`).catch(error => {
|
||||
// Unlink dir behavior is not consistent across platforms
|
||||
// https://github.com/nodejs/node-v0.x-archive/issues/5791
|
||||
if (error.code === 'EISDIR' || error.code === 'EPERM') {
|
||||
return this._rmtree(`${dir}/${file}`)
|
||||
}
|
||||
throw error
|
||||
})
|
||||
)
|
||||
return this._rmtree(dir)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
CreateMultipartUploadCommand,
|
||||
DeleteObjectCommand,
|
||||
GetObjectCommand,
|
||||
GetObjectLockConfigurationCommand,
|
||||
HeadObjectCommand,
|
||||
ListObjectsV2Command,
|
||||
PutObjectCommand,
|
||||
@@ -17,7 +18,7 @@ import { getApplyMd5BodyChecksumPlugin } from '@aws-sdk/middleware-apply-body-ch
|
||||
import { Agent as HttpAgent } from 'http'
|
||||
import { Agent as HttpsAgent } from 'https'
|
||||
import { createLogger } from '@xen-orchestra/log'
|
||||
import { PassThrough, pipeline } from 'stream'
|
||||
import { PassThrough, Transform, pipeline } from 'stream'
|
||||
import { parse } from 'xo-remote-parser'
|
||||
import copyStreamToBuffer from './_copyStreamToBuffer.js'
|
||||
import guessAwsRegion from './_guessAwsRegion.js'
|
||||
@@ -30,6 +31,8 @@ import { pRetry } from 'promise-toolbox'
|
||||
|
||||
// limits: https://docs.aws.amazon.com/AmazonS3/latest/dev/qfacts.html
|
||||
const MAX_PART_SIZE = 1024 * 1024 * 1024 * 5 // 5GB
|
||||
const MAX_PART_NUMBER = 10000
|
||||
const MIN_PART_SIZE = 5 * 1024 * 1024
|
||||
const { warn } = createLogger('xo:fs:s3')
|
||||
|
||||
export default class S3Handler extends RemoteHandlerAbstract {
|
||||
@@ -71,9 +74,6 @@ export default class S3Handler extends RemoteHandlerAbstract {
|
||||
}),
|
||||
})
|
||||
|
||||
// Workaround for https://github.com/aws/aws-sdk-js-v3/issues/2673
|
||||
this.#s3.middlewareStack.use(getApplyMd5BodyChecksumPlugin(this.#s3.config))
|
||||
|
||||
const parts = split(path)
|
||||
this.#bucket = parts.shift()
|
||||
this.#dir = join(...parts)
|
||||
@@ -223,18 +223,41 @@ export default class S3Handler extends RemoteHandlerAbstract {
|
||||
}
|
||||
}
|
||||
|
||||
async _outputStream(path, input, { validator }) {
|
||||
async _outputStream(path, input, { maxStreamLength, streamLength, validator }) {
|
||||
const maxInputLength = streamLength ?? maxStreamLength
|
||||
let partSize
|
||||
if (maxInputLength === undefined) {
|
||||
warn(`Writing ${path} to a S3 remote without a max size set will cut it to 50GB`, { path })
|
||||
partSize = MIN_PART_SIZE // min size for S3
|
||||
} else {
|
||||
partSize = Math.min(Math.max(Math.ceil(maxInputLength / MAX_PART_NUMBER), MIN_PART_SIZE), MAX_PART_SIZE)
|
||||
}
|
||||
|
||||
// esnure we d'ont try to upload a stream to big for this part size
|
||||
let readCounter = 0
|
||||
const streamCutter = new Transform({
|
||||
transform(chunk, encoding, callback) {
|
||||
const MAX_SIZE = MAX_PART_NUMBER * partSize
|
||||
readCounter += chunk.length
|
||||
if (readCounter > MAX_SIZE) {
|
||||
callback(new Error(`read ${readCounter} bytes, maximum size allowed is ${MAX_SIZE} `))
|
||||
} else {
|
||||
callback(null, chunk)
|
||||
}
|
||||
},
|
||||
})
|
||||
// Workaround for "ReferenceError: ReadableStream is not defined"
|
||||
// https://github.com/aws/aws-sdk-js-v3/issues/2522
|
||||
const Body = new PassThrough()
|
||||
pipeline(input, Body, () => {})
|
||||
|
||||
pipeline(input, streamCutter, Body, () => {})
|
||||
const upload = new Upload({
|
||||
client: this.#s3,
|
||||
params: {
|
||||
...this.#createParams(path),
|
||||
Body,
|
||||
},
|
||||
partSize,
|
||||
leavePartsOnError: false,
|
||||
})
|
||||
|
||||
await upload.done()
|
||||
@@ -418,6 +441,21 @@ export default class S3Handler extends RemoteHandlerAbstract {
|
||||
|
||||
async _closeFile(fd) {}
|
||||
|
||||
async _sync() {
|
||||
await super._sync()
|
||||
try {
|
||||
const res = await this.#s3.send(new GetObjectLockConfigurationCommand({ Bucket: this.#bucket }))
|
||||
if (res.ObjectLockConfiguration?.ObjectLockEnabled === 'Enabled') {
|
||||
// Workaround for https://github.com/aws/aws-sdk-js-v3/issues/2673
|
||||
// increase memory consumption in outputStream as if buffer the streams
|
||||
this.#s3.middlewareStack.use(getApplyMd5BodyChecksumPlugin(this.#s3.config))
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.Code !== 'ObjectLockConfigurationNotFoundError') {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
useVhdDirectory() {
|
||||
return true
|
||||
}
|
||||
|
||||
258
@xen-orchestra/fs/testupload.mjs
Normal file
258
@xen-orchestra/fs/testupload.mjs
Normal file
@@ -0,0 +1,258 @@
|
||||
import fs from 'fs/promises'
|
||||
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"
|
||||
import { createHash } from "crypto";
|
||||
import {
|
||||
CompleteMultipartUploadCommand,
|
||||
CreateMultipartUploadCommand,
|
||||
GetObjectLockConfigurationCommand,
|
||||
PutObjectCommand,
|
||||
S3Client,
|
||||
UploadPartCommand,
|
||||
} from '@aws-sdk/client-s3'
|
||||
|
||||
import { NodeHttpHandler } from '@aws-sdk/node-http-handler'
|
||||
import { Agent as HttpAgent } from 'http'
|
||||
import { Agent as HttpsAgent } from 'https'
|
||||
import { parse } from 'xo-remote-parser'
|
||||
import { join, split } from './dist/path.js'
|
||||
|
||||
import guessAwsRegion from './dist/_guessAwsRegion.js'
|
||||
import { PassThrough } from 'stream'
|
||||
import { readChunk } from '@vates/read-chunk'
|
||||
import { pFromCallback } from 'promise-toolbox'
|
||||
|
||||
async function v2(url, inputStream){
|
||||
const {
|
||||
allowUnauthorized,
|
||||
host,
|
||||
path,
|
||||
username,
|
||||
password,
|
||||
protocol,
|
||||
region = guessAwsRegion(host),
|
||||
} = parse(url)
|
||||
const client = new S3Client({
|
||||
apiVersion: '2006-03-01',
|
||||
endpoint: `${protocol}://s3.us-east-2.amazonaws.com`,
|
||||
forcePathStyle: true,
|
||||
credentials: {
|
||||
accessKeyId: username,
|
||||
secretAccessKey: password,
|
||||
},
|
||||
region,
|
||||
requestHandler: new NodeHttpHandler({
|
||||
socketTimeout: 600000,
|
||||
httpAgent: new HttpAgent({
|
||||
keepAlive: true,
|
||||
}),
|
||||
httpsAgent: new HttpsAgent({
|
||||
rejectUnauthorized: !allowUnauthorized,
|
||||
keepAlive: true,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
const pathParts = split(path)
|
||||
const bucket = pathParts.shift()
|
||||
const dir = join(...pathParts)
|
||||
|
||||
const command = new CreateMultipartUploadCommand({
|
||||
Bucket: bucket, Key: join(dir, 'flov2')
|
||||
})
|
||||
const multipart = await client.send(command)
|
||||
console.log({multipart})
|
||||
|
||||
const parts = []
|
||||
// monitor memory usage
|
||||
const intervalMonitorMemoryUsage = setInterval(()=>console.log(Math.round(process.memoryUsage().rss/1024/1024)), 2000)
|
||||
|
||||
const CHUNK_SIZE = Math.ceil(5*1024*1024*1024*1024/10000) // smallest chunk allowing 5TB upload
|
||||
|
||||
async function read(inputStream, maxReadSize){
|
||||
if(maxReadSize === 0){
|
||||
return null
|
||||
}
|
||||
process.stdout.write('+')
|
||||
const chunk = await readChunk(inputStream, maxReadSize)
|
||||
process.stdout.write('@')
|
||||
return chunk
|
||||
}
|
||||
|
||||
async function write(data, chunkStream, remainingBytes){
|
||||
const ready = chunkStream.write(data)
|
||||
if(!ready){
|
||||
process.stdout.write('.')
|
||||
await pFromCallback(cb=> chunkStream.once('drain', cb))
|
||||
process.stdout.write('@')
|
||||
}
|
||||
remainingBytes -= data.length
|
||||
process.stdout.write(remainingBytes+' ')
|
||||
return remainingBytes
|
||||
}
|
||||
|
||||
|
||||
async function uploadChunk(inputStream){
|
||||
const PartNumber = parts.length +1
|
||||
let done = false
|
||||
let remainingBytes = CHUNK_SIZE
|
||||
const maxChunkPartSize = Math.round(CHUNK_SIZE / 1000)
|
||||
const chunkStream = new PassThrough()
|
||||
console.log({maxChunkPartSize,CHUNK_SIZE})
|
||||
|
||||
|
||||
|
||||
let data
|
||||
let chunkBuffer = []
|
||||
const hash = createHash('md5');
|
||||
try{
|
||||
while((data = await read(inputStream, Math.min(remainingBytes, maxChunkPartSize))) !== null){
|
||||
chunkBuffer.push(data)
|
||||
hash.update(data)
|
||||
remainingBytes -= data.length
|
||||
//remainingBytes = await write(data, chunkStream, remainingBytes)
|
||||
}
|
||||
console.log('data put')
|
||||
const fullBuffer = Buffer.alloc(maxChunkPartSize,0)
|
||||
done = remainingBytes > 0
|
||||
// add padding at the end of the file (not a problem for tar like : xva/ova)
|
||||
// if not content length will not match and we'll have UND_ERR_REQ_CONTENT_LENGTH_MISMATCH error
|
||||
console.log('full padding')
|
||||
while(remainingBytes > maxChunkPartSize){
|
||||
chunkBuffer.push(fullBuffer)
|
||||
hash.update(fullBuffer)
|
||||
remainingBytes -= maxChunkPartSize
|
||||
//remainingBytes = await write(fullBuffer,chunkStream, remainingBytes)
|
||||
}
|
||||
console.log('full padding done ')
|
||||
chunkBuffer.push(Buffer.alloc(remainingBytes,0))
|
||||
hash.update(Buffer.alloc(remainingBytes,0))
|
||||
console.log('md5 ok ')
|
||||
//await write(Buffer.alloc(remainingBytes,0),chunkStream, remainingBytes)
|
||||
// wait for the end of the upload
|
||||
|
||||
const command = new UploadPartCommand({
|
||||
...multipart,
|
||||
PartNumber,
|
||||
ContentLength:CHUNK_SIZE,
|
||||
Body: chunkStream,
|
||||
ContentMD5 : hash.digest('base64')
|
||||
})
|
||||
const promise = client.send(command)
|
||||
for (const buffer of chunkBuffer){
|
||||
await write(buffer, chunkStream, remainingBytes)
|
||||
}
|
||||
chunkStream.on('error', err => console.error(err))
|
||||
const res = await promise
|
||||
|
||||
console.log({res, headers : res.headers })
|
||||
parts.push({ ETag:/*res.headers.get('etag') */res.ETag, PartNumber })
|
||||
}catch(err){
|
||||
console.error(err)
|
||||
throw err
|
||||
}
|
||||
return done
|
||||
}
|
||||
|
||||
while(!await uploadChunk(inputStream)){
|
||||
console.log('uploaded one chunk', parts.length)
|
||||
}
|
||||
|
||||
// mark the upload as complete and ask s3 to glue the chunk together
|
||||
const completRes = await client.send(
|
||||
new CompleteMultipartUploadCommand({
|
||||
...multipart,
|
||||
MultipartUpload: { Parts: parts },
|
||||
})
|
||||
)
|
||||
console.log({completRes})
|
||||
clearInterval(intervalMonitorMemoryUsage)
|
||||
|
||||
}
|
||||
|
||||
async function simplePut(url , inputStream){
|
||||
const {
|
||||
allowUnauthorized,
|
||||
host,
|
||||
path,
|
||||
username,
|
||||
password,
|
||||
protocol,
|
||||
region = guessAwsRegion(host),
|
||||
} = parse(url)
|
||||
const client = new S3Client({
|
||||
apiVersion: '2006-03-01',
|
||||
endpoint: `${protocol}://s3.us-east-2.amazonaws.com`,
|
||||
forcePathStyle: true,
|
||||
credentials: {
|
||||
accessKeyId: username,
|
||||
secretAccessKey: password,
|
||||
},
|
||||
region,
|
||||
requestHandler: new NodeHttpHandler({
|
||||
socketTimeout: 600000,
|
||||
httpAgent: new HttpAgent({
|
||||
keepAlive: true,
|
||||
}),
|
||||
httpsAgent: new HttpsAgent({
|
||||
rejectUnauthorized: !allowUnauthorized,
|
||||
keepAlive: true,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
const pathParts = split(path)
|
||||
const bucket = pathParts.shift()
|
||||
const dir = join(...pathParts)
|
||||
|
||||
//const hasObjectLock = await client.send(new GetObjectLockConfigurationCommand({Bucket: bucket}))
|
||||
//console.log(hasObjectLock.ObjectLockConfiguration?.ObjectLockEnabled === 'Enabled')
|
||||
|
||||
|
||||
const md5 = await createMD5('/tmp/1g')
|
||||
console.log({md5})
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: bucket, Key: join(dir, 'simple'),
|
||||
ContentMD5: md5,
|
||||
ContentLength: 1024*1024*1024,
|
||||
Body: inputStream
|
||||
})
|
||||
const intervalMonitorMemoryUsage = setInterval(()=>console.log(Math.round(process.memoryUsage().rss/1024/1024)), 2000)
|
||||
|
||||
const res = await client.send(command)
|
||||
/*
|
||||
const presignedUrl = await getSignedUrl(client, command,{ expiresIn: 3600 });
|
||||
const res = await fetch(presignedUrl, {
|
||||
method: 'PUT',
|
||||
body:inputStream,
|
||||
duplex: "half",
|
||||
headers:{
|
||||
"x-amz-decoded-content-length": 1024*1024*1024,
|
||||
"content-md5" : md5
|
||||
}
|
||||
})*/
|
||||
clearInterval(intervalMonitorMemoryUsage)
|
||||
|
||||
console.log(res)
|
||||
}
|
||||
|
||||
async function createMD5(filePath) {
|
||||
const input = await fs.open(filePath) // big ass file
|
||||
return new Promise((res, rej) => {
|
||||
const hash = createHash('md5');
|
||||
|
||||
const rStream = input.createReadStream(filePath);
|
||||
rStream.on('data', (data) => {
|
||||
hash.update(data);
|
||||
});
|
||||
rStream.on('end', () => {
|
||||
res(hash.digest('base64'));
|
||||
});
|
||||
})
|
||||
}
|
||||
const input = await fs.open('/tmp/1g') // big ass file
|
||||
const inputStream = input.createReadStream()
|
||||
const remoteUrl = ""
|
||||
|
||||
v2(remoteUrl,inputStream)
|
||||
|
||||
//simplePut(remoteUrl,inputStream)
|
||||
@@ -2,14 +2,9 @@
|
||||
|
||||
## **next**
|
||||
|
||||
- Ability to snapshot/copy a VM from its view (PR [#7087](https://github.com/vatesfr/xen-orchestra/pull/7087))
|
||||
|
||||
## **0.1.4** (2023-10-03)
|
||||
|
||||
- Ability to migrate selected VMs to another host (PR [#7040](https://github.com/vatesfr/xen-orchestra/pull/7040))
|
||||
- Ability to snapshot selected VMs (PR [#7021](https://github.com/vatesfr/xen-orchestra/pull/7021))
|
||||
- Add Patches to Pool Dashboard (PR [#6709](https://github.com/vatesfr/xen-orchestra/pull/6709))
|
||||
- Add remember me checkbox on the login page (PR [#7030](https://github.com/vatesfr/xen-orchestra/pull/7030))
|
||||
|
||||
## **0.1.3** (2023-09-01)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@xen-orchestra/lite",
|
||||
"version": "0.1.4",
|
||||
"version": "0.1.3",
|
||||
"scripts": {
|
||||
"dev": "GIT_HEAD=$(git rev-parse HEAD) vite",
|
||||
"build": "run-p type-check build-only",
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
required
|
||||
/>
|
||||
</FormInputWrapper>
|
||||
<label class="remember-me-label">
|
||||
<FormCheckbox v-model="rememberMe" />
|
||||
<p>{{ $t("keep-me-logged") }}</p>
|
||||
</label>
|
||||
<UiButton type="submit" :busy="isConnecting">
|
||||
{{ $t("login") }}
|
||||
</UiButton>
|
||||
@@ -32,9 +28,6 @@ import { usePageTitleStore } from "@/stores/page-title.store";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useLocalStorage } from "@vueuse/core";
|
||||
|
||||
import FormCheckbox from "@/components/form/FormCheckbox.vue";
|
||||
import FormInput from "@/components/form/FormInput.vue";
|
||||
import FormInputWrapper from "@/components/form/FormInputWrapper.vue";
|
||||
import UiButton from "@/components/ui/UiButton.vue";
|
||||
@@ -49,16 +42,12 @@ const password = ref("");
|
||||
const error = ref<string>();
|
||||
const passwordRef = ref<InstanceType<typeof FormInput>>();
|
||||
const isInvalidPassword = ref(false);
|
||||
const rememberMe = useLocalStorage("rememberMe", false);
|
||||
|
||||
const focusPasswordInput = () => passwordRef.value?.focus();
|
||||
|
||||
onMounted(() => {
|
||||
if (rememberMe.value) {
|
||||
xenApiStore.reconnect();
|
||||
} else {
|
||||
focusPasswordInput();
|
||||
}
|
||||
xenApiStore.reconnect();
|
||||
focusPasswordInput();
|
||||
});
|
||||
|
||||
watch(password, () => {
|
||||
@@ -83,19 +72,6 @@ async function handleSubmit() {
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
.remember-me-label {
|
||||
cursor: pointer;
|
||||
width: fit-content;
|
||||
& .form-checkbox {
|
||||
margin: 1rem 1rem 1rem 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
& p {
|
||||
display: inline;
|
||||
vertical-align: middle;
|
||||
}
|
||||
}
|
||||
|
||||
.form-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -111,6 +87,7 @@ form {
|
||||
font-size: 2rem;
|
||||
min-width: 30em;
|
||||
max-width: 100%;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
margin: 0 auto;
|
||||
@@ -127,7 +104,7 @@ h1 {
|
||||
|
||||
img {
|
||||
width: 40rem;
|
||||
margin: auto auto 5rem auto;
|
||||
margin-bottom: 5rem;
|
||||
}
|
||||
|
||||
input {
|
||||
@@ -141,6 +118,6 @@ input {
|
||||
}
|
||||
|
||||
button {
|
||||
margin: 2rem auto;
|
||||
margin-top: 2rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<LinearChart :data="data" :value-formatter="customValueFormatter" />
|
||||
<LinearChart
|
||||
title="Chart title"
|
||||
subtitle="Chart subtitle"
|
||||
:data="data"
|
||||
:value-formatter="customValueFormatter"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
<template>
|
||||
<VueCharts :option="option" autoresize class="chart" />
|
||||
<UiCard class="linear-chart">
|
||||
<VueCharts :option="option" autoresize class="chart" />
|
||||
<slot name="summary" />
|
||||
</UiCard>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import UiCard from "@/components/ui/UiCard.vue";
|
||||
import type { LinearChartData, ValueFormatter } from "@/types/chart";
|
||||
import { IK_CHART_VALUE_FORMATTER } from "@/types/injection-keys";
|
||||
import { utcFormat } from "d3-time-format";
|
||||
@@ -11,6 +15,7 @@ import { LineChart } from "echarts/charts";
|
||||
import {
|
||||
GridComponent,
|
||||
LegendComponent,
|
||||
TitleComponent,
|
||||
TooltipComponent,
|
||||
} from "echarts/components";
|
||||
import { use } from "echarts/core";
|
||||
@@ -21,6 +26,8 @@ import VueCharts from "vue-echarts";
|
||||
const Y_AXIS_MAX_VALUE = 200;
|
||||
|
||||
const props = defineProps<{
|
||||
title?: string;
|
||||
subtitle?: string;
|
||||
data: LinearChartData;
|
||||
valueFormatter?: ValueFormatter;
|
||||
maxValue?: number;
|
||||
@@ -45,10 +52,15 @@ use([
|
||||
LineChart,
|
||||
GridComponent,
|
||||
TooltipComponent,
|
||||
TitleComponent,
|
||||
LegendComponent,
|
||||
]);
|
||||
|
||||
const option = computed<EChartsOption>(() => ({
|
||||
title: {
|
||||
text: props.title,
|
||||
subtext: props.subtitle,
|
||||
},
|
||||
legend: {
|
||||
data: props.data.map((series) => series.label),
|
||||
},
|
||||
|
||||
@@ -1,44 +1,33 @@
|
||||
<template>
|
||||
<UiCard class="linear-chart" :color="hasError ? 'error' : undefined">
|
||||
<UiCardTitle>{{ $t("network-throughput") }}</UiCardTitle>
|
||||
<UiCardTitle :level="UiCardTitleLevel.Subtitle">
|
||||
{{ $t("last-week") }}
|
||||
</UiCardTitle>
|
||||
<NoDataError v-if="hasError" />
|
||||
<UiCardSpinner v-else-if="isLoading" />
|
||||
<LinearChart
|
||||
v-else
|
||||
:data="data"
|
||||
:max-value="customMaxValue"
|
||||
:value-formatter="customValueFormatter"
|
||||
/>
|
||||
</UiCard>
|
||||
<!-- TODO: add a loader when data is not fully loaded or undefined -->
|
||||
<!-- TODO: add small loader with tooltips when stats can be expired -->
|
||||
<!-- TODO: display the NoData component in case of a data recovery error -->
|
||||
<LinearChart
|
||||
:data="data"
|
||||
:max-value="customMaxValue"
|
||||
:subtitle="$t('last-week')"
|
||||
:title="$t('network-throughput')"
|
||||
:value-formatter="customValueFormatter"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { IK_HOST_LAST_WEEK_STATS } from "@/types/injection-keys";
|
||||
import { computed, defineAsyncComponent, inject } from "vue";
|
||||
import { map } from "lodash-es";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { formatSize } from "@/libs/utils";
|
||||
import type { HostStats } from "@/libs/xapi-stats";
|
||||
import { IK_HOST_LAST_WEEK_STATS } from "@/types/injection-keys";
|
||||
import type { LinearChartData } from "@/types/chart";
|
||||
import { map } from "lodash-es";
|
||||
import NoDataError from "@/components/NoDataError.vue";
|
||||
import { RRD_STEP_FROM_STRING } from "@/libs/xapi-stats";
|
||||
import UiCard from "@/components/ui/UiCard.vue";
|
||||
import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import UiCardSpinner from "@/components/ui/UiCardSpinner.vue";
|
||||
import { UiCardTitleLevel } from "@/types/enums";
|
||||
import { useHostCollection } from "@/stores/xen-api/host.store";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const LinearChart = defineAsyncComponent(
|
||||
() => import("@/components/charts/LinearChart.vue")
|
||||
);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const hostLastWeekStats = inject(IK_HOST_LAST_WEEK_STATS);
|
||||
const { hasError, isFetching } = useHostCollection();
|
||||
|
||||
const data = computed<LinearChartData>(() => {
|
||||
const stats = hostLastWeekStats?.stats?.value;
|
||||
@@ -93,25 +82,6 @@ const data = computed<LinearChartData>(() => {
|
||||
];
|
||||
});
|
||||
|
||||
const isStatFetched = computed(() => {
|
||||
const stats = hostLastWeekStats?.stats?.value;
|
||||
if (stats === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return stats.every((host) => {
|
||||
const hostStats = host.stats;
|
||||
return (
|
||||
hostStats != null &&
|
||||
Object.values(hostStats.pifs["rx"])[0].length +
|
||||
Object.values(hostStats.pifs["tx"])[0].length ===
|
||||
data.value[0].data.length + data.value[1].data.length
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const isLoading = computed(() => isFetching.value || !isStatFetched.value);
|
||||
|
||||
// TODO: improve the way to get the max value of graph
|
||||
// See: https://github.com/vatesfr/xen-orchestra/pull/6610/files#r1072237279
|
||||
const customMaxValue = computed(
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
<template>
|
||||
<UiCardTitle
|
||||
:level="UiCardTitleLevel.SubtitleWithUnderline"
|
||||
:left="$t('hosts')"
|
||||
:right="$t('top-#', { n: N_ITEMS })"
|
||||
subtitle
|
||||
/>
|
||||
<NoDataError v-if="hasError" />
|
||||
<UsageBar v-else :data="statFetched ? data : undefined" :n-items="N_ITEMS" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, inject, type ComputedRef } from "vue";
|
||||
import NoDataError from "@/components/NoDataError.vue";
|
||||
import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import UsageBar from "@/components/UsageBar.vue";
|
||||
import { useHostCollection } from "@/stores/xen-api/host.store";
|
||||
import { getAvgCpuUsage } from "@/libs/utils";
|
||||
import { IK_HOST_STATS } from "@/types/injection-keys";
|
||||
import { N_ITEMS } from "@/views/pool/PoolDashboardView.vue";
|
||||
import NoDataError from "@/components/NoDataError.vue";
|
||||
import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import { UiCardTitleLevel } from "@/types/enums";
|
||||
import UsageBar from "@/components/UsageBar.vue";
|
||||
import { useHostCollection } from "@/stores/xen-api/host.store";
|
||||
import { computed, type ComputedRef, inject } from "vue";
|
||||
|
||||
const { hasError } = useHostCollection();
|
||||
|
||||
|
||||
@@ -1,33 +1,24 @@
|
||||
<template>
|
||||
<UiCard class="linear-chart" :color="hasError ? 'error' : undefined">
|
||||
<UiCardTitle>{{ $t("pool-cpu-usage") }}</UiCardTitle>
|
||||
<UiCardTitle :level="UiCardTitleLevel.Subtitle">
|
||||
{{ $t("last-week") }}
|
||||
</UiCardTitle>
|
||||
<NoDataError v-if="hasError" />
|
||||
<UiCardSpinner v-else-if="isLoading" />
|
||||
<LinearChart
|
||||
v-else
|
||||
:data="data"
|
||||
:max-value="customMaxValue"
|
||||
:value-formatter="customValueFormatter"
|
||||
/>
|
||||
</UiCard>
|
||||
<!-- TODO: add a loader when data is not fully loaded or undefined -->
|
||||
<!-- TODO: add small loader with tooltips when stats can be expired -->
|
||||
<!-- TODO: Display the NoDataError component in case of a data recovery error -->
|
||||
<LinearChart
|
||||
:data="data"
|
||||
:max-value="customMaxValue"
|
||||
:subtitle="$t('last-week')"
|
||||
:title="$t('pool-cpu-usage')"
|
||||
:value-formatter="customValueFormatter"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, defineAsyncComponent, inject } from "vue";
|
||||
import type { HostStats } from "@/libs/xapi-stats";
|
||||
import { IK_HOST_LAST_WEEK_STATS } from "@/types/injection-keys";
|
||||
import type { LinearChartData, ValueFormatter } from "@/types/chart";
|
||||
import NoDataError from "@/components/NoDataError.vue";
|
||||
import { RRD_STEP_FROM_STRING } from "@/libs/xapi-stats";
|
||||
import { sumBy } from "lodash-es";
|
||||
import UiCard from "@/components/ui/UiCard.vue";
|
||||
import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import UiCardSpinner from "@/components/ui/UiCardSpinner.vue";
|
||||
import { UiCardTitleLevel } from "@/types/enums";
|
||||
import { useHostCollection } from "@/stores/xen-api/host.store";
|
||||
import type { HostStats } from "@/libs/xapi-stats";
|
||||
import { RRD_STEP_FROM_STRING } from "@/libs/xapi-stats";
|
||||
import type { LinearChartData, ValueFormatter } from "@/types/chart";
|
||||
import { IK_HOST_LAST_WEEK_STATS } from "@/types/injection-keys";
|
||||
import { sumBy } from "lodash-es";
|
||||
import { computed, defineAsyncComponent, inject } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const LinearChart = defineAsyncComponent(
|
||||
@@ -38,7 +29,8 @@ const { t } = useI18n();
|
||||
|
||||
const hostLastWeekStats = inject(IK_HOST_LAST_WEEK_STATS);
|
||||
|
||||
const { records: hosts, isFetching, hasError } = useHostCollection();
|
||||
const { records: hosts } = useHostCollection();
|
||||
|
||||
const customMaxValue = computed(
|
||||
() => 100 * sumBy(hosts.value, (host) => +host.cpu_info.cpu_count)
|
||||
);
|
||||
@@ -87,22 +79,6 @@ const data = computed<LinearChartData>(() => {
|
||||
},
|
||||
];
|
||||
});
|
||||
const isStatFetched = computed(() => {
|
||||
const stats = hostLastWeekStats?.stats?.value;
|
||||
if (stats === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return stats.every((host) => {
|
||||
const hostStats = host.stats;
|
||||
return (
|
||||
hostStats != null &&
|
||||
Object.values(hostStats.cpus)[0].length === data.value[0].data.length
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const isLoading = computed(() => isFetching.value || !isStatFetched.value);
|
||||
|
||||
const customValueFormatter: ValueFormatter = (value) => `${value}%`;
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<UiCardTitle
|
||||
:level="UiCardTitleLevel.SubtitleWithUnderline"
|
||||
subtitle
|
||||
:left="$t('vms')"
|
||||
:right="$t('top-#', { n: N_ITEMS })"
|
||||
/>
|
||||
@@ -9,7 +9,6 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { type ComputedRef, computed, inject } from "vue";
|
||||
import NoDataError from "@/components/NoDataError.vue";
|
||||
import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import UsageBar from "@/components/UsageBar.vue";
|
||||
@@ -17,7 +16,7 @@ import { useVmCollection } from "@/stores/xen-api/vm.store";
|
||||
import { getAvgCpuUsage } from "@/libs/utils";
|
||||
import { IK_VM_STATS } from "@/types/injection-keys";
|
||||
import { N_ITEMS } from "@/views/pool/PoolDashboardView.vue";
|
||||
import { UiCardTitleLevel } from "@/types/enums";
|
||||
import { computed, type ComputedRef, inject } from "vue";
|
||||
|
||||
const { hasError } = useVmCollection();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<UiCardTitle
|
||||
:level="UiCardTitleLevel.SubtitleWithUnderline"
|
||||
subtitle
|
||||
:left="$t('hosts')"
|
||||
:right="$t('top-#', { n: N_ITEMS })"
|
||||
/>
|
||||
@@ -13,7 +13,6 @@ import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import { useHostCollection } from "@/stores/xen-api/host.store";
|
||||
import { IK_HOST_STATS } from "@/types/injection-keys";
|
||||
import { type ComputedRef, computed, inject } from "vue";
|
||||
import { UiCardTitleLevel } from "@/types/enums";
|
||||
import UsageBar from "@/components/UsageBar.vue";
|
||||
import { formatSize, parseRamUsage } from "@/libs/utils";
|
||||
import { N_ITEMS } from "@/views/pool/PoolDashboardView.vue";
|
||||
|
||||
@@ -1,43 +1,37 @@
|
||||
<template>
|
||||
<UiCard class="linear-chart" :color="hasError ? 'error' : undefined">
|
||||
<UiCardTitle>{{ $t("pool-ram-usage") }}</UiCardTitle>
|
||||
<UiCardTitle :level="UiCardTitleLevel.Subtitle">
|
||||
{{ $t("last-week") }}
|
||||
</UiCardTitle>
|
||||
<NoDataError v-if="hasError" />
|
||||
<UiCardSpinner v-else-if="isLoading" />
|
||||
<LinearChart
|
||||
v-else
|
||||
:data="data"
|
||||
:max-value="customMaxValue"
|
||||
:value-formatter="customValueFormatter"
|
||||
/>
|
||||
<SizeStatsSummary :size="currentData.size" :usage="currentData.usage" />
|
||||
</UiCard>
|
||||
<!-- TODO: add a loader when data is not fully loaded or undefined -->
|
||||
<!-- TODO: add small loader with tooltips when stats can be expired -->
|
||||
<!-- TODO: display the NoDataError component in case of a data recovery error -->
|
||||
<LinearChart
|
||||
:data="data"
|
||||
:max-value="customMaxValue"
|
||||
:subtitle="$t('last-week')"
|
||||
:title="$t('pool-ram-usage')"
|
||||
:value-formatter="customValueFormatter"
|
||||
>
|
||||
<template #summary>
|
||||
<SizeStatsSummary :size="currentData.size" :usage="currentData.usage" />
|
||||
</template>
|
||||
</LinearChart>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, defineAsyncComponent, inject } from "vue";
|
||||
import { formatSize } from "@/libs/utils";
|
||||
import { IK_HOST_LAST_WEEK_STATS } from "@/types/injection-keys";
|
||||
import type { LinearChartData } from "@/types/chart";
|
||||
import NoDataError from "@/components/NoDataError.vue";
|
||||
import { RRD_STEP_FROM_STRING } from "@/libs/xapi-stats";
|
||||
import SizeStatsSummary from "@/components/ui/SizeStatsSummary.vue";
|
||||
import { sumBy } from "lodash-es";
|
||||
import UiCard from "@/components/ui/UiCard.vue";
|
||||
import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import UiCardSpinner from "@/components/ui/UiCardSpinner.vue";
|
||||
import { UiCardTitleLevel } from "@/types/enums";
|
||||
import { useHostCollection } from "@/stores/xen-api/host.store";
|
||||
import { useHostMetricsCollection } from "@/stores/xen-api/host-metrics.store";
|
||||
import { formatSize } from "@/libs/utils";
|
||||
import { RRD_STEP_FROM_STRING } from "@/libs/xapi-stats";
|
||||
import type { LinearChartData, ValueFormatter } from "@/types/chart";
|
||||
import { IK_HOST_LAST_WEEK_STATS } from "@/types/injection-keys";
|
||||
import { sumBy } from "lodash-es";
|
||||
import { computed, defineAsyncComponent, inject } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const LinearChart = defineAsyncComponent(
|
||||
() => import("@/components/charts/LinearChart.vue")
|
||||
);
|
||||
|
||||
const { runningHosts, isFetching, hasError } = useHostCollection();
|
||||
const { runningHosts } = useHostCollection();
|
||||
const { getHostMemory } = useHostMetricsCollection();
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -98,23 +92,6 @@ const data = computed<LinearChartData>(() => {
|
||||
];
|
||||
});
|
||||
|
||||
const isStatFetched = computed(() => {
|
||||
const stats = hostLastWeekStats?.stats?.value;
|
||||
if (stats === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return stats.every((host) => {
|
||||
const hostStats = host.stats;
|
||||
return (
|
||||
hostStats != null && hostStats.memory.length === data.value[0].data.length
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const isLoading = computed(
|
||||
() => (isFetching.value && !hasError.value) || !isStatFetched.value
|
||||
);
|
||||
|
||||
const customValueFormatter = (value: number) => String(formatSize(value));
|
||||
const customValueFormatter: ValueFormatter = (value) =>
|
||||
String(formatSize(value));
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<UiCardTitle
|
||||
:level="UiCardTitleLevel.SubtitleWithUnderline"
|
||||
subtitle
|
||||
:left="$t('vms')"
|
||||
:right="$t('top-#', { n: N_ITEMS })"
|
||||
/>
|
||||
@@ -9,15 +9,14 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, inject, type ComputedRef } from "vue";
|
||||
import NoDataError from "@/components/NoDataError.vue";
|
||||
import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import UsageBar from "@/components/UsageBar.vue";
|
||||
import { useVmCollection } from "@/stores/xen-api/vm.store";
|
||||
import { formatSize, parseRamUsage } from "@/libs/utils";
|
||||
import { IK_VM_STATS } from "@/types/injection-keys";
|
||||
import { N_ITEMS } from "@/views/pool/PoolDashboardView.vue";
|
||||
import NoDataError from "@/components/NoDataError.vue";
|
||||
import UiCardTitle from "@/components/ui/UiCardTitle.vue";
|
||||
import { UiCardTitleLevel } from "@/types/enums";
|
||||
import UsageBar from "@/components/UsageBar.vue";
|
||||
import { useVmCollection } from "@/stores/xen-api/vm.store";
|
||||
import { computed, type ComputedRef, inject } from "vue";
|
||||
|
||||
const { hasError } = useVmCollection();
|
||||
|
||||
|
||||
@@ -1,40 +1,35 @@
|
||||
<template>
|
||||
<div :class="['ui-section-title', tags.left]">
|
||||
<component :is="tags.left" v-if="$slots.default || left" class="left">
|
||||
<div :class="{ subtitle }" class="ui-section-title">
|
||||
<component
|
||||
:is="subtitle ? 'h5' : 'h4'"
|
||||
v-if="$slots.default || left"
|
||||
class="left"
|
||||
>
|
||||
<slot>{{ left }}</slot>
|
||||
<UiCounter class="count" v-if="count > 0" :value="count" color="info" />
|
||||
</component>
|
||||
<component :is="tags.right" v-if="$slots.right || right" class="right">
|
||||
<component
|
||||
:is="subtitle ? 'h6' : 'h5'"
|
||||
v-if="$slots.right || right"
|
||||
class="right"
|
||||
>
|
||||
<slot name="right">{{ right }}</slot>
|
||||
</component>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from "vue";
|
||||
import UiCounter from "@/components/ui/UiCounter.vue";
|
||||
import { UiCardTitleLevel } from "@/types/enums";
|
||||
|
||||
const props = withDefaults(
|
||||
withDefaults(
|
||||
defineProps<{
|
||||
count?: number;
|
||||
level?: UiCardTitleLevel;
|
||||
subtitle?: boolean;
|
||||
left?: string;
|
||||
right?: string;
|
||||
count?: number;
|
||||
}>(),
|
||||
{ count: 0, level: UiCardTitleLevel.Title }
|
||||
{ count: 0 }
|
||||
);
|
||||
|
||||
const tags = computed(() => {
|
||||
switch (props.level) {
|
||||
case UiCardTitleLevel.Subtitle:
|
||||
return { left: "h6", right: "h6" };
|
||||
case UiCardTitleLevel.SubtitleWithUnderline:
|
||||
return { left: "h5", right: "h6" };
|
||||
default:
|
||||
return { left: "h4", right: "h5" };
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="postcss" scoped>
|
||||
@@ -42,6 +37,7 @@ const tags = computed(() => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 2rem;
|
||||
|
||||
--section-title-left-size: 2rem;
|
||||
--section-title-left-color: var(--color-blue-scale-100);
|
||||
@@ -50,17 +46,9 @@ const tags = computed(() => {
|
||||
--section-title-right-color: var(--color-extra-blue-base);
|
||||
--section-title-right-weight: 700;
|
||||
|
||||
&.h6 {
|
||||
margin-bottom: 1rem;
|
||||
--section-title-left-size: 1.5rem;
|
||||
--section-title-left-color: var(--color-blue-scale-300);
|
||||
--section-title-left-weight: 400;
|
||||
}
|
||||
|
||||
&.h5 {
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 1rem;
|
||||
&.subtitle {
|
||||
border-bottom: 1px solid var(--color-extra-blue-base);
|
||||
|
||||
--section-title-left-size: 1.6rem;
|
||||
--section-title-left-color: var(--color-extra-blue-base);
|
||||
--section-title-left-weight: 700;
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<template>
|
||||
<MenuItem
|
||||
v-tooltip="
|
||||
!areAllSelectedVmsHalted &&
|
||||
$t(isSingleAction ? 'vm-is-running' : 'selected-vms-in-execution')
|
||||
"
|
||||
v-tooltip="!areAllSelectedVmsHalted && $t('selected-vms-in-execution')"
|
||||
:busy="areSomeSelectedVmsCloning"
|
||||
:disabled="isDisabled"
|
||||
:icon="faCopy"
|
||||
@@ -25,7 +22,6 @@ import { computed } from "vue";
|
||||
|
||||
const props = defineProps<{
|
||||
selectedRefs: XenApiVm["$ref"][];
|
||||
isSingleAction?: boolean;
|
||||
}>();
|
||||
|
||||
const { getByOpaqueRef, isOperationPending } = useVmCollection();
|
||||
|
||||
@@ -11,23 +11,6 @@
|
||||
</template>
|
||||
<VmActionPowerStateItems :vm-refs="[vm.$ref]" />
|
||||
</AppMenu>
|
||||
<AppMenu v-if="vm !== undefined" placement="bottom-end" shadow>
|
||||
<template #trigger="{ open, isOpen }">
|
||||
<UiButton
|
||||
:active="isOpen"
|
||||
:icon="faEllipsisVertical"
|
||||
@click="open"
|
||||
transparent
|
||||
class="more-actions-button"
|
||||
v-tooltip="{
|
||||
placement: 'left',
|
||||
content: $t('more-actions'),
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
<VmActionCopyItem :selected-refs="[vm.$ref]" is-single-action />
|
||||
<VmActionSnapshotItem :vm-refs="[vm.$ref]" />
|
||||
</AppMenu>
|
||||
</template>
|
||||
</TitleBar>
|
||||
</template>
|
||||
@@ -38,15 +21,11 @@ import TitleBar from "@/components/TitleBar.vue";
|
||||
import UiIcon from "@/components/ui/icon/UiIcon.vue";
|
||||
import UiButton from "@/components/ui/UiButton.vue";
|
||||
import VmActionPowerStateItems from "@/components/vm/VmActionItems/VmActionPowerStateItems.vue";
|
||||
import VmActionSnapshotItem from "@/components/vm/VmActionItems/VmActionSnapshotItem.vue";
|
||||
import VmActionCopyItem from "@/components/vm/VmActionItems/VmActionCopyItem.vue";
|
||||
import { useVmCollection } from "@/stores/xen-api/vm.store";
|
||||
import { vTooltip } from "@/directives/tooltip.directive";
|
||||
import type { XenApiVm } from "@/libs/xen-api/xen-api.types";
|
||||
import {
|
||||
faAngleDown,
|
||||
faDisplay,
|
||||
faEllipsisVertical,
|
||||
faPowerOff,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { computed } from "vue";
|
||||
@@ -61,9 +40,3 @@ const vm = computed(() =>
|
||||
|
||||
const name = computed(() => vm.value?.name_label);
|
||||
</script>
|
||||
|
||||
<style lang="postcss">
|
||||
.more-actions-button {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -10,7 +10,8 @@ export const useChartTheme = () => {
|
||||
|
||||
const getColors = () => ({
|
||||
background: style.getPropertyValue("--background-color-primary"),
|
||||
text: style.getPropertyValue("--color-blue-scale-300"),
|
||||
title: style.getPropertyValue("--color-blue-scale-100"),
|
||||
subtitle: style.getPropertyValue("--color-blue-scale-300"),
|
||||
splitLine: style.getPropertyValue("--color-blue-scale-400"),
|
||||
primary: style.getPropertyValue("--color-extra-blue-base"),
|
||||
secondary: style.getPropertyValue("--color-orange-world-base"),
|
||||
@@ -27,10 +28,24 @@ export const useChartTheme = () => {
|
||||
backgroundColor: colors.value.background,
|
||||
textStyle: {},
|
||||
grid: {
|
||||
top: 40,
|
||||
top: 80,
|
||||
left: 80,
|
||||
right: 20,
|
||||
},
|
||||
title: {
|
||||
textStyle: {
|
||||
color: colors.value.title,
|
||||
fontFamily: "Poppins, sans-serif",
|
||||
fontWeight: 500,
|
||||
fontSize: 20,
|
||||
},
|
||||
subtextStyle: {
|
||||
color: colors.value.subtitle,
|
||||
fontFamily: "Poppins, sans-serif",
|
||||
fontWeight: 400,
|
||||
fontSize: 14,
|
||||
},
|
||||
},
|
||||
line: {
|
||||
itemStyle: {
|
||||
borderWidth: 2,
|
||||
@@ -220,7 +235,7 @@ export const useChartTheme = () => {
|
||||
},
|
||||
axisLabel: {
|
||||
show: true,
|
||||
color: colors.value.text,
|
||||
color: colors.value.subtitle,
|
||||
},
|
||||
splitLine: {
|
||||
show: true,
|
||||
@@ -280,7 +295,7 @@ export const useChartTheme = () => {
|
||||
},
|
||||
axisLabel: {
|
||||
show: true,
|
||||
color: colors.value.text,
|
||||
color: colors.value.subtitle,
|
||||
},
|
||||
splitLine: {
|
||||
show: true,
|
||||
@@ -310,7 +325,7 @@ export const useChartTheme = () => {
|
||||
left: "right",
|
||||
top: "bottom",
|
||||
textStyle: {
|
||||
color: colors.value.text,
|
||||
color: colors.value.subtitle,
|
||||
},
|
||||
},
|
||||
tooltip: {
|
||||
|
||||
@@ -78,7 +78,6 @@
|
||||
"go-back": "Go back",
|
||||
"here": "Here",
|
||||
"hosts": "Hosts",
|
||||
"keep-me-logged": "Keep me logged in",
|
||||
"language": "Language",
|
||||
"last-week": "Last week",
|
||||
"learn-more": "Learn more",
|
||||
@@ -86,7 +85,6 @@
|
||||
"loading-hosts": "Loading hosts…",
|
||||
"log-out": "Log out",
|
||||
"login": "Login",
|
||||
"more-actions": "More actions",
|
||||
"migrate": "Migrate",
|
||||
"migrate-n-vms": "Migrate 1 VM | Migrate {n} VMs",
|
||||
"n-hosts-awaiting-patch": "{n} host is awaiting this patch | {n} hosts are awaiting this patch",
|
||||
@@ -174,7 +172,6 @@
|
||||
"vcpus": "vCPUs",
|
||||
"vcpus-used": "vCPUs used",
|
||||
"version": "Version",
|
||||
"vm-is-running": "The VM is running",
|
||||
"vms": "VMs",
|
||||
"xo-lite-under-construction": "XOLite is under construction"
|
||||
}
|
||||
|
||||
@@ -78,7 +78,6 @@
|
||||
"go-back": "Revenir en arrière",
|
||||
"here": "Ici",
|
||||
"hosts": "Hôtes",
|
||||
"keep-me-logged": "Rester connecté",
|
||||
"language": "Langue",
|
||||
"last-week": "Semaine dernière",
|
||||
"learn-more": "En savoir plus",
|
||||
@@ -86,7 +85,6 @@
|
||||
"loading-hosts": "Chargement des hôtes…",
|
||||
"log-out": "Se déconnecter",
|
||||
"login": "Connexion",
|
||||
"more-actions": "Plus d'actions",
|
||||
"migrate": "Migrer",
|
||||
"migrate-n-vms": "Migrer 1 VM | Migrer {n} VMs",
|
||||
"n-hosts-awaiting-patch": "{n} hôte attend ce patch | {n} hôtes attendent ce patch",
|
||||
@@ -174,7 +172,6 @@
|
||||
"vcpus": "vCPUs",
|
||||
"vcpus-used": "vCPUs utilisés",
|
||||
"version": "Version",
|
||||
"vm-is-running": "La VM est en cours d'exécution",
|
||||
"vms": "VMs",
|
||||
"xo-lite-under-construction": "XOLite est en construction"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import XapiStats from "@/libs/xapi-stats";
|
||||
import XenApi from "@/libs/xen-api/xen-api";
|
||||
import { useLocalStorage } from "@vueuse/core";
|
||||
import { defineStore } from "pinia";
|
||||
import { computed, ref, watchEffect } from "vue";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
const HOST_URL = import.meta.env.PROD
|
||||
? window.origin
|
||||
@@ -17,24 +17,16 @@ enum STATUS {
|
||||
export const useXenApiStore = defineStore("xen-api", () => {
|
||||
const xenApi = new XenApi(HOST_URL);
|
||||
const xapiStats = new XapiStats(xenApi);
|
||||
const storedSessionId = useLocalStorage<string | undefined>(
|
||||
const currentSessionId = useLocalStorage<string | undefined>(
|
||||
"sessionId",
|
||||
undefined
|
||||
);
|
||||
const currentSessionId = ref(storedSessionId.value);
|
||||
const rememberMe = useLocalStorage("rememberMe", false);
|
||||
const status = ref(STATUS.DISCONNECTED);
|
||||
const isConnected = computed(() => status.value === STATUS.CONNECTED);
|
||||
const isConnecting = computed(() => status.value === STATUS.CONNECTING);
|
||||
const getXapi = () => xenApi;
|
||||
const getXapiStats = () => xapiStats;
|
||||
|
||||
watchEffect(() => {
|
||||
storedSessionId.value = rememberMe.value
|
||||
? currentSessionId.value
|
||||
: undefined;
|
||||
});
|
||||
|
||||
const connect = async (username: string, password: string) => {
|
||||
status.value = STATUS.CONNECTING;
|
||||
|
||||
@@ -71,7 +63,7 @@ export const useXenApiStore = defineStore("xen-api", () => {
|
||||
|
||||
async function disconnect() {
|
||||
await xenApi.disconnect();
|
||||
currentSessionId.value = undefined;
|
||||
currentSessionId.value = null;
|
||||
status.value = STATUS.DISCONNECTED;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ type LinearChartData = {
|
||||
|
||||
```vue-template
|
||||
<LinearChart
|
||||
title="Chart title"
|
||||
subtitle="Chart subtitle"
|
||||
:data="data"
|
||||
/>
|
||||
```
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<template>
|
||||
<ComponentStory
|
||||
:params="[
|
||||
prop('title').preset('Chart title').widget(),
|
||||
prop('subtitle').preset('Here is a subtitle').widget(),
|
||||
prop('data')
|
||||
.preset(data)
|
||||
.required()
|
||||
@@ -56,6 +58,8 @@ const data: LinearChartData = [
|
||||
const presets = {
|
||||
"Network bandwidth": {
|
||||
props: {
|
||||
title: "Network bandwidth",
|
||||
subtitle: "Last week",
|
||||
"value-formatter": byteFormatter,
|
||||
"max-value": 500000000,
|
||||
data: [
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
export enum UiCardTitleLevel {
|
||||
Title,
|
||||
Subtitle,
|
||||
SubtitleWithUnderline,
|
||||
}
|
||||
@@ -24,8 +24,6 @@ const serializeError = error => ({
|
||||
})
|
||||
|
||||
export default class Tasks extends EventEmitter {
|
||||
#logsToClearOnSuccess = new Set()
|
||||
|
||||
// contains consolidated logs of all live and finished tasks
|
||||
#store
|
||||
|
||||
@@ -38,22 +36,6 @@ export default class Tasks extends EventEmitter {
|
||||
this.#tasks.delete(id)
|
||||
},
|
||||
onTaskUpdate: async taskLog => {
|
||||
const { id, status } = taskLog
|
||||
if (status !== 'pending') {
|
||||
if (this.#logsToClearOnSuccess.has(id)) {
|
||||
this.#logsToClearOnSuccess.delete(id)
|
||||
|
||||
if (status === 'success') {
|
||||
try {
|
||||
await this.#store.del(id)
|
||||
} catch (error) {
|
||||
warn('failure on deleting task log from store', { error, taskLog })
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Error objects are not JSON-ifiable by default
|
||||
const { result } = taskLog
|
||||
if (result instanceof Error && result.toJSON === undefined) {
|
||||
@@ -153,13 +135,10 @@ export default class Tasks extends EventEmitter {
|
||||
*
|
||||
* @returns {Task}
|
||||
*/
|
||||
create(
|
||||
{ name, objectId, userId = this.#app.apiContext?.user?.id, type, ...props },
|
||||
{ clearLogOnSuccess = false } = {}
|
||||
) {
|
||||
create({ name, objectId, userId = this.#app.apiContext?.user?.id, type }) {
|
||||
const tasks = this.#tasks
|
||||
|
||||
const task = new Task({ properties: { ...props, name, objectId, userId, type }, onProgress: this.#onProgress })
|
||||
const task = new Task({ properties: { name, objectId, userId, type }, onProgress: this.#onProgress })
|
||||
|
||||
// Use a compact, sortable, string representation of the creation date
|
||||
//
|
||||
@@ -173,9 +152,6 @@ export default class Tasks extends EventEmitter {
|
||||
task.id = id
|
||||
|
||||
tasks.set(id, task)
|
||||
if (clearLogOnSuccess) {
|
||||
this.#logsToClearOnSuccess.add(id)
|
||||
}
|
||||
|
||||
return task
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"url": "https://vates.fr"
|
||||
},
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"version": "0.13.0",
|
||||
"version": "0.12.0",
|
||||
"engines": {
|
||||
"node": ">=15.6"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@xen-orchestra/proxy",
|
||||
"version": "0.26.35",
|
||||
"version": "0.26.34",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"description": "XO Proxy used to remotely execute backup jobs",
|
||||
"keywords": [
|
||||
@@ -32,13 +32,13 @@
|
||||
"@vates/decorate-with": "^2.0.0",
|
||||
"@vates/disposable": "^0.1.4",
|
||||
"@xen-orchestra/async-map": "^0.1.2",
|
||||
"@xen-orchestra/backups": "^0.43.0",
|
||||
"@xen-orchestra/backups": "^0.42.1",
|
||||
"@xen-orchestra/fs": "^4.1.0",
|
||||
"@xen-orchestra/log": "^0.6.0",
|
||||
"@xen-orchestra/mixin": "^0.1.0",
|
||||
"@xen-orchestra/mixins": "^0.13.0",
|
||||
"@xen-orchestra/mixins": "^0.12.0",
|
||||
"@xen-orchestra/self-signed": "^0.1.3",
|
||||
"@xen-orchestra/xapi": "^3.2.0",
|
||||
"@xen-orchestra/xapi": "^3.1.0",
|
||||
"ajv": "^8.0.3",
|
||||
"app-conf": "^2.3.0",
|
||||
"async-iterator-to-stream": "^1.1.0",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"@xen-orchestra/log": "^0.6.0",
|
||||
"lodash": "^4.17.21",
|
||||
"node-fetch": "^3.3.0",
|
||||
"vhd-lib": "^4.6.1"
|
||||
"vhd-lib": "^4.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
|
||||
@@ -5,4 +5,3 @@ export { default as VBD } from './vbd.mjs'
|
||||
export { default as VDI } from './vdi.mjs'
|
||||
export { default as VIF } from './vif.mjs'
|
||||
export { default as VM } from './vm.mjs'
|
||||
export { default as VTPM } from './vtpm.mjs'
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { asyncEach } from '@vates/async-each'
|
||||
import { asyncMap } from '@xen-orchestra/async-map'
|
||||
import { decorateClass } from '@vates/decorate-with'
|
||||
import { defer } from 'golike-defer'
|
||||
import { incorrectState, operationFailed } from 'xo-common/api-errors.js'
|
||||
|
||||
import { getCurrentVmUuid } from './_XenStore.mjs'
|
||||
|
||||
@@ -33,38 +31,7 @@ class Host {
|
||||
*
|
||||
* @param {string} ref - Opaque reference of the host
|
||||
*/
|
||||
async smartReboot($defer, ref, bypassBlockedSuspend = false, bypassCurrentVmCheck = false) {
|
||||
let currentVmRef
|
||||
try {
|
||||
currentVmRef = await this.call('VM.get_by_uuid', await getCurrentVmUuid())
|
||||
} catch (error) {}
|
||||
|
||||
const residentVmRefs = await this.getField('host', ref, 'resident_VMs')
|
||||
const vmsWithSuspendBlocked = await asyncMap(residentVmRefs, ref => this.getRecord('VM', ref)).filter(
|
||||
vm =>
|
||||
vm.$ref !== currentVmRef &&
|
||||
!vm.is_control_domain &&
|
||||
vm.power_state !== 'Halted' &&
|
||||
vm.power_state !== 'Suspended' &&
|
||||
vm.blocked_operations.suspend !== undefined
|
||||
)
|
||||
|
||||
if (!bypassBlockedSuspend && vmsWithSuspendBlocked.length > 0) {
|
||||
throw incorrectState({ actual: vmsWithSuspendBlocked.map(vm => vm.uuid), expected: [], object: 'suspendBlocked' })
|
||||
}
|
||||
|
||||
if (!bypassCurrentVmCheck && residentVmRefs.includes(currentVmRef)) {
|
||||
throw operationFailed({
|
||||
objectId: await this.getField('VM', currentVmRef, 'uuid'),
|
||||
code: 'xoaOnHost',
|
||||
})
|
||||
}
|
||||
|
||||
await asyncEach(vmsWithSuspendBlocked, vm => {
|
||||
$defer(() => vm.update_blocked_operations('suspend', vm.blocked_operations.suspend ?? null))
|
||||
return vm.update_blocked_operations('suspend', null)
|
||||
})
|
||||
|
||||
async smartReboot($defer, ref) {
|
||||
const suspendedVms = []
|
||||
if (await this.getField('host', ref, 'enabled')) {
|
||||
await this.callAsync('host.disable', ref)
|
||||
@@ -75,8 +42,13 @@ class Host {
|
||||
})
|
||||
}
|
||||
|
||||
let currentVmRef
|
||||
try {
|
||||
currentVmRef = await this.call('VM.get_by_uuid', await getCurrentVmUuid())
|
||||
} catch (error) {}
|
||||
|
||||
await asyncEach(
|
||||
residentVmRefs,
|
||||
await this.getField('host', ref, 'resident_VMs'),
|
||||
async vmRef => {
|
||||
if (vmRef === currentVmRef) {
|
||||
return
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@xen-orchestra/xapi",
|
||||
"version": "3.2.0",
|
||||
"version": "3.1.0",
|
||||
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@xen-orchestra/xapi",
|
||||
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
|
||||
"repository": {
|
||||
@@ -34,7 +34,7 @@
|
||||
"json-rpc-protocol": "^0.13.2",
|
||||
"lodash": "^4.17.15",
|
||||
"promise-toolbox": "^0.21.0",
|
||||
"vhd-lib": "^4.6.1",
|
||||
"vhd-lib": "^4.6.0",
|
||||
"xo-common": "^0.8.0"
|
||||
},
|
||||
"private": false,
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import upperFirst from 'lodash/upperFirst.js'
|
||||
import { incorrectState } from 'xo-common/api-errors.js'
|
||||
|
||||
export default class Vtpm {
|
||||
async create({ is_unique = false, VM }) {
|
||||
const pool = this.pool
|
||||
|
||||
// If VTPM.create is called on a pool that doesn't support VTPM, the errors aren't explicit.
|
||||
// See https://github.com/xapi-project/xen-api/issues/5186
|
||||
if (pool.restrictions.restrict_vtpm !== 'false') {
|
||||
throw incorrectState({
|
||||
actual: pool.restrictions.restrict_vtpm,
|
||||
expected: 'false',
|
||||
object: pool.uuid,
|
||||
property: 'restrictions.restrict_vtpm',
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.call('VTPM.create', VM, is_unique)
|
||||
} catch (error) {
|
||||
const { code, params } = error
|
||||
if (code === 'VM_BAD_POWER_STATE') {
|
||||
const [, expected, actual] = params
|
||||
// In `VM_BAD_POWER_STATE` errors, the power state is lowercased
|
||||
throw incorrectState({
|
||||
actual: upperFirst(actual),
|
||||
expected: upperFirst(expected),
|
||||
object: await this.getField('VM', VM, 'uuid'),
|
||||
property: 'power_state',
|
||||
})
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
42
CHANGELOG.md
42
CHANGELOG.md
@@ -1,26 +1,17 @@
|
||||
# ChangeLog
|
||||
|
||||
## **5.87.0** (2023-09-29)
|
||||
|
||||
<img id="latest" src="https://badgen.net/badge/channel/latest/yellow" alt="Channel: latest" />
|
||||
|
||||
### Highlights
|
||||
|
||||
- [Patches] Support new XenServer Updates system. See [our documentation](https://xen-orchestra.com/docs/updater.html#xenserver-updates). (PR [#7044](https://github.com/vatesfr/xen-orchestra/pull/7044))
|
||||
- [Host/Advanced] New button to download system logs [#3968](https://github.com/vatesfr/xen-orchestra/issues/3968) (PR [#7048](https://github.com/vatesfr/xen-orchestra/pull/7048))
|
||||
- [Home/Hosts, Pools] Display host brand and version (PR [#7027](https://github.com/vatesfr/xen-orchestra/pull/7027))
|
||||
- [SR] Ability to reclaim space [#1204](https://github.com/vatesfr/xen-orchestra/issues/1204) (PR [#7054](https://github.com/vatesfr/xen-orchestra/pull/7054))
|
||||
- [XOA] New button to restart XO Server directly from the UI (PR [#7056](https://github.com/vatesfr/xen-orchestra/pull/7056))
|
||||
- [Host/Advanced] Display system disks health based on the _smartctl_ plugin. [#4458](https://github.com/vatesfr/xen-orchestra/issues/4458) (PR [#7060](https://github.com/vatesfr/xen-orchestra/pull/7060))
|
||||
- [Authentication] Failed attempts are now logged as XO tasks (PR [#7061](https://github.com/vatesfr/xen-orchestra/pull/7061))
|
||||
- [Backup] Prevent VMs from being migrated while they are backed up (PR [#7024](https://github.com/vatesfr/xen-orchestra/pull/7024))
|
||||
- [Backup] Prevent VMs from being backed up while they are migrated (PR [#7024](https://github.com/vatesfr/xen-orchestra/pull/7024))
|
||||
## **next**
|
||||
|
||||
### Enhancements
|
||||
|
||||
- [Netbox] Don't delete VMs that have been created manually in XO-synced cluster [Forum#7639](https://xcp-ng.org/forum/topic/7639) (PR [#7008](https://github.com/vatesfr/xen-orchestra/pull/7008))
|
||||
- [Kubernetes] _Search domains_ field is now optional [#7028](https://github.com/vatesfr/xen-orchestra/pull/7028)
|
||||
- [Patches] Support new XenServer Updates system. See [our documentation](https://xen-orchestra.com/docs/updater.html#xenserver-updates). (PR [#7044](https://github.com/vatesfr/xen-orchestra/pull/7044))
|
||||
- [REST API] Hosts' audit and system logs can be downloaded [#3968](https://github.com/vatesfr/xen-orchestra/issues/3968) (PR [#7048](https://github.com/vatesfr/xen-orchestra/pull/7048))
|
||||
- [Host/Advanced] New button to download system logs [#3968](https://github.com/vatesfr/xen-orchestra/issues/3968) (PR [#7048](https://github.com/vatesfr/xen-orchestra/pull/7048))
|
||||
- [Home/Hosts, Pools] Display host brand and version (PR [#7027](https://github.com/vatesfr/xen-orchestra/pull/7027))
|
||||
- [SR] Ability to reclaim space [#1204](https://github.com/vatesfr/xen-orchestra/issues/1204) (PR [#7054](https://github.com/vatesfr/xen-orchestra/pull/7054))
|
||||
- [XOA] New button to restart XO Server directly from the UI (PR [#7056](https://github.com/vatesfr/xen-orchestra/pull/7056))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
@@ -31,29 +22,22 @@
|
||||
- [Backup] Fix `VHDFile implementation is not compatible with encrypted remote` when using VHD directory with encryption (PR [#7045](https://github.com/vatesfr/xen-orchestra/pull/7045))
|
||||
- [Backup/Mirror] Fix `xo:fs:local WARN lock compromised` when mirroring a Backup Repository to a local/NFS/SMB repository ([#7043](https://github.com/vatesfr/xen-orchestra/pull/7043))
|
||||
- [Ova import] Fix importing VM with collision in disk position (PR [#7051](https://github.com/vatesfr/xen-orchestra/pull/7051)) (issue [7046](https://github.com/vatesfr/xen-orchestra/issues/7046))
|
||||
- [Backup/Mirror] Fix backup report not being sent (PR [#7049](https://github.com/vatesfr/xen-orchestra/pull/7049))
|
||||
- [New VM] Only add MBR to cloud-init drive on Windows VMs to avoid booting issues (e.g. with Talos) (PR [#7050](https://github.com/vatesfr/xen-orchestra/pull/7050))
|
||||
- [VDI Import] Add the SR name to the corresponding XAPI task (PR [#6979](https://github.com/vatesfr/xen-orchestra/pull/6979))
|
||||
|
||||
### Released packages
|
||||
|
||||
- vhd-lib 4.6.0
|
||||
- @xen-orchestra/backups 0.42.1
|
||||
- @xen-orchestra/proxy 0.26.34
|
||||
- xo-vmdk-to-vhd 2.5.6
|
||||
- xo-server 5.123.0
|
||||
- xo-server-auth-github 0.3.1
|
||||
- xo-server-auth-google 0.3.1
|
||||
- xo-server-netbox 1.3.0
|
||||
- vhd-lib 4.6.1
|
||||
- @xen-orchestra/xapi 3.2.0
|
||||
- @xen-orchestra/backups 0.43.0
|
||||
- @xen-orchestra/backups-cli 1.0.13
|
||||
- @xen-orchestra/mixins 0.13.0
|
||||
- @xen-orchestra/proxy 0.26.35
|
||||
- xo-server 5.124.0
|
||||
- xo-server-backup-reports 0.17.4
|
||||
- xo-web 5.126.0
|
||||
- xo-web 5.125.0
|
||||
|
||||
## **5.86.1** (2023-09-07)
|
||||
|
||||
<img id="stable" src="https://badgen.net/badge/channel/stable/green" alt="Channel: stable" />
|
||||
<img id="latest" src="https://badgen.net/badge/channel/latest/yellow" alt="Channel: latest" />
|
||||
|
||||
### Bug fixes
|
||||
|
||||
@@ -116,6 +100,8 @@
|
||||
|
||||
## **5.85.0** (2023-07-31)
|
||||
|
||||
<img id="stable" src="https://badgen.net/badge/channel/stable/green" alt="Channel: stable" />
|
||||
|
||||
### Highlights
|
||||
|
||||
- [Import/From VMWare] Support ESXi 6.5+ with snapshot (PR [#6909](https://github.com/vatesfr/xen-orchestra/pull/6909))
|
||||
|
||||
@@ -7,16 +7,13 @@
|
||||
|
||||
> Users must be able to say: “Nice enhancement, I'm eager to test it”
|
||||
|
||||
- [Host/Advanced] Allow to force _Smart reboot_ if some resident VMs have the suspend operation blocked [Forum#7136](https://xcp-ng.org/forum/topic/7136/suspending-vms-during-host-reboot/23) (PR [#7025](https://github.com/vatesfr/xen-orchestra/pull/7025))
|
||||
- [Plugin/backup-report] Errors are now listed in XO tasks
|
||||
- [PIF] Show network name in PIF selectors (PR [#7081](https://github.com/vatesfr/xen-orchestra/pull/7081))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
> Users must be able to say: “I had this issue, happy to know it's fixed”
|
||||
|
||||
- [Rolling Pool Update] After the update, when migrating VMs back to their host, do not migrate VMs that are already on the right host [Forum#7802](https://xcp-ng.org/forum/topic/7802) (PR [#7071](https://github.com/vatesfr/xen-orchestra/pull/7071))
|
||||
- [Home] Fix OS icons alignment (PR [#7090](https://github.com/vatesfr/xen-orchestra/pull/7090))
|
||||
- [Backup/Mirror] Fix backup report not being sent (PR [#7049](https://github.com/vatesfr/xen-orchestra/pull/7049))
|
||||
- [New VM] Only add MBR to cloud-init drive on Windows VMs to avoid booting issues (e.g. with Talos) (PR [#7050](https://github.com/vatesfr/xen-orchestra/pull/7050))
|
||||
- [VDI Import] Add the SR name to the corresponding XAPI task (PR [#6979](https://github.com/vatesfr/xen-orchestra/pull/6979))
|
||||
|
||||
### Packages to release
|
||||
|
||||
@@ -34,10 +31,9 @@
|
||||
|
||||
<!--packages-start-->
|
||||
|
||||
- @xen-orchestra/mixins minor
|
||||
- @xen-orchestra/xapi minor
|
||||
- xo-server minor
|
||||
- xo-server-backup-reports minor
|
||||
- xo-web minor
|
||||
- xo-server-backup-reports patch
|
||||
- xo-server patch
|
||||
- xo-web patch
|
||||
|
||||
<!--packages-end-->
|
||||
|
||||
@@ -362,7 +362,7 @@ XO will try to find the right prefix for each IP address. If it can't find a pre
|
||||
- Assign it to object types:
|
||||
- Virtualization > cluster
|
||||
- Virtualization > virtual machine
|
||||
- Virtualization > interface
|
||||
- Virtualization > interface`
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -94,9 +94,9 @@ uri = 'tcp://db:password@hostname:port'
|
||||
|
||||
## Proxy for updates and patches
|
||||
|
||||
To check if your hosts are up-to-date, we need to access `https://updates.ops.xenserver.com/xenserver/updates.xml`.
|
||||
To check if your hosts are up-to-date, we need to access `http://updates.xensource.com/XenServer/updates.xml`.
|
||||
|
||||
And to download the patches, we need access to `https://fileservice.citrix.com/direct/v2/download/secured/support/article/*/downloads/*.zip`.
|
||||
And to download the patches, we need access to `http://support.citrix.com/supportkc/filedownload?`.
|
||||
|
||||
To do that behind a corporate proxy, just add the `httpProxy` variable to match your current proxy configuration.
|
||||
|
||||
|
||||
@@ -82,13 +82,13 @@ As you may have seen in other parts of the documentation, XO is composed of two
|
||||
|
||||
#### NodeJS
|
||||
|
||||
XO requires Node.js 18.
|
||||
XO needs Node.js. **Please always use latest Node LTS**.
|
||||
|
||||
We'll consider at this point that you've got a working node on your box. E.g:
|
||||
|
||||
```console
|
||||
$ node -v
|
||||
v18.18.0
|
||||
v16.14.0
|
||||
```
|
||||
|
||||
If not, see [this page](https://nodejs.org/en/download/package-manager/) for instructions on how to install Node.
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
"lodash": "^4.17.21",
|
||||
"promise-toolbox": "^0.21.0",
|
||||
"uuid": "^9.0.0",
|
||||
"vhd-lib": "^4.6.1"
|
||||
"vhd-lib": "^4.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"postversion": "npm publish",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": false,
|
||||
"name": "vhd-lib",
|
||||
"version": "4.6.1",
|
||||
"version": "4.6.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"description": "Primitives for VHD file handling",
|
||||
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/packages/vhd-lib",
|
||||
|
||||
@@ -25,16 +25,8 @@ async function checkFile(vhdName) {
|
||||
// Since the qemu-img check command isn't compatible with vhd format, we use
|
||||
// the convert command to do a check by conversion. Indeed, the conversion will
|
||||
// fail if the source file isn't a proper vhd format.
|
||||
const target = vhdName + '.qcow2'
|
||||
try {
|
||||
await execa('qemu-img', ['convert', '-fvpc', '-Oqcow2', vhdName, target])
|
||||
} finally {
|
||||
try {
|
||||
await fsPromise.unlink(target)
|
||||
} catch (err) {
|
||||
console.warn(err)
|
||||
}
|
||||
}
|
||||
await execa('qemu-img', ['convert', '-fvpc', '-Oqcow2', vhdName, 'outputFile.qcow2'])
|
||||
await fsPromise.unlink('./outputFile.qcow2')
|
||||
}
|
||||
exports.checkFile = checkFile
|
||||
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
"promise-toolbox": "^0.19.2",
|
||||
"readable-stream": "^3.1.1",
|
||||
"throttle": "^1.0.3",
|
||||
"vhd-lib": "^4.6.1"
|
||||
"vhd-lib": "^4.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +130,6 @@ async function main(createClient) {
|
||||
}
|
||||
export default main
|
||||
|
||||
if (module.parent === null) {
|
||||
if (!module.parent) {
|
||||
main(require('./').createClient).catch(console.error.bind(console, 'FATAL'))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xo-server-backup-reports",
|
||||
"version": "0.17.4",
|
||||
"version": "0.17.3",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"description": "Backup reports plugin for XO-Server",
|
||||
"keywords": [
|
||||
|
||||
@@ -90,8 +90,6 @@ const formatSpeed = (bytes, milliseconds) =>
|
||||
})
|
||||
: 'N/A'
|
||||
|
||||
const noop = Function.prototype
|
||||
|
||||
const NO_VMS_MATCH_THIS_PATTERN = 'no VMs match this pattern'
|
||||
const NO_SUCH_OBJECT_ERROR = 'no such object'
|
||||
const UNHEALTHY_VDI_CHAIN_ERROR = 'unhealthy VDI chain'
|
||||
@@ -195,17 +193,13 @@ const toMarkdown = parts => {
|
||||
class BackupReportsXoPlugin {
|
||||
constructor(xo) {
|
||||
this._xo = xo
|
||||
|
||||
const report = this._report
|
||||
this._report = (...args) =>
|
||||
xo.tasks
|
||||
.create(
|
||||
{ type: 'xo:xo-server-backup-reports:sendReport', name: 'Sending backup report', runId: args[0] },
|
||||
{ clearLogOnSuccess: true }
|
||||
)
|
||||
.run(() => report.call(this, ...args))
|
||||
|
||||
this._eventListener = (...args) => this._report(...args).catch(noop)
|
||||
this._eventListener = async (...args) => {
|
||||
try {
|
||||
await this._report(...args)
|
||||
} catch (error) {
|
||||
logger.warn(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configure({ toMails, toXmpp }) {
|
||||
@@ -601,28 +595,24 @@ class BackupReportsXoPlugin {
|
||||
})
|
||||
}
|
||||
|
||||
async _sendReport({ mailReceivers, markdown, subject, success }) {
|
||||
_sendReport({ mailReceivers, markdown, subject, success }) {
|
||||
if (mailReceivers === undefined || mailReceivers.length === 0) {
|
||||
mailReceivers = this._mailsReceivers
|
||||
}
|
||||
|
||||
const xo = this._xo
|
||||
const promises = [
|
||||
mailReceivers !== undefined &&
|
||||
(xo.sendEmail === undefined
|
||||
? Promise.reject(new Error('transport-email plugin not enabled'))
|
||||
: xo.sendEmail({
|
||||
to: mailReceivers,
|
||||
subject,
|
||||
markdown,
|
||||
})),
|
||||
this._xmppReceivers !== undefined &&
|
||||
(xo.sendEmail === undefined
|
||||
? Promise.reject(new Error('transport-xmpp plugin not enabled'))
|
||||
: xo.sendToXmppClient({
|
||||
to: this._xmppReceivers,
|
||||
message: markdown,
|
||||
})),
|
||||
return Promise.all([
|
||||
xo.sendEmail !== undefined &&
|
||||
xo.sendEmail({
|
||||
to: mailReceivers,
|
||||
subject,
|
||||
markdown,
|
||||
}),
|
||||
xo.sendToXmppClient !== undefined &&
|
||||
xo.sendToXmppClient({
|
||||
to: this._xmppReceivers,
|
||||
message: markdown,
|
||||
}),
|
||||
xo.sendSlackMessage !== undefined &&
|
||||
xo.sendSlackMessage({
|
||||
message: markdown,
|
||||
@@ -632,22 +622,7 @@ class BackupReportsXoPlugin {
|
||||
status: success ? 'OK' : 'CRITICAL',
|
||||
message: markdown,
|
||||
}),
|
||||
]
|
||||
|
||||
const errors = []
|
||||
const pushError = errors.push.bind(errors)
|
||||
|
||||
await Promise.all(promises.filter(Boolean).map(_ => _.catch(pushError)))
|
||||
|
||||
if (errors.length !== 0) {
|
||||
throw new AggregateError(
|
||||
errors,
|
||||
errors
|
||||
.map(_ => _.message)
|
||||
.filter(_ => _ != null && _.length !== 0)
|
||||
.join(', ')
|
||||
)
|
||||
}
|
||||
])
|
||||
}
|
||||
|
||||
_legacyVmHandler(status) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "xo-server",
|
||||
"version": "5.124.0",
|
||||
"version": "5.123.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"description": "Server part of Xen-Orchestra",
|
||||
"keywords": [
|
||||
@@ -41,18 +41,18 @@
|
||||
"@vates/predicates": "^1.1.0",
|
||||
"@vates/read-chunk": "^1.2.0",
|
||||
"@xen-orchestra/async-map": "^0.1.2",
|
||||
"@xen-orchestra/backups": "^0.43.0",
|
||||
"@xen-orchestra/backups": "^0.42.1",
|
||||
"@xen-orchestra/cron": "^1.0.6",
|
||||
"@xen-orchestra/defined": "^0.0.1",
|
||||
"@xen-orchestra/emit-async": "^1.0.0",
|
||||
"@xen-orchestra/fs": "^4.1.0",
|
||||
"@xen-orchestra/log": "^0.6.0",
|
||||
"@xen-orchestra/mixin": "^0.1.0",
|
||||
"@xen-orchestra/mixins": "^0.13.0",
|
||||
"@xen-orchestra/mixins": "^0.12.0",
|
||||
"@xen-orchestra/self-signed": "^0.1.3",
|
||||
"@xen-orchestra/template": "^0.1.0",
|
||||
"@xen-orchestra/vmware-explorer": "^0.3.0",
|
||||
"@xen-orchestra/xapi": "^3.2.0",
|
||||
"@xen-orchestra/xapi": "^3.1.0",
|
||||
"ajv": "^8.0.3",
|
||||
"app-conf": "^2.3.0",
|
||||
"async-iterator-to-stream": "^1.0.1",
|
||||
@@ -128,7 +128,7 @@
|
||||
"unzipper": "^0.10.5",
|
||||
"uuid": "^9.0.0",
|
||||
"value-matcher": "^0.2.0",
|
||||
"vhd-lib": "^4.6.1",
|
||||
"vhd-lib": "^4.6.0",
|
||||
"ws": "^8.2.3",
|
||||
"xdg-basedir": "^5.1.0",
|
||||
"xen-api": "^1.3.6",
|
||||
|
||||
@@ -69,14 +69,3 @@ html
|
||||
button.btn.btn-block.btn-info
|
||||
i.fa.fa-sign-in
|
||||
| Sign in
|
||||
script.
|
||||
(function () {
|
||||
var d = document
|
||||
var h = d.location.hash
|
||||
d.querySelectorAll('a').forEach(a => {
|
||||
a.href += h
|
||||
})
|
||||
d.querySelectorAll('form').forEach(form => {
|
||||
form.action += h
|
||||
})
|
||||
})()
|
||||
|
||||
@@ -119,15 +119,7 @@ set.resolve = {
|
||||
|
||||
// FIXME: set force to false per default when correctly implemented in
|
||||
// UI.
|
||||
export async function restart({
|
||||
bypassBackupCheck = false,
|
||||
host,
|
||||
force = false,
|
||||
suspendResidentVms,
|
||||
|
||||
bypassBlockedSuspend = force,
|
||||
bypassCurrentVmCheck = force,
|
||||
}) {
|
||||
export async function restart({ bypassBackupCheck = false, host, force = false, suspendResidentVms }) {
|
||||
if (bypassBackupCheck) {
|
||||
log.warn('host.restart with argument "bypassBackupCheck" set to true', { hostId: host.id })
|
||||
} else {
|
||||
@@ -135,9 +127,7 @@ export async function restart({
|
||||
}
|
||||
|
||||
const xapi = this.getXapi(host)
|
||||
return suspendResidentVms
|
||||
? xapi.host_smartReboot(host._xapiRef, bypassBlockedSuspend, bypassCurrentVmCheck)
|
||||
: xapi.rebootHost(host._xapiId, force)
|
||||
return suspendResidentVms ? xapi.host_smartReboot(host._xapiRef) : xapi.rebootHost(host._xapiId, force)
|
||||
}
|
||||
|
||||
restart.description = 'restart the host'
|
||||
@@ -147,14 +137,6 @@ restart.params = {
|
||||
type: 'boolean',
|
||||
optional: true,
|
||||
},
|
||||
bypassBlockedSuspend: {
|
||||
type: 'boolean',
|
||||
optional: true,
|
||||
},
|
||||
bypassCurrentVmCheck: {
|
||||
type: 'boolean',
|
||||
optional: true,
|
||||
},
|
||||
id: { type: 'string' },
|
||||
force: {
|
||||
type: 'boolean',
|
||||
@@ -474,52 +456,3 @@ setControlDomainMemory.params = {
|
||||
setControlDomainMemory.resolve = {
|
||||
host: ['id', 'host', 'administrate'],
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
/**
|
||||
*
|
||||
* @param {{host:HOST}} params
|
||||
* @returns null if plugin is not installed or don't have the method
|
||||
* an object device: status on success
|
||||
*/
|
||||
export function getSmartctlHealth({ host }) {
|
||||
return this.getXapi(host).getSmartctlHealth(host._xapiId)
|
||||
}
|
||||
|
||||
getSmartctlHealth.description = 'get smartctl health status'
|
||||
|
||||
getSmartctlHealth.params = {
|
||||
id: { type: 'string' },
|
||||
}
|
||||
|
||||
getSmartctlHealth.resolve = {
|
||||
host: ['id', 'host', 'view'],
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {{host:HOST}} params
|
||||
* @returns null if plugin is not installed or don't have the method
|
||||
* an object device: full device information on success
|
||||
*/
|
||||
export function getSmartctlInformation({ host, deviceNames }) {
|
||||
return this.getXapi(host).getSmartctlInformation(host._xapiId, deviceNames)
|
||||
}
|
||||
|
||||
getSmartctlInformation.description = 'get smartctl information'
|
||||
|
||||
getSmartctlInformation.params = {
|
||||
id: { type: 'string' },
|
||||
|
||||
deviceNames: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
optional: true,
|
||||
},
|
||||
}
|
||||
|
||||
getSmartctlInformation.resolve = {
|
||||
host: ['id', 'host', 'view'],
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
export async function create({ vm }) {
|
||||
const xapi = this.getXapi(vm)
|
||||
const vtpmRef = await xapi.VTPM_create({ VM: vm._xapiRef })
|
||||
return xapi.getField('VTPM', vtpmRef, 'uuid')
|
||||
}
|
||||
|
||||
create.description = 'create a VTPM'
|
||||
|
||||
create.params = {
|
||||
id: { type: 'string' },
|
||||
}
|
||||
|
||||
create.resolve = {
|
||||
vm: ['id', 'VM', 'administrate'],
|
||||
}
|
||||
|
||||
export async function destroy({ vtpm }) {
|
||||
await this.getXapi(vtpm).call('VTPM.destroy', vtpm._xapiRef)
|
||||
}
|
||||
|
||||
destroy.description = 'destroy a VTPM'
|
||||
|
||||
destroy.params = {
|
||||
id: { type: 'string' },
|
||||
}
|
||||
|
||||
destroy.resolve = {
|
||||
vtpm: ['id', 'VTPM', 'administrate'],
|
||||
}
|
||||
@@ -118,7 +118,6 @@ const TRANSFORMS = {
|
||||
},
|
||||
suspendSr: link(obj, 'suspend_image_SR'),
|
||||
zstdSupported: obj.restrictions.restrict_zstd_export === 'false',
|
||||
vtpmSupported: obj.restrictions.restrict_vtpm === 'false',
|
||||
|
||||
// TODO
|
||||
// - ? networks = networksByPool.items[pool.id] (network.$pool.id)
|
||||
@@ -414,7 +413,6 @@ const TRANSFORMS = {
|
||||
suspendSr: link(obj, 'suspend_SR'),
|
||||
tags: obj.tags,
|
||||
VIFs: link(obj, 'VIFs'),
|
||||
VTPMs: link(obj, 'VTPMs'),
|
||||
virtualizationMode: domainType,
|
||||
|
||||
// deprecated, use pvDriversVersion instead
|
||||
@@ -843,14 +841,6 @@ const TRANSFORMS = {
|
||||
vgpus: link(obj, 'VGPUs'),
|
||||
}
|
||||
},
|
||||
|
||||
vtpm(obj) {
|
||||
return {
|
||||
type: 'VTPM',
|
||||
|
||||
vm: link(obj, 'VM'),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
@@ -12,7 +12,6 @@ import mixin from '@xen-orchestra/mixin/legacy.js'
|
||||
import ms from 'ms'
|
||||
import noop from 'lodash/noop.js'
|
||||
import once from 'lodash/once.js'
|
||||
import pick from 'lodash/pick.js'
|
||||
import tarStream from 'tar-stream'
|
||||
import uniq from 'lodash/uniq.js'
|
||||
import { asyncMap } from '@xen-orchestra/async-map'
|
||||
@@ -1429,34 +1428,4 @@ export default class Xapi extends XapiBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getSmartctlHealth(hostId) {
|
||||
try {
|
||||
return JSON.parse(await this.call('host.call_plugin', this.getObject(hostId).$ref, 'smartctl.py', 'health', {}))
|
||||
} catch (error) {
|
||||
if (error.code === 'XENAPI_MISSING_PLUGIN' || error.code === 'UNKNOWN_XENAPI_PLUGIN_FUNCTION') {
|
||||
return null
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async getSmartctlInformation(hostId, deviceNames) {
|
||||
try {
|
||||
const informations = JSON.parse(
|
||||
await this.call('host.call_plugin', this.getObject(hostId).$ref, 'smartctl.py', 'information', {})
|
||||
)
|
||||
if (deviceNames === undefined) {
|
||||
return informations
|
||||
}
|
||||
return pick(informations, deviceNames)
|
||||
} catch (error) {
|
||||
if (error.code === 'XENAPI_MISSING_PLUGIN' || error.code === 'UNKNOWN_XENAPI_PLUGIN_FUNCTION') {
|
||||
return null
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ const listMissingPatches = debounceWithKey(_listMissingPatches, LISTING_DEBOUNCE
|
||||
// =============================================================================
|
||||
|
||||
export default {
|
||||
// raw { uuid: patch } map translated from updates.ops.xenserver.com/xenserver/updates.xml
|
||||
// raw { uuid: patch } map translated from updates.xensource.com/XenServer/updates.xml
|
||||
// FIXME: should be static
|
||||
@decorateWith(debounceWithKey, 24 * 60 * 60 * 1000, function () {
|
||||
return this
|
||||
@@ -629,13 +629,7 @@ export default {
|
||||
continue
|
||||
}
|
||||
|
||||
const residentVms = host.$resident_VMs.map(vm => vm.uuid)
|
||||
|
||||
for (const vmId of vmIds) {
|
||||
if (residentVms.includes(vmId)) {
|
||||
continue
|
||||
}
|
||||
|
||||
try {
|
||||
await this.migrateVm(vmId, this, hostId)
|
||||
} catch (err) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import { parseDuration } from '@vates/parse-duration'
|
||||
import patch from '../patch.mjs'
|
||||
import { Tokens } from '../models/token.mjs'
|
||||
import { forEach, generateToken } from '../utils.mjs'
|
||||
import { replace } from '../sensitive-values.mjs'
|
||||
|
||||
// ===================================================================
|
||||
|
||||
@@ -137,52 +136,36 @@ export default class {
|
||||
}
|
||||
|
||||
async authenticateUser(credentials, userData) {
|
||||
const { tasks } = this._app
|
||||
const task = await tasks.create(
|
||||
{
|
||||
type: 'xo:authentication:authenticateUser',
|
||||
name: 'XO user authentication',
|
||||
credentials: replace(credentials),
|
||||
userData,
|
||||
},
|
||||
{
|
||||
// only keep trace of failed attempts
|
||||
clearLogOnSuccess: true,
|
||||
}
|
||||
)
|
||||
// don't even attempt to authenticate with empty password
|
||||
const { password } = credentials
|
||||
if (password === '') {
|
||||
throw new Error('empty password')
|
||||
}
|
||||
|
||||
return task.run(async () => {
|
||||
// don't even attempt to authenticate with empty password
|
||||
const { password } = credentials
|
||||
if (password === '') {
|
||||
throw new Error('empty password')
|
||||
}
|
||||
// TODO: remove when email has been replaced by username.
|
||||
if (credentials.email) {
|
||||
credentials.username = credentials.email
|
||||
} else if (credentials.username) {
|
||||
credentials.email = credentials.username
|
||||
}
|
||||
|
||||
// TODO: remove when email has been replaced by username.
|
||||
if (credentials.email) {
|
||||
credentials.username = credentials.email
|
||||
} else if (credentials.username) {
|
||||
credentials.email = credentials.username
|
||||
}
|
||||
const failures = this._failures
|
||||
|
||||
const failures = this._failures
|
||||
const { username } = credentials
|
||||
const now = Date.now()
|
||||
let lastFailure
|
||||
if (username && (lastFailure = failures[username]) && lastFailure + this._throttlingDelay > now) {
|
||||
throw new Error('too fast authentication tries')
|
||||
}
|
||||
|
||||
const { username } = credentials
|
||||
const now = Date.now()
|
||||
let lastFailure
|
||||
if (username && (lastFailure = failures[username]) && lastFailure + this._throttlingDelay > now) {
|
||||
throw new Error('too fast authentication tries')
|
||||
}
|
||||
const result = await this._authenticateUser(credentials, userData)
|
||||
if (result === undefined) {
|
||||
failures[username] = now
|
||||
throw invalidCredentials()
|
||||
}
|
||||
|
||||
const result = await this._authenticateUser(credentials, userData)
|
||||
if (result === undefined) {
|
||||
failures[username] = now
|
||||
throw invalidCredentials()
|
||||
}
|
||||
|
||||
delete failures[username]
|
||||
return result
|
||||
})
|
||||
delete failures[username]
|
||||
return result
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
"pako": "^2.0.4",
|
||||
"promise-toolbox": "^0.21.0",
|
||||
"tar-stream": "^2.2.0",
|
||||
"vhd-lib": "^4.6.1",
|
||||
"vhd-lib": "^4.6.0",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "xo-web",
|
||||
"version": "5.126.0",
|
||||
"version": "5.125.0",
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"description": "Web interface client for Xen-Orchestra",
|
||||
"keywords": [
|
||||
|
||||
@@ -6,7 +6,7 @@ import React from 'react'
|
||||
const Icon = ({ icon, size = 1, color, fixedWidth, ...props }) => {
|
||||
props.className = classNames(
|
||||
props.className,
|
||||
icon != null ? `xo-icon-${icon}` : 'fa', // Misaligned problem modification: if no icon or null, apply 'fa'
|
||||
icon !== undefined ? `xo-icon-${icon}` : 'fa', // Without icon prop, is a placeholder.
|
||||
isInteger(size) ? `fa-${size}x` : `fa-${size}`,
|
||||
color,
|
||||
fixedWidth && 'fa-fw'
|
||||
|
||||
@@ -963,13 +963,9 @@ const messages = {
|
||||
enableHostLabel: 'Enable',
|
||||
disableHostLabel: 'Disable',
|
||||
restartHostAgent: 'Restart toolstack',
|
||||
smartRebootBypassCurrentVmCheck:
|
||||
'As the XOA is hosted on the host that is scheduled for a reboot, it will also be restarted. Consequently, XO won\'t be able to resume VMs, and VMs with the "Protect from accidental shutdown" option enabled will not have this option reactivated automatically.',
|
||||
smartRebootHostLabel: 'Smart reboot',
|
||||
smartRebootHostTooltip: 'Suspend resident VMs, reboot host and resume VMs automatically',
|
||||
forceRebootHostLabel: 'Force reboot',
|
||||
forceSmartRebootHost:
|
||||
'Smart Reboot failed because {nVms, number} VM{nVms, plural, one {} other {s}} ha{nVms, plural, one {s} other {ve}} {nVms, plural, one {its} other {their}} Suspend operation blocked. Would you like to force?',
|
||||
rebootHostLabel: 'Reboot',
|
||||
noHostsAvailableErrorTitle: 'Error while restarting host',
|
||||
noHostsAvailableErrorMessage:
|
||||
@@ -985,7 +981,6 @@ const messages = {
|
||||
// ----- host stat tab -----
|
||||
statLoad: 'Load average',
|
||||
// ----- host advanced tab -----
|
||||
disksSystemHealthy: 'All disks are healthy ✅',
|
||||
editHostIscsiIqnTitle: 'Edit iSCSI IQN',
|
||||
editHostIscsiIqnMessage:
|
||||
'Are you sure you want to edit the iSCSI IQN? This may result in failures connecting to existing SRs if the host is attached to iSCSI SRs.',
|
||||
@@ -1036,7 +1031,6 @@ const messages = {
|
||||
hostRemoteSyslog: 'Remote syslog',
|
||||
hostIommu: 'IOMMU',
|
||||
hostNoCertificateInstalled: 'No certificates installed on this host',
|
||||
smartctlPluginNotInstalled: 'Smartctl plugin not installed',
|
||||
supplementalPacks: 'Installed supplemental packs',
|
||||
supplementalPackNew: 'Install new supplemental pack',
|
||||
supplementalPackPoolNew: 'Install supplemental pack on every host',
|
||||
@@ -1047,7 +1041,6 @@ const messages = {
|
||||
supplementalPackInstallErrorMessage: 'The installation of the supplemental pack failed.',
|
||||
supplementalPackInstallSuccessTitle: 'Installation success',
|
||||
supplementalPackInstallSuccessMessage: 'Supplemental pack successfully installed.',
|
||||
systemDisksHealth: 'System disks health',
|
||||
uniqueHostIscsiIqnInfo: 'The iSCSI IQN must be unique. ',
|
||||
// ----- Host net tabs -----
|
||||
networkCreateButton: 'Add a network',
|
||||
|
||||
@@ -299,63 +299,6 @@ Vdi.defaultProps = {
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export const Pif = decorate([
|
||||
connectStore(() => {
|
||||
const getObject = createGetObject()
|
||||
const getNetwork = createGetObject(createSelector(getObject, pif => get(() => pif.$network)))
|
||||
|
||||
// FIXME: props.self ugly workaround to get object as a self user
|
||||
return (state, props) => ({
|
||||
pif: getObject(state, props, props.self),
|
||||
network: getNetwork(state, props),
|
||||
})
|
||||
}),
|
||||
({ id, showNetwork, pif, network }) => {
|
||||
if (pif === undefined) {
|
||||
return unknowItem(id, 'PIF')
|
||||
}
|
||||
|
||||
const { carrier, device, deviceName, vlan } = pif
|
||||
const showExtraInfo = deviceName || vlan !== -1 || (showNetwork && network !== undefined)
|
||||
|
||||
return (
|
||||
<span>
|
||||
<Icon icon='network' color={carrier ? 'text-success' : 'text-danger'} /> {device}
|
||||
{showExtraInfo && (
|
||||
<span>
|
||||
{' '}
|
||||
({deviceName}
|
||||
{vlan !== -1 && (
|
||||
<span>
|
||||
{' '}
|
||||
-{' '}
|
||||
{_('keyValue', {
|
||||
key: _('pifVlanLabel'),
|
||||
value: vlan,
|
||||
})}
|
||||
</span>
|
||||
)}
|
||||
{showNetwork && network !== undefined && <span> - {network.name_label}</span>})
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
},
|
||||
])
|
||||
|
||||
Pif.propTypes = {
|
||||
id: PropTypes.string.isRequired,
|
||||
self: PropTypes.bool,
|
||||
showNetwork: PropTypes.bool,
|
||||
}
|
||||
|
||||
Pif.defaultProps = {
|
||||
self: false,
|
||||
showNetwork: false,
|
||||
}
|
||||
|
||||
// ===================================================================
|
||||
|
||||
export const Network = decorate([
|
||||
connectStore(() => {
|
||||
const getObject = createGetObject()
|
||||
@@ -618,8 +561,24 @@ const xoItemToRender = {
|
||||
),
|
||||
|
||||
// PIF.
|
||||
PIF: props => <Pif {...props} />,
|
||||
|
||||
PIF: ({ carrier, device, deviceName, vlan }) => (
|
||||
<span>
|
||||
<Icon icon='network' color={carrier ? 'text-success' : 'text-danger'} /> {device}
|
||||
{(deviceName !== '' || vlan !== -1) && (
|
||||
<span>
|
||||
{' '}
|
||||
({deviceName}
|
||||
{deviceName !== '' && vlan !== -1 && ' - '}
|
||||
{vlan !== -1 &&
|
||||
_('keyValue', {
|
||||
key: _('pifVlanLabel'),
|
||||
value: vlan,
|
||||
})}
|
||||
)
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
),
|
||||
// Tags.
|
||||
tag: tag => (
|
||||
<span>
|
||||
|
||||
@@ -251,7 +251,6 @@ class GenericSelect extends React.Component {
|
||||
? `${option.xoItem.type}-resourceSet`
|
||||
: undefined,
|
||||
memoryFree: option.xoItem.type === 'host' || undefined,
|
||||
showNetwork: true,
|
||||
})}
|
||||
</span>
|
||||
)
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
incorrectState,
|
||||
noHostsAvailable,
|
||||
operationBlocked,
|
||||
operationFailed,
|
||||
vmLacksFeature,
|
||||
} from 'xo-common/api-errors'
|
||||
|
||||
@@ -822,89 +821,42 @@ export const setRemoteSyslogHost = (host, syslogDestination) =>
|
||||
export const setRemoteSyslogHosts = (hosts, syslogDestination) =>
|
||||
Promise.all(map(hosts, host => setRemoteSyslogHost(host, syslogDestination)))
|
||||
|
||||
export const restartHost = async (
|
||||
host,
|
||||
force = false,
|
||||
suspendResidentVms = false,
|
||||
bypassBlockedSuspend = false,
|
||||
bypassCurrentVmCheck = false
|
||||
) => {
|
||||
await confirm({
|
||||
export const restartHost = (host, force = false, suspendResidentVms = false) =>
|
||||
confirm({
|
||||
title: _('restartHostModalTitle'),
|
||||
body: _('restartHostModalMessage'),
|
||||
})
|
||||
return _restartHost({ host, force, suspendResidentVms, bypassBlockedSuspend, bypassCurrentVmCheck })
|
||||
}
|
||||
|
||||
const _restartHost = async ({ host, ...opts }) => {
|
||||
opts = { ...opts, id: resolveId(host) }
|
||||
|
||||
try {
|
||||
await _call('host.restart', opts)
|
||||
} catch (error) {
|
||||
if (cantSuspend(error)) {
|
||||
await confirm({
|
||||
body: (
|
||||
<p>
|
||||
<Icon icon='alarm' /> {_('forceSmartRebootHost', { nVms: error.data.actual.length })}
|
||||
</p>
|
||||
),
|
||||
title: _('restartHostModalTitle'),
|
||||
})
|
||||
return _restartHost({ ...opts, host, bypassBlockedSuspend: true })
|
||||
}
|
||||
|
||||
if (xoaOnHost(error)) {
|
||||
await confirm({
|
||||
body: (
|
||||
<p>
|
||||
<Icon icon='alarm' /> {_('smartRebootBypassCurrentVmCheck')}
|
||||
</p>
|
||||
),
|
||||
title: _('restartHostModalTitle'),
|
||||
})
|
||||
return _restartHost({ ...opts, host, bypassCurrentVmCheck: true })
|
||||
}
|
||||
|
||||
if (backupIsRunning(error, host.$poolId)) {
|
||||
await confirm({
|
||||
body: (
|
||||
<p className='text-warning'>
|
||||
<Icon icon='alarm' /> {_('bypassBackupHostModalMessage')}
|
||||
</p>
|
||||
),
|
||||
title: _('restartHostModalTitle'),
|
||||
})
|
||||
return _restartHost({ ...opts, host, bypassBackupCheck: true })
|
||||
}
|
||||
|
||||
if (noHostsAvailableErrCheck(error)) {
|
||||
alert(_('noHostsAvailableErrorTitle'), _('noHostsAvailableErrorMessage'))
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Restart Host errors
|
||||
const cantSuspend = err =>
|
||||
err !== undefined &&
|
||||
incorrectState.is(err, {
|
||||
object: 'suspendBlocked',
|
||||
})
|
||||
const xoaOnHost = err =>
|
||||
err !== undefined &&
|
||||
operationFailed.is(err, {
|
||||
code: 'xoaOnHost',
|
||||
})
|
||||
const backupIsRunning = (err, poolId) =>
|
||||
err !== undefined &&
|
||||
(forbiddenOperation.is(err, {
|
||||
reason: `A backup may run on the pool: ${poolId}`,
|
||||
}) ||
|
||||
forbiddenOperation.is(err, {
|
||||
reason: `A backup is running on the pool: ${poolId}`,
|
||||
}))
|
||||
const noHostsAvailableErrCheck = err => err !== undefined && noHostsAvailable.is(err)
|
||||
}).then(
|
||||
() =>
|
||||
_call('host.restart', { id: resolveId(host), force, suspendResidentVms })
|
||||
.catch(async error => {
|
||||
if (
|
||||
forbiddenOperation.is(error, {
|
||||
reason: `A backup may run on the pool: ${host.$poolId}`,
|
||||
}) ||
|
||||
forbiddenOperation.is(error, {
|
||||
reason: `A backup is running on the pool: ${host.$poolId}`,
|
||||
})
|
||||
) {
|
||||
await confirm({
|
||||
body: (
|
||||
<p className='text-warning'>
|
||||
<Icon icon='alarm' /> {_('bypassBackupHostModalMessage')}
|
||||
</p>
|
||||
),
|
||||
title: _('restartHostModalTitle'),
|
||||
})
|
||||
return _call('host.restart', { id: resolveId(host), force, suspendResidentVms, bypassBackupCheck: true })
|
||||
}
|
||||
throw error
|
||||
})
|
||||
.catch(error => {
|
||||
if (noHostsAvailable.is(error)) {
|
||||
alert(_('noHostsAvailableErrorTitle'), _('noHostsAvailableErrorMessage'))
|
||||
}
|
||||
throw error
|
||||
}),
|
||||
noop
|
||||
)
|
||||
|
||||
export const restartHosts = (hosts, force = false) => {
|
||||
const nHosts = size(hosts)
|
||||
@@ -1072,11 +1024,6 @@ export const isHyperThreadingEnabledHost = host =>
|
||||
id: resolveId(host),
|
||||
})
|
||||
|
||||
export const getSmartctlHealth = host => _call('host.getSmartctlHealth', { id: resolveId(host) })
|
||||
|
||||
export const getSmartctlInformation = (host, deviceNames) =>
|
||||
_call('host.getSmartctlInformation', { id: resolveId(host), deviceNames })
|
||||
|
||||
export const installCertificateOnHost = (id, props) => _call('host.installCertificate', { id, ...props })
|
||||
|
||||
export const setControlDomainMemory = (id, memory) => _call('host.setControlDomainMemory', { id, memory })
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import _ from 'intl'
|
||||
import ActionButton from 'action-button'
|
||||
import BulkIcons from 'bulk-icons'
|
||||
import Component from 'base-component'
|
||||
import Copiable from 'copiable'
|
||||
import decorate from 'apply-decorators'
|
||||
@@ -34,8 +33,6 @@ import {
|
||||
isHyperThreadingEnabledHost,
|
||||
isNetDataInstalledOnHost,
|
||||
getPlugin,
|
||||
getSmartctlHealth,
|
||||
getSmartctlInformation,
|
||||
restartHost,
|
||||
setControlDomainMemory,
|
||||
setHostsMultipathing,
|
||||
@@ -76,7 +73,7 @@ const downloadLogs = async uuid => {
|
||||
const forceReboot = host => restartHost(host, true)
|
||||
|
||||
const smartReboot = ALLOW_SMART_REBOOT
|
||||
? host => restartHost(host, false, true, false, false) // don't force, suspend resident VMs, don't bypass blocked suspend, don't bypass current VM check
|
||||
? host => restartHost(host, false, true) // don't force, suspend resident VMs
|
||||
: () => {}
|
||||
|
||||
const formatPack = ({ name, author, description, version }, key) => (
|
||||
@@ -164,36 +161,17 @@ MultipathableSrs.propTypes = {
|
||||
})
|
||||
export default class extends Component {
|
||||
async componentDidMount() {
|
||||
const { host } = this.props
|
||||
const plugin = await getPlugin('netdata')
|
||||
const isNetDataPluginCorrectlySet = plugin !== undefined && plugin.loaded
|
||||
this.setState({ isNetDataPluginCorrectlySet })
|
||||
if (isNetDataPluginCorrectlySet) {
|
||||
this.setState({
|
||||
isNetDataPluginInstalledOnHost: await isNetDataInstalledOnHost(host),
|
||||
isNetDataPluginInstalledOnHost: await isNetDataInstalledOnHost(this.props.host),
|
||||
})
|
||||
}
|
||||
|
||||
const smartctlHealth = await getSmartctlHealth(host)
|
||||
const isSmartctlHealthEnabled = smartctlHealth !== null
|
||||
const smartctlUnhealthyDevices = isSmartctlHealthEnabled
|
||||
? Object.keys(smartctlHealth).filter(deviceName => smartctlHealth[deviceName] !== 'PASSED')
|
||||
: undefined
|
||||
|
||||
let unhealthyDevicesAlerts
|
||||
if (smartctlUnhealthyDevices?.length > 0) {
|
||||
const unhealthyDeviceInformations = await getSmartctlInformation(host, smartctlUnhealthyDevices)
|
||||
unhealthyDevicesAlerts = map(unhealthyDeviceInformations, (value, key) => ({
|
||||
level: 'warning',
|
||||
render: <pre>{_('keyValue', { key, value: JSON.stringify(value, null, 2) })}</pre>,
|
||||
}))
|
||||
}
|
||||
|
||||
this.setState({
|
||||
isHtEnabled: await isHyperThreadingEnabledHost(host).catch(() => null),
|
||||
isSmartctlHealthEnabled,
|
||||
smartctlUnhealthyDevices,
|
||||
unhealthyDevicesAlerts,
|
||||
isHtEnabled: await isHyperThreadingEnabledHost(this.props.host),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -255,14 +233,7 @@ export default class extends Component {
|
||||
|
||||
render() {
|
||||
const { controlDomain, host, pcis, pgpus, schedGran } = this.props
|
||||
const {
|
||||
isHtEnabled,
|
||||
isNetDataPluginInstalledOnHost,
|
||||
isNetDataPluginCorrectlySet,
|
||||
isSmartctlHealthEnabled,
|
||||
unhealthyDevicesAlerts,
|
||||
smartctlUnhealthyDevices,
|
||||
} = this.state
|
||||
const { isHtEnabled, isNetDataPluginInstalledOnHost, isNetDataPluginCorrectlySet } = this.state
|
||||
|
||||
const _isXcpNgHost = host.productBrand === 'XCP-ng'
|
||||
|
||||
@@ -541,21 +512,6 @@ export default class extends Component {
|
||||
{host.bios_strings['bios-vendor']} ({host.bios_strings['bios-version']})
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>{_('systemDisksHealth')}</th>
|
||||
<td>
|
||||
{isSmartctlHealthEnabled !== undefined &&
|
||||
(isSmartctlHealthEnabled ? (
|
||||
smartctlUnhealthyDevices?.length === 0 ? (
|
||||
_('disksSystemHealthy')
|
||||
) : (
|
||||
<BulkIcons alerts={unhealthyDevicesAlerts ?? []} />
|
||||
)
|
||||
) : (
|
||||
_('smartctlPluginNotInstalled')
|
||||
))}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user