def test_simple_device_info(self):
     device_info = DeviceInfo(model=safe_load(device_info_simple))
     self.assertEquals(device_info.region_name, 'region2')
     self.assertEquals(device_info.region_id, 2)
     self.assertEquals(device_info.replication_ip, None)
     self.assertEquals(device_info.presence, 'present')
     self.assertEquals(device_info.meta, 'host.example.com:disk99:/dev/sdh')
     with self.assertRaises(AttributeError):
         _ = device_info.junk
     with self.assertRaises(AttributeError):
         device_info.junk = 'junk'
Exemple #2
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)