Giter Club home page Giter Club logo

Comments (14)

dougm avatar dougm commented on July 19, 2024

@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.

jmmcatee avatar jmmcatee commented on July 19, 2024

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.

pietern avatar pietern commented on July 19, 2024

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.

jmmcatee avatar jmmcatee commented on July 19, 2024

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.

mkuzmin avatar mkuzmin commented on July 19, 2024

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.

jmmcatee avatar jmmcatee commented on July 19, 2024

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.

jmmcatee avatar jmmcatee commented on July 19, 2024

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.

jmmcatee avatar jmmcatee commented on July 19, 2024

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.

daniellockard avatar daniellockard commented on July 19, 2024

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.

jmmcatee avatar jmmcatee commented on July 19, 2024

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.

daniellockard avatar daniellockard commented on July 19, 2024

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.

jmmcatee avatar jmmcatee commented on July 19, 2024

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.

daniellockard avatar daniellockard commented on July 19, 2024

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.

pietern avatar pietern commented on July 19, 2024

Perfect, thanks for your help @daniellockard!

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.