Пример #1
0
    def __init__(self, name=None, number=None, sku=None, subscription=None,
            quantity=None, virt_limit=None, socket_limit=None,
            contract=None, quantity_used=None, warning_period=None,
            account=None, provides_management=None, service_level=None,
            service_type=None, stacking_id=None, virt_only=None):

        self.name = name
        self.number = number  # order number
        self.sku = sku  # aka the marketing product

        self.subscription = subscription  # seems to be unused

        # total quantity on the order:
        self.quantity = safe_int(quantity, None)  # rarely used

        # actual quantity used by this entitlement:
        self.quantity_used = safe_int(quantity_used, 1)

        self.virt_limit = virt_limit  # unused

        self.stacking_id = stacking_id

        self.socket_limit = safe_int(socket_limit, None)
        self.warning_period = safe_int(warning_period, 0)

        self.contract = contract
        self.account = account

        self.provides_management = provides_management or False

        self.service_level = service_level
        self.service_type = service_type

        self.virt_only = virt_only or False
Пример #2
0
    def stack_id_valid(self, stack_id, ent_certs, on_date=None):
        """
        Returns True if the given stack ID is valid.

        Assumes that the certificate is valid on the date we're sorting for.
        Future and expired certs are filtered out before this is called.
        """
        sockets_covered = 0
        log.debug("Checking stack validity: %s" % stack_id)

        date_to_check = on_date or self.on_date

        for ent in ent_certs:
            if ent.order.stacking_id == stack_id and \
              ent.valid_range.begin() <= date_to_check and \
              ent.valid_range.end() >= date_to_check:
                quantity = safe_int(ent.order.quantity_used, 1)
                sockets = safe_int(ent.order.socket_limit, 1)
                sockets_covered += sockets * quantity

        log.debug("  system has %s sockets, %s covered by entitlements" %
                  (self.socket_count, sockets_covered))
        if sockets_covered >= self.socket_count or sockets_covered == 0:
            return True
        return False
Пример #3
0
    def stack_id_valid(self, stack_id, ent_certs, on_date=None):
        """
        Returns True if the given stack ID is valid.

        Assumes that the certificate is valid on the date we're sorting for.
        Future and expired certs are filtered out before this is called.
        """
        sockets_covered = 0
        log.debug("Checking stack validity: %s" % stack_id)

        date_to_check = on_date or self.on_date

        for ent in ent_certs:
            if ent.getOrder().getStackingId() == stack_id and \
              ent.validRange().begin() <= date_to_check and \
              ent.validRange().end() >= date_to_check:
                quantity = safe_int(ent.getOrder().getQuantityUsed(), 1)
                sockets = safe_int(ent.getOrder().getSocketLimit(), 1)
                sockets_covered += sockets * quantity

        log.debug("  system has %s sockets, %s covered by entitlements" %
                (self.socket_count, sockets_covered))
        if sockets_covered >= self.socket_count or sockets_covered == 0:
            return True
        return False
Пример #4
0
    def compare_text(str1, str2):
        # Ensure our text fields are compared properly
        # 'Unlimited' is greater than all except 'Unlimited'
        # All other strings will be converted to an int or None

        if str1 == 'Unlimited':
            if str2 == 'Unlimited':
                return 0
            return 1
        elif str2 == 'Unlimited':
            return -1
        int1 = safe_int(str1)
        int2 = safe_int(str2)
        return cmp(int1, int2)
Пример #5
0
    def compare_text(str1, str2):
        # Ensure our text fields are compared properly
        # 'Unlimited' is greater than all except 'Unlimited'
        # Strings will be converted to an int if possible

        if str1 == 'Unlimited':
            if str2 == 'Unlimited':
                return 0
            return 1
        elif str2 == 'Unlimited':
            return -1
        value1 = safe_int(str1, str1)
        value2 = safe_int(str2, str2)
        return cmp(value1, value2)
Пример #6
0
    def compare_text(str1, str2):
        # Ensure our text fields are compared properly
        # 'Unlimited' is greater than all except 'Unlimited'
        # Strings will be converted to an int if possible

        if str1 == 'Unlimited':
            if str2 == 'Unlimited':
                return 0
            return 1
        elif str2 == 'Unlimited':
            return -1
        value1 = safe_int(str1, str1)
        value2 = safe_int(str2, str2)
        return cmp(value1, value2)
Пример #7
0
    def compare_text(str1, str2):
        # Ensure our text fields are compared properly
        # 'Unlimited' is greater than all except 'Unlimited'
        # All other strings will be converted to an int or None

        if str1 == 'Unlimited':
            if str2 == 'Unlimited':
                return 0
            return 1
        elif str2 == 'Unlimited':
            return -1
        int1 = safe_int(str1)
        int2 = safe_int(str2)
        return cmp(int1, int2)
Пример #8
0
    def __init__(
        self,
        name=None,
        number=None,
        sku=None,
        subscription=None,
        quantity=None,
        virt_limit=None,
        socket_limit=None,
        contract=None,
        quantity_used=None,
        warning_period=None,
        account=None,
        provides_management=None,
        service_level=None,
        service_type=None,
        stacking_id=None,
        virt_only=None,
        ram_limit=None,
        core_limit=None,
        roles=None,
        usage=None,
        addons=None,
    ):

        self.name = name
        self.number = number  # order number
        self.sku = sku  # aka the marketing product

        self.subscription = subscription  # seems to be unused

        # total quantity on the order:
        self.quantity = safe_int(quantity, None)  # rarely used

        # actual quantity used by this entitlement:
        self.quantity_used = safe_int(quantity_used, 1)

        self.virt_limit = virt_limit  # unused

        self.stacking_id = stacking_id

        self.socket_limit = safe_int(socket_limit, None)
        self.warning_period = safe_int(warning_period, 0)

        self.contract = contract
        self.account = account

        self.provides_management = provides_management or False

        self.service_level = service_level
        self.service_type = service_type
        self.usage = usage
        self.roles = roles
        self.addons = addons

        self.virt_only = virt_only or False

        self.ram_limit = safe_int(ram_limit, None)
        self.core_limit = safe_int(core_limit, None)
Пример #9
0
 def build_uep(self, options):
     return connection.UEPConnection(
         username=options.get('username', None),
         password=options.get('password', None),
         host=options.get('host', None),
         ssl_port=connection.safe_int(options.get('port', None)),
         handler=options.get('handler', None),
         insecure=options.get('insecure', None),
         proxy_hostname=options.get('proxy_hostname', None),
         proxy_port=options.get('proxy_port', None),
         proxy_user=options.get('proxy_user', None),
         proxy_password=options.get('proxy_password', None),
         restlib_class=connection.BaseRestLib
     )
Пример #10
0
    def ent_cert_sockets_valid(self, ent, on_date=None):
        """
        Returns True if the given entitlement covers enough sockets for this
        system.

        If the entitlement has no socket restriction, True will always be
        returned.
        """
        if ent.order.socket_limit is None:
            return True

        # We do not check quantity here, as this is not a stacked
        # subscription:
        sockets_covered = safe_int(ent.order.socket_limit, 1)

        log.debug("  system has %s sockets, %s covered by entitlement" % (self.socket_count, sockets_covered))
        if sockets_covered >= self.socket_count or sockets_covered == 0:
            return True
        return False
Пример #11
0
    def ent_cert_sockets_valid(self, ent, on_date=None):
        """
        Returns True if the given entitlement covers enough sockets for this
        system.

        If the entitlement has no socket restriction, True will always be
        returned.
        """
        if ent.order.socket_limit is None:
            return True

        # We do not check quantity here, as this is not a stacked
        # subscription:
        sockets_covered = safe_int(ent.order.socket_limit, 1)

        log.debug("  system has %s sockets, %s covered by entitlement" %
                  (self.socket_count, sockets_covered))
        if sockets_covered >= self.socket_count or sockets_covered == 0:
            return True
        return False
Пример #12
0
    def __init__(self, product_dir, entitlement_dir, facts_dict, on_date=None):
        self.product_dir = product_dir
        self.entitlement_dir = entitlement_dir
        if not on_date:
            on_date = datetime.now(GMT())
        self.on_date = on_date

        self.expired_entitlement_certs = []
        self.valid_entitlement_certs = []

        # All products installed on this machine, regardless of status. Maps
        # installed product ID to product certificate.
        self.installed_products = {}

        # Installed products which do not have an entitlement that is valid,
        # or expired. They may however have entitlements for the future.
        # Maps installed product ID to the product certificate.
        self.unentitled_products = {}

        # Products which are installed, there are entitlements, but they have
        # expired on the date in question. If another valid or partially valid
        # entitlement provides the installed product, that product should not
        # appear in this dict.
        # Maps product ID to the expired entitlement certificate:
        self.expired_products = {}

        # Products that are only partially entitled (aka, "yellow"). If another
        # non-stacked entitlement is valid and provides the installed product,
        # it will not appear in this dict.
        # Maps installed product ID to the stacked entitlement certificates
        # providing it.
        self.partially_valid_products = {}

        # Products which are installed, and entitled on the given date.
        # Maps product ID to a list of all valid entitlement certificates:
        self.valid_products = {}

        # Products which are installed and entitled sometime in the future.
        # Maps product ID to future entitlements.
        self.future_products = {}

        # Maps stack ID to a list of the entitlement certs composing a
        # partially valid stack:
        self.partial_stacks = {}

        # Maps stack ID to a list of the entitlement certs composing a
        # valid stack:
        self.valid_stacks = {}

        self.facts_dict = facts_dict

        # Number of sockets on this system:
        self.socket_count = 1
        if SOCKET_FACT in self.facts_dict:
            self.socket_count = safe_int(self.facts_dict[SOCKET_FACT], 1)
        else:
            log.warn("System has no socket fact, assuming 1.")

        log.debug("Sorting product and entitlement cert status for: %s" %
                  on_date)

        self._populate_installed_products()
        self._scan_entitlement_certs()
        self._scan_for_unentitled_products()

        log.debug("valid entitled products: %s" % self.valid_products.keys())
        log.debug("expired entitled products: %s" %
                  self.expired_products.keys())
        log.debug("partially entitled products: %s" %
                  self.partially_valid_products.keys())
        log.debug("unentitled products: %s" % self.unentitled_products.keys())
        log.debug("future products: %s" % self.future_products.keys())
        log.debug("partial stacks: %s" % self.partial_stacks.keys())
        log.debug("valid stacks: %s" % self.valid_stacks.keys())
Пример #13
0
    def __init__(self, product_dir, entitlement_dir, facts_dict, on_date=None):
        self.product_dir = product_dir
        self.entitlement_dir = entitlement_dir
        if not on_date:
            on_date = datetime.now(GMT())
        self.on_date = on_date

        self.expired_entitlement_certs = []
        self.valid_entitlement_certs = []

        # All products installed on this machine, regardless of status. Maps
        # installed product ID to product certificate.
        self.installed_products = {}

        # Installed products which do not have an entitlement that is valid,
        # or expired. They may however have entitlements for the future.
        # Maps installed product ID to the product certificate.
        self.unentitled_products = {}

        # Products which are installed, there are entitlements, but they have
        # expired on the date in question. If another valid or partially valid
        # entitlement provides the installed product, that product should not
        # appear in this dict.
        # Maps product ID to the expired entitlement certificate:
        self.expired_products = {}

        # Products that are only partially entitled (aka, "yellow"). If another
        # non-stacked entitlement is valid and provides the installed product,
        # it will not appear in this dict.
        # Maps installed product ID to the stacked entitlement certificates
        # providing it.
        self.partially_valid_products = {}

        # Products which are installed, and entitled on the given date.
        # Maps product ID to a list of all valid entitlement certificates:
        self.valid_products = {}

        # Products which are installed and entitled sometime in the future.
        # Maps product ID to future entitlements.
        self.future_products = {}

        # Maps stack ID to a list of the entitlement certs composing a
        # partially valid stack:
        self.partial_stacks = {}

        # Maps stack ID to a list of the entitlement certs composing a
        # valid stack:
        self.valid_stacks = {}

        self.facts_dict = facts_dict

        # Number of sockets on this system:
        self.socket_count = 1
        if SOCKET_FACT in self.facts_dict:
            self.socket_count = safe_int(self.facts_dict[SOCKET_FACT], 1)
        else:
            log.warn("System has no socket fact, assuming 1.")

        log.debug("Sorting product and entitlement cert status for: %s" %
                on_date)

        self._populate_installed_products()
        self._scan_entitlement_certs()
        self._scan_for_unentitled_products()

        log.debug("valid entitled products: %s" % self.valid_products.keys())
        log.debug("expired entitled products: %s" % self.expired_products.keys())
        log.debug("partially entitled products: %s" % self.partially_valid_products.keys())
        log.debug("unentitled products: %s" % self.unentitled_products.keys())
        log.debug("future products: %s" % self.future_products.keys())
        log.debug("partial stacks: %s" % self.partial_stacks.keys())
        log.debug("valid stacks: %s" % self.valid_stacks.keys())