Creating Namespaces
create_namespace
in the Test API.get_vlun_nvme_update_namespace
.create_namespace
create_namespace
provides a wrapper around a call to XML_API.get_vlun_nvme_update_namespace
in the XML API.
create_namespace(dut, config, fail_type='error', skip_type='action')
dut
: XML_APIns_config
: dictfail_type
: int or str Optional0
or 'pass'
: Log a PASS1
or 'notify'
: Log a NOTE2
or 'warn'
: Log a WARNING and increment the warnings counter3
or 'error'
: Log an ERROR and increment the errors counter4
or 'test'
: Log an ERROR and immediately fail the entire testskip_type
: int or str Optional0
or 'none'
: Do not skip. Proceed and attempt the creation1
or 'action'
: Do not attempt the creation. Return immediately2
or 'test'
: Immediately skip the remainder of the entire testcreate_namespace
is a dictionary containing the following elements:status
: intnsids
: list of intreason
: str{
'status': 0,
'nsids' : [1, 2],
'reason': "Successfully created 2 namespace(s) on controller 100"
}
Configuration Options
ns_config
dictionary may contain any combination of the following parameters, which are passed to get_vlun_nvme_update_namespace
after they are validated:create_num
: intcreate_size
: str'5gb'
create_priv
: int, 0 or 1create_attach
: int, 0 or 1lbaf
: int, 0-40
: Better - 5121
: Degraded - 520 (512 + 8)2
: Best - 40963
: Good - 4104 (4096 + 8)4
: Degraded - 4160 (4096 + 64)mset
: int, 0 or 1pi
: int, 0-30
or 000b
: Protection information is not enabled1
or 001b
: Protection information is enabled, Type 12
or 010b
: Protection information is enabled, Type 23
or 011b
: Protection information is enabled, Type 3pil
: int, 0 or 1csi
: int, 0-20
: NVM1
: Key Value2
: Zoned Namespacenvmsetid
: intanagrpid
: intvalid_command
or nsid
in your configuration they will be ignored.WARNING
will be issued for each improperly defined parameter.Warning
Here is an example configuration using improper parameters, and the results of their use:
ns_config = {'create_size': '100gb',
'mset': 1,
'wrong': 6, # Doesn't exist
'create_priv': 'yes', # Requires integer
'create_attach': 1}
Wed Jul 28 16:37:09 2021 WARNING: In create_namespace on target 100: removing unknown parameter 'wrong'
Wed Jul 28 16:37:09 2021 WARNING: In create_namespace on target 100: 'create_priv' must be type int. Defaulting to 0
Note
In addition to the previously mentioned features, create_namespace
sets the default namespace of the passed DUT to be the first newly created namespace.
For example, if calling create_namespace
on dut1
results in the creation of namespaces 5 and 6, subsequent operations using dut1
will default to using namespace 5.
You can override this at any time like so:
# "dut1" is the DUT for which you would like to change the default namespace
# new_namespace_id is the new default namespace identifier to be used
dut1.lun = new_namespace_id
Care should be taken to avoid assigning a namespace identifier that does not exist, or errors are likely to occur.
Basic Example
Here is a simple example in a dual-port test that will create a new private namespace 100GB in size and print the returned dictionary:
# .. Test settings ..
def main(test_config):
@setup(test_config)
def test(duts):
dut1 = duts[0]
dut2 = duts[1]
config = {'create_size': '100gb',
'create_priv': 1}
result = create_namespace(dut1, config)
print(result)
Printed result:
{'status': 0, 'nsids': [1], 'reason': 'Successfully created 1 namespace(s) on target 100'}
As part of the call, reason
will be logged:
Wed Jul 28 14:29:13 2021 DETAIL: Successfully created 1 namespace(s) on target 100
Partial Failure
Here is an attempt to create 50 new 1GB namespaces on a device that only supports 32 (none preexisting):
config_create_50 = {'create_size': '1gb',
'create_num': 50}
result = create_namespace(dut1, config_create_50)
print(result)
Output:
{'status': 1, 'nsids': [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], 'reason': 'Created 32 of 50 namespace(s) on target 100: NVMe command NamespaceManagement Create CSI=0x0 failed, NVMe Status=116h (NS_ID_UNAVAILABLE, SCT=1h, SC=16h) (1633 usec)'}
We can see that it created as many namespaces as it could before encountering the error NS_ID_UNAVAILABLE
.
In the event of a partial failure, in which only some namespaces are successfully created, an ERROR
will be issued unless an alternate fail_type
has been specified:
Wed Jul 28 15:30:13 2021 ERROR: Created 32 of 50 namespace(s) on target 100: NVMe command NamespaceManagement Create CSI=0x0 failed, NVMe Status=116h (NS_ID_UNAVAILABLE, SCT=1h, SC=16h) (1633 usec)
Complete Failure
Here is an attempt to create 5 new 100MB namespaces using an invalid (but correctly formatted) parameter, setting lbaf to 400
bad_config = {'create_size': '100mb',
'create_num': 5,
'lbaf': 400}
result = create_namespace(dut1, bad_config)
print(result)
Output:
{'status': 1, 'nsids': [], 'reason': "Created 0 of 5 namspace(s) on target 100: Error: -lbaf value '400' is not valid"}
In the event of a complete failure, in which 0 new namespaces are successfully created, an ERROR
will be issued unless an alternate fail_type
has been specified:
.. code-block:: console
Wed Jul 28 15:30:13 2021 ERROR: Created 0 of 5 namespace(s) on target 100: Error: -lbaf value ‘400’ is not valid