#NEWLINE# def create_sample_ring( self , part_power = 6 ) : #NEWLINE# #INDENT# ' Create a sample ring with four devices\n\n        At least four devices are needed to test removing\n        a device, since having less devices than replicas\n        is not allowed.\n        ' #NEWLINE# try : #NEWLINE# #INDENT# os . remove ( self . tmpfile ) #NEWLINE# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# ring = RingBuilder ( part_power , 3 , 1 ) #NEWLINE# ring . add_dev ( { #NEWLINE# #INDENT# 'weight' : 100.0 , #NEWLINE# 'region' : 0 , #NEWLINE# 'zone' : 0 , #NEWLINE# 'ip' : '127.0.0.1' , #NEWLINE# 'port' : 6200 , #NEWLINE# 'device' : 'sda1' , #NEWLINE# 'meta' : 'some meta data' , #NEWLINE# #UNINDENT# } ) #NEWLINE# ring . add_dev ( { #NEWLINE# #INDENT# 'weight' : 100.0 , #NEWLINE# 'region' : 1 , #NEWLINE# 'zone' : 1 , #NEWLINE# 'ip' : '127.0.0.2' , #NEWLINE# 'port' : 6201 , #NEWLINE# 'device' : 'sda2' , #NEWLINE# #UNINDENT# } ) #NEWLINE# ring . add_dev ( { #NEWLINE# #INDENT# 'weight' : 100.0 , #NEWLINE# 'region' : 2 , #NEWLINE# 'zone' : 2 , #NEWLINE# 'ip' : '127.0.0.3' , #NEWLINE# 'port' : 6202 , #NEWLINE# 'device' : 'sdc3' , #NEWLINE# #UNINDENT# } ) #NEWLINE# ring . add_dev ( { #NEWLINE# #INDENT# 'weight' : 100.0 , #NEWLINE# 'region' : 3 , #NEWLINE# 'zone' : 3 , #NEWLINE# 'ip' : '127.0.0.4' , #NEWLINE# 'port' : 6203 , #NEWLINE# 'device' : 'sdd4' , #NEWLINE# #UNINDENT# } ) #NEWLINE# ring . save ( self . tmpfile )