Skip to content

Instantly share code, notes, and snippets.

@WaltHP
Created February 11, 2016 22:15
Show Gist options
  • Select an option

  • Save WaltHP/8b56158c91cc7397b92a to your computer and use it in GitHub Desktop.

Select an option

Save WaltHP/8b56158c91cc7397b92a to your computer and use it in GitHub Desktop.
def process_lun_id(lun_id):
if isinstance(lun_id, list):
processed = []
for x in lun_id:
if x > 255:
val = hex(x)
length = 18-len(val)
for i in range(length):
val+='0'
processed.append(val)
else:
processed.append(x)
return processed
else:
if lun_id < 255:
return lun_id
else:
processed = hex(lun_id)
length = 18-len(processed)
for i in range(length):
processed+='0'
return processed
def ass_id(lun_id):
if lun_id < 256:
return lun_id
else:
return "0x%04x%04x00000000" % (lun_id & 0xffff, lun_id >>16 & 0xffff)
for lun in range(0, 65536):
# this doesn't work
#lun_id = process_lun_id(lun)
# this ass shit works!!
lun_id = ass_id(lun)
print "LUN(%s) = lun-%s" % (lun, lun_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment