Ejemplo n.º 1
0
    def install_missing_product_packages(self):
        '''
        Find missing products and schedule an action to install them
        '''
        h = rhnSQL.prepare(self._query_product_packages)
        package_names = {}
        h.execute(server_id=self.server['id'])
        while True:
            row = h.fetchone_dict()
            if not row:
                break
            pn_id = row['name_id']
            pa_id = row['arch_id']
            package_names[(pn_id, pa_id)] = row['name']

        if not package_names:
            return None

        package_arch_ids = list(package_names.keys())

        action_id = rhnAction.schedule_server_packages_update_by_arch(
            self.server['id'],
            package_arch_ids,
            org_id=self.server['org_id'],
            action_name="Product Package Auto-Install")
        for p in list(package_names.values()):
            log_debug(1, "Scheduled for install:  '%s'" % p)

        rhnSQL.commit()

        return action_id
Ejemplo n.º 2
0
    def install_missing_product_packages(self):
        '''
        Find missing products and schedule an action to install them
        '''
        h = rhnSQL.prepare(self._query_product_packages)
        package_names = {}
        h.execute(server_id=self.server['id'])
        while True:
            row = h.fetchone_dict()
            if not row:
                break
            pn_id = row['name_id']
            pa_id = row['arch_id']
            package_names[(pn_id, pa_id)] = row['name']

        if not package_names:
            return None

        package_arch_ids = package_names.keys()

        action_id = rhnAction.schedule_server_packages_update_by_arch(self.server['id'],
                                                                      package_arch_ids,
                                                                      org_id=self.server['org_id'],
                                                                      action_name="Product Package Auto-Install")
        for p in package_names.values():
            log_debug(1, "Scheduled for install:  '%s'" % p)

        rhnSQL.commit()

        return action_id
Ejemplo n.º 3
0
def token_packages(server_id, tokens_obj):
    assert (isinstance(tokens_obj, ActivationTokens))

    h = rhnSQL.prepare(_query_token_packages)
    package_names = {}
    for token in tokens_obj.tokens:
        token_id = token['token_id']
        h.execute(token_id=token_id)
        while True:
            row = h.fetchone_dict()
            if not row:
                break
            pn_id = row['name_id']
            pa_id = row['arch_id']
            package_names[(pn_id, pa_id)] = row['name']

    ret = []
    if not package_names:
        return ret

    package_arch_ids = list(package_names.keys())
    # Get the latest action scheduled for this token
    last_action_id = rhnFlags.get('token_last_action_id')

    action_id = rhnAction.schedule_server_packages_update_by_arch(
        server_id,
        package_arch_ids,
        org_id=token['org_id'],
        prerequisite=last_action_id,
        action_name="Activation Key Package Auto-Install")

    # This action becomes the latest now
    rhnFlags.set('token_last_action_id', action_id)

    for p in package_names.values():
        ret.append("Scheduled for install:  '%s'" % p)

    rhnSQL.commit()

    return ret
Ejemplo n.º 4
0
def token_packages(server_id, tokens_obj):
    assert(isinstance(tokens_obj, ActivationTokens))

    h = rhnSQL.prepare(_query_token_packages)
    package_names = {}
    for token in tokens_obj.tokens:
        token_id = token['token_id']
        h.execute(token_id=token_id)
        while True:
            row = h.fetchone_dict()
            if not row:
                break
            pn_id = row['name_id']
            pa_id = row['arch_id']
            package_names[(pn_id, pa_id)] = row['name']

    ret = []
    if not package_names:
        return ret

    package_arch_ids = package_names.keys()
    # Get the latest action scheduled for this token
    last_action_id = rhnFlags.get('token_last_action_id')

    action_id = rhnAction.schedule_server_packages_update_by_arch(server_id,
                                                                  package_arch_ids, org_id=token['org_id'],
                                                                  prerequisite=last_action_id,
                                                                  action_name="Activation Key Package Auto-Install")

    # This action becomes the latest now
    rhnFlags.set('token_last_action_id', action_id)

    for p in package_names.values():
        ret.append("Scheduled for install:  '%s'" % p)

    rhnSQL.commit()

    return ret