Hey all, I was playing with loopback target and I reached situation where I cannot create any other target apart of those starting with 1,2,5. Reading the code it seems to be b/c of following [1].
Second issue I have found is in the generate_wwn function [2]. When creating the NAA or EUI, You are actually stick to the one OUI (Organizationally Unique Identifier) 001405 which belongs to OpenIB (Qlogic corporation). I think it would be better to use private OUIs listed at [3].
Attaching code which generates and check's OUIs.
[1] --- def normalize_wwn(wwn_types, wwn): ''' Take a WWN as given by the user and convert it to a standard text representation.
Returns (normalized_wwn, wwn_type), or exception if invalid wwn. ''' wwn_test = { 'free': lambda wwn: True, 'iqn': lambda wwn: \ re.match("iqn.[0-9]{4}-[0-1][0-9]..*..*", wwn) \ and not re.search(' ', wwn) \ and not re.search('_', wwn), 'naa': lambda wwn: re.match("naa.[125][0-9a-fA-F]{15}$", wwn), 'eui': lambda wwn: re.match("eui.[0-9a-f]{16}$", wwn), 'ib': lambda wwn: re.match("ib.[0-9a-f]{32}$", wwn), 'unit_serial': lambda wwn: \ re.match("[0-9A-Fa-f]{8}(-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$", wwn), } ---
[2] --- def generate_wwn(wwn_type): ''' Generates a random WWN of the specified type: - unit_serial: T10 WWN Unit Serial. - iqn: iSCSI IQN - naa: SAS NAA address @param wwn_type: The WWN address type. @type wwn_type: str @returns: A string containing the WWN. ''' wwn_type = wwn_type.lower() if wwn_type == 'free': return str(uuid.uuid4()) if wwn_type == 'unit_serial': return str(uuid.uuid4()) elif wwn_type == 'iqn': localname = socket.gethostname().split(".")[0] localarch = os.uname()[4].replace("_", "") prefix = "iqn.2003-01.org.linux-iscsi.%s.%s" % (localname, localarch) prefix = prefix.strip().lower() serial = "sn.%s" % str(uuid.uuid4())[24:] return "%s:%s" % (prefix, serial) elif wwn_type == 'naa': # see http://standards.ieee.org/develop/regauth/tut/fibre.pdf # 5 = IEEE registered # 001405 = OpenIB OUI (they let us use it I guess?) # rest = random return "naa.5001405" + uuid.uuid4().hex[-9:] elif wwn_type == 'eui': return "eui.001405" + uuid.uuid4().hex[-10:] else: raise ValueError("Unknown WWN type: %s" % wwn_type)
---
[3]
http://standards-oui.ieee.org/oui/oui.txt