def test_init(self): fid = self.write_tempfile(self.repo_cfg) ostree_config = model.OstreeConfig(repo_file_path=fid.name) new_ostree_config = model.OstreeConfig(repo_file_path=fid.name) updates = model.OstreeConfigUpdates(ostree_config, new_ostree_config) updates.apply() self.assertEquals(updates.orig, updates.new) updates.save()
def test_init(self): fid = self.write_tempfile(self.repo_cfg) content_set = set() ostree_config = model.OstreeConfig(repo_file_path=fid.name) mock_content = mock.Mock() mock_content.url = "/path/from/base/url" mock_content.name = "mock-content-example" mock_content.gpg = None mock_ent_cert = mock.Mock() mock_ent_cert.path = "/somewhere/etc/pki/entitlement/123123.pem" mock_ent_content = mock.Mock() mock_ent_content.content = mock_content mock_ent_content.cert = mock_ent_cert content_set.add(mock_ent_content) updates_builder = model.OstreeConfigUpdatesBuilder( ostree_config, content_set) updates = updates_builder.build() self.assertTrue(len(updates.new.remotes)) self.assertTrue(isinstance(updates.new.remotes[0], model.OstreeRemote)) self.assertEquals(updates.new.remotes[0].url, mock_content.url) #self.assertEquals(updates.new.remotes[0].name, mock_content.name) self.assertEquals(updates.new.remotes[0].gpg_verify, True)
def setUp(self): super(TestOstreeConfigRepoFileWriter, self).setUp() self.repo_cfg_path = self.write_tempfile(self.repo_cfg) self.repo_config = model.OstreeConfig( repo_file_path=self.repo_cfg_path.name) self.repo_config.load()
def _setup_config(self, repo_cfg, origin_cfg): self.repo_cfg_path = self.write_tempfile(repo_cfg) self.repo_config = model.OstreeConfig( repo_file_path=self.repo_cfg_path.name) self.repo_config.load() self.updater = model.OstreeOriginUpdater(self.repo_config) self.origin_cfg_path = self.write_tempfile(origin_cfg) self.updater._get_deployed_origin = mock.Mock( return_value=self.origin_cfg_path.name)
def perform(self): # starting state of ostree config ostree_config = model.OstreeConfig() # populate config, handle exceptions self.load_config(ostree_config) report = OstreeContentUpdateActionReport() # return the composed set oEntitledContents entitled_contents = OstreeContents(ent_source=self.ent_source) # CALCULATE UPDATES # given current config, and the new contents, construct a list # of remotes to apply to our local config of remotes. updates_builder = \ model.OstreeConfigUpdatesBuilder(ostree_config, contents=entitled_contents) updates = updates_builder.build() log.debug("Updates orig: %s" % updates.orig) log.debug("Updates new: %s" % updates.new) log.debug("Updates.new.remote_set: %s" % updates.new.remotes) # persist the new stuff updates.apply() updates.save() report.orig_remotes = list(updates.orig.remotes) report.remote_updates = list(updates.new.remotes) # reload the new config, so we have fresh remotes, etc self.load_config(ostree_config) # Now that we've updated the ostree repo config, we need to # update the currently deployed osname tree .origin file: self.update_origin_file(ostree_config) log.debug("Ostree update report: %s" % report) return report