def get_lun_id(self, volume): """Retrieves id of the volume's backing LUN. :param volume: volume information """ if volume.provider_location: return utils.extract_provider_location(volume.provider_location, 'id') else: # In some cases, cinder will not update volume info in DB with # provider_location returned by us. We need to retrieve the id # from array. lun = self.client.get_lun(name=volume.name) return lun.get_id() if lun is not None else None
def get_lun_id(self, volume): """Retrieves id of the volume's backing LUN. :param volume: volume information """ if volume.provider_location: return utils.extract_provider_location(volume.provider_location, 'id') else: # In some cases, cinder will not update volume info in DB with # provider_location returned by us. We need to retrieve the id # from array. lun = self.client.get_lun(name=volume.name) return lun.get_id() if lun is not None else None
def test_extract_provider_location_none(self): self.assertIsNone(utils.extract_provider_location(None, 'abc'))
def test_extract_provider_location_not_found(self): location = 'id^ev_1|system^unity|type^thin|version^3' self.assertIsNone(utils.extract_provider_location(location, 'na'))
def test_extract_provider_location_id(self): location = 'id^ev_1|system^unity|type^thin|version^3' self.assertEqual('ev_1', utils.extract_provider_location(location, 'id'))
def test_extract_provider_location_none(self): self.assertIsNone(utils.extract_provider_location(None, 'abc'))
def test_extract_provider_location_not_found(self): location = 'id^ev_1|system^unity|type^thin|version^3' self.assertIsNone(utils.extract_provider_location(location, 'na'))
def test_extract_provider_location_id(self): location = 'id^ev_1|system^unity|type^thin|version^3' self.assertEqual('ev_1', utils.extract_provider_location(location, 'id'))