- |
-
+
{{ $t(`alarm-type.${alarm.type}`, { n: alarm.triggerLevel * 100 }) }}
|
{{ alarm.level * 100 }}% |
- {{ $t("on-object", { object: alarm.cls }) }} |
+ {{ $t('on-object', { object: alarm.cls }) }} |
|
@@ -26,21 +19,21 @@
diff --git a/@xen-orchestra/lite/src/components/ui/icon/UiStatusIcon.vue b/@xen-orchestra/lite/src/components/ui/icon/UiStatusIcon.vue
index 4fa1f09fd94..0b8aa4fb636 100644
--- a/@xen-orchestra/lite/src/components/ui/icon/UiStatusIcon.vue
+++ b/@xen-orchestra/lite/src/components/ui/icon/UiStatusIcon.vue
@@ -3,30 +3,26 @@
diff --git a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionDeleteItem.vue b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionDeleteItem.vue
index eed5e64e562..b6f67d336bf 100644
--- a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionDeleteItem.vue
+++ b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionDeleteItem.vue
@@ -5,40 +5,34 @@
:icon="faTrashCan"
@click="openDeleteModal"
>
- {{ $t("delete") }}
+ {{ $t('delete') }}
diff --git a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionExportItem.vue b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionExportItem.vue
index 77b57b71f4c..b1991746183 100644
--- a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionExportItem.vue
+++ b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionExportItem.vue
@@ -1,53 +1,47 @@
diff --git a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionExportItems.vue b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionExportItems.vue
index 49f1a204888..6695a5edd0b 100644
--- a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionExportItems.vue
+++ b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionExportItems.vue
@@ -1,45 +1,31 @@
diff --git a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionMigrateItem.vue b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionMigrateItem.vue
index dd1fb2d58e2..84ef6c2435a 100644
--- a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionMigrateItem.vue
+++ b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionMigrateItem.vue
@@ -3,63 +3,52 @@
v-tooltip="
selectedRefs.length > 0 &&
!isMigratable &&
- $t(
- isSingleAction
- ? 'this-vm-cant-be-migrated'
- : 'no-selected-vm-can-be-migrated'
- )
+ $t(isSingleAction ? 'this-vm-cant-be-migrated' : 'no-selected-vm-can-be-migrated')
"
:busy="isMigrating"
:disabled="isParentDisabled || !isMigratable"
:icon="faRoute"
@click="openModal()"
>
- {{ $t("migrate") }}
+ {{ $t('migrate') }}
diff --git a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionPowerStateItems.vue b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionPowerStateItems.vue
index aebff351337..275cb840fde 100644
--- a/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionPowerStateItems.vue
+++ b/@xen-orchestra/lite/src/components/vm/VmActionItems/VmActionPowerStateItems.vue
@@ -1,53 +1,26 @@
-
- {{ $t("start") }}
+
+ {{ $t('start') }}
-
- {{ $t("start-on-host") }}
+
+ {{ $t('start-on-host') }}
-
+
-
- {{ $t("pause") }}
+
+ {{ $t('pause') }}
-
- {{ $t("suspend") }}
+
+ {{ $t('suspend') }}
- {{ $t("resume") }}
+ {{ $t('resume') }}
- {{ $t("reboot") }}
+ {{ $t('reboot') }}
- {{ $t("force-reboot") }}
+ {{ $t('force-reboot') }}
- {{ $t("shutdown") }}
+ {{ $t('shutdown') }}
- {{ $t("force-shutdown") }}
+ {{ $t('force-shutdown') }}
diff --git a/@xen-orchestra/lite/src/components/vm/VmHeader.vue b/@xen-orchestra/lite/src/components/vm/VmHeader.vue
index 7f03f23f72b..93dd0c64bab 100644
--- a/@xen-orchestra/lite/src/components/vm/VmHeader.vue
+++ b/@xen-orchestra/lite/src/components/vm/VmHeader.vue
@@ -5,7 +5,7 @@
- {{ $t("change-state") }}
+ {{ $t('change-state') }}
@@ -14,15 +14,15 @@
@@ -35,35 +35,28 @@
";
- code = highlight(str, { language: "css" }).value;
- break;
+ openTag = ''
+ code = highlight(str, { language: 'css' }).value
+ break
}
- const openTagHtml = highlight(openTag, { language: "xml" }).value;
- const closeTagHtml = highlight(closeTag, { language: "xml" }).value;
+ const openTagHtml = highlight(openTag, { language: 'xml' }).value
+ const closeTagHtml = highlight(closeTag, { language: 'xml' }).value
- return `${openTagHtml}${copyable(code)}${closeTagHtml}`;
+ return `${openTagHtml}${copyable(code)}${closeTagHtml}`
}
function copyable(code: string) {
- return `${code}
`;
+ return `${code}
`
}
-export default marked;
+export default marked
diff --git a/@xen-orchestra/lite/src/libs/mixin.ts b/@xen-orchestra/lite/src/libs/mixin.ts
index fdf47517259..1e0a2cd7f31 100644
--- a/@xen-orchestra/lite/src/libs/mixin.ts
+++ b/@xen-orchestra/lite/src/libs/mixin.ts
@@ -1,19 +1,13 @@
-type UnionToIntersection = (T extends any ? (x: T) => any : never) extends (
- x: infer R
-) => any
- ? R
- : never;
+type UnionToIntersection = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never
-export type MixinConstructor = new (...args: any[]) => T;
+export type MixinConstructor = new (...args: any[]) => T
-export type MixinAbstractConstructor = abstract new (
- ...args: any[]
-) => T;
+export type MixinAbstractConstructor = abstract new (...args: any[]) => T
export type MixinFunction<
T extends MixinConstructor | MixinAbstractConstructor = MixinConstructor,
R extends T = T & MixinConstructor,
-> = (Base: T) => R;
+> = (Base: T) => R
export type MixinReturnValue<
T extends MixinConstructor | MixinAbstractConstructor,
@@ -21,16 +15,13 @@ export type MixinReturnValue<
> = UnionToIntersection<
| T
| {
- [K in keyof M]: M[K] extends MixinFunction ? U : never;
+ [K in keyof M]: M[K] extends MixinFunction ? U : never
}[number]
->;
+>
-export default function mixin<
- T extends MixinConstructor | MixinAbstractConstructor,
- M extends MixinFunction[],
->(Base: T, ...mixins: M): MixinReturnValue {
- return mixins.reduce(
- (mix, applyMixin) => applyMixin(mix),
- Base
- ) as MixinReturnValue;
+export default function mixin[]>(
+ Base: T,
+ ...mixins: M
+): MixinReturnValue {
+ return mixins.reduce((mix, applyMixin) => applyMixin(mix), Base) as MixinReturnValue
}
diff --git a/@xen-orchestra/lite/src/libs/story/story-param.ts b/@xen-orchestra/lite/src/libs/story/story-param.ts
index e572ca35839..b32f79f6580 100644
--- a/@xen-orchestra/lite/src/libs/story/story-param.ts
+++ b/@xen-orchestra/lite/src/libs/story/story-param.ts
@@ -1,451 +1,425 @@
-import {
- faFloppyDisk,
- faRocket,
- faShip,
- faTrash,
-} from "@fortawesome/free-solid-svg-icons";
-import mixin, { type MixinAbstractConstructor } from "@/libs/mixin";
-import type { Widget } from "@/libs/story/story-widget";
-import {
- boolean,
- choice,
- number,
- object,
- text,
-} from "@/libs/story/story-widget";
+import { faFloppyDisk, faRocket, faShip, faTrash } from '@fortawesome/free-solid-svg-icons'
+import mixin, { type MixinAbstractConstructor } from '@/libs/mixin'
+import type { Widget } from '@/libs/story/story-widget'
+import { boolean, choice, number, object, text } from '@/libs/story/story-widget'
function WithType(Base: MixinAbstractConstructor) {
- abstract class WithType extends Base /*implements HasType*/ {
- #type: string | undefined;
+ abstract class WithType extends Base /* implements HasType */ {
+ #type: string | undefined
type(type: string) {
- this.#type = type;
+ this.#type = type
- return this;
+ return this
}
- abstract getTypeLabel(): string;
+ abstract getTypeLabel(): string
getType() {
- return this.#type;
+ return this.#type
}
}
- return WithType;
+ return WithType
}
function WithWidget(Base: MixinAbstractConstructor) {
- abstract class WithWidget extends Base /*implements HasWidget*/ {
- #widget: Widget | undefined;
+ abstract class WithWidget extends Base /* implements HasWidget */ {
+ #widget: Widget | undefined
- abstract guessWidget(): Widget | undefined;
+ abstract guessWidget(): Widget | undefined
widget(widget?: Widget): this {
- this.#widget = widget === undefined ? this.guessWidget() : widget;
+ this.#widget = widget === undefined ? this.guessWidget() : widget
- return this;
+ return this
}
getWidget() {
- return this.#widget;
+ return this.#widget
}
hasWidget() {
- return this.#widget !== undefined;
+ return this.#widget !== undefined
}
}
- return WithWidget;
+ return WithWidget
}
abstract class BaseParam {
- #help: string | undefined;
- readonly #name: string;
- #presetValue: any;
+ #help: string | undefined
+ readonly #name: string
+ #presetValue: any
- protected abstract getNamePrefix(): string;
+ protected abstract getNamePrefix(): string
- protected abstract getNameSuffix(): string;
+ protected abstract getNameSuffix(): string
constructor(name: string) {
- this.#name = name;
+ this.#name = name
}
get name() {
- return this.#name;
+ return this.#name
}
getFullName() {
- return `${this.getNamePrefix()}${this.name}${this.getNameSuffix()}`;
+ return `${this.getNamePrefix()}${this.name}${this.getNameSuffix()}`
}
help(help: string) {
- this.#help = help;
- return this;
+ this.#help = help
+ return this
}
getHelp() {
- return this.#help;
+ return this.#help
}
preset(presetValue: any) {
- this.#presetValue = presetValue;
- return this;
+ this.#presetValue = presetValue
+ return this
}
getPresetValue() {
- return this.#presetValue;
+ return this.#presetValue
}
}
export class PropParam extends mixin(BaseParam, WithWidget, WithType) {
- #isRequired = false;
- #defaultValue: any;
- #isVModel: boolean;
+ #isRequired = false
+ #defaultValue: any
+ #isVModel: boolean
constructor(name: string, isVModel = false) {
- super(name);
- this.#isVModel = isVModel;
+ super(name)
+ this.#isVModel = isVModel
}
isRequired() {
- return this.#isRequired;
+ return this.#isRequired
}
isVModel() {
- return this.#isVModel;
+ return this.#isVModel
}
getVModelDirective() {
- return this.name === "modelValue" ? "v-model" : `v-model:${this.name}`;
+ return this.name === 'modelValue' ? 'v-model' : `v-model:${this.name}`
}
getNamePrefix() {
- return this.getType() === "string" ? "" : ":";
+ return this.getType() === 'string' ? '' : ':'
}
getNameSuffix() {
- return this.isRequired() ? "" : "?";
+ return this.isRequired() ? '' : '?'
}
getTypeLabel() {
- const type = this.getType();
+ const type = this.getType()
if (type !== undefined) {
- return type;
+ return type
}
if (this.#isEnum) {
- return this.#enumItems.map((item) => JSON.stringify(item)).join(" | ");
+ return this.#enumItems.map(item => JSON.stringify(item)).join(' | ')
}
- const presetValue = this.getPresetValue();
+ const presetValue = this.getPresetValue()
if (presetValue !== undefined) {
- return typeof presetValue;
+ return typeof presetValue
}
- return "unknown";
+ return 'unknown'
}
guessWidget() {
if (this.#isEnum) {
- return choice(...this.#enumItems);
+ return choice(...this.#enumItems)
}
if (this.#isObject) {
- return object();
+ return object()
}
switch (this.getTypeLabel()) {
- case "boolean":
- return boolean();
- case "number":
- return number();
- case "string":
- return text();
+ case 'boolean':
+ return boolean()
+ case 'number':
+ return number()
+ case 'string':
+ return text()
}
}
required() {
- this.#isRequired = true;
- return this;
+ this.#isRequired = true
+ return this
}
default(defaultValue: any) {
- this.#defaultValue = defaultValue;
- return this;
+ this.#defaultValue = defaultValue
+ return this
}
getDefaultValue() {
- return this.#defaultValue;
+ return this.#defaultValue
}
bool() {
- return this.default(false).type("boolean");
+ return this.default(false).type('boolean')
}
num() {
- return this.type("number");
+ return this.type('number')
}
str() {
- return this.type("string");
+ return this.type('string')
}
- arr(type = "any") {
- return this.type(`${type}[]`);
+ arr(type = 'any') {
+ return this.type(`${type}[]`)
}
- #isEnum = false;
- #enumItems: any[] = [];
+ #isEnum = false
+ #enumItems: any[] = []
enum(...items: any[]) {
- this.#isEnum = true;
- this.#enumItems = items;
- return this;
+ this.#isEnum = true
+ this.#enumItems = items
+ return this
}
any() {
- return this.type("any");
+ return this.type('any')
}
- #isObject = false;
+ #isObject = false
- obj(type = "object") {
- this.#isObject = true;
- return this.type(type);
+ obj(type = 'object') {
+ this.#isObject = true
+ return this.type(type)
}
- #isUsingContext = false;
+ #isUsingContext = false
ctx() {
- this.#isUsingContext = true;
- return this;
+ this.#isUsingContext = true
+ return this
}
isUsingContext() {
- return this.#isUsingContext;
+ return this.#isUsingContext
}
}
export class EventParam extends mixin(BaseParam, WithType) {
- #args: Record = {};
- #returnType: string | undefined;
- readonly #isVModel: boolean;
+ #args: Record = {}
+ #returnType: string | undefined
+ readonly #isVModel: boolean
constructor(name: string, isVModel = false) {
- super(name);
- this.#isVModel = isVModel;
+ super(name)
+ this.#isVModel = isVModel
}
get name() {
if (this.isVModel()) {
- return `update:${super.name}`;
+ return `update:${super.name}`
}
- return super.name;
+ return super.name
}
get rawName() {
- return super.name;
+ return super.name
}
isVModel() {
- return this.#isVModel;
+ return this.#isVModel
}
getNamePrefix() {
- return "@";
+ return '@'
}
getNameSuffix() {
- return "";
+ return ''
}
args(args: Record) {
- this.#args = args;
- return this;
+ this.#args = args
+ return this
}
getArguments() {
- return this.#args;
+ return this.#args
}
return(returnType: string) {
- this.#returnType = returnType;
- return this;
+ this.#returnType = returnType
+ return this
}
getTypeLabel() {
- const type = this.getType();
+ const type = this.getType()
if (type !== undefined) {
- return type;
+ return type
}
- const args: string[] = [];
+ const args: string[] = []
Object.entries(this.#args).forEach(([name, type]) => {
- args.push(`${name}: ${type}`);
- });
+ args.push(`${name}: ${type}`)
+ })
- return `(${args.join(", ")}) => ${this.#returnType ?? "void"}`;
+ return `(${args.join(', ')}) => ${this.#returnType ?? 'void'}`
}
}
export class SlotParam extends BaseParam {
- #props: { name: string; type: string }[] = [];
+ #props: { name: string; type: string }[] = []
getNamePrefix() {
- return "#";
+ return '#'
}
getNameSuffix() {
- return "";
+ return ''
}
prop(name: string, type: string) {
- this.#props.push({ name, type });
- return this;
+ this.#props.push({ name, type })
+ return this
}
getPropsType() {
- return `{ ${this.#props
- .map((prop) => `${prop.name}: ${prop.type}`)
- .join(", ")} }`;
+ return `{ ${this.#props.map(prop => `${prop.name}: ${prop.type}`).join(', ')} }`
}
hasProps() {
- return this.#props.length > 0;
+ return this.#props.length > 0
}
get props() {
- return this.#props;
+ return this.#props
}
preset(): never {
- throw new Error("Cannot preset a slot");
+ throw new Error('Cannot preset a slot')
}
}
export class SettingParam extends mixin(BaseParam, WithWidget) {
getNamePrefix() {
- return "";
+ return ''
}
getNameSuffix() {
- return "";
+ return ''
}
guessWidget() {
- const type = typeof this.getPresetValue();
+ const type = typeof this.getPresetValue()
switch (type) {
- case "string":
- return text();
+ case 'string':
+ return text()
}
}
}
export class ModelParam extends BaseParam {
- readonly #prop: PropParam;
- readonly #event: EventParam;
+ readonly #prop: PropParam
+ readonly #event: EventParam
protected getNameSuffix() {
- return "";
+ return ''
}
protected getNamePrefix() {
- return "";
+ return ''
}
constructor(name: string) {
- super(name);
- this.#prop = new PropParam(name, true);
+ super(name)
+ this.#prop = new PropParam(name, true)
this.#event = new EventParam(name, true).args({
- value: "unknown",
- });
+ value: 'unknown',
+ })
}
prop(func: (param: PropParam) => void) {
- func(this.#prop);
- return this;
+ func(this.#prop)
+ return this
}
event(func: (param: EventParam) => void) {
- func(this.#event);
- return this;
+ func(this.#event)
+ return this
}
required() {
- this.#prop.required();
- return this;
+ this.#prop.required()
+ return this
}
type(type: string) {
- this.#prop.type(type);
- this.#event.args({ value: type });
- return this;
+ this.#prop.type(type)
+ this.#event.args({ value: type })
+ return this
}
preset(presetValue: any) {
- this.#prop.preset(presetValue);
- return this;
+ this.#prop.preset(presetValue)
+ return this
}
help(help: string) {
- this.#prop.help(help);
- return this;
+ this.#prop.help(help)
+ return this
}
getPropParam() {
- return this.#prop;
+ return this.#prop
}
getEventParam() {
- return this.#event;
+ return this.#event
}
}
-export type Param =
- | EventParam
- | PropParam
- | SlotParam
- | ModelParam
- | SettingParam;
-
-export const prop = (name: string) => new PropParam(name);
-export const event = (name: string) => new EventParam(name);
-export const slot = (name = "default") => new SlotParam(name);
-export const setting = (name: string) => new SettingParam(name);
-export const model = (name = "modelValue") => new ModelParam(name);
-
-export const isPropParam = (param: any): param is PropParam =>
- param instanceof PropParam;
-export const isSettingParam = (param: any): param is SettingParam =>
- param instanceof SettingParam;
-export const isEventParam = (param: any): param is EventParam =>
- param instanceof EventParam;
-export const isSlotParam = (param: any): param is SlotParam =>
- param instanceof SlotParam;
-export const isModelParam = (param: any): param is ModelParam =>
- param instanceof ModelParam;
-
-export const colorProp = (name = "color") =>
- prop(name)
- .enum("info", "success", "warning", "error")
- .default("info")
- .widget();
+export type Param = EventParam | PropParam | SlotParam | ModelParam | SettingParam
+
+export const prop = (name: string) => new PropParam(name)
+export const event = (name: string) => new EventParam(name)
+export const slot = (name = 'default') => new SlotParam(name)
+export const setting = (name: string) => new SettingParam(name)
+export const model = (name = 'modelValue') => new ModelParam(name)
+
+export const isPropParam = (param: any): param is PropParam => param instanceof PropParam
+export const isSettingParam = (param: any): param is SettingParam => param instanceof SettingParam
+export const isEventParam = (param: any): param is EventParam => param instanceof EventParam
+export const isSlotParam = (param: any): param is SlotParam => param instanceof SlotParam
+export const isModelParam = (param: any): param is ModelParam => param instanceof ModelParam
+
+export const colorProp = (name = 'color') =>
+ prop(name).enum('info', 'success', 'warning', 'error').default('info').widget()
-export const iconProp = (name = "icon") =>
+export const iconProp = (name = 'icon') =>
prop(name)
- .type("IconDefinition")
+ .type('IconDefinition')
.widget(
choice(
- { label: "Ship", value: faShip },
- { label: "Rocket", value: faRocket },
- { label: "Floppy", value: faFloppyDisk },
- { label: "Trash", value: faTrash }
+ { label: 'Ship', value: faShip },
+ { label: 'Rocket', value: faRocket },
+ { label: 'Floppy', value: faFloppyDisk },
+ { label: 'Trash', value: faTrash }
)
- );
+ )
diff --git a/@xen-orchestra/lite/src/libs/story/story-widget.ts b/@xen-orchestra/lite/src/libs/story/story-widget.ts
index 26a44535341..2f6de8e7aaa 100644
--- a/@xen-orchestra/lite/src/libs/story/story-widget.ts
+++ b/@xen-orchestra/lite/src/libs/story/story-widget.ts
@@ -1,110 +1,95 @@
-export type WidgetType =
- | "select"
- | "radio"
- | "boolean"
- | "text"
- | "object"
- | "static"
- | "number";
+export type WidgetType = 'select' | 'radio' | 'boolean' | 'text' | 'object' | 'static' | 'number'
export abstract class Widget {
- #type: WidgetType;
+ #type: WidgetType
protected constructor(type: WidgetType) {
- this.#type = type;
+ this.#type = type
}
get type() {
- return this.#type;
+ return this.#type
}
protected set type(type: WidgetType) {
- this.#type = type;
+ this.#type = type
}
}
const hasOwn = (obj: object, ...properties: PropertyKey[]) => {
- return properties.every((property) =>
- Object.prototype.hasOwnProperty.call(obj, property)
- );
-};
+ return properties.every(property => Object.prototype.hasOwnProperty.call(obj, property))
+}
class ChoiceWidget extends Widget {
- #choices: any[];
- #isEnum = false;
+ #choices: any[]
+ #isEnum = false
constructor(choices: any[]) {
- super("select");
- this.#choices = choices;
+ super('select')
+ this.#choices = choices
}
get choices(): { label: any; value: any }[] {
- return this.#choices.map((choice) => {
- if (hasOwn(choice, "label", "value")) {
- return choice;
+ return this.#choices.map(choice => {
+ if (hasOwn(choice, 'label', 'value')) {
+ return choice
}
- return { label: choice, value: choice };
- });
+ return { label: choice, value: choice }
+ })
}
enum() {
- this.#isEnum = true;
+ this.#isEnum = true
}
radio() {
- this.type = "radio";
- return this;
+ this.type = 'radio'
+ return this
}
}
class TextWidget extends Widget {
constructor() {
- super("text");
+ super('text')
}
}
class NumberWidget extends Widget {
constructor() {
- super("number");
+ super('number')
}
}
class BooleanWidget extends Widget {
constructor() {
- super("boolean");
+ super('boolean')
}
}
class ObjectWidget extends Widget {
constructor() {
- super("object");
+ super('object')
}
}
-export const choice = (...choices: any[]) => new ChoiceWidget(choices);
-export const text = () => new TextWidget();
-export const number = () => new NumberWidget();
-export const boolean = () => new BooleanWidget();
-export const object = () => new ObjectWidget();
+export const choice = (...choices: any[]) => new ChoiceWidget(choices)
+export const text = () => new TextWidget()
+export const number = () => new NumberWidget()
+export const boolean = () => new BooleanWidget()
+export const object = () => new ObjectWidget()
-export const isSelectWidget = (widget: Widget): widget is ChoiceWidget =>
- widget.type === "select";
+export const isSelectWidget = (widget: Widget): widget is ChoiceWidget => widget.type === 'select'
-export const isRadioWidget = (widget: Widget): widget is ChoiceWidget =>
- widget.type === "radio";
+export const isRadioWidget = (widget: Widget): widget is ChoiceWidget => widget.type === 'radio'
export const isChoiceWidget = (widget: Widget): widget is ChoiceWidget =>
- isSelectWidget(widget) || isRadioWidget(widget);
+ isSelectWidget(widget) || isRadioWidget(widget)
-export const isBooleanWidget = (widget: Widget): widget is BooleanWidget =>
- widget.type === "boolean";
+export const isBooleanWidget = (widget: Widget): widget is BooleanWidget => widget.type === 'boolean'
-export const isNumberWidget = (widget: Widget): widget is NumberWidget =>
- widget.type === "number";
+export const isNumberWidget = (widget: Widget): widget is NumberWidget => widget.type === 'number'
-export const isTextWidget = (widget: Widget): widget is TextWidget =>
- widget.type === "text";
+export const isTextWidget = (widget: Widget): widget is TextWidget => widget.type === 'text'
-export const isObjectWidget = (widget: Widget): widget is ObjectWidget =>
- widget.type === "object";
+export const isObjectWidget = (widget: Widget): widget is ObjectWidget => widget.type === 'object'
diff --git a/@xen-orchestra/lite/src/libs/utils.ts b/@xen-orchestra/lite/src/libs/utils.ts
index 1ce7d692183..a0a5abda76f 100644
--- a/@xen-orchestra/lite/src/libs/utils.ts
+++ b/@xen-orchestra/lite/src/libs/utils.ts
@@ -1,22 +1,19 @@
-import type { Filter } from "@/types/filter";
-import { faSquareCheck } from "@fortawesome/free-regular-svg-icons";
-import { faFont, faHashtag, faList } from "@fortawesome/free-solid-svg-icons";
-import { utcParse } from "d3-time-format";
-import humanFormat from "human-format";
-import { find, forEach, round, size, sum } from "lodash-es";
-
-export function sortRecordsByNameLabel(
- record1: { name_label: string },
- record2: { name_label: string }
-) {
- const label1 = record1.name_label.toLocaleLowerCase();
- const label2 = record2.name_label.toLocaleLowerCase();
-
- return label1.localeCompare(label2);
+import type { Filter } from '@/types/filter'
+import { faSquareCheck } from '@fortawesome/free-regular-svg-icons'
+import { faFont, faHashtag, faList } from '@fortawesome/free-solid-svg-icons'
+import { utcParse } from 'd3-time-format'
+import format from 'human-format'
+import { find, forEach, round, size, sum } from 'lodash-es'
+
+export function sortRecordsByNameLabel(record1: { name_label: string }, record2: { name_label: string }) {
+ const label1 = record1.name_label.toLocaleLowerCase()
+ const label2 = record2.name_label.toLocaleLowerCase()
+
+ return label1.localeCompare(label2)
}
export function escapeRegExp(string: string) {
- return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
}
const iconsByType = {
@@ -24,86 +21,79 @@ const iconsByType = {
number: faHashtag,
boolean: faSquareCheck,
enum: faList,
-};
+}
export function formatSize(bytes: number) {
- return bytes != null
- ? humanFormat(bytes, { scale: "binary", unit: "B" })
- : "N/D";
+ return bytes != null ? format(bytes, { scale: 'binary', unit: 'B' }) : 'N/D'
}
export function getFilterIcon(filter: Filter | undefined) {
if (!filter) {
- return;
+ return
}
if (filter.icon) {
- return filter.icon;
+ return filter.icon
}
- return iconsByType[filter.type];
+ return iconsByType[filter.type]
}
export function parseDateTime(dateTime: Date | string | number): number {
- if (typeof dateTime === "number") {
- return dateTime;
+ if (typeof dateTime === 'number') {
+ return dateTime
}
if (dateTime instanceof Date) {
- return dateTime.getTime();
+ return dateTime.getTime()
}
- dateTime = dateTime.replace(/(-|\.\d{3})/g, ""); // Allow toISOString() date-time format
- const date = utcParse("%Y%m%dT%H:%M:%SZ")(dateTime);
+ dateTime = dateTime.replace(/(-|\.\d{3})/g, '') // Allow toISOString() date-time format
+ const date = utcParse('%Y%m%dT%H:%M:%SZ')(dateTime)
if (date === null) {
- throw new RangeError(
- `unable to parse XAPI datetime ${JSON.stringify(dateTime)}`
- );
+ throw new RangeError(`unable to parse XAPI datetime ${JSON.stringify(dateTime)}`)
}
- return date.getTime();
+ return date.getTime()
}
-export const hasEllipsis = (
- target: Element | undefined | null,
- { vertical = false }: { vertical?: boolean } = {}
-) => {
+export const hasEllipsis = (target: Element | undefined | null, { vertical = false }: { vertical?: boolean } = {}) => {
if (target == null) {
- return false;
+ return false
}
if (vertical) {
- return target.clientHeight < target.scrollHeight;
+ return target.clientHeight < target.scrollHeight
}
- return target.clientWidth < target.scrollWidth;
-};
+ return target.clientWidth < target.scrollWidth
+}
export function percent(currentValue: number, maxValue: number, precision = 2) {
- return round((currentValue / maxValue) * 100, precision);
+ return round((currentValue / maxValue) * 100, precision)
}
export function getAvgCpuUsage(cpus?: object | any[], { nSequence = 4 } = {}) {
- const statsLength = getStatsLength(cpus);
+ const statsLength = getStatsLength(cpus)
if (statsLength === undefined) {
- return;
+ return
}
- const _nSequence = statsLength < nSequence ? statsLength : nSequence;
+ const _nSequence = statsLength < nSequence ? statsLength : nSequence
- let totalCpusUsage = 0;
+ let totalCpusUsage = 0
forEach(cpus, (cpuState: number[]) => {
- totalCpusUsage += sum(cpuState.slice(cpuState.length - _nSequence));
- });
- const stackedValue = totalCpusUsage / _nSequence;
- return stackedValue / size(cpus);
+ totalCpusUsage += sum(cpuState.slice(cpuState.length - _nSequence))
+ })
+ const stackedValue = totalCpusUsage / _nSequence
+ return stackedValue / size(cpus)
}
// stats can be null.
// Return the size of the first non-null object.
export function getStatsLength(stats?: object | any[]) {
if (stats === undefined) {
- return undefined;
+ return undefined
}
- return size(find(stats, (stat) => stat != null));
+ return size(find(stats, stat => stat != null))
}
export function parseRamUsage(
@@ -111,34 +101,32 @@ export function parseRamUsage(
memory,
memoryFree,
}: {
- memory: number[];
- memoryFree?: number[];
+ memory: number[]
+ memoryFree?: number[]
},
{ nSequence = 4 } = {}
) {
- const _nSequence = Math.min(memory.length, nSequence);
+ const _nSequence = Math.min(memory.length, nSequence)
- let total = 0;
- let used = 0;
+ let total = 0
+ let used = 0
- memory = memory.slice(memory.length - _nSequence);
- memoryFree = memoryFree?.slice(memoryFree.length - _nSequence);
+ memory = memory.slice(memory.length - _nSequence)
+ memoryFree = memoryFree?.slice(memoryFree.length - _nSequence)
memory.forEach((ram, key) => {
- total += ram;
- used += ram - (memoryFree?.[key] ?? 0);
- });
+ total += ram
+ used += ram - (memoryFree?.[key] ?? 0)
+ })
- const percentUsed = percent(used, total);
+ const percentUsed = percent(used, total)
return {
// In case `memoryFree` is not given by the xapi,
// we won't be able to calculate the percentage of used memory properly.
- percentUsed:
- memoryFree === undefined || isNaN(percentUsed) ? 0 : percentUsed,
+ percentUsed: memoryFree === undefined || isNaN(percentUsed) ? 0 : percentUsed,
total: total / _nSequence,
used: memoryFree === undefined ? 0 : used / _nSequence,
- };
+ }
}
-export const getFirst = (value: T | T[]): T | undefined =>
- Array.isArray(value) ? value[0] : value;
+export const getFirst = (value: T | T[]): T | undefined => (Array.isArray(value) ? value[0] : value)
diff --git a/@xen-orchestra/lite/src/libs/vm.ts b/@xen-orchestra/lite/src/libs/vm.ts
index d4d039fb925..003e8f4d844 100644
--- a/@xen-orchestra/lite/src/libs/vm.ts
+++ b/@xen-orchestra/lite/src/libs/vm.ts
@@ -1,41 +1,36 @@
-import { saveAs } from "file-saver";
-import type { XenApiVm } from "@/libs/xen-api/xen-api.types";
+import { saveAs } from 'file-saver'
+import type { XenApiVm } from '@/libs/xen-api/xen-api.types'
function stringifyCsvValue(value: any) {
- let res = "";
+ let res = ''
if (Array.isArray(value)) {
- res = value.join(";");
- } else if (typeof value === "object") {
- res = JSON.stringify(value);
+ res = value.join(';')
+ } else if (typeof value === 'object') {
+ res = JSON.stringify(value)
} else {
- res = String(value);
+ res = String(value)
}
- return `"${res.replace(/"/g, '""')}"`;
+ return `"${res.replace(/"/g, '""')}"`
}
export function exportVmsAsCsvFile(vms: XenApiVm[], fileName: string) {
- const csvHeaders = Object.keys(vms[0]);
+ const csvHeaders = Object.keys(vms[0])
- const csvRows = vms.map((vm) =>
- csvHeaders.map((header) => stringifyCsvValue(vm[header as keyof XenApiVm]))
- );
+ const csvRows = vms.map(vm => csvHeaders.map(header => stringifyCsvValue(vm[header as keyof XenApiVm])))
saveAs(
- new Blob(
- [[csvHeaders, ...csvRows].map((row) => row.join(",")).join("\n")],
- {
- type: "text/csv;charset=utf-8",
- }
- ),
+ new Blob([[csvHeaders, ...csvRows].map(row => row.join(',')).join('\n')], {
+ type: 'text/csv;charset=utf-8',
+ }),
fileName
- );
+ )
}
export function exportVmsAsJsonFile(vms: XenApiVm[], fileName: string) {
saveAs(
new Blob([JSON.stringify(vms, null, 2)], {
- type: "application/json",
+ type: 'application/json',
}),
fileName
- );
+ )
}
diff --git a/@xen-orchestra/lite/src/libs/xapi-stats.ts b/@xen-orchestra/lite/src/libs/xapi-stats.ts
index f8c3b8e688e..6069cd1a3dc 100644
--- a/@xen-orchestra/lite/src/libs/xapi-stats.ts
+++ b/@xen-orchestra/lite/src/libs/xapi-stats.ts
@@ -1,10 +1,11 @@
-import { synchronized } from "decorator-synchronized";
-import JSON5 from "json5";
-import { limitConcurrency } from "limit-concurrency-decorator";
-import { defaults, findKey, forEach, identity, map } from "lodash-es";
-import { BaseError } from "make-error";
-import type XenApi from "@/libs/xen-api/xen-api";
-import type { XenApiHost } from "@/libs/xen-api/xen-api.types";
+import type XenApi from '@/libs/xen-api/xen-api'
+import type { XenApiHost } from '@/libs/xen-api/xen-api.types'
+import { synchronized } from 'decorator-synchronized'
+// eslint-disable-next-line import/default -- https://github.com/json5/json5/issues/287
+import JSON5 from 'json5'
+import { limitConcurrency } from 'limit-concurrency-decorator'
+import { defaults, findKey, forEach, identity, map } from 'lodash-es'
+import { BaseError } from 'make-error'
class FaultyGranularity extends BaseError {}
@@ -24,10 +25,10 @@ enum RRD_STEP {
}
export enum GRANULARITY {
- Seconds = "seconds",
- Minutes = "minutes",
- Hours = "hours",
- Days = "days",
+ Seconds = 'seconds',
+ Minutes = 'minutes',
+ Hours = 'hours',
+ Days = 'days',
}
export const RRD_STEP_FROM_STRING: { [key in GRANULARITY]: RRD_STEP } = {
@@ -35,7 +36,7 @@ export const RRD_STEP_FROM_STRING: { [key in GRANULARITY]: RRD_STEP } = {
[GRANULARITY.Minutes]: RRD_STEP.Minutes,
[GRANULARITY.Hours]: RRD_STEP.Hours,
[GRANULARITY.Days]: RRD_STEP.Days,
-};
+}
// points = intervalInSeconds / step
const RRD_POINTS_PER_STEP: { [key in RRD_STEP]: number } = {
@@ -43,69 +44,52 @@ const RRD_POINTS_PER_STEP: { [key in RRD_STEP]: number } = {
[RRD_STEP.Minutes]: 120,
[RRD_STEP.Hours]: 168,
[RRD_STEP.Days]: 366,
-};
+}
// -------------------------------------------------------------------
// Utils
// -------------------------------------------------------------------
function convertNanToNull(value: number) {
- return isNaN(value) ? null : value;
+ return isNaN(value) ? null : value
}
// -------------------------------------------------------------------
// Stats
// -------------------------------------------------------------------
-const computeValues = (
- dataRow: any,
- legendIndex: number,
- transformValue = identity
-) =>
- map(dataRow, ({ values }) =>
- transformValue(convertNanToNull(values[legendIndex]))
- );
-
-const createGetProperty = (
- obj: object,
- property: string,
- defaultValue: unknown
-) => defaults(obj, { [property]: defaultValue })[property] as any;
+const computeValues = (dataRow: any, legendIndex: number, transformValue = identity) =>
+ map(dataRow, ({ values }) => transformValue(convertNanToNull(values[legendIndex])))
+
+const createGetProperty = (obj: object, property: string, defaultValue: unknown) =>
+ defaults(obj, { [property]: defaultValue })[property] as any
const testMetric = (
- test:
- | string
- | { exec: (type: string) => boolean }
- | { (type: string): boolean },
+ test: string | { exec: (type: string) => boolean } | { (type: string): boolean },
type: string
-): boolean =>
- typeof test === "string"
- ? test === type
- : typeof test === "function"
- ? test(type)
- : test.exec(type);
+): boolean => (typeof test === 'string' ? test === type : typeof test === 'function' ? test(type) : test.exec(type))
const findMetric = (metrics: any, metricType: string) => {
- let testResult;
- let metric;
+ let testResult
+ let metric
- forEach(metrics, (current) => {
+ forEach(metrics, current => {
if (current.test === undefined) {
- const newValues = findMetric(current, metricType);
+ const newValues = findMetric(current, metricType)
- metric = newValues.metric;
+ metric = newValues.metric
if (metric !== undefined) {
- testResult = newValues.testResult;
- return false;
+ testResult = newValues.testResult
+ return false
}
} else if ((testResult = testMetric(current.test, metricType))) {
- metric = current;
- return false;
+ metric = current
+ return false
}
- });
+ })
- return { metric, testResult };
-};
+ return { metric, testResult }
+}
// -------------------------------------------------------------------
@@ -116,115 +100,115 @@ const findMetric = (metrics: any, metricType: string) => {
const STATS: { [key: string]: object } = {
host: {
load: {
- test: "loadavg",
+ test: 'loadavg',
},
memoryFree: {
- test: "memory_free_kib",
+ test: 'memory_free_kib',
transformValue: (value: number) => value * 1024,
},
memory: {
- test: "memory_total_kib",
+ test: 'memory_total_kib',
transformValue: (value: number) => value * 1024,
},
cpus: {
test: /^cpu(\d+)$/,
- getPath: (matches: any) => ["cpus", matches[1]],
+ getPath: (matches: any) => ['cpus', matches[1]],
transformValue: (value: number) => value * 1e2,
},
pifs: {
rx: {
test: /^pif_eth(\d+)_rx$/,
- getPath: (matches: unknown[]) => ["pifs", "rx", matches[1]],
+ getPath: (matches: unknown[]) => ['pifs', 'rx', matches[1]],
},
tx: {
test: /^pif_eth(\d+)_tx$/,
- getPath: (matches: unknown[]) => ["pifs", "tx", matches[1]],
+ getPath: (matches: unknown[]) => ['pifs', 'tx', matches[1]],
},
},
iops: {
r: {
test: /^iops_read_(\w+)$/,
- getPath: (matches: unknown[]) => ["iops", "r", matches[1]],
+ getPath: (matches: unknown[]) => ['iops', 'r', matches[1]],
},
w: {
test: /^iops_write_(\w+)$/,
- getPath: (matches: unknown[]) => ["iops", "w", matches[1]],
+ getPath: (matches: unknown[]) => ['iops', 'w', matches[1]],
},
},
ioThroughput: {
r: {
test: /^io_throughput_read_(\w+)$/,
- getPath: (matches: unknown[]) => ["ioThroughput", "r", matches[1]],
+ getPath: (matches: unknown[]) => ['ioThroughput', 'r', matches[1]],
transformValue: (value: number) => value * 2 ** 20,
},
w: {
test: /^io_throughput_write_(\w+)$/,
- getPath: (matches: unknown[]) => ["ioThroughput", "w", matches[1]],
+ getPath: (matches: unknown[]) => ['ioThroughput', 'w', matches[1]],
transformValue: (value: number) => value * 2 ** 20,
},
},
latency: {
r: {
test: /^read_latency_(\w+)$/,
- getPath: (matches: unknown[]) => ["latency", "r", matches[1]],
+ getPath: (matches: unknown[]) => ['latency', 'r', matches[1]],
transformValue: (value: number) => value / 1e3,
},
w: {
test: /^write_latency_(\w+)$/,
- getPath: (matches: unknown[]) => ["latency", "w", matches[1]],
+ getPath: (matches: unknown[]) => ['latency', 'w', matches[1]],
transformValue: (value: number) => value / 1e3,
},
},
iowait: {
test: /^iowait_(\w+)$/,
- getPath: (matches: unknown[]) => ["iowait", matches[1]],
+ getPath: (matches: unknown[]) => ['iowait', matches[1]],
},
},
vm: {
memoryFree: {
- test: "memory_internal_free",
+ test: 'memory_internal_free',
transformValue: (value: number) => value * 1024,
},
memory: {
- test: (metricType: string) => metricType.endsWith("memory"),
+ test: (metricType: string) => metricType.endsWith('memory'),
},
cpus: {
test: /^cpu(\d+)$/,
- getPath: (matches: unknown[]) => ["cpus", matches[1]],
+ getPath: (matches: unknown[]) => ['cpus', matches[1]],
transformValue: (value: number) => value * 1e2,
},
vifs: {
rx: {
test: /^vif_(\d+)_rx$/,
- getPath: (matches: unknown[]) => ["vifs", "rx", matches[1]],
+ getPath: (matches: unknown[]) => ['vifs', 'rx', matches[1]],
},
tx: {
test: /^vif_(\d+)_tx$/,
- getPath: (matches: unknown[]) => ["vifs", "tx", matches[1]],
+ getPath: (matches: unknown[]) => ['vifs', 'tx', matches[1]],
},
},
xvds: {
r: {
test: /^vbd_xvd(.)_read$/,
- getPath: (matches: unknown[]) => ["xvds", "r", matches[1]],
+ getPath: (matches: unknown[]) => ['xvds', 'r', matches[1]],
},
w: {
test: /^vbd_xvd(.)_write$/,
- getPath: (matches: unknown[]) => ["xvds", "w", matches[1]],
+ getPath: (matches: unknown[]) => ['xvds', 'w', matches[1]],
},
},
iops: {
r: {
test: /^vbd_xvd(.)_iops_read$/,
- getPath: (matches: unknown[]) => ["iops", "r", matches[1]],
+ getPath: (matches: unknown[]) => ['iops', 'r', matches[1]],
},
w: {
test: /^vbd_xvd(.)_iops_write$/,
- getPath: (matches: unknown[]) => ["iops", "w", matches[1]],
+ getPath: (matches: unknown[]) => ['iops', 'w', matches[1]],
},
},
},
-};
+}
// -------------------------------------------------------------------
@@ -253,66 +237,66 @@ const STATS: { [key: string]: object } = {
// }
export type VmStats = {
- cpus: Record;
+ cpus: Record
iops: {
- r: Record;
- w: Record;
- };
- memory: number[];
- memoryFree?: number[];
+ r: Record
+ w: Record
+ }
+ memory: number[]
+ memoryFree?: number[]
vifs: {
- rx: Record;
- tx: Record;
- };
+ rx: Record
+ tx: Record
+ }
xvds: {
- w: Record;
- r: Record;
- };
-};
+ w: Record
+ r: Record
+ }
+}
export type HostStats = {
- cpus: Record;
+ cpus: Record
ioThroughput: {
- r: Record;
- w: Record;
- };
+ r: Record
+ w: Record
+ }
iops: {
- r: Record;
- w: Record;
- };
- iowait: Record;
+ r: Record
+ w: Record
+ }
+ iowait: Record
latency: {
- r: Record;
- w: Record;
- };
- load: number[];
- memory: number[];
- memoryFree: number[];
+ r: Record
+ w: Record
+ }
+ load: number[]
+ memory: number[]
+ memoryFree: number[]
pifs: {
- rx: Record;
- tx: Record;
- };
-};
+ rx: Record
+ tx: Record
+ }
+}
export type XapiStatsResponse = {
- canBeExpired: boolean;
- endTimestamp: number;
- interval: number;
- stats: T;
-};
+ canBeExpired: boolean
+ endTimestamp: number
+ interval: number
+ stats: T
+}
type StatsByObject = {
[uuid: string]: {
- [step: string]: XapiStatsResponse;
- };
-};
+ [step: string]: XapiStatsResponse
+ }
+}
export default class XapiStats {
- #xapi;
- #statsByObject: StatsByObject = {};
- #cachedStatsByObject: StatsByObject = {};
+ #xapi
+ #statsByObject: StatsByObject = {}
+ #cachedStatsByObject: StatsByObject = {}
constructor(xapi: XenApi) {
- this.#xapi = xapi;
+ this.#xapi = xapi
}
// Execute one http request on a XenServer for get stats
@@ -324,45 +308,41 @@ export default class XapiStats {
step: RRD_STEP,
{ abortSignal }: { abortSignal?: AbortSignal } = {}
) {
- const resp = await this.#xapi.getResource("/rrd_updates", {
+ const resp = await this.#xapi.getResource('/rrd_updates', {
host,
query: {
- cf: "AVERAGE",
- host: "true",
+ cf: 'AVERAGE',
+ host: 'true',
interval: step,
- json: "true",
+ json: 'true',
start: timestamp,
},
abortSignal,
- });
- return JSON5.parse(await resp.text());
+ })
+ // eslint-disable-next-line import/no-named-as-default-member -- https://github.com/json5/json5/issues/287
+ return JSON5.parse(await resp.text())
}
// To avoid multiple requests, we keep a cache for the stats and
// only return it if we not exceed a step
- #getCachedStats(
- uuid: string,
- step: RRD_STEP,
- currentTimeStamp: number,
- ignoreExpired = false
- ) {
+ #getCachedStats(uuid: string, step: RRD_STEP, currentTimeStamp: number, ignoreExpired = false) {
if (ignoreExpired) {
- return this.#cachedStatsByObject[uuid]?.[step];
+ return this.#cachedStatsByObject[uuid]?.[step]
}
- const statsByObject = this.#statsByObject;
+ const statsByObject = this.#statsByObject
- const stats = statsByObject[uuid]?.[step];
+ const stats = statsByObject[uuid]?.[step]
if (stats === undefined) {
- return;
+ return
}
if (stats.endTimestamp + step < currentTimeStamp) {
- delete statsByObject[uuid][step];
- return;
+ delete statsByObject[uuid][step]
+ return
}
- return stats;
+ return stats
}
@synchronized.withKey(({ host }: { host: XenApiHost }) => host.uuid)
@@ -373,145 +353,107 @@ export default class XapiStats {
uuid,
granularity,
}: {
- abortSignal?: AbortSignal;
- host: XenApiHost;
- ignoreExpired?: boolean;
- uuid: any;
- granularity: GRANULARITY;
+ abortSignal?: AbortSignal
+ host: XenApiHost
+ ignoreExpired?: boolean
+ uuid: any
+ granularity: GRANULARITY
}) {
- const step =
- granularity === undefined
- ? RRD_STEP.Seconds
- : RRD_STEP_FROM_STRING[granularity];
+ const step = granularity === undefined ? RRD_STEP.Seconds : RRD_STEP_FROM_STRING[granularity]
if (step === undefined) {
throw new FaultyGranularity(
`Unknown granularity: '${granularity}'. Use 'seconds', 'minutes', 'hours', or 'days'.`
- );
+ )
}
- const currentTimeStamp = Math.floor(new Date().getTime() / 1000);
+ const currentTimeStamp = Math.floor(new Date().getTime() / 1000)
- const stats = this.#getCachedStats(
- uuid,
- step,
- currentTimeStamp,
- ignoreExpired
- ) as XapiStatsResponse;
+ const stats = this.#getCachedStats(uuid, step, currentTimeStamp, ignoreExpired) as XapiStatsResponse
if (stats !== undefined) {
- return stats;
+ return stats
}
- const maxDuration = step * RRD_POINTS_PER_STEP[step];
+ const maxDuration = step * RRD_POINTS_PER_STEP[step]
// To avoid crossing over the boundary, we ask for one less step
- const optimumTimestamp = currentTimeStamp - maxDuration + step;
+ const optimumTimestamp = currentTimeStamp - maxDuration + step
try {
const json = await this._getJson(host, optimumTimestamp, step, {
abortSignal,
- });
+ })
- const actualStep = json.meta.step as number;
+ const actualStep = json.meta.step as number
if (json.data.length > 0) {
// fetched data is organized from the newest to the oldest
// but this implementation requires it in the other direction
- json.data.reverse();
+ json.data.reverse()
json.meta.legend.forEach((legend: any, index: number) => {
- const [, type, uuid, metricType] = /^AVERAGE:([^:]+):(.+):(.+)$/.exec(
- legend
- ) as any;
+ const [, type, uuid, metricType] = /^AVERAGE:([^:]+):(.+):(.+)$/.exec(legend) as any
- const metrics = STATS[type] as any;
+ const metrics = STATS[type] as any
if (metrics === undefined) {
- return;
+ return
}
- const { metric, testResult } = findMetric(metrics, metricType) as any;
+ const { metric, testResult } = findMetric(metrics, metricType) as any
if (metric === undefined) {
- return;
+ return
}
- const xoObjectStats = createGetProperty(
- this.#statsByObject,
- uuid,
- {}
- );
- const cacheXoObjectStats = createGetProperty(
- this.#cachedStatsByObject,
- uuid,
- {}
- );
-
- let stepStats = xoObjectStats[actualStep];
- let cacheStepStats = cacheXoObjectStats[actualStep];
- if (
- stepStats === undefined ||
- stepStats.endTimestamp !== json.meta.end
- ) {
+ const xoObjectStats = createGetProperty(this.#statsByObject, uuid, {})
+ const cacheXoObjectStats = createGetProperty(this.#cachedStatsByObject, uuid, {})
+
+ let stepStats = xoObjectStats[actualStep]
+ let cacheStepStats = cacheXoObjectStats[actualStep]
+ if (stepStats === undefined || stepStats.endTimestamp !== json.meta.end) {
stepStats = xoObjectStats[actualStep] = {
endTimestamp: json.meta.end,
interval: actualStep,
canBeExpired: false,
- };
+ }
cacheStepStats = cacheXoObjectStats[actualStep] = {
endTimestamp: json.meta.end,
interval: actualStep,
canBeExpired: true,
- };
+ }
}
- const path =
- metric.getPath !== undefined
- ? metric.getPath(testResult)
- : [findKey(metrics, metric)];
+ const path = metric.getPath !== undefined ? metric.getPath(testResult) : [findKey(metrics, metric)]
- const lastKey = path.length - 1;
- let metricStats = createGetProperty(stepStats, "stats", {});
- let cacheMetricStats = createGetProperty(cacheStepStats, "stats", {});
+ const lastKey = path.length - 1
+ let metricStats = createGetProperty(stepStats, 'stats', {})
+ let cacheMetricStats = createGetProperty(cacheStepStats, 'stats', {})
path.forEach((property: any, key: number) => {
if (key === lastKey) {
- metricStats[property] = computeValues(
- json.data,
- index,
- metric.transformValue
- );
- cacheMetricStats[property] = computeValues(
- json.data,
- index,
- metric.transformValue
- );
- return;
+ metricStats[property] = computeValues(json.data, index, metric.transformValue)
+ cacheMetricStats[property] = computeValues(json.data, index, metric.transformValue)
+ return
}
- metricStats = createGetProperty(metricStats, property, {});
- cacheMetricStats = createGetProperty(
- cacheMetricStats,
- property,
- {}
- );
- });
- });
+ metricStats = createGetProperty(metricStats, property, {})
+ cacheMetricStats = createGetProperty(cacheMetricStats, property, {})
+ })
+ })
}
if (actualStep !== step) {
- throw new FaultyGranularity(
- `Unable to get the true granularity: ${actualStep}`
- );
+ throw new FaultyGranularity(`Unable to get the true granularity: ${actualStep}`)
}
} catch (error) {
- if (error instanceof Error && error.name === "AbortError") {
- return;
+ if (error instanceof Error && error.name === 'AbortError') {
+ return
}
- throw error;
+ throw error
}
return (this.#statsByObject[uuid]?.[step] ?? {
endTimestamp: currentTimeStamp,
interval: step,
stats: {},
- }) as XapiStatsResponse;
+ }) as XapiStatsResponse
}
}
diff --git a/@xen-orchestra/lite/src/libs/xen-api/xen-api.enums.ts b/@xen-orchestra/lite/src/libs/xen-api/xen-api.enums.ts
index 0a2f286001d..7b2dea9b32a 100644
--- a/@xen-orchestra/lite/src/libs/xen-api/xen-api.enums.ts
+++ b/@xen-orchestra/lite/src/libs/xen-api/xen-api.enums.ts
@@ -1,499 +1,499 @@
export enum TASK_ALLOWED_OPERATION {
- CANCEL = "cancel",
- DESTROY = "destroy",
+ CANCEL = 'cancel',
+ DESTROY = 'destroy',
}
export enum TASK_STATUS_TYPE {
- CANCELLED = "cancelled",
- CANCELLING = "cancelling",
- FAILURE = "failure",
- PENDING = "pending",
- SUCCESS = "success",
+ CANCELLED = 'cancelled',
+ CANCELLING = 'cancelling',
+ FAILURE = 'failure',
+ PENDING = 'pending',
+ SUCCESS = 'success',
}
export enum EVENT_OPERATION {
- ADD = "add",
- DEL = "del",
- MOD = "mod",
+ ADD = 'add',
+ DEL = 'del',
+ MOD = 'mod',
}
export enum POOL_ALLOWED_OPERATION {
- APPLY_UPDATES = "apply_updates",
- CERT_REFRESH = "cert_refresh",
- CLUSTER_CREATE = "cluster_create",
- CONFIGURE_REPOSITORIES = "configure_repositories",
- COPY_PRIMARY_HOST_CERTS = "copy_primary_host_certs",
- DESIGNATE_NEW_MASTER = "designate_new_master",
- EXCHANGE_CA_CERTIFICATES_ON_JOIN = "exchange_ca_certificates_on_join",
- EXCHANGE_CERTIFICATES_ON_JOIN = "exchange_certificates_on_join",
- GET_UPDATES = "get_updates",
- HA_DISABLE = "ha_disable",
- HA_ENABLE = "ha_enable",
- SYNC_UPDATES = "sync_updates",
- TLS_VERIFICATION_ENABLE = "tls_verification_enable",
+ APPLY_UPDATES = 'apply_updates',
+ CERT_REFRESH = 'cert_refresh',
+ CLUSTER_CREATE = 'cluster_create',
+ CONFIGURE_REPOSITORIES = 'configure_repositories',
+ COPY_PRIMARY_HOST_CERTS = 'copy_primary_host_certs',
+ DESIGNATE_NEW_MASTER = 'designate_new_master',
+ EXCHANGE_CA_CERTIFICATES_ON_JOIN = 'exchange_ca_certificates_on_join',
+ EXCHANGE_CERTIFICATES_ON_JOIN = 'exchange_certificates_on_join',
+ GET_UPDATES = 'get_updates',
+ HA_DISABLE = 'ha_disable',
+ HA_ENABLE = 'ha_enable',
+ SYNC_UPDATES = 'sync_updates',
+ TLS_VERIFICATION_ENABLE = 'tls_verification_enable',
}
export enum TELEMETRY_FREQUENCY {
- DAILY = "daily",
- MONTHLY = "monthly",
- WEEKLY = "weekly",
+ DAILY = 'daily',
+ MONTHLY = 'monthly',
+ WEEKLY = 'weekly',
}
export enum UPDATE_SYNC_FREQUENCY {
- DAILY = "daily",
- WEEKLY = "weekly",
+ DAILY = 'daily',
+ WEEKLY = 'weekly',
}
export enum AFTER_APPLY_GUIDANCE {
- RESTART_HOST = "restartHost",
- RESTART_HVM = "restartHVM",
- RESTART_PV = "restartPV",
- RESTART_XAPI = "restartXAPI",
+ RESTART_HOST = 'restartHost',
+ RESTART_HVM = 'restartHVM',
+ RESTART_PV = 'restartPV',
+ RESTART_XAPI = 'restartXAPI',
}
export enum UPDATE_AFTER_APPLY_GUIDANCE {
- RESTART_HOST = "restartHost",
- RESTART_HVM = "restartHVM",
- RESTART_PV = "restartPV",
- RESTART_XAPI = "restartXAPI",
+ RESTART_HOST = 'restartHost',
+ RESTART_HVM = 'restartHVM',
+ RESTART_PV = 'restartPV',
+ RESTART_XAPI = 'restartXAPI',
}
export enum LIVEPATCH_STATUS {
- OK = "ok",
- OK_LIVEPATCH_COMPLETE = "ok_livepatch_complete",
- OK_LIVEPATCH_INCOMPLETE = "ok_livepatch_incomplete",
+ OK = 'ok',
+ OK_LIVEPATCH_COMPLETE = 'ok_livepatch_complete',
+ OK_LIVEPATCH_INCOMPLETE = 'ok_livepatch_incomplete',
}
export enum VM_POWER_STATE {
- HALTED = "Halted",
- PAUSED = "Paused",
- RUNNING = "Running",
- SUSPENDED = "Suspended",
+ HALTED = 'Halted',
+ PAUSED = 'Paused',
+ RUNNING = 'Running',
+ SUSPENDED = 'Suspended',
}
export enum UPDATE_GUIDANCE {
- REBOOT_HOST = "reboot_host",
- REBOOT_HOST_ON_LIVEPATCH_FAILURE = "reboot_host_on_livepatch_failure",
- RESTART_DEVICE_MODEL = "restart_device_model",
- RESTART_TOOLSTACK = "restart_toolstack",
+ REBOOT_HOST = 'reboot_host',
+ REBOOT_HOST_ON_LIVEPATCH_FAILURE = 'reboot_host_on_livepatch_failure',
+ RESTART_DEVICE_MODEL = 'restart_device_model',
+ RESTART_TOOLSTACK = 'restart_toolstack',
}
export enum ON_SOFTREBOOT_BEHAVIOR {
- DESTROY = "destroy",
- PRESERVE = "preserve",
- RESTART = "restart",
- SOFT_REBOOT = "soft_reboot",
+ DESTROY = 'destroy',
+ PRESERVE = 'preserve',
+ RESTART = 'restart',
+ SOFT_REBOOT = 'soft_reboot',
}
export enum ON_NORMAL_EXIT {
- DESTROY = "destroy",
- RESTART = "restart",
+ DESTROY = 'destroy',
+ RESTART = 'restart',
}
export enum VM_OPERATION {
- ASSERT_OPERATION_VALID = "assert_operation_valid",
- AWAITING_MEMORY_LIVE = "awaiting_memory_live",
- CALL_PLUGIN = "call_plugin",
- CHANGING_DYNAMIC_RANGE = "changing_dynamic_range",
- CHANGING_MEMORY_LIMITS = "changing_memory_limits",
- CHANGING_MEMORY_LIVE = "changing_memory_live",
- CHANGING_NVRAM = "changing_NVRAM",
- CHANGING_SHADOW_MEMORY = "changing_shadow_memory",
- CHANGING_SHADOW_MEMORY_LIVE = "changing_shadow_memory_live",
- CHANGING_STATIC_RANGE = "changing_static_range",
- CHANGING_VCPUS = "changing_VCPUs",
- CHANGING_VCPUS_LIVE = "changing_VCPUs_live",
- CHECKPOINT = "checkpoint",
- CLEAN_REBOOT = "clean_reboot",
- CLEAN_SHUTDOWN = "clean_shutdown",
- CLONE = "clone",
- COPY = "copy",
- CREATE_TEMPLATE = "create_template",
- CREATE_VTPM = "create_vtpm",
- CSVM = "csvm",
- DATA_SOURCE_OP = "data_source_op",
- DESTROY = "destroy",
- EXPORT = "export",
- GET_BOOT_RECORD = "get_boot_record",
- HARD_REBOOT = "hard_reboot",
- HARD_SHUTDOWN = "hard_shutdown",
- IMPORT = "import",
- MAKE_INTO_TEMPLATE = "make_into_template",
- METADATA_EXPORT = "metadata_export",
- MIGRATE_SEND = "migrate_send",
- PAUSE = "pause",
- POOL_MIGRATE = "pool_migrate",
- POWER_STATE_RESET = "power_state_reset",
- PROVISION = "provision",
- QUERY_SERVICES = "query_services",
- RESUME = "resume",
- RESUME_ON = "resume_on",
- REVERT = "revert",
- REVERTING = "reverting",
- SEND_SYSRQ = "send_sysrq",
- SEND_TRIGGER = "send_trigger",
- SHUTDOWN = "shutdown",
- SNAPSHOT = "snapshot",
- SNAPSHOT_WITH_QUIESCE = "snapshot_with_quiesce",
- START = "start",
- START_ON = "start_on",
- SUSPEND = "suspend",
- UNPAUSE = "unpause",
- UPDATE_ALLOWED_OPERATIONS = "update_allowed_operations",
+ ASSERT_OPERATION_VALID = 'assert_operation_valid',
+ AWAITING_MEMORY_LIVE = 'awaiting_memory_live',
+ CALL_PLUGIN = 'call_plugin',
+ CHANGING_DYNAMIC_RANGE = 'changing_dynamic_range',
+ CHANGING_MEMORY_LIMITS = 'changing_memory_limits',
+ CHANGING_MEMORY_LIVE = 'changing_memory_live',
+ CHANGING_NVRAM = 'changing_NVRAM',
+ CHANGING_SHADOW_MEMORY = 'changing_shadow_memory',
+ CHANGING_SHADOW_MEMORY_LIVE = 'changing_shadow_memory_live',
+ CHANGING_STATIC_RANGE = 'changing_static_range',
+ CHANGING_VCPUS = 'changing_VCPUs',
+ CHANGING_VCPUS_LIVE = 'changing_VCPUs_live',
+ CHECKPOINT = 'checkpoint',
+ CLEAN_REBOOT = 'clean_reboot',
+ CLEAN_SHUTDOWN = 'clean_shutdown',
+ CLONE = 'clone',
+ COPY = 'copy',
+ CREATE_TEMPLATE = 'create_template',
+ CREATE_VTPM = 'create_vtpm',
+ CSVM = 'csvm',
+ DATA_SOURCE_OP = 'data_source_op',
+ DESTROY = 'destroy',
+ EXPORT = 'export',
+ GET_BOOT_RECORD = 'get_boot_record',
+ HARD_REBOOT = 'hard_reboot',
+ HARD_SHUTDOWN = 'hard_shutdown',
+ IMPORT = 'import',
+ MAKE_INTO_TEMPLATE = 'make_into_template',
+ METADATA_EXPORT = 'metadata_export',
+ MIGRATE_SEND = 'migrate_send',
+ PAUSE = 'pause',
+ POOL_MIGRATE = 'pool_migrate',
+ POWER_STATE_RESET = 'power_state_reset',
+ PROVISION = 'provision',
+ QUERY_SERVICES = 'query_services',
+ RESUME = 'resume',
+ RESUME_ON = 'resume_on',
+ REVERT = 'revert',
+ REVERTING = 'reverting',
+ SEND_SYSRQ = 'send_sysrq',
+ SEND_TRIGGER = 'send_trigger',
+ SHUTDOWN = 'shutdown',
+ SNAPSHOT = 'snapshot',
+ SNAPSHOT_WITH_QUIESCE = 'snapshot_with_quiesce',
+ START = 'start',
+ START_ON = 'start_on',
+ SUSPEND = 'suspend',
+ UNPAUSE = 'unpause',
+ UPDATE_ALLOWED_OPERATIONS = 'update_allowed_operations',
}
export enum ON_CRASH_BEHAVIOUR {
- COREDUMP_AND_DESTROY = "coredump_and_destroy",
- COREDUMP_AND_RESTART = "coredump_and_restart",
- DESTROY = "destroy",
- PRESERVE = "preserve",
- RENAME_RESTART = "rename_restart",
- RESTART = "restart",
+ COREDUMP_AND_DESTROY = 'coredump_and_destroy',
+ COREDUMP_AND_RESTART = 'coredump_and_restart',
+ DESTROY = 'destroy',
+ PRESERVE = 'preserve',
+ RENAME_RESTART = 'rename_restart',
+ RESTART = 'restart',
}
export enum DOMAIN_TYPE {
- HVM = "hvm",
- PV = "pv",
- PVH = "pvh",
- PV_IN_PVH = "pv_in_pvh",
- UNSPECIFIED = "unspecified",
+ HVM = 'hvm',
+ PV = 'pv',
+ PVH = 'pvh',
+ PV_IN_PVH = 'pv_in_pvh',
+ UNSPECIFIED = 'unspecified',
}
export enum TRISTATE_TYPE {
- NO = "no",
- UNSPECIFIED = "unspecified",
- YES = "yes",
+ NO = 'no',
+ UNSPECIFIED = 'unspecified',
+ YES = 'yes',
}
export enum VMPP_BACKUP_TYPE {
- CHECKPOINT = "checkpoint",
- SNAPSHOT = "snapshot",
+ CHECKPOINT = 'checkpoint',
+ SNAPSHOT = 'snapshot',
}
export enum VMPP_BACKUP_FREQUENCY {
- DAILY = "daily",
- HOURLY = "hourly",
- WEEKLY = "weekly",
+ DAILY = 'daily',
+ HOURLY = 'hourly',
+ WEEKLY = 'weekly',
}
export enum VMPP_ARCHIVE_FREQUENCY {
- ALWAYS_AFTER_BACKUP = "always_after_backup",
- DAILY = "daily",
- NEVER = "never",
- WEEKLY = "weekly",
+ ALWAYS_AFTER_BACKUP = 'always_after_backup',
+ DAILY = 'daily',
+ NEVER = 'never',
+ WEEKLY = 'weekly',
}
export enum VMPP_ARCHIVE_TARGET_TYPE {
- CIFS = "cifs",
- NFS = "nfs",
- NONE = "none",
+ CIFS = 'cifs',
+ NFS = 'nfs',
+ NONE = 'none',
}
export enum VMSS_FREQUENCY {
- DAILY = "daily",
- HOURLY = "hourly",
- WEEKLY = "weekly",
+ DAILY = 'daily',
+ HOURLY = 'hourly',
+ WEEKLY = 'weekly',
}
export enum VMSS_TYPE {
- CHECKPOINT = "checkpoint",
- SNAPSHOT = "snapshot",
- SNAPSHOT_WITH_QUIESCE = "snapshot_with_quiesce",
+ CHECKPOINT = 'checkpoint',
+ SNAPSHOT = 'snapshot',
+ SNAPSHOT_WITH_QUIESCE = 'snapshot_with_quiesce',
}
export enum VM_APPLIANCE_OPERATION {
- CLEAN_SHUTDOWN = "clean_shutdown",
- HARD_SHUTDOWN = "hard_shutdown",
- SHUTDOWN = "shutdown",
- START = "start",
+ CLEAN_SHUTDOWN = 'clean_shutdown',
+ HARD_SHUTDOWN = 'hard_shutdown',
+ SHUTDOWN = 'shutdown',
+ START = 'start',
}
export enum HOST_ALLOWED_OPERATION {
- APPLY_UPDATES = "apply_updates",
- EVACUATE = "evacuate",
- POWER_ON = "power_on",
- PROVISION = "provision",
- REBOOT = "reboot",
- SHUTDOWN = "shutdown",
- VM_MIGRATE = "vm_migrate",
- VM_RESUME = "vm_resume",
- VM_START = "vm_start",
+ APPLY_UPDATES = 'apply_updates',
+ EVACUATE = 'evacuate',
+ POWER_ON = 'power_on',
+ PROVISION = 'provision',
+ REBOOT = 'reboot',
+ SHUTDOWN = 'shutdown',
+ VM_MIGRATE = 'vm_migrate',
+ VM_RESUME = 'vm_resume',
+ VM_START = 'vm_start',
}
export enum LATEST_SYNCED_UPDATES_APPLIED_STATE {
- NO = "no",
- UNKNOWN = "unknown",
- YES = "yes",
+ NO = 'no',
+ UNKNOWN = 'unknown',
+ YES = 'yes',
}
export enum HOST_DISPLAY {
- DISABLED = "disabled",
- DISABLE_ON_REBOOT = "disable_on_reboot",
- ENABLED = "enabled",
- ENABLE_ON_REBOOT = "enable_on_reboot",
+ DISABLED = 'disabled',
+ DISABLE_ON_REBOOT = 'disable_on_reboot',
+ ENABLED = 'enabled',
+ ENABLE_ON_REBOOT = 'enable_on_reboot',
}
export enum HOST_SCHED_GRAN {
- CORE = "core",
- CPU = "cpu",
- SOCKET = "socket",
+ CORE = 'core',
+ CPU = 'cpu',
+ SOCKET = 'socket',
}
export enum NETWORK_OPERATION {
- ATTACHING = "attaching",
+ ATTACHING = 'attaching',
}
export enum NETWORK_DEFAULT_LOCKING_MODE {
- DISABLED = "disabled",
- UNLOCKED = "unlocked",
+ DISABLED = 'disabled',
+ UNLOCKED = 'unlocked',
}
export enum NETWORK_PURPOSE {
- INSECURE_NBD = "insecure_nbd",
- NBD = "nbd",
+ INSECURE_NBD = 'insecure_nbd',
+ NBD = 'nbd',
}
export enum VIF_OPERATION {
- ATTACH = "attach",
- PLUG = "plug",
- UNPLUG = "unplug",
+ ATTACH = 'attach',
+ PLUG = 'plug',
+ UNPLUG = 'unplug',
}
export enum VIF_LOCKING_MODE {
- DISABLED = "disabled",
- LOCKED = "locked",
- NETWORK_DEFAULT = "network_default",
- UNLOCKED = "unlocked",
+ DISABLED = 'disabled',
+ LOCKED = 'locked',
+ NETWORK_DEFAULT = 'network_default',
+ UNLOCKED = 'unlocked',
}
export enum VIF_IPV4_CONFIGURATION_MODE {
- NONE = "None",
- STATIC = "Static",
+ NONE = 'None',
+ STATIC = 'Static',
}
export enum VIF_IPV6_CONFIGURATION_MODE {
- NONE = "None",
- STATIC = "Static",
+ NONE = 'None',
+ STATIC = 'Static',
}
export enum PIF_IGMP_STATUS {
- DISABLED = "disabled",
- ENABLED = "enabled",
- UNKNOWN = "unknown",
+ DISABLED = 'disabled',
+ ENABLED = 'enabled',
+ UNKNOWN = 'unknown',
}
export enum IP_CONFIGURATION_MODE {
- DHCP = "DHCP",
- NONE = "None",
- STATIC = "Static",
+ DHCP = 'DHCP',
+ NONE = 'None',
+ STATIC = 'Static',
}
export enum IPV6_CONFIGURATION_MODE {
- AUTOCONF = "Autoconf",
- DHCP = "DHCP",
- NONE = "None",
- STATIC = "Static",
+ AUTOCONF = 'Autoconf',
+ DHCP = 'DHCP',
+ NONE = 'None',
+ STATIC = 'Static',
}
export enum PRIMARY_ADDRESS_TYPE {
- IPV4 = "IPv4",
- IPV6 = "IPv6",
+ IPV4 = 'IPv4',
+ IPV6 = 'IPv6',
}
export enum BOND_MODE {
- ACTIVE_BACKUP = "active-backup",
- BALANCE_SLB = "balance-slb",
- LACP = "lacp",
+ ACTIVE_BACKUP = 'active-backup',
+ BALANCE_SLB = 'balance-slb',
+ LACP = 'lacp',
}
export enum STORAGE_OPERATION {
- DESTROY = "destroy",
- FORGET = "forget",
- PBD_CREATE = "pbd_create",
- PBD_DESTROY = "pbd_destroy",
- PLUG = "plug",
- SCAN = "scan",
- UNPLUG = "unplug",
- UPDATE = "update",
- VDI_CLONE = "vdi_clone",
- VDI_CREATE = "vdi_create",
- VDI_DATA_DESTROY = "vdi_data_destroy",
- VDI_DESTROY = "vdi_destroy",
- VDI_DISABLE_CBT = "vdi_disable_cbt",
- VDI_ENABLE_CBT = "vdi_enable_cbt",
- VDI_INTRODUCE = "vdi_introduce",
- VDI_LIST_CHANGED_BLOCKS = "vdi_list_changed_blocks",
- VDI_MIRROR = "vdi_mirror",
- VDI_RESIZE = "vdi_resize",
- VDI_SET_ON_BOOT = "vdi_set_on_boot",
- VDI_SNAPSHOT = "vdi_snapshot",
+ DESTROY = 'destroy',
+ FORGET = 'forget',
+ PBD_CREATE = 'pbd_create',
+ PBD_DESTROY = 'pbd_destroy',
+ PLUG = 'plug',
+ SCAN = 'scan',
+ UNPLUG = 'unplug',
+ UPDATE = 'update',
+ VDI_CLONE = 'vdi_clone',
+ VDI_CREATE = 'vdi_create',
+ VDI_DATA_DESTROY = 'vdi_data_destroy',
+ VDI_DESTROY = 'vdi_destroy',
+ VDI_DISABLE_CBT = 'vdi_disable_cbt',
+ VDI_ENABLE_CBT = 'vdi_enable_cbt',
+ VDI_INTRODUCE = 'vdi_introduce',
+ VDI_LIST_CHANGED_BLOCKS = 'vdi_list_changed_blocks',
+ VDI_MIRROR = 'vdi_mirror',
+ VDI_RESIZE = 'vdi_resize',
+ VDI_SET_ON_BOOT = 'vdi_set_on_boot',
+ VDI_SNAPSHOT = 'vdi_snapshot',
}
export enum SR_HEALTH {
- HEALTHY = "healthy",
- RECOVERING = "recovering",
+ HEALTHY = 'healthy',
+ RECOVERING = 'recovering',
}
export enum VDI_OPERATION {
- BLOCKED = "blocked",
- CLONE = "clone",
- COPY = "copy",
- DATA_DESTROY = "data_destroy",
- DESTROY = "destroy",
- DISABLE_CBT = "disable_cbt",
- ENABLE_CBT = "enable_cbt",
- FORCE_UNLOCK = "force_unlock",
- FORGET = "forget",
- GENERATE_CONFIG = "generate_config",
- LIST_CHANGED_BLOCKS = "list_changed_blocks",
- MIRROR = "mirror",
- RESIZE = "resize",
- RESIZE_ONLINE = "resize_online",
- SET_ON_BOOT = "set_on_boot",
- SNAPSHOT = "snapshot",
- UPDATE = "update",
+ BLOCKED = 'blocked',
+ CLONE = 'clone',
+ COPY = 'copy',
+ DATA_DESTROY = 'data_destroy',
+ DESTROY = 'destroy',
+ DISABLE_CBT = 'disable_cbt',
+ ENABLE_CBT = 'enable_cbt',
+ FORCE_UNLOCK = 'force_unlock',
+ FORGET = 'forget',
+ GENERATE_CONFIG = 'generate_config',
+ LIST_CHANGED_BLOCKS = 'list_changed_blocks',
+ MIRROR = 'mirror',
+ RESIZE = 'resize',
+ RESIZE_ONLINE = 'resize_online',
+ SET_ON_BOOT = 'set_on_boot',
+ SNAPSHOT = 'snapshot',
+ UPDATE = 'update',
}
export enum VDI_TYPE {
- CBT_METADATA = "cbt_metadata",
- CRASHDUMP = "crashdump",
- EPHEMERAL = "ephemeral",
- HA_STATEFILE = "ha_statefile",
- METADATA = "metadata",
- PVS_CACHE = "pvs_cache",
- REDO_LOG = "redo_log",
- RRD = "rrd",
- SUSPEND = "suspend",
- SYSTEM = "system",
- USER = "user",
+ CBT_METADATA = 'cbt_metadata',
+ CRASHDUMP = 'crashdump',
+ EPHEMERAL = 'ephemeral',
+ HA_STATEFILE = 'ha_statefile',
+ METADATA = 'metadata',
+ PVS_CACHE = 'pvs_cache',
+ REDO_LOG = 'redo_log',
+ RRD = 'rrd',
+ SUSPEND = 'suspend',
+ SYSTEM = 'system',
+ USER = 'user',
}
export enum ON_BOOT {
- PERSIST = "persist",
- RESET = "reset",
+ PERSIST = 'persist',
+ RESET = 'reset',
}
export enum VBD_OPERATION {
- ATTACH = "attach",
- EJECT = "eject",
- INSERT = "insert",
- PAUSE = "pause",
- PLUG = "plug",
- UNPAUSE = "unpause",
- UNPLUG = "unplug",
- UNPLUG_FORCE = "unplug_force",
+ ATTACH = 'attach',
+ EJECT = 'eject',
+ INSERT = 'insert',
+ PAUSE = 'pause',
+ PLUG = 'plug',
+ UNPAUSE = 'unpause',
+ UNPLUG = 'unplug',
+ UNPLUG_FORCE = 'unplug_force',
}
export enum VBD_TYPE {
- CD = "CD",
- DISK = "Disk",
- FLOPPY = "Floppy",
+ CD = 'CD',
+ DISK = 'Disk',
+ FLOPPY = 'Floppy',
}
export enum VBD_MODE {
- RO = "RO",
- RW = "RW",
+ RO = 'RO',
+ RW = 'RW',
}
export enum VTPM_OPERATION {
- DESTROY = "destroy",
+ DESTROY = 'destroy',
}
export enum PERSISTENCE_BACKEND {
- XAPI = "xapi",
+ XAPI = 'xapi',
}
export enum CONSOLE_PROTOCOL {
- RDP = "rdp",
- RFB = "rfb",
- VT100 = "vt100",
+ RDP = 'rdp',
+ RFB = 'rfb',
+ VT100 = 'vt100',
}
export enum CLS {
- CERTIFICATE = "Certificate",
- HOST = "Host",
- POOL = "Pool",
- PVS_PROXY = "PVS_proxy",
- SR = "SR",
- VDI = "VDI",
- VM = "VM",
- VMPP = "VMPP",
- VMSS = "VMSS",
+ CERTIFICATE = 'Certificate',
+ HOST = 'Host',
+ POOL = 'Pool',
+ PVS_PROXY = 'PVS_proxy',
+ SR = 'SR',
+ VDI = 'VDI',
+ VM = 'VM',
+ VMPP = 'VMPP',
+ VMSS = 'VMSS',
}
export enum TUNNEL_PROTOCOL {
- GRE = "gre",
- VXLAN = "vxlan",
+ GRE = 'gre',
+ VXLAN = 'vxlan',
}
export enum SRIOV_CONFIGURATION_MODE {
- MANUAL = "manual",
- MODPROBE = "modprobe",
- SYSFS = "sysfs",
- UNKNOWN = "unknown",
+ MANUAL = 'manual',
+ MODPROBE = 'modprobe',
+ SYSFS = 'sysfs',
+ UNKNOWN = 'unknown',
}
export enum PGPU_DOM0_ACCESS {
- DISABLED = "disabled",
- DISABLE_ON_REBOOT = "disable_on_reboot",
- ENABLED = "enabled",
- ENABLE_ON_REBOOT = "enable_on_reboot",
+ DISABLED = 'disabled',
+ DISABLE_ON_REBOOT = 'disable_on_reboot',
+ ENABLED = 'enabled',
+ ENABLE_ON_REBOOT = 'enable_on_reboot',
}
export enum ALLOCATION_ALGORITHM {
- BREADTH_FIRST = "breadth_first",
- DEPTH_FIRST = "depth_first",
+ BREADTH_FIRST = 'breadth_first',
+ DEPTH_FIRST = 'depth_first',
}
export enum VGPU_TYPE_IMPLEMENTATION {
- GVT_G = "gvt_g",
- MXGPU = "mxgpu",
- NVIDIA = "nvidia",
- NVIDIA_SRIOV = "nvidia_sriov",
- PASSTHROUGH = "passthrough",
+ GVT_G = 'gvt_g',
+ MXGPU = 'mxgpu',
+ NVIDIA = 'nvidia',
+ NVIDIA_SRIOV = 'nvidia_sriov',
+ PASSTHROUGH = 'passthrough',
}
export enum PVS_PROXY_STATUS {
- CACHING = "caching",
- INCOMPATIBLE_PROTOCOL_VERSION = "incompatible_protocol_version",
- INCOMPATIBLE_WRITE_CACHE_MODE = "incompatible_write_cache_mode",
- INITIALISED = "initialised",
- STOPPED = "stopped",
+ CACHING = 'caching',
+ INCOMPATIBLE_PROTOCOL_VERSION = 'incompatible_protocol_version',
+ INCOMPATIBLE_WRITE_CACHE_MODE = 'incompatible_write_cache_mode',
+ INITIALISED = 'initialised',
+ STOPPED = 'stopped',
}
export enum SDN_CONTROLLER_PROTOCOL {
- PSSL = "pssl",
- SSL = "ssl",
+ PSSL = 'pssl',
+ SSL = 'ssl',
}
export enum VUSB_OPERATION {
- ATTACH = "attach",
- PLUG = "plug",
- UNPLUG = "unplug",
+ ATTACH = 'attach',
+ PLUG = 'plug',
+ UNPLUG = 'unplug',
}
export enum CLUSTER_OPERATION {
- ADD = "add",
- DESTROY = "destroy",
- DISABLE = "disable",
- ENABLE = "enable",
- REMOVE = "remove",
+ ADD = 'add',
+ DESTROY = 'destroy',
+ DISABLE = 'disable',
+ ENABLE = 'enable',
+ REMOVE = 'remove',
}
export enum CLUSTER_HOST_OPERATION {
- DESTROY = "destroy",
- DISABLE = "disable",
- ENABLE = "enable",
+ DESTROY = 'destroy',
+ DISABLE = 'disable',
+ ENABLE = 'enable',
}
export enum CERTIFICATE_TYPE {
- CA = "ca",
- HOST = "host",
- HOST_INTERNAL = "host_internal",
+ CA = 'ca',
+ HOST = 'host',
+ HOST_INTERNAL = 'host_internal',
}
export enum VM_COMPRESSION_TYPE {
- DISABLED = "false",
- GZIP = "true",
- ZSTD = "zstd",
+ DISABLED = 'false',
+ GZIP = 'true',
+ ZSTD = 'zstd',
}
diff --git a/@xen-orchestra/lite/src/libs/xen-api/xen-api.ts b/@xen-orchestra/lite/src/libs/xen-api/xen-api.ts
index b082670507f..54888a08521 100644
--- a/@xen-orchestra/lite/src/libs/xen-api/xen-api.ts
+++ b/@xen-orchestra/lite/src/libs/xen-api/xen-api.ts
@@ -14,406 +14,313 @@ import type {
XenApiRecordLoadErrorEvent,
XenApiRecordModEvent,
XenApiVm,
-} from "@/libs/xen-api/xen-api.types";
-import { buildXoObject, typeToRawType } from "@/libs/xen-api/xen-api.utils";
-import { JSONRPCClient } from "json-rpc-2.0";
-import { castArray } from "lodash-es";
-import type { VM_COMPRESSION_TYPE } from "@/libs/xen-api/xen-api.enums";
-import { useModal } from "@/composables/modal.composable";
+} from '@/libs/xen-api/xen-api.types'
+import { buildXoObject, typeToRawType } from '@/libs/xen-api/xen-api.utils'
+import { JSONRPCClient } from 'json-rpc-2.0'
+import { castArray } from 'lodash-es'
+import type { VM_COMPRESSION_TYPE } from '@/libs/xen-api/xen-api.enums'
+import { useModal } from '@/composables/modal.composable'
export default class XenApi {
- private client: JSONRPCClient;
- private sessionId: string | undefined;
- private events = new Map<
- XenApiRecordEvent,
- Set<(...args: any[]) => void>
- >();
- private fromToken: string | undefined;
- private hostUrl: string;
+ private client: JSONRPCClient
+ private sessionId: string | undefined
+ private events = new Map, Set<(...args: any[]) => void>>()
+ private fromToken: string | undefined
+ private hostUrl: string
constructor(hostUrl: string) {
- this.hostUrl = hostUrl;
- this.client = new JSONRPCClient(async (request) => {
+ this.hostUrl = hostUrl
+ this.client = new JSONRPCClient(async request => {
const response = await fetch(`${this.hostUrl}/jsonrpc`, {
- method: "POST",
- headers: { "content-type": "application/json" },
+ method: 'POST',
+ headers: { 'content-type': 'application/json' },
body: JSON.stringify(request),
- });
+ })
if (response.status === 200) {
- const json = await response.json();
- return this.client.receive(json);
+ const json = await response.json()
+ return this.client.receive(json)
} else if (request.id !== undefined) {
- return Promise.reject(new Error(response.statusText));
+ return Promise.reject(new Error(response.statusText))
}
- });
+ })
}
async connectWithPassword(username: string, password: string) {
- this.sessionId = await this.request("session.login_with_password", [
- username,
- password,
- ]);
+ this.sessionId = await this.request('session.login_with_password', [username, password])
- return this.sessionId;
+ return this.sessionId
}
async connectWithSessionId(sessionId: string) {
try {
- this.sessionId = undefined;
+ this.sessionId = undefined
- await this.request("session.get_all_subject_identifiers", [sessionId]);
+ await this.request('session.get_all_subject_identifiers', [sessionId])
- this.sessionId = sessionId;
+ this.sessionId = sessionId
- return true;
+ return true
} catch (error: any) {
- if (error?.message === "SESSION_INVALID") {
- return false;
+ if (error?.message === 'SESSION_INVALID') {
+ return false
} else {
- throw error;
+ throw error
}
}
}
async disconnect() {
- await this.call("session.logout");
- this.sessionId = undefined;
- this.fromToken = undefined;
+ await this.call('session.logout')
+ this.sessionId = undefined
+ this.fromToken = undefined
}
private request(method: string, args: any[] = []): PromiseLike {
- return this.client.request(method, args);
+ return this.client.request(method, args)
}
call = (method: string, args: any[] = []): PromiseLike => {
- return this.request(method, [this.sessionId, ...args]);
- };
+ return this.request(method, [this.sessionId, ...args])
+ }
async getResource(
pathname: string,
- {
- abortSignal,
- host,
- query,
- }: { abortSignal?: AbortSignal; host: XenApiHost; query: any }
+ { abortSignal, host, query }: { abortSignal?: AbortSignal; host: XenApiHost; query: any }
) {
- const url = new URL("http://localhost");
- url.protocol = window.location.protocol;
- url.hostname = host.address;
- url.pathname = pathname;
+ const url = new URL('http://localhost')
+ url.protocol = window.location.protocol
+ url.hostname = host.address
+ url.pathname = pathname
url.search = new URLSearchParams({
...query,
session_id: this.sessionId,
- }).toString();
+ }).toString()
- return fetch(url, { signal: abortSignal });
+ return fetch(url, { signal: abortSignal })
}
- async loadRecords<
- Type extends ObjectType,
- XRecord extends ObjectTypeToRecord,
- >(type: Type): Promise {
- this.emitEvent(`${type}.beforeLoad`);
+ async loadRecords>(type: Type): Promise {
+ this.emitEvent(`${type}.beforeLoad`)
try {
- const result = await this.call<
- Record>
- >(`${typeToRawType(type)}.get_all_records`);
+ const result = await this.call>>(
+ `${typeToRawType(type)}.get_all_records`
+ )
const records = Object.entries(result).map(([opaqueRef, record]) =>
buildXoObject(record as RawXenApiRecord, {
- opaqueRef: opaqueRef as XRecord["$ref"],
+ opaqueRef: opaqueRef as XRecord['$ref'],
})
- );
+ )
- this.emitEvent(`${type}.afterLoad`, records);
+ this.emitEvent(`${type}.afterLoad`, records)
- return records;
+ return records
} catch (e) {
- this.emitEvent(`${type}.loadError`, e);
- return [];
+ this.emitEvent(`${type}.loadError`, e)
+ return []
}
}
- addEventListener<
- Type extends ObjectType,
- XRecord extends ObjectTypeToRecord,
- >(
+ addEventListener>(
event: XenApiRecordAfterLoadEvent,
callback: (records: XRecord[]) => void
- ): void;
+ ): void
- addEventListener(
- event: XenApiRecordBeforeLoadEvent,
- callback: () => void
- ): void;
+ addEventListener(event: XenApiRecordBeforeLoadEvent, callback: () => void): void
addEventListener(
event: XenApiRecordLoadErrorEvent,
callback: (error: Error) => void
- ): void;
+ ): void
- addEventListener<
- Type extends ObjectType,
- XRecord extends ObjectTypeToRecord,
- >(
+ addEventListener>(
event: XenApiRecordAddEvent | XenApiRecordModEvent,
callback: (record: XRecord) => void
- ): void;
+ ): void
- addEventListener<
- Type extends ObjectType,
- XRecord extends ObjectTypeToRecord,
- >(
+ addEventListener>(
event: XenApiRecordDelEvent,
- callback: (opaqueRef: XRecord["$ref"]) => void
- ): void;
+ callback: (opaqueRef: XRecord['$ref']) => void
+ ): void
- addEventListener(
- event: XenApiRecordEvent,
- callback: (...args: any[]) => void
- ) {
+ addEventListener(event: XenApiRecordEvent, callback: (...args: any[]) => void) {
if (!this.events.has(event)) {
- this.events.set(event, new Set());
+ this.events.set(event, new Set())
}
- this.events.get(event)!.add(callback);
+ this.events.get(event)!.add(callback)
}
- removeEventListener(
- event: XenApiRecordBeforeLoadEvent,
- callback: () => void
- ): void;
+ removeEventListener(event: XenApiRecordBeforeLoadEvent, callback: () => void): void
removeEventListener(
event: XenApiRecordLoadErrorEvent,
callback: (error: Error) => void
- ): void;
+ ): void
- removeEventListener<
- Type extends ObjectType,
- XRecord extends ObjectTypeToRecord,
- >(
+ removeEventListener>(
event: XenApiRecordAfterLoadEvent,
callback: (records: XRecord[]) => void
- ): void;
+ ): void
- removeEventListener<
- Type extends ObjectType,
- XRecord extends ObjectTypeToRecord,
- >(
+ removeEventListener>(
event: XenApiRecordAddEvent | XenApiRecordModEvent,
callback: (record: XRecord) => void
- ): void;
+ ): void
- removeEventListener<
- Type extends ObjectType,
- XRecord extends ObjectTypeToRecord,
- >(
+ removeEventListener>(
event: XenApiRecordDelEvent,
- callback: (opaqueRef: XRecord["$ref"]) => void
- ): void;
+ callback: (opaqueRef: XRecord['$ref']) => void
+ ): void
- removeEventListener(
- event: XenApiRecordEvent,
- callback: (value: any) => void
- ) {
- this.events.get(event)?.delete(callback);
+ removeEventListener(event: XenApiRecordEvent, callback: (value: any) => void) {
+ this.events.get(event)?.delete(callback)
}
get listenedTypes() {
- const keys = new Set();
+ const keys = new Set()
for (const event of this.events.keys()) {
- keys.add(event.split(".")[0] as ObjectType);
+ keys.add(event.split('.')[0] as ObjectType)
}
- return Array.from(keys);
+ return Array.from(keys)
}
- private emitEvent(
- event: XenApiRecordEvent,
- ...args: any[]
- ) {
- const callbacks = this.events.get(event);
+ private emitEvent(event: XenApiRecordEvent, ...args: any[]) {
+ const callbacks = this.events.get(event)
if (callbacks !== undefined) {
- callbacks.forEach((callback) => {
- callback(...args);
- });
+ callbacks.forEach(callback => {
+ // eslint-disable-next-line n/no-callback-literal
+ callback(...args)
+ })
}
}
private handleEvents(events: XenApiEvent>[]) {
events.forEach(({ class: cls, operation, ref, snapshot }) => {
- const eventName = `${cls}.${operation}` as XenApiRecordEvent;
+ const eventName = `${cls}.${operation}` as XenApiRecordEvent
- if (operation === "add" || operation === "mod") {
- this.emitEvent(eventName, buildXoObject(snapshot, { opaqueRef: ref }));
- return;
+ if (operation === 'add' || operation === 'mod') {
+ this.emitEvent(eventName, buildXoObject(snapshot, { opaqueRef: ref }))
+ return
}
- if (operation === "del") {
- this.emitEvent(eventName, ref);
- return;
+ if (operation === 'del') {
+ this.emitEvent(eventName, ref)
}
- });
+ })
}
- async startWatching(poolRef: XenApiPool["$ref"]) {
- this.fromToken = await this.call("event.inject", ["pool", poolRef]);
- return this.watch();
+ async startWatching(poolRef: XenApiPool['$ref']) {
+ this.fromToken = await this.call('event.inject', ['pool', poolRef])
+ return this.watch()
}
- private async watch() {
+ private async watch(): Promise {
if (this.fromToken === undefined || this.sessionId === undefined) {
- return;
+ return
}
- await new Promise((resolve) => setTimeout(resolve, 2000));
+ await new Promise(resolve => setTimeout(resolve, 2000))
if (this.listenedTypes.length === 0) {
- void this.watch();
- return;
+ return this.watch()
}
const result: {
- token: string;
- events: XenApiEvent>[];
- } = await this.call("event.from", [
- this.listenedTypes,
- this.fromToken,
- 5.001,
- ]);
+ token: string
+ events: XenApiEvent>[]
+ } = await this.call('event.from', [this.listenedTypes, this.fromToken, 5.001])
- this.fromToken = result.token;
+ this.fromToken = result.token
- this.handleEvents(result.events);
+ this.handleEvents(result.events)
- void this.watch();
+ return this.watch()
}
get vm() {
- type VmRefs = XenApiVm["$ref"] | XenApiVm["$ref"][];
- type VmRefsWithPowerState = Record<
- XenApiVm["$ref"],
- XenApiVm["power_state"]
- >;
- type VmRefsWithNameLabel = Record;
+ type VmRefs = XenApiVm['$ref'] | XenApiVm['$ref'][]
+ type VmRefsWithPowerState = Record
+ type VmRefsWithNameLabel = Record
return {
- delete: (vmRefs: VmRefs) =>
- Promise.all(
- castArray(vmRefs).map((vmRef) => this.call("VM.destroy", [vmRef]))
- ),
+ delete: (vmRefs: VmRefs) => Promise.all(castArray(vmRefs).map(vmRef => this.call('VM.destroy', [vmRef]))),
start: (vmRefs: VmRefs) =>
- Promise.all(
- castArray(vmRefs).map((vmRef) =>
- this.call("VM.start", [vmRef, false, false])
- )
- ),
- startOn: (vmRefs: VmRefs, hostRef: XenApiHost["$ref"]) =>
- Promise.all(
- castArray(vmRefs).map((vmRef) =>
- this.call("VM.start_on", [vmRef, hostRef, false, false])
- )
- ),
- pause: (vmRefs: VmRefs) =>
- Promise.all(
- castArray(vmRefs).map((vmRef) => this.call("VM.pause", [vmRef]))
- ),
+ Promise.all(castArray(vmRefs).map(vmRef => this.call('VM.start', [vmRef, false, false]))),
+ startOn: (vmRefs: VmRefs, hostRef: XenApiHost['$ref']) =>
+ Promise.all(castArray(vmRefs).map(vmRef => this.call('VM.start_on', [vmRef, hostRef, false, false]))),
+ pause: (vmRefs: VmRefs) => Promise.all(castArray(vmRefs).map(vmRef => this.call('VM.pause', [vmRef]))),
suspend: (vmRefs: VmRefs) => {
- return Promise.all(
- castArray(vmRefs).map((vmRef) => this.call("VM.suspend", [vmRef]))
- );
+ return Promise.all(castArray(vmRefs).map(vmRef => this.call('VM.suspend', [vmRef])))
},
resume: (vmRefsWithPowerState: VmRefsWithPowerState) => {
- const vmRefs = Object.keys(vmRefsWithPowerState) as XenApiVm["$ref"][];
+ const vmRefs = Object.keys(vmRefsWithPowerState) as XenApiVm['$ref'][]
return Promise.all(
- vmRefs.map((vmRef) => {
- if (vmRefsWithPowerState[vmRef] === "Suspended") {
- return this.call("VM.resume", [vmRef, false, false]);
+ vmRefs.map(vmRef => {
+ if (vmRefsWithPowerState[vmRef] === 'Suspended') {
+ return this.call('VM.resume', [vmRef, false, false])
}
- return this.call("VM.unpause", [vmRef]);
+ return this.call('VM.unpause', [vmRef])
})
- );
+ )
},
reboot: (vmRefs: VmRefs, force = false) => {
- return Promise.all(
- castArray(vmRefs).map((vmRef) =>
- this.call(`VM.${force ? "hard" : "clean"}_reboot`, [vmRef])
- )
- );
+ return Promise.all(castArray(vmRefs).map(vmRef => this.call(`VM.${force ? 'hard' : 'clean'}_reboot`, [vmRef])))
},
shutdown: (vmRefs: VmRefs, force = false) => {
return Promise.all(
- castArray(vmRefs).map((vmRef) =>
- this.call(`VM.${force ? "hard" : "clean"}_shutdown`, [vmRef])
- )
- );
+ castArray(vmRefs).map(vmRef => this.call(`VM.${force ? 'hard' : 'clean'}_shutdown`, [vmRef]))
+ )
},
clone: (vmRefsToClone: VmRefsWithNameLabel) => {
- const vmRefs = Object.keys(vmRefsToClone) as XenApiVm["$ref"][];
+ const vmRefs = Object.keys(vmRefsToClone) as XenApiVm['$ref'][]
- return Promise.all(
- vmRefs.map((vmRef) =>
- this.call("VM.clone", [vmRef, vmRefsToClone[vmRef]])
- )
- );
+ return Promise.all(vmRefs.map(vmRef => this.call('VM.clone', [vmRef, vmRefsToClone[vmRef]])))
},
- migrate: (vmRefs: VmRefs, destinationHostRef: XenApiHost["$ref"]) => {
+ migrate: (vmRefs: VmRefs, destinationHostRef: XenApiHost['$ref']) => {
return Promise.all(
- castArray(vmRefs).map((vmRef) =>
- this.call("VM.pool_migrate", [
- vmRef,
- destinationHostRef,
- { force: "false" },
- ])
- )
- );
+ castArray(vmRefs).map(vmRef => this.call('VM.pool_migrate', [vmRef, destinationHostRef, { force: 'false' }]))
+ )
},
snapshot: (vmRefsToSnapshot: VmRefsWithNameLabel) => {
- const vmRefs = Object.keys(vmRefsToSnapshot) as XenApiVm["$ref"][];
+ const vmRefs = Object.keys(vmRefsToSnapshot) as XenApiVm['$ref'][]
- return Promise.all(
- vmRefs.map((vmRef) =>
- this.call("VM.snapshot", [vmRef, vmRefsToSnapshot[vmRef]])
- )
- );
+ return Promise.all(vmRefs.map(vmRef => this.call('VM.snapshot', [vmRef, vmRefsToSnapshot[vmRef]])))
},
export: (vmRefs: VmRefs, compression: VM_COMPRESSION_TYPE) => {
- const blockedUrls: URL[] = [];
+ const blockedUrls: URL[] = []
- castArray(vmRefs).forEach((vmRef) => {
- const url = new URL(this.hostUrl);
- url.pathname = "/export/";
+ castArray(vmRefs).forEach(vmRef => {
+ const url = new URL(this.hostUrl)
+ url.pathname = '/export/'
url.search = new URLSearchParams({
session_id: this.sessionId!,
ref: vmRef,
use_compression: compression,
- }).toString();
+ }).toString()
- const _window = window.open(url.href, "_blank");
+ const _window = window.open(url.href, '_blank')
if (_window === null) {
- blockedUrls.push(url);
+ blockedUrls.push(url)
} else {
- URL.revokeObjectURL(url.toString());
+ URL.revokeObjectURL(url.toString())
}
- });
+ })
if (blockedUrls.length > 0) {
- const { onClose } = useModal(
- () => import("@/components/modals/VmExportBlockedUrlsModal.vue"),
- { blockedUrls }
- );
- onClose(() =>
- blockedUrls.forEach((url) => URL.revokeObjectURL(url.toString()))
- );
+ const { onClose } = useModal(() => import('@/components/modals/VmExportBlockedUrlsModal.vue'), {
+ blockedUrls,
+ })
+ onClose(() => blockedUrls.forEach(url => URL.revokeObjectURL(url.toString())))
}
},
- };
+ }
}
}
diff --git a/@xen-orchestra/lite/src/libs/xen-api/xen-api.types.ts b/@xen-orchestra/lite/src/libs/xen-api/xen-api.types.ts
index 66afcbc11aa..22075e4fe59 100644
--- a/@xen-orchestra/lite/src/libs/xen-api/xen-api.types.ts
+++ b/@xen-orchestra/lite/src/libs/xen-api/xen-api.types.ts
@@ -1,3 +1,5 @@
+/* eslint-disable no-use-before-define */
+
import type {
ALLOCATION_ALGORITHM,
BOND_MODE,
@@ -39,600 +41,591 @@ import type {
VMSS_TYPE,
VTPM_OPERATION,
VUSB_OPERATION,
-} from "@/libs/xen-api/xen-api.enums";
-import type { XEN_API_OBJECT_TYPES } from "@/libs/xen-api/xen-api.utils";
+} from '@/libs/xen-api/xen-api.enums'
+import type { XEN_API_OBJECT_TYPES } from '@/libs/xen-api/xen-api.utils'
-type TypeMapping = typeof XEN_API_OBJECT_TYPES;
-export type ObjectType = keyof TypeMapping;
-export type RawObjectType = TypeMapping[ObjectType];
+type TypeMapping = typeof XEN_API_OBJECT_TYPES
+export type ObjectType = keyof TypeMapping
+export type RawObjectType = TypeMapping[ObjectType]
-export type RawTypeToType = Lowercase;
-export type TypeToRawType = TypeMapping[Type];
+export type RawTypeToType = Lowercase
+export type TypeToRawType = TypeMapping[Type]
type ObjectTypeToRecordMapping = {
- console: XenApiConsole;
- host: XenApiHost;
- host_metrics: XenApiHostMetrics;
- message: XenApiMessage;
- network: XenApiNetwork;
- pool: XenApiPool;
- sr: XenApiSr;
- vm: XenApiVm;
- vm_guest_metrics: XenApiVmGuestMetrics;
- vm_metrics: XenApiVmMetrics;
-};
-
-export type ObjectTypeToRecord =
- Type extends keyof ObjectTypeToRecordMapping
- ? ObjectTypeToRecordMapping[Type]
- : never;
-
-export type XenApiRecordBeforeLoadEvent =
- `${Type}.beforeLoad`;
-export type XenApiRecordAfterLoadEvent =
- `${Type}.afterLoad`;
-export type XenApiRecordLoadErrorEvent =
- `${Type}.loadError`;
-export type XenApiRecordAddEvent = `${Type}.add`;
-export type XenApiRecordModEvent = `${Type}.mod`;
-export type XenApiRecordDelEvent = `${Type}.del`;
+ console: XenApiConsole
+ host: XenApiHost
+ host_metrics: XenApiHostMetrics
+ message: XenApiMessage
+ network: XenApiNetwork
+ pool: XenApiPool
+ sr: XenApiSr
+ vm: XenApiVm
+ vm_guest_metrics: XenApiVmGuestMetrics
+ vm_metrics: XenApiVmMetrics
+}
+
+export type ObjectTypeToRecord = Type extends keyof ObjectTypeToRecordMapping
+ ? ObjectTypeToRecordMapping[Type]
+ : never
+
+export type XenApiRecordBeforeLoadEvent = `${Type}.beforeLoad`
+export type XenApiRecordAfterLoadEvent = `${Type}.afterLoad`
+export type XenApiRecordLoadErrorEvent = `${Type}.loadError`
+export type XenApiRecordAddEvent = `${Type}.add`
+export type XenApiRecordModEvent = `${Type}.mod`
+export type XenApiRecordDelEvent = `${Type}.del`
export type XenApiRecordEvent =
| XenApiRecordBeforeLoadEvent
| XenApiRecordAfterLoadEvent
| XenApiRecordLoadErrorEvent
| XenApiRecordAddEvent
| XenApiRecordModEvent
- | XenApiRecordDelEvent;
+ | XenApiRecordDelEvent
-declare const __brand: unique symbol;
+declare const __brand: unique symbol
export interface XenApiRecord {
- $ref: string & { [__brand]: `${Type}Ref` };
- uuid: string & { [__brand]: `${Type}Uuid` };
+ $ref: string & { [__brand]: `${Type}Ref` }
+ uuid: string & { [__brand]: `${Type}Uuid` }
}
-export type RawXenApiRecord> = Omit<
- T,
- "$ref"
->;
+export type RawXenApiRecord> = Omit
-export interface XenApiPool extends XenApiRecord<"pool"> {
+export interface XenApiPool extends XenApiRecord<'pool'> {
cpu_info: {
- cpu_count: string;
- };
- master: XenApiHost["$ref"];
- name_label: string;
-}
-
-export interface XenApiHost extends XenApiRecord<"host"> {
- address: string;
- name_label: string;
- metrics: XenApiHostMetrics["$ref"];
- resident_VMs: XenApiVm["$ref"][];
- cpu_info: { cpu_count: string };
- software_version: { product_version: string };
-}
-
-export interface XenApiSr extends XenApiRecord<"sr"> {
- content_type: string;
- name_label: string;
- physical_size: number;
- physical_utilisation: number;
- shared: boolean;
-}
-
-export interface XenApiVm extends XenApiRecord<"vm"> {
- HVM_boot_params: Record;
- HVM_boot_policy: string;
- HVM_shadow_multiplier: number;
- NVRAM: Record;
- PCI_bus: string;
- PV_args: string;
- PV_bootloader: string;
- PV_bootloader_args: string;
- PV_kernel: string;
- PV_legacy_args: string;
- PV_ramdisk: string;
- VBDs: XenApiVbd["$ref"][];
- VCPUs_at_startup: number;
- VCPUs_max: number;
- VCPUs_params: Record;
- VGPUs: XenApiVgpu["$ref"][];
- VIFs: XenApiVif["$ref"][];
- VTPMs: XenApiVtpm["$ref"][];
- VUSBs: XenApiVusb["$ref"][];
- actions_after_crash: ON_CRASH_BEHAVIOUR;
- actions_after_reboot: ON_NORMAL_EXIT;
- actions_after_shutdown: ON_NORMAL_EXIT;
- actions_after_softreboot: ON_SOFTREBOOT_BEHAVIOR;
- affinity: XenApiHost["$ref"];
- allowed_operations: VM_OPERATION[];
- appliance: XenApiVmAppliance["$ref"];
- attached_PCIs: XenApiPci["$ref"][];
- bios_strings: Record;
- blobs: Record;
- blocked_operations: Record;
- children: XenApiVm["$ref"][];
- consoles: XenApiConsole["$ref"][];
- crash_dumps: XenApiCrashdump["$ref"][];
- current_operations: Record;
- domain_type: DOMAIN_TYPE;
- domarch: string;
- domid: number;
- generation_id: string;
- guest_metrics: XenApiVmGuestMetrics["$ref"];
- ha_always_run: boolean;
- ha_restart_priority: string;
- hardware_platform_version: number;
- has_vendor_device: boolean;
- is_a_snapshot: boolean;
- is_a_template: boolean;
- is_control_domain: boolean;
- is_default_template: boolean;
- is_snapshot_from_vmpp: boolean;
- is_vmss_snapshot: boolean;
- last_boot_CPU_flags: Record;
- last_booted_record: string;
- memory_dynamic_max: number;
- memory_dynamic_min: number;
- memory_overhead: number;
- memory_static_max: number;
- memory_static_min: number;
- memory_target: number;
- metrics: XenApiVmMetrics["$ref"];
- name_description: string;
- name_label: string;
- order: number;
- other_config: Record;
- parent: XenApiVm["$ref"];
- pending_guidances: UPDATE_GUIDANCE[];
- platform: Record;
- power_state: VM_POWER_STATE;
- protection_policy: XenApiVmpp["$ref"];
- recommendations: string;
- reference_label: string;
- requires_reboot: boolean;
- resident_on: XenApiHost["$ref"];
- scheduled_to_be_resident_on: XenApiHost["$ref"];
- shutdown_delay: number;
- snapshot_info: Record;
- snapshot_metadata: string;
- snapshot_of: XenApiVm["$ref"];
- snapshot_schedule: XenApiVmss["$ref"];
- snapshot_time: string;
- snapshots: XenApiVm["$ref"][];
- start_delay: number;
- suspend_SR: XenApiSr["$ref"];
- suspend_VDI: XenApiVdi["$ref"];
- tags: string[];
- transportable_snapshot_id: string;
- user_version: number;
- version: number;
- xenstore_data: Record;
-}
-
-export interface XenApiVtpm extends XenApiRecord<"vtpm"> {
- VM: XenApiVm["$ref"];
- allowed_operations: VTPM_OPERATION[];
- backend: XenApiVm["$ref"];
- current_operations: Record;
- is_protected: boolean;
- is_unique: boolean;
- persistence_backend: PERSISTENCE_BACKEND;
-}
-
-export interface XenApiVusb extends XenApiRecord<"vusb"> {
- USB_group: XenApiUsbGroup["$ref"];
- VM: XenApiVm["$ref"];
- allowed_operations: VUSB_OPERATION[];
- current_operations: Record;
- currently_attached: boolean;
- other_config: Record;
-}
-
-export interface XenApiUsbGroup extends XenApiRecord<"usb_group"> {
- PUSBs: XenApiPusb["$ref"][];
- VUSBs: XenApiVusb["$ref"][];
- name_description: string;
- name_label: string;
- other_config: Record;
-}
-
-export interface XenApiPusb extends XenApiRecord<"pusb"> {
- USB_group: XenApiUsbGroup["$ref"];
- description: string;
- host: XenApiHost["$ref"];
- other_config: Record;
- passthrough_enabled: boolean;
- path: string;
- product_desc: string;
- product_id: string;
- serial: string;
- speed: number;
- vendor_desc: string;
- vendor_id: string;
- version: string;
-}
-
-export interface XenApiVgpu extends XenApiRecord<"vgpu"> {
- GPU_group: XenApiGpuGroup["$ref"];
- PCI: XenApiPci["$ref"];
- VM: XenApiVm["$ref"];
- compatibility_metadata: Record;
- currently_attached: boolean;
- device: string;
- extra_args: string;
- other_config: Record;
- resident_on: XenApiPgpu["$ref"];
- scheduled_to_be_resident_on: XenApiPgpu["$ref"];
- type: XenApiVgpuType["$ref"];
-}
-
-export interface XenApiGpuGroup extends XenApiRecord<"gpu_group"> {
- GPU_types: string[];
- PGPUs: XenApiPgpu["$ref"][];
- VGPUs: XenApiVgpu["$ref"][];
- allocation_algorithm: ALLOCATION_ALGORITHM;
- enabled_VGPU_types: XenApiVgpuType["$ref"][];
- name_description: string;
- name_label: string;
- other_config: Record;
- supported_VGPU_types: XenApiVgpuType["$ref"][];
-}
-
-export interface XenApiPgpu extends XenApiRecord<"pgpu"> {
- GPU_group: XenApiGpuGroup["$ref"];
- PCI: XenApiPci["$ref"];
- compatibility_metadata: Record;
- dom0_access: PGPU_DOM0_ACCESS;
- enabled_VGPU_types: XenApiVgpuType["$ref"][];
- host: XenApiHost["$ref"];
- is_system_display_device: boolean;
- other_config: Record;
- resident_VGPUs: XenApiVgpu["$ref"][];
- supported_VGPU_max_capacities: Record;
- supported_VGPU_types: XenApiVgpuType["$ref"][];
-}
-
-export interface XenApiVgpuType extends XenApiRecord<"vgpu_type"> {
- VGPUs: XenApiVgpu["$ref"][];
- compatible_types_in_vm: XenApiVgpuType["$ref"][];
- enabled_on_GPU_groups: XenApiGpuGroup["$ref"][];
- enabled_on_PGPUs: XenApiPgpu["$ref"][];
- experimental: boolean;
- framebuffer_size: number;
- identifier: string;
- implementation: VGPU_TYPE_IMPLEMENTATION;
- max_heads: number;
- max_resolution_x: number;
- max_resolution_y: number;
- model_name: string;
- supported_on_GPU_groups: XenApiGpuGroup["$ref"][];
- supported_on_PGPUs: XenApiPgpu["$ref"][];
- vendor_name: string;
-}
-
-export interface XenApiVmAppliance extends XenApiRecord<"vm_appliance"> {
- VMs: XenApiVm["$ref"][];
- allowed_operations: VM_APPLIANCE_OPERATION[];
- current_operations: Record;
- name_description: string;
- name_label: string;
-}
-
-export interface XenApiVmpp extends XenApiRecord<"vmpp"> {
- VMs: XenApiVm["$ref"][];
- alarm_config: Record;
- archive_frequency: VMPP_ARCHIVE_FREQUENCY;
- archive_last_run_time: string;
- archive_schedule: Record;
- archive_target_config: Record;
- archive_target_type: VMPP_ARCHIVE_TARGET_TYPE;
- backup_frequency: VMPP_BACKUP_FREQUENCY;
- backup_last_run_time: string;
- backup_retention_value: number;
- backup_schedule: Record;
- backup_type: VMPP_BACKUP_TYPE;
- is_alarm_enabled: boolean;
- is_archive_running: boolean;
- is_backup_running: boolean;
- is_policy_enabled: boolean;
- name_description: string;
- name_label: string;
- recent_alerts: string[];
-}
-
-export interface XenApiVmss extends XenApiRecord<"vmss"> {
- VMs: XenApiVm["$ref"][];
- enabled: boolean;
- frequency: VMSS_FREQUENCY;
- last_run_time: string;
- name_description: string;
- name_label: string;
- retained_snapshots: number;
- schedule: Record;
- type: VMSS_TYPE;
-}
-
-export interface XenApiConsole extends XenApiRecord<"console"> {
- protocol: string;
- location: string;
-}
-
-export interface XenApiHostMetrics extends XenApiRecord<"host_metrics"> {
- live: boolean;
- memory_free: number;
- memory_total: number;
-}
-
-export interface XenApiVmMetrics extends XenApiRecord<"vm_metrics"> {
- VCPUs_number: number;
-}
-
-export type XenApiVmGuestMetrics = XenApiRecord<"vm_guest_metrics">;
-
-export interface XenApiTask extends XenApiRecord<"task"> {
- name_label: string;
- resident_on: XenApiHost["$ref"];
- created: string;
- finished: string;
- status: string;
- progress: number;
-}
-
-export interface XenApiMessage
- extends XenApiRecord<"message"> {
- body: string;
- cls: RelationType;
- name: string;
- obj_uuid: ObjectTypeToRecord>["uuid"];
- priority: number;
- timestamp: string;
-}
-
-export interface XenApiVbd extends XenApiRecord<"vbd"> {
- VDI: XenApiVdi["$ref"];
- VM: XenApiVm["$ref"];
- allowed_operations: VBD_OPERATION[];
- bootable: boolean;
- current_operations: Record;
- currently_attached: boolean;
- device: string;
- empty: boolean;
- metrics: XenApiVbdMetrics["$ref"];
- mode: VBD_MODE;
- other_config: Record;
- qos_algorithm_params: Record;
- qos_algorithm_type: string;
- qos_supported_algorithms: string[];
- runtime_properties: Record;
- status_code: number;
- status_detail: string;
- storage_lock: boolean;
- type: VBD_TYPE;
- unpluggable: boolean;
- userdevice: string;
-}
-
-export interface XenApiVbdMetrics extends XenApiRecord<"vbd_metrics"> {
- io_read_kbs: number;
- io_write_kbs: number;
- last_updated: string;
- other_config: Record;
-}
-
-export interface XenApiVdi extends XenApiRecord<"vdi"> {
- SR: XenApiSr["$ref"];
- VBDs: XenApiVbd["$ref"][];
- allow_caching: boolean;
- allowed_operations: VDI_OPERATION[];
- cbt_enabled: boolean;
- crash_dumps: XenApiCrashdump["$ref"][];
- current_operations: Record;
- is_a_snapshot: boolean;
- is_tools_iso: boolean;
- location: string;
- managed: boolean;
- metadata_latest: boolean;
- metadata_of_pool: XenApiPool["$ref"];
- missing: boolean;
- name_description: string;
- name_label: string;
- on_boot: ON_BOOT;
- other_config: Record;
- parent: XenApiVdi["$ref"];
- physical_utilisation: number;
- read_only: boolean;
- sharable: boolean;
- sm_config: Record;
- snapshot_of: XenApiVdi["$ref"];
- snapshot_time: string;
- snapshots: XenApiVdi["$ref"][];
- storage_lock: boolean;
- tags: string[];
- type: VDI_TYPE;
- virtual_size: number;
- xenstore_data: Record;
-}
-
-export interface XenApiCrashdump extends XenApiRecord<"crashdump"> {
- VDI: XenApiVdi["$ref"];
- VM: XenApiVm["$ref"];
- other_config: Record;
-}
-
-export interface XenApiNetwork extends XenApiRecord<"network"> {
- MTU: number;
- PIFs: XenApiPif["$ref"][];
- VIFs: XenApiVif["$ref"][];
- allowed_operations: NETWORK_OPERATION[];
- assigned_ips: Record;
- blobs: Record;
- bridge: string;
- current_operations: Record;
- default_locking_mode: NETWORK_DEFAULT_LOCKING_MODE;
- managed: boolean;
- name_description: string;
- name_label: string;
- other_config: Record;
- purpose: NETWORK_PURPOSE[];
- tags: string[];
-}
-
-export interface XenApiBlob extends XenApiRecord<"blob"> {
- last_updated: string;
- mime_type: string;
- name_description: string;
- name_label: string;
- public: boolean;
- size: number;
-}
-
-export interface XenApiVif extends XenApiRecord<"vif"> {
- MAC: string;
- MAC_autogenerated: boolean;
- MTU: number;
- VM: XenApiVm["$ref"];
- allowed_operations: VIF_OPERATION[];
- current_operations: Record;
- currently_attached: boolean;
- device: string;
- ipv4_addresses: string[];
- ipv4_allowed: string[];
- ipv4_configuration_mode: VIF_IPV4_CONFIGURATION_MODE;
- ipv4_gateway: string;
- ipv6_addresses: string[];
- ipv6_allowed: string[];
- ipv6_configuration_mode: VIF_IPV6_CONFIGURATION_MODE;
- ipv6_gateway: string;
- locking_mode: VIF_LOCKING_MODE;
- metrics: XenApiVifMetrics["$ref"];
- network: XenApiNetwork["$ref"];
- other_config: Record;
- qos_algorithm_params: Record;
- qos_algorithm_type: string;
- qos_supported_algorithms: string[];
- runtime_properties: Record;
- status_code: number;
- status_detail: string;
-}
-
-export interface XenApiVifMetrics extends XenApiRecord<"vif_metrics"> {
- io_read_kbs: number;
- io_write_kbs: number;
- last_updated: string;
- other_config: Record;
-}
-
-export interface XenApiPif extends XenApiRecord<"pif"> {
- DNS: string;
- IP: string;
- IPv6: string[];
- MAC: string;
- MTU: number;
- PCI: XenApiPci["$ref"];
- VLAN: number;
- VLAN_master_of: XenApiVlan["$ref"];
- VLAN_slave_of: XenApiVlan["$ref"][];
- bond_master_of: XenApiBond["$ref"][];
- bond_slave_of: XenApiBond["$ref"];
- capabilities: string[];
- currently_attached: boolean;
- device: string;
- disallow_unplug: boolean;
- gateway: string;
- host: XenApiHost["$ref"];
- igmp_snooping_status: PIF_IGMP_STATUS;
- ip_configuration_mode: IP_CONFIGURATION_MODE;
- ipv6_configuration_mode: IPV6_CONFIGURATION_MODE;
- ipv6_gateway: string;
- managed: boolean;
- management: boolean;
- metrics: XenApiPifMetrics["$ref"];
- netmask: string;
- network: XenApiNetwork["$ref"];
- other_config: Record;
- physical: boolean;
- primary_address_type: PRIMARY_ADDRESS_TYPE;
- properties: Record;
- sriov_logical_PIF_of: XenApiNetworkSriov["$ref"][];
- sriov_physical_PIF_of: XenApiNetworkSriov["$ref"][];
- tunnel_access_PIF_of: XenApiTunnel["$ref"][];
- tunnel_transport_PIF_of: XenApiTunnel["$ref"][];
-}
-
-export interface XenApiNetworkSriov extends XenApiRecord<"network_sriov"> {
- configuration_mode: SRIOV_CONFIGURATION_MODE;
- logical_PIF: XenApiPif["$ref"];
- physical_PIF: XenApiPif["$ref"];
- requires_reboot: boolean;
-}
-
-export interface XenApiVlan extends XenApiRecord<"vlan"> {
- other_config: Record;
- tag: number;
- tagged_PIF: XenApiPif["$ref"];
- untagged_PIF: XenApiPif["$ref"];
-}
-
-export interface XenApiTunnel extends XenApiRecord<"tunnel"> {
- access_PIF: XenApiPif["$ref"];
- other_config: Record;
- protocol: TUNNEL_PROTOCOL;
- status: Record;
- transport_PIF: XenApiPif["$ref"];
-}
-
-export interface XenApiPci extends XenApiRecord<"pci"> {
- class_name: string;
- dependencies: XenApiPci["$ref"][];
- device_name: string;
- driver_name: string;
- host: XenApiHost["$ref"];
- other_config: Record;
- pci_id: string;
- subsystem_device_name: string;
- subsystem_vendor_name: string;
- vendor_name: string;
-}
-
-export interface XenApiPifMetrics extends XenApiRecord<"pif_metrics"> {
- carrier: boolean;
- device_id: string;
- device_name: string;
- duplex: boolean;
- io_read_kbs: number;
- io_write_kbs: number;
- last_updated: string;
- other_config: Record;
- pci_bus_path: string;
- speed: number;
- vendor_id: string;
- vendor_name: string;
-}
-
-export interface XenApiBond extends XenApiRecord<"bond"> {
- auto_update_mac: boolean;
- links_up: number;
- master: XenApiPif["$ref"];
- mode: BOND_MODE;
- other_config: Record;
- primary_slave: XenApiPif["$ref"];
- properties: Record;
- slaves: XenApiPif["$ref"][];
-}
-
-export type XenApiEvent<
- RelationType extends ObjectType,
- XRecord extends ObjectTypeToRecord,
-> = {
- id: string;
- class: RelationType;
- operation: "add" | "mod" | "del";
- ref: XRecord["$ref"];
- snapshot: RawXenApiRecord;
-};
+ cpu_count: string
+ }
+ master: XenApiHost['$ref']
+ name_label: string
+}
+
+export interface XenApiHost extends XenApiRecord<'host'> {
+ address: string
+ name_label: string
+ metrics: XenApiHostMetrics['$ref']
+ resident_VMs: XenApiVm['$ref'][]
+ cpu_info: { cpu_count: string }
+ software_version: { product_version: string }
+}
+
+export interface XenApiSr extends XenApiRecord<'sr'> {
+ content_type: string
+ name_label: string
+ physical_size: number
+ physical_utilisation: number
+ shared: boolean
+}
+
+export interface XenApiVm extends XenApiRecord<'vm'> {
+ HVM_boot_params: Record
+ HVM_boot_policy: string
+ HVM_shadow_multiplier: number
+ NVRAM: Record
+ PCI_bus: string
+ PV_args: string
+ PV_bootloader: string
+ PV_bootloader_args: string
+ PV_kernel: string
+ PV_legacy_args: string
+ PV_ramdisk: string
+ VBDs: XenApiVbd['$ref'][]
+ VCPUs_at_startup: number
+ VCPUs_max: number
+ VCPUs_params: Record
+ VGPUs: XenApiVgpu['$ref'][]
+ VIFs: XenApiVif['$ref'][]
+ VTPMs: XenApiVtpm['$ref'][]
+ VUSBs: XenApiVusb['$ref'][]
+ actions_after_crash: ON_CRASH_BEHAVIOUR
+ actions_after_reboot: ON_NORMAL_EXIT
+ actions_after_shutdown: ON_NORMAL_EXIT
+ actions_after_softreboot: ON_SOFTREBOOT_BEHAVIOR
+ affinity: XenApiHost['$ref']
+ allowed_operations: VM_OPERATION[]
+ appliance: XenApiVmAppliance['$ref']
+ attached_PCIs: XenApiPci['$ref'][]
+ bios_strings: Record
+ blobs: Record
+ blocked_operations: Record
+ children: XenApiVm['$ref'][]
+ consoles: XenApiConsole['$ref'][]
+ crash_dumps: XenApiCrashdump['$ref'][]
+ current_operations: Record
+ domain_type: DOMAIN_TYPE
+ domarch: string
+ domid: number
+ generation_id: string
+ guest_metrics: XenApiVmGuestMetrics['$ref']
+ ha_always_run: boolean
+ ha_restart_priority: string
+ hardware_platform_version: number
+ has_vendor_device: boolean
+ is_a_snapshot: boolean
+ is_a_template: boolean
+ is_control_domain: boolean
+ is_default_template: boolean
+ is_snapshot_from_vmpp: boolean
+ is_vmss_snapshot: boolean
+ last_boot_CPU_flags: Record
+ last_booted_record: string
+ memory_dynamic_max: number
+ memory_dynamic_min: number
+ memory_overhead: number
+ memory_static_max: number
+ memory_static_min: number
+ memory_target: number
+ metrics: XenApiVmMetrics['$ref']
+ name_description: string
+ name_label: string
+ order: number
+ other_config: Record
+ parent: XenApiVm['$ref']
+ pending_guidances: UPDATE_GUIDANCE[]
+ platform: Record
+ power_state: VM_POWER_STATE
+ protection_policy: XenApiVmpp['$ref']
+ recommendations: string
+ reference_label: string
+ requires_reboot: boolean
+ resident_on: XenApiHost['$ref']
+ scheduled_to_be_resident_on: XenApiHost['$ref']
+ shutdown_delay: number
+ snapshot_info: Record
+ snapshot_metadata: string
+ snapshot_of: XenApiVm['$ref']
+ snapshot_schedule: XenApiVmss['$ref']
+ snapshot_time: string
+ snapshots: XenApiVm['$ref'][]
+ start_delay: number
+ suspend_SR: XenApiSr['$ref']
+ suspend_VDI: XenApiVdi['$ref']
+ tags: string[]
+ transportable_snapshot_id: string
+ user_version: number
+ version: number
+ xenstore_data: Record
+}
+
+export interface XenApiVtpm extends XenApiRecord<'vtpm'> {
+ VM: XenApiVm['$ref']
+ allowed_operations: VTPM_OPERATION[]
+ backend: XenApiVm['$ref']
+ current_operations: Record
+ is_protected: boolean
+ is_unique: boolean
+ persistence_backend: PERSISTENCE_BACKEND
+}
+
+export interface XenApiVusb extends XenApiRecord<'vusb'> {
+ USB_group: XenApiUsbGroup['$ref']
+ VM: XenApiVm['$ref']
+ allowed_operations: VUSB_OPERATION[]
+ current_operations: Record
+ currently_attached: boolean
+ other_config: Record
+}
+
+export interface XenApiUsbGroup extends XenApiRecord<'usb_group'> {
+ PUSBs: XenApiPusb['$ref'][]
+ VUSBs: XenApiVusb['$ref'][]
+ name_description: string
+ name_label: string
+ other_config: Record
+}
+
+export interface XenApiPusb extends XenApiRecord<'pusb'> {
+ USB_group: XenApiUsbGroup['$ref']
+ description: string
+ host: XenApiHost['$ref']
+ other_config: Record
+ passthrough_enabled: boolean
+ path: string
+ product_desc: string
+ product_id: string
+ serial: string
+ speed: number
+ vendor_desc: string
+ vendor_id: string
+ version: string
+}
+
+export interface XenApiVgpu extends XenApiRecord<'vgpu'> {
+ GPU_group: XenApiGpuGroup['$ref']
+ PCI: XenApiPci['$ref']
+ VM: XenApiVm['$ref']
+ compatibility_metadata: Record
+ currently_attached: boolean
+ device: string
+ extra_args: string
+ other_config: Record
+ resident_on: XenApiPgpu['$ref']
+ scheduled_to_be_resident_on: XenApiPgpu['$ref']
+ type: XenApiVgpuType['$ref']
+}
+
+export interface XenApiGpuGroup extends XenApiRecord<'gpu_group'> {
+ GPU_types: string[]
+ PGPUs: XenApiPgpu['$ref'][]
+ VGPUs: XenApiVgpu['$ref'][]
+ allocation_algorithm: ALLOCATION_ALGORITHM
+ enabled_VGPU_types: XenApiVgpuType['$ref'][]
+ name_description: string
+ name_label: string
+ other_config: Record
+ supported_VGPU_types: XenApiVgpuType['$ref'][]
+}
+
+export interface XenApiPgpu extends XenApiRecord<'pgpu'> {
+ GPU_group: XenApiGpuGroup['$ref']
+ PCI: XenApiPci['$ref']
+ compatibility_metadata: Record
+ dom0_access: PGPU_DOM0_ACCESS
+ enabled_VGPU_types: XenApiVgpuType['$ref'][]
+ host: XenApiHost['$ref']
+ is_system_display_device: boolean
+ other_config: Record
+ resident_VGPUs: XenApiVgpu['$ref'][]
+ supported_VGPU_max_capacities: Record
+ supported_VGPU_types: XenApiVgpuType['$ref'][]
+}
+
+export interface XenApiVgpuType extends XenApiRecord<'vgpu_type'> {
+ VGPUs: XenApiVgpu['$ref'][]
+ compatible_types_in_vm: XenApiVgpuType['$ref'][]
+ enabled_on_GPU_groups: XenApiGpuGroup['$ref'][]
+ enabled_on_PGPUs: XenApiPgpu['$ref'][]
+ experimental: boolean
+ framebuffer_size: number
+ identifier: string
+ implementation: VGPU_TYPE_IMPLEMENTATION
+ max_heads: number
+ max_resolution_x: number
+ max_resolution_y: number
+ model_name: string
+ supported_on_GPU_groups: XenApiGpuGroup['$ref'][]
+ supported_on_PGPUs: XenApiPgpu['$ref'][]
+ vendor_name: string
+}
+
+export interface XenApiVmAppliance extends XenApiRecord<'vm_appliance'> {
+ VMs: XenApiVm['$ref'][]
+ allowed_operations: VM_APPLIANCE_OPERATION[]
+ current_operations: Record
+ name_description: string
+ name_label: string
+}
+
+export interface XenApiVmpp extends XenApiRecord<'vmpp'> {
+ VMs: XenApiVm['$ref'][]
+ alarm_config: Record
+ archive_frequency: VMPP_ARCHIVE_FREQUENCY
+ archive_last_run_time: string
+ archive_schedule: Record