def setUp(self): # Change env for context self.orig_environ = os.environ os.environ = os.environ.copy() self.temp_dir = self.mkdtemp() self.local_dir = os.path.join(self.temp_dir, "local") self.hostdir = cdist.str_hash(self.target_host[0]) self.host_base_path = os.path.join(self.local_dir, self.hostdir) os.makedirs(self.host_base_path) self.local = cdist.exec.local.Local( target_host=self.target_host, target_host_tags=self.target_host_tags, base_root_path=self.host_base_path, host_dir_name=self.hostdir) # Setup test objects self.object_base_path = op.join(self.temp_dir, 'object') self.objects = [] for cdist_object_name in expected_object_names: cdist_type, cdist_object_id = cdist_object_name.split("/", 1) cdist_object = core.CdistObject(core.CdistType(type_base_path, cdist_type), self.object_base_path, self.local.object_marker_name, cdist_object_id) cdist_object.create() self.objects.append(cdist_object) self.object_index = dict((o.name, o) for o in self.objects) self.object_names = [o.name for o in self.objects] self.remote_dir = os.path.join(self.temp_dir, "remote") os.mkdir(self.remote_dir) self.remote = cdist.exec.remote.Remote( target_host=self.target_host, remote_copy=self.remote_copy, remote_exec=self.remote_exec, base_path=self.remote_dir, stdout_base_path=self.local.stdout_base_path, stderr_base_path=self.local.stderr_base_path) self.local.object_path = self.object_base_path self.local.type_path = type_base_path self.config = cdist.config.Config(self.local, self.remote)
def setUp(self): # Change env for context self.orig_environ = os.environ os.environ = os.environ.copy() self.temp_dir = self.mkdtemp() self.local_dir = os.path.join(self.temp_dir, "local") self.hostdir = cdist.str_hash(self.target_host[0]) self.host_base_path = os.path.join(self.local_dir, self.hostdir) os.makedirs(self.host_base_path) self.local = cdist.exec.local.Local( target_host=self.target_host, target_host_tags=self.target_host_tags, base_root_path=self.host_base_path, host_dir_name=self.hostdir) # Setup test objects self.object_base_path = op.join(self.temp_dir, 'object') self.objects = [] for cdist_object_name in expected_object_names: cdist_type, cdist_object_id = cdist_object_name.split("/", 1) cdist_object = core.CdistObject( core.CdistType(type_base_path, cdist_type), self.object_base_path, self.local.object_marker_name, cdist_object_id) cdist_object.create() self.objects.append(cdist_object) self.object_index = dict((o.name, o) for o in self.objects) self.object_names = [o.name for o in self.objects] self.remote_dir = os.path.join(self.temp_dir, "remote") os.mkdir(self.remote_dir) self.remote = cdist.exec.remote.Remote( target_host=self.target_host, remote_copy=self.remote_copy, remote_exec=self.remote_exec, base_path=self.remote_dir, stdout_base_path=self.local.stdout_base_path, stderr_base_path=self.local.stderr_base_path) self.local.object_path = self.object_base_path self.local.type_path = type_base_path self.config = cdist.config.Config(self.local, self.remote)