Skip to content

Commit

Permalink
fixup! refactor(xo-server): extract vmware import method to its own m…
Browse files Browse the repository at this point in the history
…ixin
  • Loading branch information
fbeauchamp committed Apr 15, 2024
1 parent dacd370 commit 71513de
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/xo-server/src/xo-mixins/vmware/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class MigrateVm {

async #createVmAndNetworks({ metadata, networkId, xapi }) {
const { firmware, memory, name_label, networks, nCpus } = metadata
return await Task.run({ properties: { name: 'creating MV on XCP side' } }, async () => {
return await Task.run({ properties: { name: 'creating VM on XCP side' } }, async () => {
// got data, ready to start creating
const vm = await xapi._getOrWaitObject(
await xapi.VM_create({
Expand Down Expand Up @@ -85,14 +85,17 @@ export default class MigrateVm {
}
)

const coldChainsByNodes = chainsByNodes.map(_ => [..._]) // contains a copy
const runningChainByNodes = []
if (isRunning) {
coldChainsByNodes.forEach((coldChainByNodes, index) => {
const running = coldChainByNodes.pop() // cold chain doew not contain the running one anymore
const coldChainsByNodes = {}
const runningChainByNodes ={}
Object.entries(chainsByNodes).forEach(([key, chain])=>{
const chainCopy = [...chain]
if (isRunning) {
const running = chainCopy.pop() // cold chain does not contain the running one anymore
runningChainByNodes[index] = [running]

Check failure on line 94 in packages/xo-server/src/xo-mixins/vmware/index.mjs

View workflow job for this annotation

GitHub Actions / CI

'index' is not defined
})
}
}
coldChainsByNodes[key] = chainCopy
})


const vhds = await importDisksFromDatastore({
esxi,
Expand Down

0 comments on commit 71513de

Please sign in to comment.