Now that snapshot_get_by_host is fixed we can and should
pass in a list of snapshot-refs to the drivers update_provider
method (just like we do with volumes).
Change-Id: I062efd1b7ab16f3f999464d3190c204026bba5ec
Closes-Bug: #
1489182
vid_1 = 'c9125d6d-22ff-4cc3-974d-d4e350df9c91'
vid_2 = '79883868-6933-47a1-a362-edfbf8d55a18'
+ sid_1 = 'e3caa4fa-485e-45ca-970e-1d3e693a2520'
project_1 = 'e6fb073c-11f0-4f4c-897c-90e7c7c4bcf8'
project_2 = '4ff32607-305c-4a6b-a51a-0dd33124eecf'
{'id': vid_2,
'project_id': project_2,
'provider_id': 22}]
-
+ snaprefs = [{'id': sid_1,
+ 'project_id': project_1,
+ 'provider_id': None,
+ 'volume_id': 'vid_1'}]
sf_vols = [{'volumeID': 99,
'name': 'UUID-' + vid_1,
'accountID': 100},
with mock.patch.object(
sfv, '_issue_api_request', side_effect=_fake_issue_api_req):
- volume_updates, snapshot_updates = sfv.update_provider_info(vrefs)
+ volume_updates, snapshot_updates = sfv.update_provider_info(
+ vrefs, snaprefs)
self.assertEqual(99, volume_updates[0]['provider_id'])
self.assertEqual(1, len(volume_updates))
"""
return None
- def update_provider_info(self, volumes):
+ def update_provider_info(self, volumes, snapshots):
"""Get provider info updates from driver.
:param volumes: List of Cinder volumes to check for updates
+ :param snapshots: List of Cinder snapshots to check for updates
:return: tuple (volume_updates, snapshot_updates)
where volume updates {'id': uuid, provider_id: <provider-id>}
'provider_id': sfvol['volumeID']})
return updates
- def update_provider_info(self, vrefs):
+ def update_provider_info(self, vrefs, snaprefs):
volume_updates = self._init_volume_mappings(vrefs)
snapshot_updates = None
return (volume_updates, snapshot_updates)
LOG.info(_LI("Determined volume DB was not empty at startup."))
return False
- def _sync_provider_info(self, ctxt, volumes):
+ def _sync_provider_info(self, ctxt, volumes, snapshots):
# NOTE(jdg): For now this just updates provider_id, we can add more
# add more items to the update if theyr'e releveant but we need
# to be safe in what we allow and add a list of allowed keys
# things that make sense are provider_*, replication_status etc
- updates, snapshot_updates = self.driver.update_provider_info(volumes)
+ updates, snapshot_updates = self.driver.update_provider_info(
+ volumes, snapshots)
host_vols = utils.list_of_dicts_to_dict(volumes, 'id')
for u in updates or []:
self.driver.init_capabilities()
volumes = self.db.volume_get_all_by_host(ctxt, self.host)
- self._sync_provider_info(ctxt, volumes)
+ snapshots = self.db.snapshot_get_by_host(ctxt, self.host)
+ self._sync_provider_info(ctxt, volumes, snapshots)
# FIXME volume count for exporting is wrong
try: