Example #1
0
    def test_find_content_everything(self):
        yum_content = create_mock_content(name="yum_content",
                                          tags=["awesomeos-1"],
                                          content_type="yum")
        container_content = create_mock_content(name="container_content",
                                                tags=["awesomeos-1"],
                                                content_type="containerImage")
        ostree_content = create_mock_content(name="ostree_content",
                                             tags=["awesomeos-1"],
                                             content_type="ostree")

        ent1 = model.Entitlement(contents=[yum_content])
        ent2 = model.Entitlement(contents=[container_content, ostree_content])

        ent_src = model.EntitlementSource()
        ent_src._entitlements = [ent1, ent2]
        ent_src.product_tags = ["awesomeos-1"]

        yum_list = model.find_content(ent_src, content_type='yum')
        self.assertEquals(1, len(yum_list))
        self.assertEquals('yum_content', yum_list[0].name)

        cont_list = model.find_content(ent_src,
            content_type='containerImage')
        self.assertEquals(1, len(cont_list))
        self.assertEquals('container_content', cont_list[0].name)

        ostree_list = model.find_content(ent_src,
                                         content_type="ostree")
        self.assertEquals(1, len(ostree_list))
        self.assertEquals('ostree_content', ostree_list[0].name)
    def get_all_content(self, baseurl, ca_cert):
        matching_content = model.find_content(self.ent_source,
                                              content_type="yum")

        content_list = []

        # avoid checking for release/etc if there is no matching_content
        if not matching_content:
            return content_list

        # wait until we know we have content before fetching
        # release. We could make YumReleaseverSource understand
        # cache_only as well.
        release_source = YumReleaseverSource()

        for content in matching_content:
            repo = Repo.from_ent_cert_content(content, baseurl, ca_cert,
                                              release_source)

            # overrides are yum repo only at the moment, but
            # content sources will likely need to learn how to
            # apply overrides as well, perhaps generically
            if self.override_supported and self.apply_overrides:
                repo = self._set_override_info(repo)

            content_list.append(repo)

        return content_list
Example #3
0
    def test_product_tags(self):
        esb = EntitlementSourceBuilder()
        es = esb.ent_source()
        es.product_tags = []

        res = model.find_content(es, content_type="yum")
        self.assertEquals(len(res), 4)
Example #4
0
    def test_product_tags_one_non_match(self):
        esb = EntitlementSourceBuilder()
        es = esb.ent_source()
        es.product_tags = ['something-random-tag']

        res = model.find_content(es, content_type="yum")
        self.assertEquals(len(res), 4)
    def update_repo_config(self):
        ostree_repo_config = model.OstreeRepoConfig()

        # populate config, handle exceptions
        self.load_config(ostree_repo_config)

        report = OstreeContentUpdateActionReport()

        # return the composed set of EntitledContents
        entitled_contents = find_content(self.ent_source,
                                         content_type=OSTREE_CONTENT_TYPE)

        # update repo configs
        updates = self.update_config(ostree_repo_config,
                                     contents=entitled_contents)

        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_repo_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_repo_config)

        log.debug("Ostree update report: %s" % report)
        return report
Example #6
0
    def test_no_content_tags(self):
        content = create_mock_content(content_type="ostree")
        content_list = [content]

        entitlement = model.Entitlement(contents=content_list)
        es = model.EntitlementSource()
        es._entitlements = [entitlement]
        es.product_tags = ['awesomeos-ostree-1']

        res = model.find_content(es, content_type="ostree")
        self.assertEquals(len(res), 1)
        self.assertEquals(res[0], content)
    def test_product_tags_and_content_tags_no_match_no_product_tags(self):
        content1 = create_mock_content(tags=["awesomeos-ostree-23"], content_type="ostree")
        content2 = create_mock_content(
            name="more-test-content", tags=["awesomeos-ostree-24"], content_type="ostree"
        )
        content_list = [content1, content2]

        entitlement = model.Entitlement(contents=content_list)
        es = model.EntitlementSource()
        es._entitlements = [entitlement]

        res = model.find_content(es, content_type="ostree")

        self.assertEqual(len(res), 0)
Example #8
0
    def test_find_container_content(self):
        container_content = create_mock_content(name="container_content",
                                                tags=["awesomeos-1"],
                                                content_type="containerImage")

        ent1 = model.Entitlement(contents=[container_content])

        ent_src = model.EntitlementSource()
        ent_src._entitlements = [ent1]
        ent_src.product_tags = ["awesomeos-1"]

        cont_list = model.find_content(ent_src, content_type='containerImage')
        self.assertEqual(1, len(cont_list))
        self.assertEqual('container_content', cont_list[0].name)
    def test_ent_source(self):
        yc = self.create_content("yum", "yum_content")
        oc = self.create_content("ostree", "ostree_content")

        ent1 = Entitlement(contents=[yc])
        ent2 = Entitlement(contents=[oc])

        ent_src = EntitlementSource()
        ent_src._entitlements = [ent1, ent2]

        contents = find_content(ent_src, content_type=action_invoker.OSTREE_CONTENT_TYPE)
        self.assertEquals(len(contents), 1)

        for content in contents:
            self.assertEquals(content.content_type, action_invoker.OSTREE_CONTENT_TYPE)
Example #10
0
    def test_ent_source(self):
        yc = self.create_content("yum", "yum_content")
        oc = self.create_content("ostree", "ostree_content")

        ent1 = Entitlement(contents=[yc])
        ent2 = Entitlement(contents=[oc])

        ent_src = EntitlementSource()
        ent_src._entitlements = [ent1, ent2]

        contents = find_content(ent_src, content_type=action_invoker.OSTREE_CONTENT_TYPE)
        self.assertEqual(len(contents), 1)

        for content in contents:
            self.assertEqual(content.content_type, action_invoker.OSTREE_CONTENT_TYPE)
    def test_product_tags_and_content_tags_no_match_no_product_tags(self):
        content1 = create_mock_content(tags=['awesomeos-ostree-23'],
                                      content_type="ostree")
        content2 = create_mock_content(name="more-test-content",
                                       tags=['awesomeos-ostree-24'],
                                       content_type="ostree")
        content_list = [content1, content2]

        entitlement = model.Entitlement(contents=content_list)
        es = model.EntitlementSource()
        es._entitlements = [entitlement]

        res = model.find_content(es, content_type="ostree")

        self.assertEquals(len(res), 0)
    def test_find_container_content(self):
        container_content = create_mock_content(name="container_content",
                                                tags=["awesomeos-1"],
                                                content_type="containerImage")

        ent1 = model.Entitlement(contents=[container_content])

        ent_src = model.EntitlementSource()
        ent_src._entitlements = [ent1]
        ent_src.product_tags = ["awesomeos-1"]

        cont_list = model.find_content(ent_src,
            content_type='containerImage')
        self.assertEquals(1, len(cont_list))
        self.assertEquals('container_content', cont_list[0].name)
Example #13
0
    def test_product_tags_and_content_tags_multiple_content_one_match(self):
        content1 = create_mock_content(tags=['awesomeos-ostree-23'],
                                      content_type="ostree")
        content2 = create_mock_content(name="more-test-content",
                                       tags=['awesomeos-ostree-1'],
                                       content_type="ostree")
        content_list = [content1, content2]

        entitlement = model.Entitlement(contents=content_list)
        es = model.EntitlementSource()
        es._entitlements = [entitlement]
        es.product_tags = ['awesomeos-ostree-1']

        res = model.find_content(es, content_type="ostree")

        self.assertEquals(len(res), 1)
        self.assertEquals(res[0], content2)
    def test_product_tags_and_content_tags_multiple_content_one_match(self):
        content1 = create_mock_content(tags=['awesomeos-ostree-23'],
                                      content_type="ostree")
        content2 = create_mock_content(name="more-test-content",
                                       tags=['awesomeos-ostree-1'],
                                       content_type="ostree")
        content_list = [content1, content2]

        entitlement = model.Entitlement(contents=content_list)
        es = model.EntitlementSource()
        es._entitlements = [entitlement]
        es.product_tags = ['awesomeos-ostree-1']

        res = model.find_content(es, content_type="ostree")

        self.assertEqual(len(res), 1)
        self.assertEqual(res[0], content2)
Example #15
0
    def get_all_content(self, baseurl, ca_cert):
        matching_content = model.find_content(self.ent_source,
                                              content_type="yum")

        content_list = []
        for content in matching_content:
            repo = Repo.from_ent_cert_content(content, baseurl, ca_cert,
                                              self.release)

            # overrides are yum repo only at the moment, but
            # content sources will likely need to learn how to
            # apply overrides as well, perhaps generically
            if self.override_supported and self.apply_overrides:
                repo = self._set_override_info(repo)

            content_list.append(repo)

        return content_list
    def test_ent_source_product_tags(self):
        yc = self.create_content("yum", "yum_content")
        oc = self.create_content("ostree", "ostree_content")

        ent1 = Entitlement(contents=[yc])
        ent2 = Entitlement(contents=[oc])

        ent_src = EntitlementSource()
        ent_src._entitlements = [ent1, ent2]

        # faux product_tags to hit find_content, but no content tags
        ent_src.product_tags = ["awesomeos-ostree-1", "awesomeos-ostree-super"]

        contents = find_content(ent_src, content_type=action_invoker.OSTREE_CONTENT_TYPE)
        self.assertEquals(len(contents), 1)

        for content in contents:
            self.assertEquals(content.content_type, action_invoker.OSTREE_CONTENT_TYPE)
Example #17
0
    def test_ent_source_product_tags_and_content_tags(self):
        oc = self.create_content("ostree", "ostree_content")
        oc.tags = ["awesomeos-ostree-1"]

        ent = Entitlement(contents=[oc])

        ent_src = EntitlementSource()
        ent_src._entitlements = [ent]

        # faux product_tags to hit find_content, but no content tags
        ent_src.product_tags = ["awesomeos-ostree-1", "awesomeos-ostree-super"]

        contents = find_content(ent_src, content_type=action_invoker.OSTREE_CONTENT_TYPE)
        print("contents", contents)
        self.assertEqual(len(contents), 1)

        for content in contents:
            self.assertEqual(content.content_type, action_invoker.OSTREE_CONTENT_TYPE)
    def update_repo_config(self):
        ostree_repo_config = model.OstreeRepoConfig()

        # populate config, handle exceptions
        self.load_config(ostree_repo_config)

        # return the composed set of EntitledContents
        entitled_contents = find_content(self.ent_source,
                                         content_type=OSTREE_CONTENT_TYPE)

        # update repo configs
        report = self.update_config(ostree_repo_config,
                                     contents=entitled_contents)

        # reload the new config, so we have fresh remotes, etc
        self.load_config(ostree_repo_config)

        log.debug("Ostree update report: %s" % report)
        return report
    def update_repo_config(self):
        ostree_repo_config = model.OstreeRepoConfig()

        # populate config, handle exceptions
        self.load_config(ostree_repo_config)

        # return the composed set of EntitledContents
        entitled_contents = find_content(self.ent_source,
                                         content_type=OSTREE_CONTENT_TYPE)

        # update repo configs
        report = self.update_config(ostree_repo_config,
                                    contents=entitled_contents)

        # reload the new config, so we have fresh remotes, etc
        self.load_config(ostree_repo_config)

        log.debug("Ostree update report: %s" % report)
        return report
    def test_ent_source_product_tags_and_content_tags(self):
        oc = self.create_content("ostree", "ostree_content")
        oc.tags = ['awesomeos-ostree-1']

        ent = Entitlement(contents=[oc])

        ent_src = EntitlementSource()
        ent_src._entitlements = [ent]

        # faux product_tags to hit find_content, but no content tags
        ent_src.product_tags = ['awesomeos-ostree-1', 'awesomeos-ostree-super']

        contents = find_content(ent_src,
            content_type=action_invoker.OSTREE_CONTENT_TYPE)
        print "contents", contents
        self.assertEquals(len(contents), 1)

        for content in contents:
            self.assertEquals(content.content_type,
                action_invoker.OSTREE_CONTENT_TYPE)
    def test_ent_source_product_tags(self):
        yc = self.create_content("yum", "yum_content")
        oc = self.create_content("ostree", "ostree_content")

        ent1 = Entitlement(contents=[yc])
        ent2 = Entitlement(contents=[oc])

        ent_src = EntitlementSource()
        ent_src._entitlements = [ent1, ent2]

        # faux product_tags to hit find_content, but no content tags
        ent_src.product_tags = ['awesomeos-ostree-1', 'awesomeos-ostree-super']

        contents = find_content(
            ent_src, content_type=action_invoker.OSTREE_CONTENT_TYPE)
        self.assertEquals(len(contents), 1)

        for content in contents:
            self.assertEquals(content.content_type,
                              action_invoker.OSTREE_CONTENT_TYPE)
Example #22
0
    def update_repo_config(self):
        ostree_repo_config = model.OstreeRepoConfig()

        # populate config, handle exceptions
        self.load_config(ostree_repo_config)

        # return the composed set of EntitledContents
        entitled_contents = find_content(self.ent_source,
                                         content_type=OSTREE_CONTENT_TYPE)

        # update repo configs
        report = self.update_config(ostree_repo_config,
                                     contents=entitled_contents)

        # reload the new config, so we have fresh remotes, etc
        self.load_config(ostree_repo_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_repo_config)

        log.debug("Ostree update report: %s" % report)
        return report
Example #23
0
    def test(self):
        esb = EntitlementSourceBuilder()
        es = esb.ent_source()

        res = model.find_content(es, content_type="yum")
        self.assertEqual(len(res), 4)
Example #24
0
 def matching_content(self):
     return model.find_content(self.ent_source, content_type="yum")
Example #25
0
 def matching_content(self):
     content = []
     for content_type in ALLOWED_CONTENT_TYPES:
         content += model.find_content(self.ent_source,
                                       content_type=content_type)
     return content
Example #26
0
    def test_awesomeos_product_tags(self):
        product_tags_beta = ["awesomeos-ostree-beta", "awesomeos-ostree-beta-7"]
        product_tags_htb = ["awesomeos-ostree-htb", "awesomeos-ostree-htb-7"]
        product_tags_os = ["awesomeos-ostree", "awesomeos-ostree-7"]

        content_tags_beta = ["awesomeos-ostree-beta-7"]
        content_tags_htb = ["awesomeos-ostree-htb-7"]
        content_tags_os = ["awesomeos-ostree-7"]

        beta_ostree_content = create_mock_content(name="awesomeos_beta_ostree_content",
                                                  tags=content_tags_beta,
                                                  content_type="ostree")

        htb_ostree_content = create_mock_content(name="awesomeos_htb_ostree_content",
                                                 tags=content_tags_htb,
                                                 content_type="ostree")

        ostree_content = create_mock_content(name="awesomeos_ostree_content",
                                             tags=content_tags_os,
                                             content_type="ostree")

        ent = model.Entitlement(contents=[ostree_content,
                                          htb_ostree_content,
                                          beta_ostree_content])

        ent_src = model.EntitlementSource()
        ent_src._entitlements = [ent]

        # beta product
        ent_src.product_tags = product_tags_beta
        ostree_list = model.find_content(ent_src, content_type='ostree')
        self.assertEquals(1, len(ostree_list))
        self.assertEquals('awesomeos_beta_ostree_content', ostree_list[0].name)

        # htb products
        ent_src.product_tags = product_tags_htb
        ostree_list = model.find_content(ent_src, content_type='ostree')
        self.assertEquals(1, len(ostree_list))
        self.assertEquals('awesomeos_htb_ostree_content', ostree_list[0].name)

        ent_src.product_tags = product_tags_os
        ostree_list = model.find_content(ent_src, content_type='ostree')
        self.assertEquals(1, len(ostree_list))
        self.assertEquals('awesomeos_ostree_content', ostree_list[0].name)

        # beta product, no beta content
        ent = model.Entitlement(contents=[ostree_content])
        ent_src._entitlements = [ent]
        ent_src.product_tags = product_tags_beta
        ostree_list = model.find_content(ent_src, content_type='ostree')
        self.assertEquals(0, len(ostree_list))

        # awesomeos product, no os content, beta, htb content
        ent = model.Entitlement(contents=[htb_ostree_content,
                                          beta_ostree_content])
        ent_src._entitlements = [ent]
        ent_src.product_tags = product_tags_os
        ostree_list = model.find_content(ent_src, content_type='ostree')
        self.assertEquals(0, len(ostree_list))

        # awesomeos and beta product, all content
        ent = model.Entitlement(contents=[ostree_content,
                                          htb_ostree_content,
                                          beta_ostree_content])
        ent_src._entitlements = [ent]
        ent_src.product_tags = product_tags_os + product_tags_beta
        ostree_list = model.find_content(ent_src, content_type='ostree')
        # should be os and beta content
        self.assertEquals(2, len(ostree_list))
        content_names = [x.name for x in ostree_list]
        self.assertTrue('awesomeos_ostree_content' in content_names)
        self.assertTrue('awesomeos_beta_ostree_content' in content_names)
        self.assertFalse('awesomeos_htb_ostree_content' in content_names)
Example #27
0
 def matching_content(self):
     content = []
     for content_type in ALLOWED_CONTENT_TYPES:
         content += model.find_content(self.ent_source,
                                       content_type=content_type)
     return content
Example #28
0
 def _find_content(self):
     return find_content(self.ent_source,
         content_type=CONTAINER_CONTENT_TYPE)
Example #29
0
 def matching_content(self):
     return model.find_content(self.ent_source,
                               content_type="yum")
    def test(self):
        esb = EntitlementSourceBuilder()
        es = esb.ent_source()

        res = model.find_content(es, content_type="yum")
        self.assertEqual(len(res), 4)