Hacker News new | comments | ask | show | jobs | submit login
Go Library for the VMware vSphere API (github.com)
65 points by alexellisuk 11 months ago | hide | past | web | favorite | 14 comments

One of the nicest parts of this library, to me, is the 'govc' command which it provides: https://github.com/vmware/govmomi/tree/master/govc

It fits in really nicely with plain-old Bash scripts, and has some niceties such as being able to output dumps of data as both human-readable and to JSON for further manipulation/inspection (e.g. jq)

Govc is great. We use it all the time in-house at VMware. :)

I love govc - it should be a defacto standard tool in the industry so I put it in my resume.

Wait... I can already put it in my resume and be more impressive for hiring managers (and HR?) who can appreciate the superpowers of govc.

I love govc.

> err = v.Retrieve(ctx, []string{"Datastore"}, []string{"summary"}, &dss)

I am no Go expert but is that sort of thing ([]string part) used commonly in Go? Sounds like the API would be better if it wasn't so "string oriented" for a lack of better term? This sounds like you are parsing random text which is fine at a lower level where it could be better abstracted out?

The whole library is pretty low level actually. If you plan on using it I recommend wrapping it with a better API.

Not sure how familiar you are with the vSphere API but the whole thing is done over HTTP, which would explain why it's so string heavy. The SDKs VMware releases for various languages just papers over this.

I guess the least the API could do is provide some suitably named constants that represent the various elements such that the call becomes something like -

        err = v.Retrieve(ctx, VSphere.DATASTORE, VSphere.SUMMARY, &dss)
The constants can just be enums that map to the actual valid string representations. That way API user knows the full extent of the parameters and doesn't have to rely on arbitrary strings.

Not sure why this is a "Show HN" post as this is the official VMware govmomi library?

It certainly is worthwhile to look at if you are into VMware and go, but should IMO just have been a normal submission.

Thanks. It isn't clear that the submitter is a major contributor to this project, so we've removed “Show HN” from the title.

I found this library interesting (as a developer that uses Go and has access to vSphere at work). I'd seen the Python library but this looked easier to use. I'm thinking about creating an OpenFaaS function to clone/list VMs etc.

I love the vSphere API. It's solid, complete, well documented (also available in Dash). The only time it's failed to do what was asked is when it crashed because I passed it a null instead of a value, or when there's something outside its control like a network issue. In case it's not obvious: for python there is the official pyVmomi project

Wow, I've never heard anyone say anything nice about the API before. In my brief experience with using it via pyvmomi it was almost completely undocumented. Or maybe just documented at such a low level that it didn't help much.

As someone else in this thread mentioned, the libraries are "string oriented" (for lack of a better term), but finding what string to enter is a pain. I'd have to make API call after API call, printing the objects each time, find the string I needed, do another API call to get the next string, and go on and on, like digging into a deeply nested data structure. Compared to AWS via boto, it's hard to imagine not hating the vSphere API, let alone loving it.

But it is good that some people like it, these libraries must be hitting their target market to some extent.

There's a 250+ page PDF "Programming Guide" for the vSphere SDK, on top of almost every Object/Type/Fault/Method etc documented, and a built-in API/object browser. What more do you want?

There are community samples for pyvmomi, multiple blogs explaining common use cases etc. But yes, sometimes it's quicker/easier to create thing in the UI and read back the values.

Maybe my standards are low.

EDIT: I also don't understand your "string oriented" comment. Do you mean the object IDs (MOIDs/morefs)?

In pyvmomi you can do this:

  vm = vim.VirtualMachine("vm-1297")
  vm._stub = service_instance._stub
You now have a VM object, not a string.

etc (yes you need some helper methods to lookup things by name etc, but various things by name are not unique)


At least when I looked at it a year ago, govmomi was terrible. Little documentation. Most return values being opaque objects that you have no idea what to do with (and if pass to another function that takes the opaque object, but not what its wrapping) it errors out.

I only was able to manage to get things done via lots of trial and error and seeing examples others had written.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact