In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how nova creates a virtual machine. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
1. Original intention
Often asked about "nova's process of creating a virtual machine", although roughly aware of the process, in some cases, saying "rough" knowledge often determines the end of a conversation. If you want to say the details completely and logically, you still need to consider it carefully, and that kind of "rough" speech looks pale. After all, as a practitioner, a detailed and in-depth understanding of the whole internal process should be a necessary basic skill, which is the original intention.
two。 A storm caused by an order
Nova-- debug boot ubuntu_test-- flavor 2\-- image cde1d850-65bb-48f6-8ee9-b990c7ccf158\-- num-instance 1\-- nic net-id=cfa25cef-96c3-46f1-8522-d9518eb5a451
This is a command to create a virtual machine (instance). In the command, the name of the new instance is specified: ubuntu_test, CVM type: 2, image: cde1d850-65bb-48f6-8ee9-b990c7ccf158, number: 1, and network: cfa25cef-96c3-46f1-8522-d9518eb5a451.
Here is an explanation of the image and the network:
The mirror network in the command is queried by these two commands.
As you can see, the-debug parameter is added to the command, which gives us a clear idea of what is done during the execution of the command.
The following figure shows the process after we create the instance.
There is a lot of information here, so I have to cut off part of the picture. The details are sorted out and put below. And analyze them one by one.
3. Main requests for debug output
Here are the four most important points.
3.1. Get token from keystone
REQ: curl\-I 'http://ubuntu80:35357/v2.0/tokens'-X POST-H "Accept: application/json"\-H "Content-Type: application/json"-H "User-Agent: python-novaclient"\-d' {"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "{SHA1} 5705cc2e5fda0ab7529d5093c5e389fffe45d615"}}'
3.2. Verify the image through nova-api
REQ: curl-I 'http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e/images/cde1d850-65bb-48f6-8ee9-b990c7ccf158'\-X GET\-H "Accept: application/json"\-H "User-Agent: python-novaclient"\-H "X-Auth-Project-Id: admin"\-H "X-Auth-Token: {SHA1} e87219521f61238b143fbb323b962930380ce022"
3.3. Verify the type of CVM through nova-api
REQ: curl-I 'http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e/flavors/2'\-X GET-H "Accept: application/json"-H "User-Agent: python-novaclient"\-H "X-Auth-Project-Id: admin"\-H "X-Auth-Token: {SHA1} e87219521f61238b143fbb323b962930380ce022"
3.4. Create an instance
REQ: curl-I 'http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e/servers'\-X POST-H "Accept: application/json"\-H "Content-Type: application/json"\-H "User-Agent: python-novaclient"\-H "X-Auth-Project-Id: admin"\-H "X-Auth-Token: {SHA1} e87219521f61238b143fbb323b962930380ce022"\-d' {"server": {"name": "ubuntu_test" "imageRef": "cde1d850-65bb-48f6-8ee9-b990c7ccf158", "flavorRef": "2", "max_count": 1, "min_count": 1, "networks": [{"uuid": "cfa25cef-96c3-46f1-8522-d9518eb5a451"}]}'
4. Start with how to get token
We all know that 35357 is the port of keystone, ask me why I know it is keystone, OK, I found it through the port.
Well, yes, it's keystone, and let's go back to our topic, where when we send a request to keystone, we organize such a data.
{"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin", "password": "{SHA1} 5705cc2e5fda0ab7529d5093c5e389fffe45d615"}
Send this data to keystone in order to get a token, that is, a key, with which the rest of our operations can be unimpeded. So what did keystone do with it.
Find the source code of keystone
See token? mm-hmm. It's in there.
Nano token/controllers.py
Find the authenticate method of the Auth class
Is it similar to the parameters given to keystone above? If all goes well with this method, it returns a token (key) at the end.
What did keystone reply to?
REQ: curl\-I 'http://ubuntu80:35357/v2.0/tokens'\-X POST-H "Accept: application/json"\-H "Content-Type: application/json"\-H "User-Agent: python-novaclient"\-d' {"auth": {"tenantName": "admin", "passwordCredentials": {"username": "admin" "password": "{SHA1} 5705cc2e5fda0ab7529d5093c5e389fffe45d615"}} 'INFO (connectionpool:259) Starting new HTTP connection (1): ubuntu80DEBUG (connectionpool:390) Setting read timeout to 600.0DEBUG (connectionpool:430) "POST / v2.0/tokens HTTP/1.1" 200 1744RESP: {' date': 'Mon, 18 Jan 2016 01:58:37 GMT',' vary':'X authorization, 'content-length':' 1744th, 'content-type':' application/json' RESP BODY: {"access": {"token": {"issued_at": "2016-01-18T01:58:37.093849", "expires": "2016-01-18T02:58:37Z", "id": "{SHA1} e87219521f61238b143fbb323b962930380ce022", "tenant": {"enabled": true, "description": "Admin Tenant", "name": "admin", "id": "0e962df9db3f4469b3d9bfbc5ffdaf7e"} "audit_ids": ["RugmwI0_R3ysmpJ3zF8k4Q"]}, "serviceCatalog": [{"endpoints_links": [], "endpoints": [{"adminURL": "http://ubuntu80:9292"," region ":" regionOne "," publicURL ":" http://ubuntu80:9292", "internalURL": "http://ubuntu80:9292"," id ":" 4794a2d722ab4f6bbda00d779c1410d1 "}]," type ":" image " "name": "glance"}, {"endpoints_links": [], "endpoints": [{"adminURL": "http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e"," region ":" regionOne "," publicURL ":" http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e", "internalURL": "http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e"," id ":" a8ccc19100934fc1ae7c899dc5e17bdd "}]," type ":" compute " "name": "nova"}, {"endpoints_links": [], "endpoints": [{"adminURL": "http://ubuntu80:9696"," region ":" regionOne "," publicURL ":" http://ubuntu80:9696", "internalURL": "http://ubuntu80:9696"," id ":" 656371fd3163415c95ff2fc0facbe5e1 "}]," type ":" network "," name ":" neutron "} {"endpoints_links": [], "endpoints": [{"adminURL": "http://ubuntu80:35357/v2.0"," region ":" regionOne "," publicURL ":" http://ubuntu80:5000/v2.0", "internalURL": "http://ubuntu80:5000/v2.0"," id ":" 4f1d53f12dc6485cb5816c83f68b7053 "}]," type ":" identity "," name ":" keystone "}] "user": {"username": "admin", "roles_links": [], "id": "96a7c834b3f8485c87d79df7b6480c92", "roles": [{"name": "_ member_"}, {"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": ["9fe2ff9ee4384b1894a90878d3e92bab", "fc2574382dd74936b1bc85cc2110c3c2"]}
It's too messy. Sort it out and pull out the json of the reply.
{"access": {"token": {"issued_at": "2016-01-18T01:58:37.093849", "expires": "2016-01-18T02:58:37Z", "id": "{SHA1} e87219521f61238b143fbb323b962930380ce022", "tenant": {"enabled": true, "description": "Admin Tenant", "name": "admin" "id": "0e962df9db3f4469b3d9bfbc5ffdaf7e"}, "audit_ids": ["RugmwI0_R3ysmpJ3zF8k4Q"]}, "serviceCatalog": [{"endpoints_links": [], "endpoints": [{"adminURL": "http://ubuntu80:9292"," region ":" regionOne " "publicURL": "http://ubuntu80:9292"," internalURL ":" http://ubuntu80:9292", "id": "4794a2d722ab4f6bbda00d779c1410d1"}], "type": "image", "name": "glance"}, {"endpoints_links": [] "endpoints": [{"adminURL": "http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e"," region ":" regionOne "," publicURL ":" http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e", "internalURL": "http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e", "id": "a8ccc19100934fc1ae7c899dc5e17bdd"}], "type": "compute", "name": "nova"}, {"endpoints_links": [], "endpoints": [{"adminURL": "http://ubuntu80:9696"," "region": "regionOne", "publicURL": "http://ubuntu80:9696"," internalURL ":" http://ubuntu80:9696", "id": "656371fd3163415c95ff2fc0facbe5e1"}], "type": "network", "name": "neutron"} {"endpoints_links": [], "endpoints": [{"adminURL": "http://ubuntu80:35357/v2.0"," region ":" regionOne "," publicURL ":" http://ubuntu80:5000/v2.0", "internalURL": "http://ubuntu80:5000/v2.0"," "id": "4f1d53f12dc6485cb5816c83f68b7053"}], "type": "identity", "name": "keystone"}], "user": {"username": "admin", "roles_links": [], "id": "96a7c834b3f8485c87d79df7b6480c92" "roles": [{"name": "_ member_"}, {"name": "admin"}], "name": "admin"}, "metadata": {"is_admin": 0, "roles": ["9fe2ff9ee4384b1894a90878d3e92bab" "fc2574382dd74936b1bc85cc2110c3c2"]}
You see the id ({SHA1} e87219521f61238b143fbb323b962930380ce022) in token. The rest of the operation is to bring it.
5. Verify image and CVM type
You can see these two verification requests in Section 3, namely, the verification image and the CVM type.
3.2. Verify the image through nova-api
REQ: curl\-I 'http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e/images/cde1d850-65bb-48f6-8ee9-b990c7ccf158'\-X GET-H "Accept: application/json"\-H "User-Agent: python-novaclient"\-H "X-Auth-Project-Id: admin"\-H "X-Auth-Token: {SHA1} e87219521f61238b143fbb323b962930380ce022"
3.3. Verify the type of CVM through nova-api
REQ: curl\-I 'http://ubuntu80:8774/v2/0e962df9db3f4469b3d9bfbc5ffdaf7e/flavors/2'\-X GET\-H "Accept: application/json"\-H "User-Agent: python-novaclient"\-H "X-Auth-Project-Id: admin"\-H "X-Auth-Token: {SHA1} e87219521f61238b143fbb323b962930380ce022"
These two requests are similar, and their code is in images.py in nova.api.openstack.compute and Controller in flavors.py.
This is the end of the process of creating a virtual machine for nova. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.