def _get_cloud(self, distro): paths = helpers.Paths({}) cls = distros.fetch(distro) mydist = cls(distro, {}, paths) myds = DataSourceNone.DataSourceNone({}, mydist, paths) paths.datasource = myds return cloud.Cloud(myds, paths, {}, mydist, None)
def _get_cloud(self, distro): self.patchUtils(self.new_root) paths = helpers.Paths({'templates_dir': self.new_root}) cls = distros.fetch(distro) mydist = cls(distro, {}, paths) myds = DataSourceNone.DataSourceNone({}, mydist, paths) return cloud.Cloud(myds, paths, {}, mydist, None)
def _get_cloud(self, distro): self.patchUtils(self.new_root) paths = helpers.Paths({'scripts': self.new_root}) cls = distros.fetch(distro) mydist = cls(distro, {}, paths) myds = DataSourceNone.DataSourceNone({}, mydist, paths) paths.datasource = myds return cloud.Cloud(myds, paths, {}, mydist, None)
def _get_cloud(self, distro, metadata=None): paths = helpers.Paths({}) cls = distros.fetch(distro) ubuntu_distro = cls(distro, {}, paths) ds = DataSourceNone.DataSourceNone({}, ubuntu_distro, paths) if metadata: ds.metadata = metadata return cloud.Cloud(ds, paths, {}, ubuntu_distro, None)
def _get_cloud(self, distro, metadata=None): self.patchUtils(self.new_root) paths = helpers.Paths({}) cls = distros.fetch(distro) mydist = cls(distro, {}, paths) myds = DataSourceNone.DataSourceNone({}, mydist, paths) if metadata: myds.metadata.update(metadata) return cloud.Cloud(myds, paths, {}, mydist, None)
def _get_cloud(self, distro, sys_cfg=None): self.new_root = self.reRoot(root=self.new_root) paths = helpers.Paths({'templates_dir': self.new_root}) cls = distros.fetch(distro) if not sys_cfg: sys_cfg = {} mydist = cls(distro, sys_cfg, paths) myds = DataSourceNone.DataSourceNone(sys_cfg, mydist, paths) return cloud.Cloud(myds, paths, sys_cfg, mydist, None)
def test_localhost_default_hostname(self, get_hostname): """ No hostname set. Default value returned is localhost, but we shouldn't write it in /etc/hostname """ distro = self._fetch_distro("debian") paths = helpers.Paths({"cloud_dir": self.tmp}) ds = DataSourceNone.DataSourceNone({}, None, paths) cc = cloud.Cloud(ds, paths, {}, distro, None) self.patchUtils(self.tmp) util.write_file("/etc/hostname", "") cc_set_hostname.handle("cc_set_hostname", {}, cc, LOG, []) contents = util.load_file("/etc/hostname") self.assertEqual("", contents.strip())
def test_localhost_user_given_hostname(self, get_hostname): """ User set hostname is localhost. We should write it in /etc/hostname """ distro = self._fetch_distro("debian") paths = helpers.Paths({"cloud_dir": self.tmp}) ds = DataSourceNone.DataSourceNone({}, None, paths) cc = cloud.Cloud(ds, paths, {}, distro, None) self.patchUtils(self.tmp) # user-provided localhost should not be ignored util.write_file("/etc/hostname", "") cc_set_hostname.handle("cc_set_hostname", {"hostname": "localhost"}, cc, LOG, []) contents = util.load_file("/etc/hostname") self.assertEqual("localhost", contents.strip())
def tmp_cloud(self, distro, sys_cfg=None, metadata=None): """Create a cloud with tmp working directory paths. @param distro: Name of the distro to attach to the cloud. @param metadata: Optional metadata to set on the datasource. @return: The built cloud instance. """ self.new_root = self.tmp_dir() if not sys_cfg: sys_cfg = {} tmp_paths = {} for var in ['templates_dir', 'run_dir', 'cloud_dir']: tmp_paths[var] = self.tmp_path(var, dir=self.new_root) util.ensure_dir(tmp_paths[var]) self.paths = ch.Paths(tmp_paths) cls = distros.fetch(distro) mydist = cls(distro, sys_cfg, self.paths) myds = DataSourceNone.DataSourceNone(sys_cfg, mydist, self.paths) if metadata: myds.metadata.update(metadata) return cloud.Cloud(myds, self.paths, sys_cfg, mydist, None)
def fetch_cloud(self, distro_kind): cls = distros.fetch(distro_kind) paths = helpers.Paths({}) distro = cls(distro_kind, {}, paths) ds = DataSourceNone.DataSourceNone({}, distro, paths, None) return cloud.Cloud(ds, paths, {}, distro, None)