Merge pull request #136 from vatesfr/olivierlambert-cloudconfig
Cloud config management for CoreOS
This commit is contained in:
commit
ab3577c369
@ -917,6 +917,39 @@ setBootOrder.resolve = {
|
||||
}
|
||||
exports.setBootOrder = setBootOrder
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
getCloudInitConfig = $coroutine ({template}) ->
|
||||
return yield @getXAPI(template).getCloudInitConfig(template._xapiId)
|
||||
|
||||
getCloudInitConfig.params = {
|
||||
template: { type: 'string' }
|
||||
}
|
||||
|
||||
getCloudInitConfig.resolve = {
|
||||
template: ['template', 'VM-template', 'administrate'],
|
||||
}
|
||||
exports.getCloudInitConfig = getCloudInitConfig
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
createCloudInitConfigDrive = $coroutine ({vm, sr, config}) ->
|
||||
xapi = @getXAPI vm
|
||||
yield xapi.createCloudInitConfigDrive(vm._xapiId, sr._xapiId, config)
|
||||
return true
|
||||
|
||||
createCloudInitConfigDrive.params = {
|
||||
vm: { type: 'string' },
|
||||
sr: { type: 'string' },
|
||||
config: { type: 'string' }
|
||||
}
|
||||
|
||||
createCloudInitConfigDrive.resolve = {
|
||||
vm: ['vm', 'VM', 'administrate'],
|
||||
sr: [ 'sr', 'SR', 'operate' ]
|
||||
}
|
||||
exports.createCloudInitConfigDrive = createCloudInitConfigDrive
|
||||
|
||||
#=====================================================================
|
||||
|
||||
Object.defineProperty(exports, '__esModule', {
|
||||
|
24
src/xapi.js
24
src/xapi.js
@ -1325,7 +1325,7 @@ export default class Xapi extends XapiBase {
|
||||
|
||||
async _doDockerAction (vmId, action, containerId) {
|
||||
const vm = this.getObject(vmId)
|
||||
const host = vm.$resident_on
|
||||
const host = vm.$resident_on || this.pool.$master
|
||||
|
||||
return await this.call('host.call_plugin', host.$ref, 'xscontainer', action, {
|
||||
vmuuid: vm.uuid,
|
||||
@ -1361,6 +1361,28 @@ export default class Xapi extends XapiBase {
|
||||
await this._doDockerAction(vmId, 'unpause', containerId)
|
||||
}
|
||||
|
||||
async getCloudInitConfig (templateId) {
|
||||
const template = this.getObject(templateId)
|
||||
const host = this.pool.$master
|
||||
|
||||
let config = await this.call('host.call_plugin', host.$ref, 'xscontainer', 'get_config_drive_default', {
|
||||
templateuuid: template.uuid
|
||||
})
|
||||
return config.slice(4) // FIXME remove the "True" string on the begining
|
||||
}
|
||||
|
||||
async createCloudInitConfigDrive (vmId, srId, config) {
|
||||
const vm = this.getObject(vmId)
|
||||
const host = this.pool.$master
|
||||
const sr = this.getObject(srId)
|
||||
|
||||
await this.call('host.call_plugin', host.$ref, 'xscontainer', 'create_config_drive', {
|
||||
vmuuid: vm.uuid,
|
||||
sruuid: sr.uuid,
|
||||
configuration: config
|
||||
})
|
||||
}
|
||||
|
||||
// =================================================================
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user