Skip to content

Simpler Metadata querying from inside the VM #1115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lorennorman opened this issue Feb 5, 2016 · 3 comments
Closed

Simpler Metadata querying from inside the VM #1115

lorennorman opened this issue Feb 5, 2016 · 3 comments
Assignees

Comments

@lorennorman
Copy link

Hello!

I would like to use gcloud-node on a VM to fetch its Metadata. I expected this to be simple, since the CLI way of grabbing the Metadata is a simple CURL to a magic URL. My expectation would be that gcloud-node wraps that nicely for me already. Unfortunately, this is not the case.

Instead, the docs say:

var gcloud = require('gcloud')({
  keyFilename: '/path/to/keyfile.json',
  projectId: 'grape-spaceship-123'
});

var gce = gcloud.compute();

var zone = gce.zone('zone-name');

var vm = zone.vm('vm-name');

var metadata = vm.getMetadata(); // Finally!

Whoa, whoa, whoa, I'm already on the VM in question, do I really need to know Project ID, Zone, and VM Name just to get back to square one?

How about some kind of factory method for grabbing the current VM, such as:

var vm = gcloud.getCurrentVM();

...that does whatever magic is needed to figure out where it is running? (Or even better maybe just getLocalMetadata()?)

Just a friendly suggestion! I spent a day trying to figure out "the right way" to do this and I am ultimately falling back to the HTTP method, wanted to put this here in case it is helpful for someone else or adds some usability to the project.

Thank you!

@jgeewax
Copy link
Contributor

jgeewax commented Feb 5, 2016

I'm a big fan of that. A couple questions:

  1. If you run this while not on a VM, should the result be null or an
    Error thrown ?
  2. If you're trying to develop against this, how do you do it?

@stephenplusplus
Copy link
Contributor

This is a great explanation of what you went through. We actually have this discussed in #917, please feel free to add any thoughts over on that issue, as we talked through some problems/solutions.

Supporting this is not exactly at the top of the priority list (reaching 1.0, using promises natively, introducing more services are currently ranked higher), but it's definitely planned.

@stephenplusplus
Copy link
Contributor

@lorennorman @jgeewax please continue discussing in #917

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants