def pull_volumes(self): backend_volumes = self.get_volumes() volumes = models.Volume.objects.filter( service_project_link__service__settings=self.settings, state__in=[models.Volume.States.OK, models.Volume.States.ERRED] ) backend_volumes_map = {backend_volume.backend_id: backend_volume for backend_volume in backend_volumes} for volume in volumes: try: backend_volume = backend_volumes_map[volume.backend_id] except KeyError: handle_resource_not_found(volume) else: update_pulled_fields(volume, backend_volume, models.Volume.get_backend_fields()) handle_resource_update_success(volume)
def pull_instances(self): backend_instances = self.get_instances() instances = models.Instance.objects.filter( service_project_link__service__settings=self.settings, state__in=[models.Instance.States.OK, models.Instance.States.ERRED], ) backend_instances_map = {backend_instance.backend_id: backend_instance for backend_instance in backend_instances} for instance in instances: try: backend_instance = backend_instances_map[instance.backend_id] except KeyError: handle_resource_not_found(instance) else: self.update_instance_fields(instance, backend_instance) handle_resource_update_success(instance)