Comments (14)
@jmmcatee can you give more context here, govc command or api you're using? There is no managed object for templates, so the api will return the VirtualMachine type for templates. But you can check the VirtualMachineConfigInfo.Template flag. For example:
% govc vm.info -json foo | jq .VirtualMachines[].Config.Template
false
from govmomi.
Sorry I was referencing the API and all I get back is an empty VM for
templates. I don't even get the name. I'll put a gist online later tonight
for reference.
On Jan 5, 2015 1:28 PM, "Doug MacEachern" [email protected] wrote:
@jmmcatee https://github.com/jmmcatee can you give more context here,
govc command or api you're using? There is no managed object for templates,
so the api will return the VirtualMachine type for templates. But you can
check the VirtualMachineConfigInfo.Template flag. For example:% govc vm.info -json foo | jq .VirtualMachines[].Config.Template
falseβ
Reply to this email directly or view it on GitHub
#193 (comment).
from govmomi.
Sounds good. Please include how you're using the API as well, so we know where to look if it is a bug.
from govmomi.
Here is a gist of what I am experiencing.
https://gist.github.com/jmmcatee/f2f77184d20cc86e96b3
Templates show up as empty VirtualMachine structs. Let me know if this helps identify the problem at all.
from govmomi.
I also work with templates and don't experience such issues. Can it be a problem in the 3rd-party library you're using?
from govmomi.
I'm only using govmomi. If you run my code do you get different results?
On Jan 20, 2015 3:23 PM, "Michael Kuzmin" [email protected] wrote:
I also work with templates and don't experience such issues. Can it be a
problem in thΡ 3rd-party library you're using?β
Reply to this email directly or view it on GitHub
#193 (comment).
from govmomi.
Ultimately I'd like to create a VirtualMachine from a template via the API. How might I got about doing that? Does the API or govc support that at this time?
from govmomi.
I have created another Gist that includes all code that is not pulled from govmomi. This returns false for all VirtualMachines, but panics in the event a template is hit. I really am not sure what I'm doing wrong here.
https://gist.github.com/jmmcatee/eba0f808275301eae802
from govmomi.
What type does it say the Template is? It should be a VirtualMachine. A template is still a VirtualMachine that has just been registered as a template (or marked as one). They way I'm accomplishing this right now is just knowing my templates name and then using some (slightly simplified) code like this:
finder := find.NewFinder(client, false)
vm, _ := finder.VirtualMachine("TemplateName")
resourcePool, _ := finder.DefaultResourcePool()
rpRef := resourcePool.Reference()
clonespec := types.VirtualMachineCloneSpec{
Location: types.VirtualMachineRelocateSpec{
Pool: &rpRef,
}
}
task, _ := vm.Clone(folders.VmFolder, "New VM Name", clonespec)
task.WaitForResult(nil)
Are you wanting to iterate through your VM list and pick out just the templates? I'm not sure if you can do that as it stands right now, you may consider putting them all in a specific folder so that you can just list a folder and pick a template from there.
from govmomi.
I'd like to be able to iteration so I can provide a selection menu. They do show up as VirtualMachines in the Reference, but any attempt to pull up the name or anything else about them either panics or is nil. Could this be a problem with how VirtualMachines that are marked as templates change in the XML response?
from govmomi.
I think you were just constructing the VM objects incorrectly. This should loop over your VMs and output "vmname,template". Essentially I believe you were constructing an empty VirtualMachine object and never pulling the Properties into it.
https://gist.github.com/daniellockard/b9ae34e270333f0887bb
from govmomi.
Your version works for me. I guess i don't understand why this is required for Templates, but not Virtual Machines as those load the whole structure just fine without the "Summary" addition.
from govmomi.
I didn't see it work with your version, for VMs or Templates. Glad I could help. I think this can be closed @dougm @pietern.
from govmomi.
Perfect, thanks for your help @daniellockard!
from govmomi.
Related Issues (20)
- How to migrate both vm and storage using govc commands. HOT 5
- [BUG] WaitEx omits updates when the server GUID is not set HOT 1
- [BUG] add optional SSLCertificate to TransferEndpoint in content library API HOT 1
- [BUG] Fail to create a new VM using PowerCLI integration HOT 2
- [BUG] vcsim: #2911 mandated to pass the new disk size in Bytes and KB. If either of value is 0, ReconfigVM_Task is throwing *types.InvalidDeviceOperation HOT 1
- Ability to create file-share volumes using vcsim HOT 1
- [BUG] govc import.ova not working if ESXI hostnames don't don't resolve HOT 1
- [BUG] Export to ovf makes a bad ovf file HOT 1
- [BUG] Invalid operation for device '0' in 0.37.2 HOT 2
- [BUG] Customize option failing for Windows VM due to missing Userdata HOT 1
- [BUG] DistributedVirtualSwitchManager:DVSManager does not implement: QueryDvsByUuid HOT 1
- vCenter : QueryPerf metrics support
- [BUG] ReadNextEvents method gets stuck HOT 7
- How to expand a block storage by methods.ExpandVmfsDatastore? HOT 1
- [BUG] VirtualAppList function can't handle nested Virtual Apps HOT 1
- [BUG] govc v0.37.2 command vm.disk.change always fail HOT 2
- [BUG] Permission Error with ContinueRetrievePropertiesEx in govc v0.37.0+ on vSphere 8.x HOT 5
- [BUG] govc.exe find . -type m -runtime.powerState poweredOn fails on Windows HOT 3
- Virtual Watchdog timer support HOT 2
- [BUG] Can't resize a VM's disk HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from govmomi.