I’d like to read instance metadata from within the VM. In particular, I’d like to know which Elastic IPs may have been attached to a given VM instantiated through the EC2 OpenNebula API.
I was thinking on writing an HTTP server that listens on http://169.254.169.254, like what Amazon offers in http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html.
Is there a simpler way of doing it right now?
Thanks, @dmolina! I just set it up at home, and I can connect to OneGate from within my VM.
I cannot find the Elastic IP information I’m interested in, however. I have associated an Elastic IP (192.168.1.1) to my instance (
instanceId ImageId State IP instanceType
i-00000118 ami-00000043 running 172.16.0.1 t1.micro
When I query the OneGate endpoint, I do not see any Elastic IP information:
$ sh -x query.sh
+ curl -v http://192.168.1.64:5030/vm --header 'X-ONEGATE-VMID: 118' --header 'X-ONEGATE-TOKEN: pBSIH1Q33KmiMm7TYHW/2w=='
* Trying 192.168.1.64...
* Connected to 192.168.1.64 (192.168.1.64) port 5030 (#0)
> GET /vm HTTP/1.1
> Host: 192.168.1.64:5030
> User-Agent: curl/7.47.1
> Accept: */*
> X-ONEGATE-VMID: 118
> X-ONEGATE-TOKEN: pBSIH1Q33KmiMm7TYHW/2w==
< HTTP/1.1 200 OK
< Content-Type: text/html;charset=utf-8
< Content-Length: 254
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< Connection: keep-alive
< Server: thin 1.3.1 codename Triple Espresso
* Connection #0 to host 192.168.1.64 left intact
Should I perhaps be using a different URL, instead of http://XXX.XXX.XXX.XXX:5030/vm?
You are right. That information is stored in the VNET template and not in the VM template. If you want to retrieve this information you should extend the OneGate server to retrieve this information from the attached NICs.
[…] you should extend the OneGate server to retrieve this information from the attached NICs.
Yep! What about adding to
TEMPLATE a new field called
EC2_ADDRESSES, for instance:
I can start working on extending the OneGate server on a pull request on GitHub.
you should extend the OneGate server to retrieve this information from the attached NICs.
Here’s a first draft, @dmolina: https://github.com/OpenNebula/one/pull/90
The pull request looks great, but since this is too EC2-specific, we think it would be better to integrate this functionality into the OpenNebula core and being able to use it from any of the interfaces. We will try to think about it and let you know if we find a solution for this.
Thanks, @dmolina! Looking forward to that, let me know whether I can be of any help.