Created
April 11, 2014 06:27
-
-
Save wido/10444038 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from optparse import OptionParser | |
def get_object_name(prefix, sector, order): | |
sector_size = 512 | |
return "%s.%012x" % (prefix, (sector * sector_size) / pow(2, order)) | |
def main(): | |
parser = OptionParser() | |
parser.add_option("-p", "--prefix", dest="prefix", type="string", | |
help="The RBD block name prefix") | |
parser.add_option("-o", "--order", dest="order", type="int", | |
default=22, help="The order size of the image") | |
parser.add_option("-s", "--sector", dest="sector", type="int", | |
default=0, help="The sector of the disk") | |
(options, args) = parser.parse_args() | |
print get_object_name(options.prefix, options.sector, options.order) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment