Example #1
0
    def use_token(self):
        # Fetch token
        tokens_obj = rhnFlags.get("registration_token")
        if not tokens_obj:
            # No token present
            return 0

        is_rereg_token = tokens_obj.is_rereg_token

        # We get back a history of what is being done in the
        # registration process
        history = server_token.process_token(self.server, self.archname,
                                             tokens_obj, self.virt_type)

        if is_rereg_token:
            event_name = "Reactivation via Token"
            event_text = "System reactivated"
        else:
            event_name = "Subscription via Token"
            event_text = "System created"

        token_name = tokens_obj.get_names()
        # now record that history nicely
        self.add_history(event_name,
                         "%s with token <strong>%s</strong><br />\n%s" %
                         (event_text, token_name, history))
        self.save_history_byid(self.server["id"])

        # 6/23/05 wregglej 157262, use get_kickstart session_id() to see if we're in the middle of a kickstart.
        ks_id = tokens_obj.get_kickstart_session_id()

        # 4/5/05 wregglej, Added for bugzilla: 149932. Actions need to be flushed on reregistration.
        # 6/23/05 wregglej 157262, don't call flush_actions() if we're in the middle of a kickstart.
        #   It would cause all of the remaining kickstart actions to get flushed, which is bad.
        if is_rereg_token and ks_id is None:
            self.flush_actions()

        # XXX: will need to call self.save() later to commit all that
        return 0
Example #2
0
    def use_token(self):
        # Fetch token
        tokens_obj = rhnFlags.get("registration_token")
        if not tokens_obj:
            # No token present
            return 0

        is_rereg_token = tokens_obj.is_rereg_token

        # We get back a history of what is being done in the
        # registration process
        history = server_token.process_token(self.server, self.archname,
                                             tokens_obj, self.virt_type)

        if is_rereg_token:
            event_name = "Reactivation via Token"
            event_text = "System reactivated"
        else:
            event_name = "Subscription via Token"
            event_text = "System created"

        token_name = tokens_obj.get_names()
        # now record that history nicely
        self.add_history(event_name,
                         "%s with token <strong>%s</strong><br />\n%s" %
                         (event_text, token_name, history))
        self.save_history_byid(self.server["id"])

        # 6/23/05 wregglej 157262, use get_kickstart session_id() to see if we're in the middle of a kickstart.
        ks_id = tokens_obj.get_kickstart_session_id()

        # 4/5/05 wregglej, Added for bugzilla: 149932. Actions need to be flushed on reregistration.
        # 6/23/05 wregglej 157262, don't call flush_actions() if we're in the middle of a kickstart.
        #   It would cause all of the remaining kickstart actions to get flushed, which is bad.
        if is_rereg_token and ks_id is None:
            self.flush_actions()

        # XXX: will need to call self.save() later to commit all that
        return 0