예제 #1
0
    def _init_sla(self):
        if self.skip_auto_subscribe():
            return self._move_to_manual_install(_("You have opted to skip auto-subscribe."))

        # sla autosubscribe time. load up the possible slas, to decide if
        # we need to display the selection screen, or go to the confirm
        # screen.
        # XXX this should really be done async.

        controller = autobind.init_controller(self.backend, self.consumer,
                Facts())

        # XXX see autobind.AutobindWizard load() and _show_initial_screen
        # for matching error handling.
        try:
            controller.load()
        except autobind.ServiceLevelNotSupportedException:
            message = _("Unable to auto-subscribe, server does not support service levels. Please run 'Subscription Manager' to manually subscribe.")
            return self._move_to_manual_install(message)

        except autobind.NoProductsException:
            message = _("No installed products on system. No need to update certificates at this time.")
            return self._move_to_manual_install(message)

        except autobind.AllProductsCoveredException:
            message = _("All installed products are covered by valid entitlements. Please run 'Subscription Manager' to subscribe to additional products.")
            return self._move_to_manual_install(message)

        except socket.error, e:
            handle_gui_exception(e, None, self.registerWin)
            return
예제 #2
0
    def _on_get_environment_list_cb(self, result_tuple, error=None):
        environments = result_tuple
        if error != None:
            handle_gui_exception(error, REGISTER_ERROR, self.registerWin)
            self._finish_registration(failed=True)
            return

        if not environments:
            self._run_register_step(self.owner_key, None)
            return

        envs = [(env['id'], env['name']) for env in environments]
        if len(envs) == 1:
            self._run_register_step(self.owner_key, envs[0][0])
        else:
            environment_model = gtk.ListStore(str, str)
            for env in envs:
                environment_model.append(env)

            self.environment_treeview.set_model(environment_model)

            self.environment_treeview.get_selection().select_iter(
                    environment_model.get_iter_first())

            self.cancel_button.set_sensitive(True)
            self.register_button.set_sensitive(True)
            self.register_notebook.set_page(ENVIRONMENT_SELECT_PAGE)
예제 #3
0
    def apply(self, interface, testing=False):
        """
        'Next' button has been clicked - try to register with the
        provided user credentials and return the appropriate result
        value.
        """

        # on el5 we can't just move to another page, we have to set the next
        # page then do an apply. since we've already done our work async, skip
        # this time through
        if self._skip_apply_for_page_jump:
            self._skip_apply_for_page_jump = False
            # Reset back to first screen in our module in case the user hits back.
            # The firstboot register screen subclass will handle unregistering
            # if necessary when it runs again.
            self.show()
            return self._RESULT_SUCCESS

        self.interface = interface

        self._read_rhn_proxy_settings()

        # bad proxy settings can cause socket.error or friends here
        # see bz #810363
        try:
            valid_registration = self.register()
        except socket.error, e:
            handle_gui_exception(e, e, self.window)
            return self._RESULT_FAILURE
예제 #4
0
    def apply(self, interface, testing=False):
        """
        'Next' button has been clicked - try to register with the
        provided user credentials and return the appropriate result
        value.
        """

        # on el5 we can't just move to another page, we have to set the next
        # page then do an apply. since we've already done our work async, skip
        # this time through
        if self._skip_apply_for_page_jump:
            self._skip_apply_for_page_jump = False
            return self._RESULT_SUCCESS

        self.interface = interface

        self._read_rhn_proxy_settings()

        credentials = self._get_credentials_hash()

        # bad proxy settings can cause socket.error or friends here
        # see bz #810363
        try:
            valid_registration = self.register(testing=testing)
        except socket.error, e:
            handle_gui_exception(e, e, self.registerWin)
            return self._RESULT_FAILURE
    def _on_refresh_cb(self, error=None):
        if error is not None:
            handle_gui_exception(error, _("Error subscribing: %s"), self._parent.parent)
            self._parent.finish_registration(failed=True)
            return

        self._parent.pre_done(FINISH)
예제 #6
0
    def search_button_clicked(self, widget=None):
        """
        Reload the subscriptions from the server when the Search button
        is clicked.
        """
        if not self.date_picker.date_entry_validate():
            return
        try:
            pb_title = _("Searching")
            pb_label = _("Searching for subscriptions. Please wait.")
            if self.pb:
                self.pb.set_title(pb_title)
                self.pb.set_label(pb_label)
            else:
                # show pulsating progress bar while we wait for results
                self.pb = progress.Progress(pb_title, pb_label)
                self.timer = ga_GObject.timeout_add(100, self.pb.pulse)
                self.pb.set_transient_for(self.parent_win)

            # fire off async refresh
            async_stash = async_utils.AsyncPool(self.pool_stash)
            async_stash.refresh(self.date_picker.date, self._update_display)
        except Exception as e:
            handle_gui_exception(e, _("Error fetching subscriptions from server:  %s"),
                    self.parent_win)
예제 #7
0
 def _repos_item_clicked(self, widget):
     try:
         self.repos_dialog.show()
     except Exception as e:
         handle_gui_exception(e, _("Error in repos dialog. "
                                   "Please see /var/log/rhsm/rhsm.log for more information."),
                              self._get_window())
예제 #8
0
    def _on_get_owner_list_cb(self, owners, error=None):
        if error != None:
            handle_gui_exception(error, REGISTER_ERROR,
                    self.registerWin)
            self._finish_registration(failed=True)
            return

        owners = [(owner['key'], owner['displayName']) for owner in owners]

        if len(owners) == 0:
            handle_gui_exception(None,
                    _("<b>User %s is not able to register with any orgs.</b>") \
                            % (self.uname.get_text().strip()),
                    self.registerWin)
            self._finish_registration(failed=True)
            return

        if len(owners) == 1:
            self.owner_key = owners[0][0]
            self.async.get_environment_list(self.owner_key, self._on_get_environment_list_cb)

        else:
            owner_model = gtk.ListStore(str, str)
            for owner in owners:
                owner_model.append(owner)

            self.owner_treeview.set_model(owner_model)

            self.owner_treeview.get_selection().select_iter(
                    owner_model.get_iter_first())

            self.cancel_button.set_sensitive(True)
            self.register_button.set_sensitive(True)
            self.register_notebook.set_page(OWNER_SELECT_PAGE)
예제 #9
0
    def _on_registration_finished_cb(self, new_account, error=None):
        if error is not None:
            handle_gui_exception(error, registergui.REGISTER_ERROR,
                    self._parent.window)
            self._parent.finish_registration(failed=True)
            return

        try:
            managerlib.persist_consumer_cert(new_account)
            self._parent.backend.cs.force_cert_check()  # Ensure there isn't much wait time

            if self._parent.activation_keys:
                self._parent.pre_done(registergui.REFRESH_SUBSCRIPTIONS_PAGE)
            elif self._parent.skip_auto_bind:
                message = _("You have opted to skip auto-attach.")
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            else:
                self._parent.pre_done(registergui.SELECT_SLA_PAGE)

        # If we get errors related to consumer name on register,
        # go back to the credentials screen where we set the
        # consumer name. See bz#865954
        except RestlibException, e:
            handle_gui_exception(e, registergui.REGISTER_ERROR,
                self._parent.window)
            if e.code == 404 and self._parent.activation_keys:
                self._parent.pre_done(registergui.ACTIVATION_KEY_PAGE)
            if e.code == 400:
                self._parent.pre_done(registergui.CREDENTIALS_PAGE)
예제 #10
0
    def _on_get_owner_list_cb(self, owners, error=None):
        if error is not None:
            handle_gui_exception(error, REGISTER_ERROR,
                    self._parent.window)
            self._parent.pre_done(CREDENTIALS_PAGE)
            return

        owners = [(owner['key'], owner['displayName']) for owner in owners]
        # Sort by display name so the list doesn't randomly change.
        owners = sorted(owners, key=lambda item: item[1])

        if len(owners) == 0:
            handle_gui_exception(None,
                                 _("<b>User %s is not able to register with any orgs.</b>") %
                                   (self._parent.username),
                    self._parent.parent)
            self._parent.finish_registration(failed=True)
            return

        if len(owners) == 1:
            self._owner_key = owners[0][0]
            self._parent.pre_done(ENVIRONMENT_SELECT_PAGE)
        else:
            self.set_model(owners)
            self._parent.pre_done(DONT_CHANGE)
    def _on_subscribing_finished_cb(self, unused, error=None):
        if error is not None:
            handle_gui_exception(error, _("Error subscribing: %s"), self._parent.parent)
            self._parent.finish_registration(failed=True)
            return

        self._parent.pre_done(FINISH)
        self._parent.backend.cs.force_cert_check()
예제 #12
0
 def update(self, widget_update, backend_method, args=[], kwargs={}, exception_msg=None, callback=None):
     try:
         result = backend_method(*args, **kwargs)
         if callback:
             callback(result)
     except Exception, e:
         message = exception_msg or str(e)
         handle_gui_exception(e, message, self.parent_window)
예제 #13
0
 def _update_certificates_button_clicked(self, widget):
     # Catch exceptions in the autobind wizard initialization (only)
     try:
         autobind_wizard = AutobindWizard(self.backend, self.consumer, self.facts,
                 self._get_window())
         autobind_wizard.show()
     except Exception, e:
         handle_gui_exception(e, _("Error in autobind wizard"), self._get_window())
예제 #14
0
    def _update_display(self, data, error):
        self._clear_progress_bar()

        if error:
            handle_gui_exception(error, _("Unable to search for subscriptions:  %s"),
                    self.parent_win)
        else:
            self.display_pools()
예제 #15
0
 def _preferences_item_clicked(self, widget):
     try:
         self.preferences_dialog.show()
     except Exception, e:
         handle_gui_exception(
             e,
             _("Error in preferences dialog." "Please see /var/log/rhsm/rhsm.log for more information."),
             self._get_window(),
         )
예제 #16
0
 def _handle_unbind_exception(self, e, selection):
     self._clear_progress_bar()
     handle_gui_exception(
         e,
         _("There was an error removing %s with serial number %s")
         % (selection["subscription"], selection["serial"]),
         self.parent_win,
         format_msg=False,
     )
예제 #17
0
    def update_facts(self):
        """Sends the current system facts to the UEP server."""
        consumer_uuid = self.consumer.uuid

        try:
            self.facts.update_check(self.backend.uep, consumer_uuid, force=True)
        except Exception, e:
            log.error("Could not update system facts \nError: %s" % e)
            handle_gui_exception(e, linkify(str(e)), self.system_facts_dialog)
예제 #18
0
    def _on_subscribing_finished_cb(self, unused, error=None):
        try:
            if error != None:
                raise error
            self._parent.pre_done(FINISH)

        except Exception, e:
            handle_gui_exception(e, _("Error subscribing: %s"),
                                 self._parent.window)
            self._parent.finish_registration(failed=True)
예제 #19
0
    def update_facts(self):
        """Sends the current system facts to the UEP server."""

        identity = inj.require(inj.IDENTITY)

        try:
            self.facts.update_check(self.cp_provider.get_consumer_auth_cp(), identity.uuid, force=True)
        except Exception, e:
            log.error("Could not update system facts \nError: %s" % e)
            handle_gui_exception(e, linkify(str(e)), self.system_facts_dialog)
예제 #20
0
    def _redeem(self, button):
        email = self.email_entry.get_text()

        # TODO:  Validate email address?
        try:
            self.backend.cp_provider.get_consumer_auth_cp().activateMachine(self.identity.uuid, email)
            self.hide()
        except Exception as e:
            handle_gui_exception(e,
                _("Error redeeming subscription: %s"),
                self.redeem_dialog)
예제 #21
0
    def update_facts(self):
        """Sends the current system facts to the UEP server."""
        consumer_uuid = self.consumer.uuid

        try:
            self.facts.update_check(self.backend.uep,
                                    consumer_uuid,
                                    force=True)
        except Exception, e:
            log.error("Could not update system facts \nError: %s" % e)
            handle_gui_exception(e, linkify(str(e)), self.system_facts_dialog)
예제 #22
0
    def _redeem(self, button):
        email = self.email_entry.get_text()

        # TODO:  Validate email address?
        try:
            self.backend.cp_provider.get_consumer_auth_cp().activateMachine(
                self.identity.uuid, email)
            self.hide()
        except Exception, e:
            handle_gui_exception(e, _("Error redeeming subscription: %s"),
                                 self.redeem_dialog)
예제 #23
0
 def _perform_unregister(self):
     try:
         managerlib.unregister(self.backend.cp_provider.get_consumer_auth_cp(), self.identity.uuid)
     except Exception, e:
         log.error("Error unregistering system with entitlement platform.")
         handle_gui_exception(e, _("<b>Errors were encountered during unregister.</b>") +
                                   "\n%s\n" +
                                   _("Please see /var/log/rhsm/rhsm.log for more information."),
                             self.main_window,
                             log_msg="Consumer may need to be manually cleaned up: %s" %
                             self.identity.uuid)
예제 #24
0
    def _redeem(self, button):
        email = self.email_entry.get_text()

        # TODO:  Validate email address?
        try:
            self.backend.uep.activateMachine(self.consumer.uuid, email)
            self.hide()
        except Exception, e:
            handle_gui_exception(e,
                _("Error redeeming subscription: %s"),
                self.redeem_dialog)
예제 #25
0
 def _perform_unregister(self):
     try:
         managerlib.unregister(self.backend.cp_provider.get_consumer_auth_cp(), self.identity.uuid)
     except Exception, e:
         log.error("Error unregistering system with entitlement platform.")
         handle_gui_exception(e, _("<b>Errors were encountered during unregister.</b>") +
                                   "\n%s\n" +
                                   _("Please see /var/log/rhsm/rhsm.log for more information."),
                             self.main_window,
                             log_msg="Consumer may need to be manually cleaned up: %s" %
                             self.identity.uuid)
예제 #26
0
    def update_facts(self):
        """Sends the current system facts to the UEP server."""

        identity = inj.require(inj.IDENTITY)

        try:
            self.facts.update_check(self.cp_provider.get_consumer_auth_cp(),
                                    identity.uuid,
                                    force=True)
        except Exception, e:
            log.error("Could not update system facts \nError: %s" % e)
            handle_gui_exception(e, linkify(str(e)), self.system_facts_dialog)
예제 #27
0
    def _on_registration_finished_cb(self, new_account, error=None):
        try:
            if error != None:
                raise error

            managerlib.persist_consumer_cert(new_account)
            self.consumer.reload()
            self._finish_registration()

        except Exception, e:
            handle_gui_exception(e, REGISTER_ERROR, self.registerWin)
            self._finish_registration(failed=True)
예제 #28
0
    def _on_registration_finished_cb(self, new_account, error=None):
        try:
            if error != None:
                raise error

            managerlib.persist_consumer_cert(new_account)
            self.consumer.reload()
            self._finish_registration()

        except Exception, e:
            handle_gui_exception(e, REGISTER_ERROR, self.registerWin)
            self._finish_registration(failed=True)
예제 #29
0
 def pre(self):
     # Because the RHN client tools check if certs exist and bypass our
     # firstboot module if so, we know that if we reach this point and
     # identity certs exist, someone must have hit the back button.
     # TODO: i'd like this call to be inside the async progress stuff,
     # since it does take some time
     if ConsumerIdentity.exists():
         try:
             managerlib.unregister(self._parent.backend.cp_provider.get_consumer_auth_cp(),
                     self._parent.identity.uuid)
         except socket.error, e:
             handle_gui_exception(e, e, self._parent.window)
         self._parent._registration_finished = False
예제 #30
0
    def _on_get_service_levels_cb(self, result, error=None):
        if error is not None:
            if isinstance(error[1], ServiceLevelNotSupportedException):
                message = _(
                    "Unable to auto-attach, server does not support "
                    "service levels. Please run 'Subscription Manager' "
                    "to manually attach a subscription."
                )
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            elif isinstance(error[1], NoProductsException):
                message = _("No installed products on system. No need to " "update subscriptions at this time.")
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            elif isinstance(error[1], AllProductsCoveredException):
                message = _("All installed products are fully subscribed.")
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            else:
                handle_gui_exception(error, _("Error subscribing"), self._parent.window)
                self._parent.finish_registration(failed=True)
            return

        (current_sla, unentitled_products, sla_data_map) = result

        self._parent.current_sla = current_sla
        if len(sla_data_map) == 1:
            # If system already had a service level, we can hit this point
            # when we cannot fix any unentitled products:
            if current_sla is not None and not self._can_add_more_subs(current_sla, sla_data_map):
                message = (
                    _("Unable to attach any additional subscriptions at " "current service level: %s") % current_sla
                )
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
                return

            self._dry_run_result = sla_data_map.values()[0]
            self._parent.pre_done(registergui.CONFIRM_SUBS_PAGE)
        elif len(sla_data_map) > 1:
            self._sla_data_map = sla_data_map
            self.set_model(unentitled_products, sla_data_map)
            self._parent.pre_done(registergui.DONT_CHANGE)
        else:
            message = _(
                "No service levels will cover all installed products. "
                "Please run 'Subscription Manager' to manually "
                "attach subscriptions."
            )
            self._parent.manual_message = message
            self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
예제 #31
0
    def _on_get_service_levels_cb(self, result, error=None):
        if error != None:
            if isinstance(error, ServiceLevelNotSupportedException):
                message = _(
                    "Unable to auto-subscribe, server does not support "
                    "service levels. Please run 'Subscription Manager' "
                    "to manually subscribe.")
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            elif isinstance(error, NoProductsException):
                message = _("No installed products on system. No need to "
                            "update subscriptions at this time.")
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            elif isinstance(error, AllProductsCoveredException):
                message = _("All installed products are fully subscribed.")
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            else:
                handle_gui_exception(error, _("Error subscribing"),
                                     self._parent.window)
                self._parent.finish_registration(failed=True)
            return

        (current_sla, unentitled_products, sla_data_map) = result

        self._parent.current_sla = current_sla
        if len(sla_data_map) == 1:
            # If system already had a service level, we can hit this point
            # when we cannot fix any unentitled products:
            if current_sla is not None and \
                    not self._can_add_more_subs(current_sla, sla_data_map):
                message = _(
                    "Unable to subscribe to any additional products at "
                    "current service level: %s") % current_sla
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
                return

            self._dry_run_result = sla_data_map.values()[0]
            self._parent.pre_done(registergui.CONFIRM_SUBS_PAGE)
        elif len(sla_data_map) > 1:
            self._sla_data_map = sla_data_map
            self.set_model(unentitled_products, sla_data_map)
            self._parent.pre_done(registergui.DONT_CHANGE)
        else:
            message = _("No service levels will cover all installed products. "
                        "Please run 'Subscription Manager' to manually "
                        "subscribe this system.")
            self._parent.manual_message = message
            self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
예제 #32
0
 def pre(self):
     # Because the RHN client tools check if certs exist and bypass our
     # firstboot module if so, we know that if we reach this point and
     # identity certs exist, someone must have hit the back button.
     # TODO: i'd like this call to be inside the async progress stuff,
     # since it does take some time
     if ConsumerIdentity.exists():
         try:
             managerlib.unregister(
                 self._parent.backend.cp_provider.get_consumer_auth_cp(),
                 self._parent.identity.uuid)
         except socket.error, e:
             handle_gui_exception(e, e, self._parent.window)
         self._parent._registration_finished = False
예제 #33
0
 def update(self,
            widget_update,
            backend_method,
            args=[],
            kwargs={},
            exception_msg=None,
            callback=None):
     try:
         result = backend_method(*args, **kwargs)
         if callback:
             callback(result)
     except Exception, e:
         message = exception_msg or str(e)
         handle_gui_exception(e, message, self.parent_window)
예제 #34
0
    def initializeUI(self):
        # Need to make sure that each time the UI is initialized we reset back
        # to the main register screen.

        # if they've already registered during firstboot and have clicked
        # back to register again, we must first unregister.
        # XXX i'd like this call to be inside the async progress stuff,
        # since it does take some time
        if self._registration_finished and ConsumerIdentity.exists():
            try:
                managerlib.unregister(self.backend.uep, self.consumer.uuid)
            except socket.error, e:
                handle_gui_exception(e, e, self.registerWin)
            self.consumer.reload()
            self._registration_finished = False
예제 #35
0
    def _on_registration_finished_cb(self, new_account, error=None):
        try:
            if error != None:
                raise error

            managerlib.persist_consumer_cert(new_account)
            self._parent.consumer.reload()
            if self._parent.skip_auto_bind:
                self._parent.pre_done(FINISH)
            else:
                self._parent.pre_done(SELECT_SLA_PAGE)

        except Exception, e:
            handle_gui_exception(e, REGISTER_ERROR, self._parent.window)
            self._parent.finish_registration(failed=True)
예제 #36
0
    def _on_registration_finished_cb(self, new_account, error=None):
        try:
            if error != None:
                raise error

            managerlib.persist_consumer_cert(new_account)
            self._parent.consumer.reload()
            if self._parent.skip_auto_bind:
                self._parent.pre_done(FINISH)
            else:
                self._parent.pre_done(SELECT_SLA_PAGE)

        except Exception, e:
            handle_gui_exception(e, REGISTER_ERROR, self._parent.window)
            self._parent.finish_registration(failed=True)
예제 #37
0
    def initializeUI(self):
        # Need to make sure that each time the UI is initialized we reset back
        # to the main register screen.

        # if they've already registered during firstboot and have clicked
        # back to register again, we must first unregister.
        # XXX i'd like this call to be inside the async progress stuff,
        # since it does take some time
        if self._registration_finished and ConsumerIdentity.exists():
            try:
                managerlib.unregister(self.backend.uep, self.consumer.uuid)
            except socket.error, e:
                handle_gui_exception(e, e, self.registerWin)
            self.consumer.reload()
            self._registration_finished = False
예제 #38
0
    def _on_unsubscribe_prompt_response(self, dialog, response, selection):
        if not response:
            return

        serial = long(selection['serial'])

        if self.backend.is_registered():
            try:
                self.backend.uep.unbindBySerial(self.consumer.uuid, serial)
            except Exception, e:
                handle_gui_exception(e, _("There was an error unsubscribing from %s with serial number %s") % (selection['subscription'], serial), self.parent_win, formatMsg=False)

            try:
                self.backend.certlib.update()
            except Disconnected, e:
                pass
예제 #39
0
    def _on_reset_repo_response(self, dialog, response):
        if not response:
            return

        selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                     self.overrides_store)

        if not selection.is_valid():
            return

        repo_id = selection['repo_id']

        try:
            self._delete_all_overrides(repo_id)
        except Exception, e:
            handle_gui_exception(e, _("Unable to reset repository overrides."),
                                 self._get_dialog_widget())
예제 #40
0
    def _on_registration_finished_cb(self, new_account, error=None):
        try:
            if error != None:
                raise error

            managerlib.persist_consumer_cert(new_account)
            self._parent.consumer.reload()
            if self._parent.skip_auto_bind:
                message = _("You have opted to skip auto-subscribe.")
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            else:
                self._parent.pre_done(registergui.SELECT_SLA_PAGE)

        except Exception, e:
            handle_gui_exception(e, registergui.REGISTER_ERROR,
                                 self._parent.window)
            self._parent.finish_registration(failed=True)
예제 #41
0
    def _on_remove_gpgcheck_confirmation(self, dialog, response):
        if not response:
            return

        override_selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                              self.overrides_store)
        if not override_selection.is_valid():
            # TODO Should never happen, but we should update the UI somehow
            # to make sure that nothing bad can happen.
            return

        # Delete the override
        try:
            self._delete_override(override_selection['repo_id'], 'gpgcheck')
        except Exception, e:
            handle_gui_exception(e, _("Unable to delete the gpgcheck override."),
                                 self._get_dialog_widget())
            return
예제 #42
0
    def _on_gpgcheck_edit_button_clicked(self, button):
        override_selection = SelectionWrapper(self.overrides_treeview.get_selection(),
                                              self.overrides_store)
        if not override_selection.is_valid():
            # TODO Should never happen, but we should update the UI somewho
            # to make sure that nothing bad can happen.
            return

        current_value = override_selection['gpgcheck']
        self.gpgcheck_combo_box.set_active(not current_value)

        # Create an override despite the fact that the values are likely the same.
        try:
            self._add_override(override_selection['repo_id'], "gpgcheck",
                               int(current_value))
        except Exception, e:
            handle_gui_exception(e, _("Unable to update the gpgcheck override."),
                                 self._get_dialog_widget())
            return
예제 #43
0
    def _on_registration_finished_cb(self, new_account, error=None):
        if error is not None:
            handle_gui_exception(error, REGISTER_ERROR, self._parent.parent)
            self._parent.finish_registration(failed=True)
            return

        try:
            managerlib.persist_consumer_cert(new_account)
            self._parent.backend.cs.force_cert_check()  # Ensure there isn't much wait time

            if self._parent.activation_keys:
                self._parent.pre_done(REFRESH_SUBSCRIPTIONS_PAGE)
            elif self._parent.skip_auto_bind:
                self._parent.pre_done(FINISH)
            else:
                self._parent.pre_done(SELECT_SLA_PAGE)
        except Exception, e:
            handle_gui_exception(e, REGISTER_ERROR, self._parent.parent)
            self._parent.finish_registration(failed=True)
예제 #44
0
    def _on_get_environment_list_cb(self, result_tuple, error=None):
        environments = result_tuple
        if error is not None:
            handle_gui_exception(error, REGISTER_ERROR, self._parent.parent)
            self._parent.finish_registration(failed=True)
            return

        if not environments:
            self._environment = None
            self._parent.pre_done(PERFORM_REGISTER_PAGE)
            return

        envs = [(env['id'], env['name']) for env in environments]
        if len(envs) == 1:
            self._environment = envs[0][0]
            self._parent.pre_done(PERFORM_REGISTER_PAGE)
        else:
            self.set_model(envs)
            self._parent.pre_done(DONT_CHANGE)
예제 #45
0
    def _on_unsubscribe_prompt_response(self, dialog, response, selection):
        if not response:
            return

        serial = long(selection['serial'])

        if self.backend.is_registered():
            try:
                self.backend.uep.unbindBySerial(self.consumer.uuid, serial)
            except Exception, e:
                handle_gui_exception(
                    e,
                    _("There was an error unsubscribing from %s with serial number %s"
                      ) % (selection['subscription'], serial),
                    self.parent_win,
                    formatMsg=False)

            try:
                self.backend.certlib.update()
            except Disconnected, e:
                pass
예제 #46
0
    def _on_unsubscribe_prompt_response(self, dialog, response, selection):
        if not response:
            return

        serial = long(selection['serial'])

        if self.identity.is_valid():
            try:
                self.backend.cp_provider.get_consumer_auth_cp().unbindBySerial(
                    self.identity.uuid, serial)
            except Exception, e:
                handle_gui_exception(
                    e,
                    _("There was an error removing %s with serial number %s") %
                    (selection['subscription'], serial),
                    self.parent_win,
                    format_msg=False)

            try:
                self.backend.certlib.update()
            except Disconnected, e:
                pass
예제 #47
0
    def _on_get_owner_list_cb(self, owners, error=None):
        if error != None:
            handle_gui_exception(error, REGISTER_ERROR, self._parent.window)
            self._parent.pre_done(CREDENTIALS_PAGE)
            return

        owners = [(owner['key'], owner['displayName']) for owner in owners]

        if len(owners) == 0:
            handle_gui_exception(None,
                    _("<b>User %s is not able to register with any orgs.</b>") \
                            % (self._parent.username),
                    self._parent.window)
            self._parent.finish_registration(failed=True)
            return

        if len(owners) == 1:
            self._owner_key = owners[0][0]
            self._parent.pre_done(ENVIRONMENT_SELECT_PAGE)
        else:
            self.set_model(owners)
            self._parent.pre_done(DONT_CHANGE)
예제 #48
0
    def _init_sla(self):
        if self.skip_auto_subscribe():
            return self._move_to_manual_install(
                _("You have opted to skip auto-subscribe."))

        # sla autosubscribe time. load up the possible slas, to decide if
        # we need to display the selection screen, or go to the confirm
        # screen.
        # XXX this should really be done async.

        controller = autobind.init_controller(self.backend, self.consumer,
                                              Facts())

        # XXX see autobind.AutobindWizard load() and _show_initial_screen
        # for matching error handling.
        try:
            controller.load()
        except autobind.ServiceLevelNotSupportedException:
            message = _(
                "Unable to auto-subscribe, server does not support service levels. Please run 'Subscription Manager' to manually subscribe."
            )
            return self._move_to_manual_install(message)

        except autobind.NoProductsException:
            message = _(
                "No installed products on system. No need to update certificates at this time."
            )
            return self._move_to_manual_install(message)

        except autobind.AllProductsCoveredException:
            message = _(
                "All installed products are covered by valid entitlements. Please run 'Subscription Manager' to subscribe to additional products."
            )
            return self._move_to_manual_install(message)

        except socket.error, e:
            handle_gui_exception(e, None, self.registerWin)
            return
예제 #49
0
    def _perform_unregister(self):
        try:
            reset_resolver()
            unregister.UnregisterService(
                self.backend.cp_provider.get_consumer_auth_cp()).unregister()
        except Exception as e:
            log.error("Error unregistering system with entitlement platform.")
            handle_gui_exception(
                e,
                _("<b>Errors were encountered during unregister.</b>") +
                "\n%s\n" +
                _("Please see /var/log/rhsm/rhsm.log for more information."),
                self.main_window,
                log_msg="Consumer may need to be manually cleaned up: %s" %
                self.identity.uuid)
        # managerlib.unregister removes product and entitlement directories
        self.backend.product_dir.__init__()
        self.backend.entitlement_dir.__init__()

        # We have new credentials, restart virt-who
        restart_virt_who()

        self.backend.cs.force_cert_check()
예제 #50
0
    def _on_toggle_changed(self, override_model_iter, enabled, key):
        repo = self.overrides_store.get_value(override_model_iter,
                                              self.overrides_store['repo_data'])
        overrides = self.overrides_store.get_value(override_model_iter,
                                              self.overrides_store['override_data'])

        value = repo[key]
        has_active_override = overrides and key in overrides

        try:
            if not has_active_override and enabled != int(value):
                # We get True/False from the model, convert to int so that
                # the override gets the correct value.
                self._add_override(repo.id, key, int(enabled))

            elif has_active_override and overrides[key] != value:
                self._delete_override(repo.id, key)
            else:
                # Should only ever be one path here, else we have a UI logic error.
                self._add_override(repo.id, key, int(enabled))
        except Exception, e:
            handle_gui_exception(e, _("Unable to update %s override.") % key,
                                 self._get_dialog_widget())
예제 #51
0
    def _on_enable_repo_toggle(self, override_model_iter, enabled):
        repo = self.overrides_store.get_value(override_model_iter,
                                              self.overrides_store['repo_data'])
        overrides = self.overrides_store.get_value(override_model_iter,
                                              self.overrides_store['override_data'])

        repo_enabled = repo['enabled']
        has_enabled_override = overrides and 'enabled' in overrides

        try:
            if not has_enabled_override and enabled != int(repo_enabled):
                # We get True/False from the model, convert to int so that
                # the override gets the correct value.
                self._add_override(repo.id, "enabled", int(enabled))

            elif has_enabled_override and overrides['enabled'] != repo_enabled:
                self._delete_override(repo.id, 'enabled')
            else:
                # Should only ever be one path here, else we have a UI logic error.
                self._add_override(repo.id, "enabled", int(enabled))
        except Exception, e:
            handle_gui_exception(e, _("Unable to update enabled override."),
                                 self._get_dialog_widget())
예제 #52
0
    def _on_get_service_levels_cb(self, result, error=None):
        if error != None:
            if isinstance(error, ServiceLevelNotSupportedException):
                OkDialog(_(
                    "Unable to auto-subscribe, server does not support service levels."
                ),
                         parent=self._parent.window)
            elif isinstance(error, NoProductsException):
                InfoDialog(_(
                    "No installed products on system. No need to update subscriptions at this time."
                ),
                           parent=self._parent.window)
            elif isinstance(error, AllProductsCoveredException):
                InfoDialog(_(
                    "All installed products are covered by valid entitlements. No need to update subscriptions at this time."
                ),
                           parent=self._parent.window)
            else:
                handle_gui_exception(error, _("Error subscribing"),
                                     self._parent.window)
            self._parent.finish_registration(failed=True)
            return

        (current_sla, unentitled_products, sla_data_map) = result

        self._parent.current_sla = current_sla
        if len(sla_data_map) == 1:
            # If system already had a service level, we can hit this point
            # when we cannot fix any unentitled products:
            if current_sla is not None and \
                    not self._can_add_more_subs(current_sla, sla_data_map):
                handle_gui_exception(
                    None,
                    _("No available subscriptions at "
                      "the current service level: %s. "
                      "Please use the \"All Available "
                      "Subscriptions\" tab to manually "
                      "subscribe this system.") % current_sla,
                    self._parent.window)
                self._parent.finish_registration(failed=True)
                return

            self._dry_run_result = sla_data_map.values()[0]
            self._parent.pre_done(CONFIRM_SUBS_PAGE)
        elif len(sla_data_map) > 1:
            self._sla_data_map = sla_data_map
            self.set_model(unentitled_products, sla_data_map)
            self._parent.pre_done(DONT_CHANGE)
        else:
            log.info("No suitable service levels found.")
            handle_gui_exception(None,
                                 _("No service level will cover all installed "
                                   "products. Please use the \"All Available "
                                   "Subscriptions\" tab to manually subscribe "
                                   "this system."),
                                 parent=self._parent.window)
            self._parent.finish_registration(failed=True)
예제 #53
0
    def _on_get_service_levels_cb(self, result, error=None):
        # The parent for the dialogs is set to the grandparent window
        # (which is MainWindow) because the parent window is closed
        # by finish_registration() after displaying the dialogs.  See
        # BZ #855762.
        if error is not None:
            if isinstance(error[1], ServiceLevelNotSupportedException):
                OkDialog(_("Unable to auto-attach, server does not support service levels."),
                        parent=self._parent.parent)
            elif isinstance(error[1], NoProductsException):
                InfoDialog(_("No installed products on system. No need to attach subscriptions at this time."),
                           parent=self._parent.parent)
            elif isinstance(error[1], AllProductsCoveredException):
                InfoDialog(_("All installed products are covered by valid entitlements. No need to attach subscriptions at this time."),
                           parent=self._parent.parent)
            else:
                handle_gui_exception(error, _("Error subscribing"),
                                     self._parent.parent)
            self._parent.finish_registration(failed=True)
            return

        (current_sla, unentitled_products, sla_data_map) = result

        self._parent.current_sla = current_sla
        if len(sla_data_map) == 1:
            # If system already had a service level, we can hit this point
            # when we cannot fix any unentitled products:
            if current_sla is not None and \
                    not self._can_add_more_subs(current_sla, sla_data_map):
                handle_gui_exception(None,
                                     _("No available subscriptions at "
                                     "the current service level: %s. "
                                     "Please use the \"All Available "
                                     "Subscriptions\" tab to manually "
                                     "attach subscriptions.") % current_sla,
                                    self._parent.parent)
                self._parent.finish_registration(failed=True)
                return

            self._dry_run_result = sla_data_map.values()[0]
            self._parent.pre_done(CONFIRM_SUBS_PAGE)
        elif len(sla_data_map) > 1:
            self._sla_data_map = sla_data_map
            self.set_model(unentitled_products, sla_data_map)
            self._parent.pre_done(DONT_CHANGE)
        else:
            log.info("No suitable service levels found.")
            handle_gui_exception(None,
                                 _("No service level will cover all "
                                 "installed products. Please manually "
                                 "subscribe using multiple service levels "
                                 "via the \"All Available Susbscriptions\" "
                                 "tab or purchase additional subscriptions."),
                                 parent=self._parent.parent)
            self._parent.finish_registration(failed=True)
예제 #54
0
class PerformRegisterScreen(registergui.PerformRegisterScreen):

    def _on_registration_finished_cb(self, new_account, error=None):
        if error is not None:
            handle_gui_exception(error, registergui.REGISTER_ERROR,
                    self._parent.window)
            self._parent.finish_registration(failed=True)
            return

        try:
            managerlib.persist_consumer_cert(new_account)
            self._parent.backend.cs.force_cert_check()  # Ensure there isn't much wait time

            if self._parent.activation_keys:
                self._parent.pre_done(registergui.REFRESH_SUBSCRIPTIONS_PAGE)
            elif self._parent.skip_auto_bind:
                message = _("You have opted to skip auto-attach.")
                self._parent.manual_message = message
                self._parent.pre_done(MANUALLY_SUBSCRIBE_PAGE)
            else:
                self._parent.pre_done(registergui.SELECT_SLA_PAGE)

        # If we get errors related to consumer name on register,
        # go back to the credentials screen where we set the
        # consumer name. See bz#865954
        except RestlibException, e:
            handle_gui_exception(e, registergui.REGISTER_ERROR,
                self._parent.window)
            if e.code == 404 and self._parent.activation_keys:
                self._parent.pre_done(registergui.ACTIVATION_KEY_PAGE)
            if e.code == 400:
                self._parent.pre_done(registergui.CREDENTIALS_PAGE)

        except Exception, e:
            handle_gui_exception(e, registergui.REGISTER_ERROR,
                    self._parent.window)
            self._parent.finish_registration(failed=True)
예제 #55
0
 def _on_update_failure(self, e):
     handle_gui_exception(e, _("Unable to update overrides."),
                          self._get_dialog_widget())
     self._clear_progress_bar()
예제 #56
0
 def _on_async_delete_all_overrides_failure(self, e):
     self._clear_progress_bar()
     handle_gui_exception(e, _("Unable to reset repository overrides."),
                          self._get_dialog_widget())
예제 #57
0
 def _on_async_load_data_failure(self, e):
     self._clear_progress_bar()
     handle_gui_exception(e, _("Unable to load repository data."),
                          self._get_dialog_widget())
예제 #58
0
 def test_hge_restlib_exception_url_msg(self):
     utils.log.set_expected_msg(self.msg)
     utils.handle_gui_exception(
         connection.RestlibException(404, "page not found"),
         self.msg_with_url, None)
     self.assertEqual(utils.log.expected_msg, self.msg)