Ejemplo n.º 1
0
    def on_selection(self, selection):
        """
        Updates the 'Subscription Details' panel with the currently selected
        subscription.
        """

        if selection['is_group_row']:
            self.sub_details.clear()
            self.unsubscribe_button.set_property('sensitive', False)
            return

        self.unsubscribe_button.set_property('sensitive', True)
        # Load the entitlement certificate for the selected row:
        serial = selection['serial']
        cert = self.entitlement_dir.find(long(serial))
        order = cert.order
        products = [(product.name, product.id) for product in cert.products]

        reasons = []
        if self.backend.cs.are_reasons_supported():
            reasons = self.backend.cs.reasons.get_subscription_reasons(
                cert.subject['CN'])
            if not reasons:
                if cert in self.backend.cs.valid_entitlement_certs:
                    reasons.append(_('Subscription is current.'))
                else:
                    if cert.valid_range.end() < datetime.now(GMT()):
                        reasons.append(_('Subscription is expired.'))
                    else:
                        reasons.append(_('Subscription has not begun.'))
        else:
            reasons.append(
                _("Subscription management service doesn't support Status Details."
                  ))

        if is_true_value(order.virt_only):
            virt_only = _("Virtual")
        else:
            virt_only = _("Physical")

        if is_true_value(order.provides_management):
            management = _("Yes")
        else:
            management = _("No")

        self.sub_details.show(order.name,
                              contract=order.contract or "",
                              start=cert.valid_range.begin(),
                              end=cert.valid_range.end(),
                              account=order.account or "",
                              management=management,
                              virt_only=virt_only or "",
                              support_level=order.service_level or "",
                              support_type=order.service_type or "",
                              products=products,
                              sku=order.sku,
                              reasons=reasons,
                              expiring=cert.is_expiring())
Ejemplo n.º 2
0
    def on_selection(self, selection):
        """
        Updates the 'Subscription Details' panel with the currently selected
        subscription.
        """

        if selection['is_group_row']:
            self.sub_details.clear()
            self.unsubscribe_button.set_property('sensitive', False)
            return

        self.unsubscribe_button.set_property('sensitive', True)
        # Load the entitlement certificate for the selected row:
        serial = selection['serial']
        cert = self.entitlement_dir.find(long(serial))
        order = cert.order
        products = [(product.name, product.id)
                        for product in cert.products]

        reasons = []
        if self.backend.cs.are_reasons_supported():
            reasons = self.backend.cs.reasons.get_subscription_reasons(cert.subject['CN'])
            if not reasons:
                if cert in self.backend.cs.valid_entitlement_certs:
                    reasons.append(_('Subscription is current.'))
                else:
                    if cert.valid_range.end() < datetime.now(GMT()):
                        reasons.append(_('Subscription is expired.'))
                    else:
                        reasons.append(_('Subscription has not begun.'))
        else:
            reasons.append(_("Subscription management service doesn't support Status Details."))

        if is_true_value(order.virt_only):
            virt_only = _("Virtual")
        else:
            virt_only = _("Physical")

        if is_true_value(order.provides_management):
            management = _("Yes")
        else:
            management = _("No")

        self.sub_details.show(order.name,
                              contract=order.contract or "",
                              start=cert.valid_range.begin(),
                              end=cert.valid_range.end(),
                              account=order.account or "",
                              management=management,
                              virt_only=virt_only or "",
                              support_level=order.service_level or "",
                              support_type=order.service_type or "",
                              products=products,
                              sku=order.sku,
                              reasons=reasons,
                              expiring=cert.is_expiring())
Ejemplo n.º 3
0
 def test_false_value(self):
     self.assertFalse(is_true_value("0"))
     self.assertFalse(is_true_value("False"))
     self.assertFalse(is_true_value("FalsE"))
     self.assertFalse(is_true_value("no"))
     self.assertFalse(is_true_value("nO"))
     self.assertFalse(is_true_value("y"))
     self.assertFalse(is_true_value("n"))
     self.assertFalse(is_true_value("t"))
     self.assertFalse(is_true_value("f"))
Ejemplo n.º 4
0
def allows_multi_entitlement(pool):
    """
    Determine if this pool allows multi-entitlement based on the pool's
    top-level product's multi-entitlement attribute.
    """
    for attribute in pool['productAttributes']:
        if attribute['name'] == "multi-entitlement" and \
            utils.is_true_value(attribute['value']):
            return True
    return False
    def is_virt_only(self):
        attributes = self.data['attributes']
        virt_only = False
        for attribute in attributes:
            name = attribute['name']
            value = attribute['value']
            if name == "virt_only":
                virt_only = is_true_value(value)
                break

        return virt_only
Ejemplo n.º 6
0
 def test_true_value(self):
     self.assertTrue(is_true_value("1"))
     self.assertTrue(is_true_value("True"))
     self.assertTrue(is_true_value("true"))
     self.assertTrue(is_true_value("truE"))
     self.assertTrue(is_true_value("yes"))
     self.assertTrue(is_true_value("YeS"))
Ejemplo n.º 7
0
    def find_disabled_repos(self):
        """Find repos disabled in redhat.repo"""
        repo_file = repolib.YumRepoFile()
        repo_file.read()

        disabled_in_redhat_repo = []
        for section in repo_file.sections():
            repo = repo_file.section(section)

            if not utils.is_true_value(repo.get('enabled', '0')):
                disabled_in_redhat_repo.append(repo.id)

        return disabled_in_redhat_repo
Ejemplo n.º 8
0
    def find_temp_disabled_repos(self, enabled):
        """Find repo from redhat.repo that have been disabled from cli."""
        yum_enabled = [x[1] for x in enabled]

        # Read the redhat.repo file so we can check if any of our
        # repos have been disabled by --disablerepo or another plugin.
        repo_file = repolib.YumRepoFile()
        repo_file.read()

        enabled_in_redhat_repo = []
        for section in repo_file.sections():
            repo = repo_file.section(section)

            if utils.is_true_value(repo.get('enabled', '0')):
                enabled_in_redhat_repo.append(repo.id)

        temp_disabled = []
        for enabled_repo in enabled_in_redhat_repo:
            if enabled_repo not in yum_enabled:
                temp_disabled.append(enabled_repo)

        return temp_disabled
 def management_enabled(self):
     return is_true_value(self._get_attribute_value('productAttributes', 'management_enabled'))