1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
def send_nvme_cmd(client, name, cmd_type, data_direction, cmdbuf,
data=None, metadata=None,
data_len=None, metadata_len=None,
timeout_ms=None):
"""Send one NVMe command
Args:
name: Name of the operating NVMe controller
cmd_type: Type of nvme cmd. Valid values are: admin, io
data_direction: Direction of data transfer. Valid values are: c2h, h2c
cmdbuf: NVMe command encoded by base64 urlsafe
data: Data transferring to controller from host, encoded by base64 urlsafe
metadata: metadata transferring to controller from host, encoded by base64 urlsafe
data_length: Data length required to transfer from controller to host
metadata_length: Metadata length required to transfer from controller to host
timeout-ms: Command execution timeout value, in milliseconds, if 0, don't track timeout
Returns:
NVMe completion queue entry, requested data and metadata, all are encoded by base64 urlsafe.
"""
params = {'name': name,
'cmd_type': cmd_type,
'data_direction': data_direction,
'cmdbuf': cmdbuf}
if data:
params['data'] = data
if metadata:
params['metadata'] = metadata
if data_len:
params['data_len'] = data_len
if metadata_len:
params['metadata_len'] = metadata_len
if timeout_ms:
params['timeout_ms'] = timeout_ms
return client.call('send_nvme_cmd', params)
def get_nvme_controllers(client, name=None):
"""Get information about NVMe controllers.
Args:
name: NVMe controller name to query (optional; if omitted, query all NVMe controllers)
Returns:
List of NVMe controller information objects.
"""
params = {}
if name:
params['name'] = name
return client.call('get_nvme_controllers', params)
|