commit
18268acc1f
@ -11,16 +11,17 @@ export * as group from './group'
|
|||||||
export * as host from './host'
|
export * as host from './host'
|
||||||
export * as job from './job'
|
export * as job from './job'
|
||||||
export * as message from './message'
|
export * as message from './message'
|
||||||
export * as remote from './remote'
|
|
||||||
export * as pbd from './pbd'
|
export * as pbd from './pbd'
|
||||||
export * as pif from './pif'
|
export * as pif from './pif'
|
||||||
export * as pool from './pool'
|
export * as pool from './pool'
|
||||||
|
export * as remote from './remote'
|
||||||
export * as role from './role'
|
export * as role from './role'
|
||||||
export * as schedule from './schedule'
|
export * as schedule from './schedule'
|
||||||
export * as scheduler from './scheduler'
|
export * as scheduler from './scheduler'
|
||||||
export * as server from './server'
|
export * as server from './server'
|
||||||
export * as session from './session'
|
export * as session from './session'
|
||||||
export * as sr from './sr'
|
export * as sr from './sr'
|
||||||
|
export * as tag from './tag'
|
||||||
export * as task from './task'
|
export * as task from './task'
|
||||||
export * as test from './test'
|
export * as test from './test'
|
||||||
export * as token from './token'
|
export * as token from './token'
|
||||||
|
31
src/api/tag.js
Normal file
31
src/api/tag.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
export async function add ({tag, object}) {
|
||||||
|
await this.getXAPI(object).addTag(object.id, tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
add.description = 'add a new tag to an object'
|
||||||
|
|
||||||
|
add.resolve = {
|
||||||
|
object: ['id', null, 'administrate']
|
||||||
|
}
|
||||||
|
|
||||||
|
add.params = {
|
||||||
|
tag: { type: 'string' },
|
||||||
|
id: { type: 'string' }
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
|
||||||
|
export async function remove ({tag, object}) {
|
||||||
|
await this.getXAPI(object).removeTag(object.id, tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
remove.description = 'remove an existing tag from an object'
|
||||||
|
|
||||||
|
remove.resolve = {
|
||||||
|
object: ['id', null, 'administrate']
|
||||||
|
}
|
||||||
|
|
||||||
|
remove.params = {
|
||||||
|
tag: { type: 'string' },
|
||||||
|
id: { type: 'string' }
|
||||||
|
}
|
@ -55,6 +55,7 @@ export function pool (obj) {
|
|||||||
default_SR: link(obj, 'default_SR'),
|
default_SR: link(obj, 'default_SR'),
|
||||||
HA_enabled: Boolean(obj.ha_enabled),
|
HA_enabled: Boolean(obj.ha_enabled),
|
||||||
master: link(obj, 'master'),
|
master: link(obj, 'master'),
|
||||||
|
tags: obj.tags,
|
||||||
name_description: obj.name_description,
|
name_description: obj.name_description,
|
||||||
name_label: obj.name_label || obj.$master.name_label
|
name_label: obj.name_label || obj.$master.name_label
|
||||||
|
|
||||||
@ -111,6 +112,7 @@ export function host (obj) {
|
|||||||
patches: link(obj, 'patches'),
|
patches: link(obj, 'patches'),
|
||||||
powerOnMode: obj.power_on_mode,
|
powerOnMode: obj.power_on_mode,
|
||||||
power_state: isRunning ? 'Running' : 'Halted',
|
power_state: isRunning ? 'Running' : 'Halted',
|
||||||
|
tags: obj.tags,
|
||||||
version: obj.software_version.product_version,
|
version: obj.software_version.product_version,
|
||||||
|
|
||||||
// TODO: dedupe.
|
// TODO: dedupe.
|
||||||
@ -225,6 +227,7 @@ export function vm (obj) {
|
|||||||
PV_drivers_up_to_date: Boolean(guestMetrics && guestMetrics.PV_drivers_up_to_date),
|
PV_drivers_up_to_date: Boolean(guestMetrics && guestMetrics.PV_drivers_up_to_date),
|
||||||
snapshot_time: toTimestamp(obj.snapshot_time),
|
snapshot_time: toTimestamp(obj.snapshot_time),
|
||||||
snapshots: link(obj, 'snapshots'),
|
snapshots: link(obj, 'snapshots'),
|
||||||
|
tags: obj.tags,
|
||||||
VIFs: link(obj, 'VIFs'),
|
VIFs: link(obj, 'VIFs'),
|
||||||
|
|
||||||
$container: (
|
$container: (
|
||||||
@ -290,6 +293,7 @@ export function sr (obj) {
|
|||||||
physical_usage: +obj.physical_utilisation,
|
physical_usage: +obj.physical_utilisation,
|
||||||
size: +obj.physical_size,
|
size: +obj.physical_size,
|
||||||
SR_type: obj.type,
|
SR_type: obj.type,
|
||||||
|
tags: obj.tags,
|
||||||
usage: +obj.virtual_allocation,
|
usage: +obj.virtual_allocation,
|
||||||
VDIs: link(obj, 'VDIs'),
|
VDIs: link(obj, 'VDIs'),
|
||||||
|
|
||||||
@ -357,6 +361,7 @@ export function vdi (obj) {
|
|||||||
size: +obj.virtual_size,
|
size: +obj.virtual_size,
|
||||||
snapshots: link(obj, 'snapshots'),
|
snapshots: link(obj, 'snapshots'),
|
||||||
snapshot_time: toTimestamp(obj.snapshot_time),
|
snapshot_time: toTimestamp(obj.snapshot_time),
|
||||||
|
tags: obj.tags,
|
||||||
usage: +obj.physical_utilisation,
|
usage: +obj.physical_utilisation,
|
||||||
|
|
||||||
$snapshot_of: link(obj, 'snapshot_of'),
|
$snapshot_of: link(obj, 'snapshot_of'),
|
||||||
@ -405,6 +410,7 @@ export function network (obj) {
|
|||||||
MTU: +obj.MTU,
|
MTU: +obj.MTU,
|
||||||
name_description: obj.name_description,
|
name_description: obj.name_description,
|
||||||
name_label: obj.name_label,
|
name_label: obj.name_label,
|
||||||
|
tags: obj.tags,
|
||||||
PIFs: link(obj, 'PIFs'),
|
PIFs: link(obj, 'PIFs'),
|
||||||
VIFs: link(obj, 'VIFs')
|
VIFs: link(obj, 'VIFs')
|
||||||
}
|
}
|
||||||
|
22
src/xapi.js
22
src/xapi.js
@ -242,6 +242,28 @@ export default class Xapi extends XapiBase {
|
|||||||
|
|
||||||
// =================================================================
|
// =================================================================
|
||||||
|
|
||||||
|
async addTag (id, tag) {
|
||||||
|
const {
|
||||||
|
$ref: ref,
|
||||||
|
$type: type
|
||||||
|
} = this.getObject(id)
|
||||||
|
|
||||||
|
const namespace = getNamespaceForType(type)
|
||||||
|
await this.call(`${namespace}.add_tags`, ref, tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
async removeTag (id, tag) {
|
||||||
|
const {
|
||||||
|
$ref: ref,
|
||||||
|
$type: type
|
||||||
|
} = this.getObject(id)
|
||||||
|
|
||||||
|
const namespace = getNamespaceForType(type)
|
||||||
|
await this.call(`${namespace}.remove_tags`, ref, tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
// =================================================================
|
||||||
|
|
||||||
// FIXME: should be static
|
// FIXME: should be static
|
||||||
@debounce(24 * 60 * 60 * 1000)
|
@debounce(24 * 60 * 60 * 1000)
|
||||||
async _getXenUpdates () {
|
async _getXenUpdates () {
|
||||||
|
Loading…
Reference in New Issue
Block a user