Process Analysis of adding a cinder volume to Nova

Source: Internet
Author: User
Process Analysis of adding a cinder volume to Nova
  
1. Nova uses the command Nova volume-Attach server volume device-name or HTTP Request
Req: Post/v2/{tenant-ID}/servers/{server-ID}/os-volume_attachments'
Body: {'volumeattachment ': {'device':'/dev/vdb ',
'Volumeid': '951be889-b794-4723-9ac9-efde61cacf3a '}}'
Initiate a volume mount request.


2. nova obtains available mount points. If a mount point is specified, it verifies its validity. If no mount point is specified, it finds a valid mount point and creates database information. In the block_device_mapping table, it writes the following information:
* *************************** 1. row ***************************
Created_at: 2014-07-07 06:24:12
Updated_at: NULL
ID: 6
Device_name:/dev/vdb
Volume_id: b5ce6d0f-e7db-41cb-a5f1-5c47454248c1
Volume_size: NULL
Connection_info: NULL
Instance_uuid: 9de3d836-be91-4348-9fc1-b67d8623157f source_type: volume
Destination_type: volume
   
3. Nova sends a request to cinder to obtain the volume information. The request and response are as follows:
Req: Get/V1/{tenant-ID}/volumes/{VOLUME-ID}
Header:-h "X-auth-Token: 8138b1ace73b4e359122be531c55d2dd"
Res:
{
"Volume ":{
"Status": "available ",
"Display_name": "dfg ",
"Attachments": [],
"Availability_zone": "NOVA ",
"Bootable": "false ",
"Encrypted": false,
"Created_at": "2014-06-30t08: 33: 47.000000 ",
"OS-Vol-tenant-ATTR: tenant_id": "XXX-tenant-ID ",
"Display_description": NULL,
"OS-Vol-host-ATTR: Host": "xfolsom ",
"Volume_type": "NONE ",
"Snapshot_id": NULL,
"Source_volid": NULL,
"OS-Vol-Mig-status-ATTR: name_id": NULL,
"Metadata ":{
"Readonly": "false"
},
"ID": "951be889-b794-4723-9ac9-efde61cacf3a ",
"OS-Vol-Mig-status-ATTR: migstat": NULL,
"Size": 1
}
}


4. Check the volume status of Nova. If volume ['status']! = 'Available': throw a 400 exception. The exception message is status must be 'available'. A typical error message is as follows:
Error (badrequest): Invalid volume: status must be 'available' (HTTP 400)
If volume ['status'] = 'attached', an error (badrequest): Invalid volume: already attached (HTTP 400) is thrown)
   
5. Send a request to cinder to keep the disk and avoid being used by others. The request and reply are as follows:
Req: Post V1/{tenant-ID}/volumes/{VOLUME-ID}/Action
Header:-h "X-auth-Token: 8138b1ace73b4e359122be531c55d2dd"
Body: {"OS-reserve": NULL}
Res: HTTP 202
After cinder receives the request, if volume ['status'] = 'available', change the status to volume ['status'] = 'attaching'. Otherwise, a 400 exception is thrown.


6. Nova obtains the connector information as follows:
{'IP': '10. 160.162.24 ', 'host': 'nvs-1', 'Initiator': 'iqn .1993-08.org. Debian: 01: 35725f2f2a '}
The initiator is the content of the/etc/iSCSI/initiatorname. iSCSI file.


7. Send the connector and volume-ID obtained in the previous step to cinder, initialize the connection interface, and obtain the iSCSI on_info of iSCSI. Cinder returns connection_info. The request and reply information is as follows:
Req: Post V1/{tenant-ID}/volumes/{VOLUME-ID}/Action
Header:-h "X-auth-Token: 8138b1ace73b4e359122be531c55d2dd"
Body:
{
"Os-initialize_connection ":{
"Connector ":{
"Ip": "10.160.161.32 ",
"Host": "xfolsom ",
"Initiator": "iqn.1993-08.org. Debian: 01: 11a1a0aa28f1"
}
}
}
Res:
{U'data': {u'access _ mode': u'rw ',
U'auth _ method': u'chap ',
U'auth _ password': u'jvu68hfyhub1_5vqgpq ',
U'auth _ username': u'pg9zc8o7jicpjf6lhh9c ',
U'encrypted': false,
U'qos _ specs': none,
U'target _ discovered': false,
U'target _ iqn': u'iqn .2010-10.org. openstack: volume-b5ce6d0f-a5f1-5c47454248c1 ',
U'target _ Lun ': 1,
U'target _ portal ': u'10. 160.162.24: 3260 ',
U'volume _ id': u'b5ce6d0f-e7db-41cb-a5f1-5c47454248c1 '},
U'driver _ volume_type ': u'iscsi '}


8. If there are exceptions in steps 6th and 7 (no exception types are distinguished, and all exceptions are the same), send an unreserve request to cinder and modify the volume status. The request and response are as follows:
Req: Post V1/{tenant-ID}/volumes/{VOLUME-ID}/Action
Header:-h "X-auth-Token: 8138b1ace73b4e359122be531c55d2dd"
Body: {"OS-unreserve": NULL}
Res: HTTP 202
Cinder: If volume ['status'] = "attaching", change its status to 'available'. At the same time, Nova deletes the database row corresponding to the block_device_mapping table, terminate volume mounting.
   
9. nova calls the driver to mount the volume to the host machine. By default, Nova calls the lib_volume method of the libjavasiscsivolumedriver driver. This method uses libvirt to execute related iSCSI commands to mount the cloud disk to the host machine, call libvirt to mount the volume to the VM. If an exception occurs when mounting the volume to the VM, attach the volume to the VM to cancel this operation, the disconnect_volume method driven by libvirtiscsivolumedriver is executed. Now, the mounting process is complete.


10. Send the request mounting information to cinder to notify cinder that the volume has been mounted to the host machine:
Req: Post V1/{tenant-ID}/volumes/{VOLUME-ID}/Action
Header:-h "X-auth-Token: 8138b1ace73b4e359122be531c55d2dd"
Body:
{
"OS-Attach ":{
"Instance_uuid": "5f1c49d6-f3ec-4564-9b9a-f6b3dc938dd2 ",
"Mountpoint": "/dev/vdb ",
"Mode": "RW"
}
}
Res: HTTP 202
After receiving the request, cinder mounts it. From the cinder Code, there is no operation, but the information is updated to the database and the volume status is changed to in-use.
   
11. Nova updates the database mainly by updating the connection_info information. The updated database is as follows:
* *************************** 1. row ***************************
Created_at: 2014-07-07 06:24:12
Updated_at: 2014-07-07 07:03:28
Deleted_at: NULL
ID: 6
Device_name:/dev/vdb
Delete_on_termination: 0
Snapshot_id: NULL
Volume_id: b5ce6d0f-e7db-41cb-a5f1-5c47454248c1
Volume_size: NULL
No_device: NULL
Connection_info: {"driver_volume_type": "iSCSI", "serial": "b5ce6d0f-e7db-41cb-a5f1-5c47454248c1", "data": {"access_mode": "RW", "target_discovered": false, "encrypted": false, "qos_specs": NULL, "target_iqn": "iqn.2010-10.org. openstack: volume-b5ce6d0f-e7db-41cb-a5f1-5c47454248c1 "," target_portal ":" 10.160.162.24: 3260 "," volume_id ":" b5ce6d0f-e7db-41cb-a5f1-5c47454248c1 "," target_lun ": 1," device_path ": "/dev/Disk/by-path/ip-10.160.162.24: 3260-iscsi-iqn.2010-10.org.openstack: volume-b5ce6d0f-e7db-41cb-a5f1-5c47454248c1-lun-1", "auth_password": "jvu68hfyhub1_5vqgpq", "auth_username": "principal", "auth_method ": "chap "}}
Instance_uuid: 9de3d836-be91-4348-9fc1-b67d8623157f
Deleted: 0
Source_type: volume
Destination_type: volume
   
   












Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.