fix(xo-web/new VM): missing cloud configs in some cases (#3535)

Fixes #3532
This commit is contained in:
Pierre Donias
2018-10-16 14:14:46 +02:00
committed by GitHub
parent fa5c707fbc
commit 4d18ab1ae0
2 changed files with 21 additions and 5 deletions

View File

@@ -18,6 +18,7 @@
- [Remotes] Fix removal of broken remotes [#3327](https://github.com/vatesfr/xen-orchestra/issues/3327) (PR [#3521](https://github.com/vatesfr/xen-orchestra/pull/3521))
- [Backups] Fix stuck backups due to broken NFS remotes [#3467](https://github.com/vatesfr/xen-orchestra/issues/3467) (PR [#3534](https://github.com/vatesfr/xen-orchestra/pull/3534))
- [New VM] Fix missing cloud config when creating multiple VMs at once in some cases [#3532](https://github.com/vatesfr/xen-orchestra/issues/3532) (PR [#3535](https://github.com/vatesfr/xen-orchestra/pull/3535))
### Released packages

View File

@@ -349,18 +349,30 @@ export default class NewVm extends BaseComponent {
let cloudConfig
let cloudConfigs
if (state.installMethod !== 'noConfigDrive') {
const hostname = state.name_label
.replace(/^\s+|\s+$/g, '')
.replace(/\s+/g, '-')
if (state.installMethod === 'SSH') {
cloudConfig = `#cloud-config\nhostname: ${hostname}\nssh_authorized_keys:\n${join(
const format = hostname =>
hostname.replace(/^\s+|\s+$/g, '').replace(/\s+/g, '-')
const stringifiedKeys = join(
map(state.sshKeys, keyId => {
return this.props.userSshKeys[keyId]
? ` - ${this.props.userSshKeys[keyId].key}\n`
: ''
}),
''
)}`
)
cloudConfig = `#cloud-config\nhostname: ${format(
state.name_label
)}\nssh_authorized_keys:\n${stringifiedKeys}`
if (state.multipleVms) {
cloudConfigs = map(
state.nameLabels,
nameLabel =>
`#cloud-config\nhostname: ${format(
nameLabel
)}\nssh_authorized_keys:\n${stringifiedKeys}`
)
}
} else if (state.installMethod === 'customConfig') {
const replacer = this._buildTemplate(
defined(state.customConfig, DEFAULT_CLOUD_CONFIG_TEMPLATE)
@@ -375,6 +387,9 @@ export default class NewVm extends BaseComponent {
}
} else if (state.template.name_label === 'CoreOS') {
cloudConfig = state.cloudConfig
if (state.multipleVms) {
cloudConfigs = new Array(state.nbVms).fill(state.cloudConfig)
}
}
// Split allowed IPs into IPv4 and IPv6