Merge pull request #136 from vatesfr/olivierlambert-cloudconfig

Cloud config management for CoreOS
This commit is contained in:
Olivier Lambert 2015-11-20 17:30:53 +01:00
commit ab3577c369
2 changed files with 56 additions and 1 deletions

View File

@ -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', {

View File

@ -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
})
}
// =================================================================
}