carletes
(Carlos Valiente)
April 3, 2016, 8:32pm
1
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?
dmolina
(Daniel Molina)
April 4, 2016, 9:48am
2
carletes
(Carlos Valiente)
April 4, 2016, 7:23pm
3
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 (i-00000118
):
$ econe-describe-instances
instanceId ImageId State IP instanceType
i-00000118 ami-00000043 running 172.16.0.1 t1.micro
$ econe-describe-addresses
publicIp instanceId
192.168.1.1 i-00000118
$
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
{"VM":{"NAME":"t1.micro-118","ID":"118","STATE":"3","LCM_STATE":"3","USER_TEMPLATE":{"EC2_INSTANCE_TYPE":"t1.micro","HYPERVISOR":"kvm","IMAGE_ID":"ami-00000043"},"TEMPLATE":{"NIC":[{"IP":"172.16.0.1","MAC":"02:00:ac:10:00:01","NETWORK":"private-net"}]}}}
Should I perhaps be using a different URL, instead of http://XXX.XXX.XXX.XXX:5030/vm ?
dmolina
(Daniel Molina)
April 5, 2016, 8:56am
4
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.
carletes
(Carlos Valiente)
April 5, 2016, 5:26pm
5
[…] 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:
"TEMPLATE": {
"NIC": [
[..]
},
"EC2_ADDRESSES": [
"192.168.1.42",
[..]
}
[..]
}
I can start working on extending the OneGate server on a pull request on GitHub.
carletes
(Carlos Valiente)
April 10, 2016, 3:25pm
6
you should extend the OneGate server to retrieve this information from the attached NICs.
Here’s a first draft, @dmolina : onegate-server: Return associated EC2 ElasticIPs by carletes · Pull Request #90 · OpenNebula/one · GitHub
dmolina
(Daniel Molina)
April 11, 2016, 10:18am
7
Hi Carlos,
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.
Cheers
carletes
(Carlos Valiente)
April 11, 2016, 12:35pm
8
Thanks, @dmolina ! Looking forward to that, let me know whether I can be of any help.