knife-vsphere icon indicating copy to clipboard operation
knife-vsphere copied to clipboard

implement cloning to multiple datastores (or upd documentation if that's possible now)

Open bby-bishopclark opened this issue 7 years ago • 1 comments

Versions:

2.0.1

Scenario:

I'm hoping to allocate clone a host with disks from multiple datastores, TO multiple datastores.

Template VM has 4 vHBAs. Disks on those vHBAs correspond to OS, Logs, Tmp/swap and Data, to evenly spread out writes to many queues.

While cloning this new layout, I realized that --datastore seems to only accept the one string . Docs and code didn't quickly suggest an array is possible (like --cvlan/cips) .

I'd like to clone with a

knife vsphere vm clone \
:
:
   --cvlan 'service-vlan,dbase-vlan' --cips '10.1.1.5,10.2.1.5' \
   --datastorecluster 'dsc-sas-os,dsc-sata-logs,dsc-ssd-tmpswp,dsc-sas-data' \
:
:

.. but I'm thinking rbvmomi doesn't give us the option. True? I tried to dive into that, but it quickly lost me.

Any chance?

I can clone, deploy and (later) migrate the fast, small VMDKs over to the SSD; that's no big deal. But it'd be so pretty to have it all in the one command, right?

No stress. I'm sure after that, someone would want to mix --ds and --dsc . Can of worms, this one ;-)

bby-bishopclark avatar Jan 30 '18 23:01 bby-bishopclark

Just thinking out loud here.

https://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.vm.RelocateSpec.html describes the RelocateSpec we use to clone the VM. We use the datastore option here. That seems to apply to any and all disks on that template.

It does look like there's a disk option that lets you specify an array of disks, though it needs both the datastore and a disk ID. Not sure where the second comes from, but that doesn't seem insurmountable to either look up or ask the user for.

Your comma idea is probably the ideal way to do it, and if we saw a comma in the string we'd split on that and fill in disk instead. It might be that we have to pass the id in too, such as --datastore dsc-sas-os:0,dsc-sata-logs:1,dsc-ssd-tmpswp:2,dsc-sas-data:3

That's datastores. Clusters seem a bit more complicated as we end up picking a data store from the cluster and not passing the cluster to VMWare itself (maybe it works? Who knows? Never tried. That code was from before my time here.)

So your ask doesn't sound that bad especially if we start with the simple case of datastores.

swalberg avatar Jan 31 '18 01:01 swalberg