Git Product home page Git Product logo

Comments (4)

github-actions avatar github-actions commented on August 15, 2024

Howdy 🖐   rickatnight11 ! Thank you for your interest in this project. We value your feedback and will respond soon.

If you want to contribute to this project, please make yourself familiar with the CONTRIBUTION guidelines.

from govmomi.

rickatnight11 avatar rickatnight11 commented on August 15, 2024

Digging more into the code, it looks like EditDevice is the helper function I'm looking for. Trying to figure out how to use it correctly.

from govmomi.

rickatnight11 avatar rickatnight11 commented on August 15, 2024

So far I've tried swapping out the disk's backing with a bare-bones one that sets a different path:

// vm = object.VirtualMachine
// newdiskpath = "[datastore-name] vm-name/new-disk.vmdk"

vmdevices, err := vm.Device(ctx)
vmrootdisk := vmdevices.FindByKey(2000)

vmrootdisk.GetVirtualDevice().Backing = &types.VirtualDiskFlatVer2BackingInfo{
    VirtualDeviceFileBackingInfo: types.VirtualDeviceFileBackingInfo{
        FileName:  newdiskpath,
        Datastore: vmrootdisk.GetVirtualDevice().Backing.(types.BaseVirtualDeviceFileBackingInfo).GetVirtualDeviceFileBackingInfo().Datastore,
    },
}

vm.EditDevice(ctx, vmrootdisk)

...but vCenter is returning:

"error": {
  "fault": {
    "property": "virtualDevice.backing",
    "deviceIndex": 0,
    "badFileOp": "replace"
  },
  "localizedMessage": "Invalid operation for device '0'.",
  "Description": {
    "key": "com.vmware.vim.vpxd.vpx.vmprov.ReconfigureVm",
    "message": "Reconfiguring Virtual Machine on destination host"
  }
}

I feel like I'm close.

from govmomi.

rickatnight11 avatar rickatnight11 commented on August 15, 2024

I didn't manage to figure this out, but I did finally get RemoveDevice + AddDevice working, borrowing heavily from govc's device.remove and vm.disk.attach implementations. It's slightly annoying, because I end up needing to removing all disks and adding them back to maintain the original label order (i.e. "Hard disk 1", "Hard disk 2", etc), but it works! Would still love any feedback on cleaner/preferred ways to do this.

from govmomi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.