def create_sample_ring(self, part_power=6):
        """ Create a sample ring with four devices

        At least four devices are needed to test removing
        a device, since having less devices than replicas
        is not allowed.
        """

        # Ensure there is no existing test builder file because
        # create_sample_ring() might be used more than once in a single test
        try:
            os.remove(self.tmpfile)
        except __HOLE__:
            pass

        ring = RingBuilder(part_power, 3, 1)
        ring.add_dev({'weight': 100.0,
                      'region': 0,
                      'zone': 0,
                      'ip': '127.0.0.1',
                      'port': 6200,
                      'device': 'sda1',
                      'meta': 'some meta data',
                      })
        ring.add_dev({'weight': 100.0,
                      'region': 1,
                      'zone': 1,
                      'ip': '127.0.0.2',
                      'port': 6201,
                      'device': 'sda2'
                      })
        ring.add_dev({'weight': 100.0,
                      'region': 2,
                      'zone': 2,
                      'ip': '127.0.0.3',
                      'port': 6202,
                      'device': 'sdc3'
                      })
        ring.add_dev({'weight': 100.0,
                      'region': 3,
                      'zone': 3,
                      'ip': '127.0.0.4',
                      'port': 6203,
                      'device': 'sdd4'
                      })
        ring.save(self.tmpfile)
dataset/ETHPy150Open openstack/swift/test/unit/cli/test_ringbuilder.py/TestCommands.create_sample_ring