Exemple #1
0
 def register_ring(self,
                   ring_name,
                   replica_count,
                   balance=0.0,
                   dispersion=0.0,
                   min_part_hours=24,
                   remaining='unknown',
                   overload=0.0):
     if not self.builder_rings.get(ring_name):
         model = {
             'name': ring_name,
             'partition_power': 0,
             'replication_policy': {
                 'replica_count': replica_count
             },
             'display_name': 'unknown',
             'balance': balance,
             'dispersion': dispersion,
             'min_part_hours': min_part_hours,
             'remaining': remaining,
             'overload': overload
         }
         ringspec = RingSpecification(None)
         ringspec.load_model(model)
         self.builder_rings[ring_name] = ringspec
Exemple #2
0
 def register_ring(self, region_name, ring_name, replica_count, balance):
     if not self.builder_rings.get((region_name, ring_name)):
         model = {'name': ring_name,
                  'partition_power': 0,
                  'replication_policy': {'replica_count': replica_count},
                  'min_part_time': 0,
                  'display_name': 'unknown',
                  'server_network_group': 'unknown',
                  'balance': balance}
         ringspec = RingSpecification(None)
         ringspec.load_model(model)
         self.builder_rings[(region_name, ring_name)] = ringspec
Exemple #3
0
 def load_model(self, data):
     staged_rings = data.get('delta_rings')
     for staged_ring in staged_rings:
         ring_name = staged_ring.get('ring_name')
         ring_specification = RingSpecification(None)
         ring_specification.load_model(
             staged_ring.get('ring_specification'))
         self.delta_rings[ring_name] = ring_specification
     stage_ring_actions = data.get('delta_ring_actions')
     for stage_ring_action in stage_ring_actions:
         ring_name = stage_ring_action.get('ring_name')
         action = stage_ring_action.get('action')
         self.delta_ring_actions[ring_name] = action
     for staged_device in data.get('delta_devices'):
         device = DeviceInfo()
         device.load_from_model(staged_device)
         self.delta_devices.append(device)
Exemple #4
0
 def test_ringspec_load(self):
     model = {'name': 'dummy',
              'partition_power': 1,
              'replication_policy': {'replica_count': 3},
              'min_part_time': 2,
              'display_name': 'dummy_display',
              'balance': 100.0,
              'weight_step': 30}
     ringspec = RingSpecification(None)
     ringspec.load_model(model)
     self.assertEquals(ringspec.name, 'dummy')
     self.assertEquals(ringspec.display_name, 'dummy_display')
     self.assertEquals(ringspec.partition_power, 1)
     self.assertEquals(ringspec.min_part_time, 2)
     self.assertEquals(ringspec.balance, 100.0)
     self.assertRaises(AttributeError, ringspec.__getattr__, 'junk')
     self.assertEquals(ringspec.replica_count, 3.0)
     self.assertEquals(ringspec.weight_step, 30.0)
Exemple #5
0
 def load_model(self, data):
     staged_rings = data.get('delta_rings')
     for staged_ring in staged_rings:
         region_name = staged_ring.get('region_name')
         ring_name = staged_ring.get('ring_name')
         ring_specification = RingSpecification(None)
         ring_specification.load_model(staged_ring.get(
             'ring_specification'))
         self.delta_rings[(region_name, ring_name)] = ring_specification
     stage_ring_actions = data.get('delta_ring_actions')
     for stage_ring_action in stage_ring_actions:
         region_name = stage_ring_action.get('region_name')
         ring_name = stage_ring_action.get('ring_name')
         action = stage_ring_action.get('action')
         self.delta_ring_actions[(region_name, ring_name)] = action
     for staged_device in data.get('delta_devices'):
         device = DeviceInfo()
         device.load_from_model(staged_device)
         self.delta_devices.append(device)