def _get_container_image_info(self, image_name: str) -> ContainerInspectInfo: # pick a random host... host = None for host_name in self.mgr.inventory.keys(): host = host_name break if not host: raise OrchestratorError('no hosts defined') if self.mgr.cache.host_needs_registry_login( host) and self.mgr.registry_url: self._registry_login(host, self.mgr.registry_url, self.mgr.registry_username, self.mgr.registry_password) out, err, code = self._run_cephadm(host, '', 'pull', [], image=image_name, no_fsid=True, error_ok=True) if code: raise OrchestratorError('Failed to pull %s on %s: %s' % (image_name, host, '\n'.join(out))) try: j = json.loads('\n'.join(out)) r = ContainerInspectInfo(j['image_id'], j.get('ceph_version'), j.get('repo_digest')) self.log.debug(f'image {image_name} -> {r}') return r except (ValueError, KeyError) as _: msg = 'Failed to pull %s on %s: Cannot decode JSON' % (image_name, host) self.log.exception('%s: \'%s\'' % (msg, '\n'.join(out))) raise OrchestratorError(msg)
def _get_container_image_info(self, image_name: str) -> ContainerInspectInfo: # pick a random host... host = None for host_name in self.mgr.inventory.keys(): host = host_name break if not host: raise OrchestratorError('no hosts defined') if self.mgr.cache.host_needs_registry_login( host) and self.mgr.registry_url: self._registry_login(host, self.mgr.registry_url, self.mgr.registry_username, self.mgr.registry_password) j = self._run_cephadm_json(host, '', 'pull', [], image=image_name, no_fsid=True) r = ContainerInspectInfo(j['image_id'], j.get('ceph_version'), j.get('repo_digests')) self.log.debug(f'image {image_name} -> {r}') return r