feat(xo-server/vm.create): change cloud-init configdrive to nocloud type (#3877)

Related to #3872
This commit is contained in:
Jon Sands 2019-01-22 05:42:25 -05:00 committed by Julien Fontanet
parent 449dd2998b
commit 4badf48c45
4 changed files with 16 additions and 12 deletions

View File

@ -7,6 +7,7 @@
- [VM migration] Display hosts' free memory [#3264](https://github.com/vatesfr/xen-orchestra/issues/3264) (PR [#3832](https://github.com/vatesfr/xen-orchestra/pull/3832))
- [Plugins] New field to filter displayed plugins (PR [#3832](https://github.com/vatesfr/xen-orchestra/pull/3871))
- Ability to copy ID of "unknown item"s [#3833](https://github.com/vatesfr/xen-orchestra/issues/3833) (PR [#3856](https://github.com/vatesfr/xen-orchestra/pull/3856))
- [Cloud-Init] switch config drive type to `nocloud` to prepare for the passing of network config (PR [#3877](https://github.com/vatesfr/xen-orchestra/pull/3877))
### Bug fixes

View File

@ -24,10 +24,11 @@ to create a [GitHub pull request](https://help.github.com/articles/using-pull-re
1. Create a branch for your work
2. Create a pull request for this branch against the `master` branch
3. Push into the branch until the pull request is ready to merge
4. Avoid unnecessary merges: keep you branch up to date by regularly rebasing `git rebase origin/master`
5. When ready to merge, clean up the history (reorder commits, squash some of them together, rephrase messages): `git rebase -i origin/master`
2. Add a summary of your changes to `CHANGELOG.md` under the `next` section, if your changes do not relate to an existing changelog item
3. Create a pull request for this branch against the `master` branch
4. Push into the branch until the pull request is ready to merge
5. Avoid unnecessary merges: keep you branch up to date by regularly rebasing `git rebase origin/master`
6. When ready to merge, clean up the history (reorder commits, squash some of them together, rephrase messages): `git rebase -i origin/master`
### Issue triage

View File

@ -16,6 +16,7 @@
// }
// })
import assert from 'assert'
import { boot16 as fat16 } from 'fatfs/structs'
const SECTOR_SIZE = 512
@ -23,7 +24,10 @@ const SECTOR_SIZE = 512
const TEN_MIB = 10 * 1024 * 1024
// Creates a 10MB buffer and initializes it as a FAT 16 volume.
export function init() {
export function init({ label: 'cidata ' } = {}) {
assert.strictEqual(typeof label, 'string')
assert.strictEqual(label.length, 11)
const buf = Buffer.alloc(TEN_MIB)
// https://github.com/natevw/fatfs/blob/master/structs.js
@ -47,7 +51,7 @@ export function init() {
Reserved1: 0,
BootSig: 41,
VolID: 895111106,
VolLab: 'NO NAME ',
VolLab: label,
FilSysType: 'FAT16 ',
},
buf

View File

@ -2327,7 +2327,7 @@ export default class Xapi extends XapiBase {
const sr = this.getObject(srId)
// First, create a small VDI (10MB) which will become the ConfigDrive
const buffer = fatfsBufferInit()
const buffer = fatfsBufferInit({ label: 'cidata ' })
const vdi = await this.createVdi({
name_label: 'XO CloudConfigDrive',
size: buffer.length,
@ -2338,14 +2338,12 @@ export default class Xapi extends XapiBase {
// Then, generate a FAT fs
const fs = promisifyAll(fatfs.createFileSystem(fatfsBuffer(buffer)))
await fs.mkdir('openstack')
await fs.mkdir('openstack/latest')
await Promise.all([
fs.writeFile(
'openstack/latest/meta_data.json',
'{\n "uuid": "' + vm.uuid + '"\n}\n'
'meta-data',
'instance-id: ' + vm.uuid + '\n'
),
fs.writeFile('openstack/latest/user_data', config),
fs.writeFile('user-data', config),
])
// ignore errors, I (JFT) don't understand why they are emitted