예제 #1
0
 def test_get_server_versions_cp_no_status(self, MockClassicCheck, MockUep):
     instance = MockClassicCheck.return_value
     instance.is_registered_with_classic.return_value = False
     MockUep.supports_resource.return_value = False
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'subscription management service')
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #2
0
    def __init__(self, parent, backend):
        self.backend = backend
        self.dialog = GtkAboutDialog()
        self.dialog.set_transient_for(parent)
        self.dialog.set_modal(True)
        self.dialog.set_name(_("Subscription Manager"))
        self.dialog.set_license(LICENSE)
        self.dialog.set_wrap_license(True)
        self.dialog.set_website("https://fedorahosted.org/subscription-manager/")
        self.dialog.set_copyright(_("Copyright (c) 2012 Red Hat, Inc."))
        self.dialog.set_logo(gdk.pixbuf_new_from_file_at_size(LOGO_PATH, 100, 100))

        rhsm_version_label = Label()
        backend_version_label = Label()
        context_box = self.dialog.vbox.get_children()[0]
        context_box.pack_end(rhsm_version_label)
        context_box.pack_end(backend_version_label)

        # Set the component versions.
        server_versions = get_server_versions(self.backend.uep)
        client_versions = get_client_versions()

        self.dialog.set_version(client_versions['subscription-manager'])
        rhsm_version_label.set_markup(_("<b>python-rhsm version:</b> %s" % \
            client_versions['python-rhsm']))
        backend_version_label.set_markup(_("<b>subscription management service version:</b> %s" % \
            server_versions['candlepin']))

        self.dialog.connect("response", self._handle_response)
        self.dialog.show_all()
예제 #3
0
    def test_get_server_versions_cp_with_status_bad_data(self, mock_classic, MockUep):
        instance = mock_classic.return_value
        instance.is_registered_with_classic.return_value = False
        self._inject_mock_valid_consumer()
        MockUep.supports_resource.return_value = True

        dataset = [
            {'version': None, 'release': '123'},
            {'version': 123, 'release': '123'},

            {'version': '123', 'release': None},
            {'version': '123', 'release': 123},

            {'version': None, 'release': None},
            {'version': None, 'release': 123},
            {'version': 123, 'release': None},
            {'version': 123, 'release': 123},
        ]

        for value in dataset:
            MockUep.getStatus.return_value = value
            sv = get_server_versions(MockUep)
            self.assertEquals(sv['server-type'], 'Red Hat Subscription Management')
            self.assertEquals(sv['candlepin'], 'Unknown')
            self.assertEquals(sv['rules-version'], 'Unknown')
예제 #4
0
 def test_get_server_versions_cp_no_status(self, MockClassicCheck, MockUep):
     instance = MockClassicCheck.return_value
     instance.is_registered_with_classic.return_value = False
     MockUep.supports_resource.return_value = False
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'subscription management service')
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #5
0
    def test_get_server_versions_cp_with_status_bad_data(self, mock_classic, MockUep):
        instance = mock_classic.return_value
        instance.is_registered_with_classic.return_value = False
        self._inject_mock_valid_consumer()
        MockUep.supports_resource.return_value = True

        dataset = [
            {'version': None, 'release': '123'},
            {'version': 123, 'release': '123'},

            {'version': '123', 'release': None},
            {'version': '123', 'release': 123},

            {'version': None, 'release': None},
            {'version': None, 'release': 123},
            {'version': 123, 'release': None},
            {'version': 123, 'release': 123},
        ]

        for value in dataset:
            MockUep.getStatus.return_value = value
            sv = get_server_versions(MockUep)
            self.assertEqual(sv['server-type'], 'Red Hat Subscription Management')
            self.assertEqual(sv['candlepin'], 'Unknown')
            self.assertEqual(sv['rules-version'], 'Unknown')
예제 #6
0
 def test_get_server_versions_cp_with_status(self, MockClassicCheck, MockUep):
     instance = MockClassicCheck.return_value
     instance.is_registered_with_classic.return_value = False
     MockUep.supports_resource.return_value = True
     MockUep.getStatus.return_value = {'version': '101', 'release': '23423c'}
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'subscription management service')
     self.assertEquals(sv['candlepin'], '101-23423c')
예제 #7
0
    def test_get_server_versions_classic(self, MockClassicCheck):
        self._inject_mock_invalid_consumer()
        instance = MockClassicCheck.return_value
        instance.is_registered_with_classic.return_value = True

        sv = get_server_versions(None)
        self.assertEquals(sv['server-type'], "RHN Classic")
        self.assertEquals(sv['candlepin'], "Unknown")
예제 #8
0
 def test_get_server_versions_cp_no_status(self, mci_exists_and_valid, MockClassicCheck, MockUep):
     instance = MockClassicCheck.return_value
     instance.is_registered_with_classic.return_value = False
     mci_exists_and_valid.return_value = True
     MockUep.supports_resource.return_value = False
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'Red Hat Subscription Management')
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #9
0
    def test_get_server_versions_classic(self, mock_classic, mock_versions):
        self._inject_mock_invalid_consumer()
        instance = mock_classic.return_value
        instance.is_registered_with_classic.return_value = True

        sv = get_server_versions(None)
        self.assertEquals(sv['server-type'], "RHN Classic")
        self.assertEquals(sv['candlepin'], "Unknown")
예제 #10
0
 def test_get_server_versions_cp_no_status(self, mock_classic, MockUep):
     instance = mock_classic.return_value
     instance.is_registered_with_classic.return_value = False
     self._inject_mock_valid_consumer()
     MockUep.supports_resource.return_value = False
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'Red Hat Subscription Management')
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #11
0
 def test_get_server_versions_cp_no_status(self, mock_classic, MockUep):
     instance = mock_classic.return_value
     instance.is_registered_with_classic.return_value = False
     self._inject_mock_valid_consumer()
     MockUep.supports_resource.return_value = False
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'Red Hat Subscription Management')
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #12
0
 def test_get_server_versions_cp_no_status(self, mci_exists_and_valid,
                                           MockClassicCheck, MockUep):
     instance = MockClassicCheck.return_value
     instance.is_registered_with_classic.return_value = False
     mci_exists_and_valid.return_value = True
     MockUep.supports_resource.return_value = False
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'Red Hat Subscription Management')
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #13
0
 def test_get_server_versions_cp_with_status_and_classic(self, mock_classic, MockUep):
     instance = mock_classic.return_value
     instance.is_registered_with_classic.return_value = True
     self._inject_mock_valid_consumer()
     MockUep.supports_resource.return_value = True
     MockUep.getStatus.return_value = {'version': '101', 'release': '23423c'}
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'RHN Classic and Red Hat Subscription Management')
     self.assertEquals(sv['candlepin'], '101-23423c')
예제 #14
0
    def test_get_server_versions_classic(self, MockClassicCheck):
        from subscription_manager import utils
        instance = MockClassicCheck.return_value
        instance.is_registered_with_classic.return_value = True
        utils.Versions = VersionsStub

        sv = get_server_versions(None)
        self.assertEquals(sv['server-type'], "RHN Classic")
        self.assertEquals(sv['candlepin'], "Unknown")
예제 #15
0
    def test_get_server_versions_classic(self, MockClassicCheck):
        from subscription_manager import utils
        instance = MockClassicCheck.return_value
        instance.is_registered_with_classic.return_value = True
        utils.Versions = VersionsStub

        sv = get_server_versions(None)
        self.assertEquals(sv['server-type'], "RHN Classic")
        self.assertEquals(sv['candlepin'], "Unknown")
예제 #16
0
 def test_get_server_versions_cp_exception(self, MockClassicCheck, MockUep):
     def raise_exception(arg):
         raise Exception("boom")
     instance = MockClassicCheck.return_value
     instance.is_registered_with_classic.return_value = False
     MockUep.supports_resource.side_effect = raise_exception
     MockUep.getStatus.return_value = {'version': '101', 'release': '23423c'}
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], "Unknown")
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #17
0
 def test_get_server_versions_cp_exception_and_classic(self, mock_classic, MockUep):
     def raise_exception(arg):
         raise Exception("boom")
     instance = mock_classic.return_value
     instance.is_registered_with_classic.return_value = True
     self._inject_mock_invalid_consumer()
     MockUep.supports_resource.side_effect = raise_exception
     MockUep.getStatus.return_value = {'version': '101', 'release': '23423c'}
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], "RHN Classic")
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #18
0
 def test_get_server_versions_cp_exception_and_classic(self, mock_classic, MockUep):
     def raise_exception(arg):
         raise Exception("boom")
     instance = mock_classic.return_value
     instance.is_registered_with_classic.return_value = True
     self._inject_mock_invalid_consumer()
     MockUep.supports_resource.side_effect = raise_exception
     MockUep.getStatus.return_value = {'version': '101', 'release': '23423c'}
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], "RHN Classic")
     self.assertEquals(sv['candlepin'], "Unknown")
예제 #19
0
 def test_get_server_versions_cp_with_status_no_keys(
         self, mock_classic, MockUep):
     instance = mock_classic.return_value
     instance.is_registered_with_classic.return_value = False
     self._inject_mock_valid_consumer()
     MockUep.supports_resource.return_value = True
     MockUep.getStatus.return_value = {}
     sv = get_server_versions(MockUep)
     self.assertEqual(sv["server-type"], "Red Hat Subscription Management")
     self.assertEqual(sv["candlepin"], "Unknown-Unknown")
     self.assertEqual(sv["rules-version"], "Unknown")
예제 #20
0
 def test_get_server_versions_cp_with_status(self, MockClassicCheck,
                                             MockUep):
     instance = MockClassicCheck.return_value
     instance.is_registered_with_classic.return_value = False
     MockUep.supports_resource.return_value = True
     MockUep.getStatus.return_value = {
         'version': '101',
         'release': '23423c'
     }
     sv = get_server_versions(MockUep)
     self.assertEquals(sv['server-type'], 'subscription management service')
     self.assertEquals(sv['candlepin'], '101-23423c')
예제 #21
0
 def test_get_server_versions_cp_exception(self, mock_classic, MockUep):
     def raise_exception(arg):
         raise Exception("boom")
     instance = mock_classic.return_value
     instance.is_registered_with_classic.return_value = False
     self._inject_mock_valid_consumer()
     self.mock_get_resources.side_effect = raise_exception
     MockUep.getStatus.return_value = {'version': '101', 'release': '23423c'}
     sv = get_server_versions(MockUep)
     print(sv)
     self.assertEqual(sv['server-type'], "Red Hat Subscription Management")
     self.assertEqual(sv['candlepin'], "Unknown")
예제 #22
0
    def log_server_version(self):
        # can't check the server version without a connection
        # and valid registration
        if not self.require_connection():
            return

        # get_server_versions needs to handle any exceptions
        # and return the server dict
        self.server_versions = get_server_versions(self.no_auth_cp,
                                                   exception_on_timeout=False)
        log.debug("Server Versions: {versions}".format(
            versions=self.server_versions))
예제 #23
0
    def test_get_server_versions_cp_exception(self, MockClassicCheck, MockUep):
        def raise_exception(arg):
            raise Exception("boom")

        instance = MockClassicCheck.return_value
        instance.is_registered_with_classic.return_value = False
        MockUep.supports_resource.side_effect = raise_exception
        MockUep.getStatus.return_value = {
            'version': '101',
            'release': '23423c'
        }
        sv = get_server_versions(MockUep)
        self.assertEquals(sv['server-type'], "Unknown")
        self.assertEquals(sv['candlepin'], "Unknown")
예제 #24
0
 def test_get_server_versions_cp_with_status(self, mock_classic, MockUep):
     instance = mock_classic.return_value
     instance.is_registered_with_classic.return_value = False
     self._inject_mock_valid_consumer()
     MockUep.supports_resource.return_value = True
     MockUep.getStatus.return_value = {
         "version": "101",
         "release": "23423c",
         "rulesVersion": "6.1"
     }
     sv = get_server_versions(MockUep)
     self.assertEqual(sv["server-type"], "Red Hat Subscription Management")
     self.assertEqual(sv["candlepin"], "101-23423c")
     self.assertEqual(sv["rules-version"], "6.1")
예제 #25
0
    def test_get_server_versions_cp_with_status_bad_data(
            self, mock_classic, MockUep):
        instance = mock_classic.return_value
        instance.is_registered_with_classic.return_value = False
        self._inject_mock_valid_consumer()
        MockUep.supports_resource.return_value = True

        dataset = [
            {
                "version": None,
                "release": "123"
            },
            {
                "version": 123,
                "release": "123"
            },
            {
                "version": "123",
                "release": None
            },
            {
                "version": "123",
                "release": 123
            },
            {
                "version": None,
                "release": None
            },
            {
                "version": None,
                "release": 123
            },
            {
                "version": 123,
                "release": None
            },
            {
                "version": 123,
                "release": 123
            },
        ]

        for value in dataset:
            MockUep.getStatus.return_value = value
            sv = get_server_versions(MockUep)
            self.assertEqual(sv["server-type"],
                             "Red Hat Subscription Management")
            self.assertEqual(sv["candlepin"], "Unknown")
            self.assertEqual(sv["rules-version"], "Unknown")
예제 #26
0
    def test_get_server_versions_cp_exception_and_classic(
            self, mock_classic, MockUep):
        def raise_exception(arg):
            raise Exception("boom")

        instance = mock_classic.return_value
        instance.is_registered_with_classic.return_value = True
        self._inject_mock_invalid_consumer()
        self.mock_get_resources.side_effect = raise_exception
        MockUep.getStatus.return_value = {
            "version": "101",
            "release": "23423c"
        }
        sv = get_server_versions(MockUep)
        self.assertEqual(sv["server-type"], "RHN Classic")
        self.assertEqual(sv["candlepin"], "Unknown")
예제 #27
0
    def __init__(self, parent, backend):
        self.backend = backend
        self.dialog = ga_Gtk.AboutDialog()
        self.dialog.set_transient_for(parent)
        self.dialog.set_modal(True)
        self.dialog.set_name(_("Subscription Manager"))
        self.dialog.set_license(LICENSE)
        self.dialog.set_wrap_license(True)
        if not get_running_as_firstboot():
            self.dialog.set_website(
                "https://fedorahosted.org/subscription-manager/")
        self.dialog.set_copyright(_("Copyright (c) 2012 Red Hat, Inc."))
        self.dialog.set_logo_icon_name("subscription-manager")
        self.dialog.set_icon_name("subscription-manager")
        self.dialog.set_authors(["The Subscription Manager Team"])

        next_update_label = ga_Gtk.Label()
        python_rhsm_version_label = ga_Gtk.Label()
        sub_man_version_label = ga_Gtk.Label()
        backend_version_label = ga_Gtk.Label()
        context_box = self.dialog.vbox.get_children()[0]
        context_box.pack_end(next_update_label, True, True, 0)
        context_box.pack_end(python_rhsm_version_label, True, True, 0)
        context_box.pack_end(sub_man_version_label, True, True, 0)
        context_box.pack_end(backend_version_label, True, True, 0)

        self._set_next_update(next_update_label)

        # Set the component versions.
        server_versions = get_server_versions(
            self.backend.cp_provider.get_consumer_auth_cp())
        client_versions = get_client_versions()

        python_rhsm_version_label.set_markup(
            _("<b>%s version:</b> %s") %
            ("python-rhsm", client_versions['python-rhsm']))
        sub_man_version_label.set_markup(
            _("<b>%s version:</b> %s") %
            ("subscription manager", client_versions['subscription-manager']))
        backend_version_label.set_markup(
            _("<b>subscription management service version:</b> %s") %
            server_versions['candlepin'])

        self.dialog.connect("response", self._handle_response)
        self.dialog.show_all()
예제 #28
0
    def __init__(self, parent, backend):
        self.backend = backend
        self.dialog = ga_Gtk.AboutDialog()
        self.dialog.set_transient_for(parent)
        self.dialog.set_modal(True)
        self.dialog.set_name(_("Subscription Manager"))
        self.dialog.set_license(LICENSE)
        self.dialog.set_wrap_license(True)
        if not get_running_as_firstboot():
            self.dialog.set_website("https://fedorahosted.org/subscription-manager/")
        self.dialog.set_copyright(_("Copyright (c) 2012 Red Hat, Inc."))
        self.dialog.set_logo_icon_name("subscription-manager")
        self.dialog.set_icon_name("subscription-manager")
        self.dialog.set_authors(["The Subscription Manager Team"])

        next_update_label = ga_Gtk.Label()
        python_rhsm_version_label = ga_Gtk.Label()
        sub_man_version_label = ga_Gtk.Label()
        backend_version_label = ga_Gtk.Label()
        context_box = self.dialog.vbox.get_children()[0]
        context_box.pack_end(next_update_label, True, True, 0)
        context_box.pack_end(python_rhsm_version_label, True, True, 0)
        context_box.pack_end(sub_man_version_label, True, True, 0)
        context_box.pack_end(backend_version_label, True, True, 0)

        self._set_next_update(next_update_label)

        # Set the component versions.
        server_versions = get_server_versions(self.backend.cp_provider.get_consumer_auth_cp())
        client_versions = get_client_versions()

        python_rhsm_version_label.set_markup(_("<b>%s version:</b> %s") %
                                        ("python-rhsm", client_versions['python-rhsm']))
        sub_man_version_label.set_markup(_("<b>%s version:</b> %s") %
                                        ("subscription manager", client_versions['subscription-manager']))
        backend_version_label.set_markup(_("<b>subscription management service version:</b> %s") %
                                           server_versions['candlepin'])

        self.dialog.connect("response", self._handle_response)
        self.dialog.show_all()
예제 #29
0
    def __init__(self,
                 backend=None,
                 facts=None,
                 ent_dir=None,
                 prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__('mainwindow.glade')

        self.backend = backend or Backend()
        self.identity = require(IDENTITY)

        self.facts = facts or Facts(self.backend.entitlement_dir,
                                    self.backend.product_dir)
        # We need to make sure facts are loaded immediately, some GUI operations
        # are done in separate threads, and if facts try to load in another
        # thread the virt guest detection code breaks due to hwprobe's use of
        # signals.
        self.facts.get_facts()

        log.debug("Client Versions: %s " % get_client_versions())
        log.debug("Server Versions: %s " % get_server_versions(
            self.backend.cp_provider.get_consumer_auth_cp()))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(
            self.backend, self.facts)

        self.registration_dialog = registergui.RegisterScreen(
            self.backend, self.facts, self._get_window())

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.xml.get_widget("closeButton").connect(
            "clicked", self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend)

        self.installed_tab_icon = gtk.Image()
        self.installed_tab_icon.set_from_stock(gtk.STOCK_YES,
                                               gtk.ICON_SIZE_MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.facts,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)
        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.facts,
                                                self.main_window)

        hbox = gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False)
        hbox.pack_start(gtk.Label(self.installed_tab.get_label()), False,
                        False)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                                  gtk.Label(self.my_subs_tab.get_label()))

        self.glade.signal_autoconnect({
            "on_register_menu_item_activate":
            self._register_item_clicked,
            "on_unregister_menu_item_activate":
            self._unregister_item_clicked,
            "on_import_cert_menu_item_activate":
            self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate":
            self._facts_item_clicked,
            "on_proxy_config_menu_item_activate":
            self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate":
            self._redeem_item_clicked,
            "on_preferences_menu_item_activate":
            self._preferences_item_clicked,
            "on_about_menu_item_activate":
            self._about_item_clicked,
            "on_getting_started_menu_item_activate":
            self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate":
            self._online_docs_item_clicked,
            "on_quit_menu_item_activate":
            gtk.main_quit,
        })

        def on_cert_change():
            # Update installed products
            self.installed_tab.update_products()
            self.installed_tab._set_validity_status()
            # Update attached subs
            self.my_subs_tab.update_subscriptions()
            # Update main window
            self.refresh()

        self.backend.cs.add_callback(on_cert_change)

        self.main_window.show_all()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        # Update everything with compliance data
        self.backend.cs.notify()

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)
예제 #30
0
    def __init__(self,
                 backend=None,
                 consumer=None,
                 facts=None,
                 ent_dir=None,
                 prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__('mainwindow.glade')

        self.backend = backend or Backend()
        self.consumer = consumer or Consumer()
        self.facts = facts or Facts(self.backend.entitlement_dir,
                                    self.backend.product_dir)

        log.debug("Client Versions: %s " % get_client_versions())
        log.debug("Server Versions: %s " %
                  get_server_versions(self.backend.uep))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(
            self.backend, self.consumer, self.facts)

        self.registration_dialog = registergui.RegisterScreen(
            self.backend,
            self.consumer,
            self.facts,
            callbacks=[self.registration_changed])

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self.consumer,
                                                    self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.xml.get_widget("closeButton").connect(
            "clicked", self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend, self.consumer)

        self.installed_tab_icon = gtk.Image()
        self.installed_tab_icon.set_from_stock(gtk.STOCK_YES,
                                               gtk.ICON_SIZE_MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.consumer,
                                                  self.facts,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)
        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.consumer,
                                              self.facts,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.consumer,
                                                self.facts, self.main_window)

        hbox = gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False)
        hbox.pack_start(gtk.Label(self.installed_tab.get_label()), False,
                        False)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                                  gtk.Label(self.my_subs_tab.get_label()))

        self.glade.signal_autoconnect({
            "on_register_menu_item_activate":
            self._register_item_clicked,
            "on_unregister_menu_item_activate":
            self._unregister_item_clicked,
            "on_import_cert_menu_item_activate":
            self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate":
            self._facts_item_clicked,
            "on_proxy_config_menu_item_activate":
            self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate":
            self._redeem_item_clicked,
            "on_preferences_menu_item_activate":
            self._preferences_item_clicked,
            "on_about_menu_item_activate":
            self._about_item_clicked,
            "on_getting_started_menu_item_activate":
            self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate":
            self._online_docs_item_clicked,
            "on_quit_menu_item_activate":
            gtk.main_quit,
        })

        def on_identity_change(filemonitor):
            self.consumer.reload()
            self.refresh()

        self.backend.monitor_identity(on_identity_change)

        self.main_window.show_all()
        self.refresh()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)
예제 #31
0
    def __init__(
        self, backend=None, consumer=None, facts=None, ent_dir=None, prod_dir=None, auto_launch_registration=False
    ):
        super(MainWindow, self).__init__("mainwindow.glade")

        self.backend = backend or Backend()
        self.consumer = consumer or Consumer()
        self.facts = facts or Facts(self.backend.entitlement_dir, self.backend.product_dir)

        log.debug("Client Versions: %s " % get_client_versions())
        log.debug("Server Versions: %s " % get_server_versions(self.backend.uep))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(self.backend, self.consumer, self.facts)

        self.registration_dialog = registergui.RegisterScreen(
            self.backend, self.consumer, self.facts, callbacks=[self.registration_changed]
        )

        self.preferences_dialog = PreferencesDialog(self.backend, self.consumer, self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.xml.get_widget("closeButton").connect("clicked", self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend, self.consumer)

        self.installed_tab_icon = gtk.Image()
        self.installed_tab_icon.set_from_stock(gtk.STOCK_YES, gtk.ICON_SIZE_MENU)

        self.installed_tab = InstalledProductsTab(
            self.backend,
            self.consumer,
            self.facts,
            self.installed_tab_icon,
            self,
            ent_dir=self.entitlement_dir,
            prod_dir=self.product_dir,
        )
        self.my_subs_tab = MySubscriptionsTab(
            self.backend,
            self.consumer,
            self.facts,
            self.main_window,
            ent_dir=self.entitlement_dir,
            prod_dir=self.product_dir,
        )

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.consumer, self.facts, self.main_window)

        hbox = gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False)
        hbox.pack_start(gtk.Label(self.installed_tab.get_label()), False, False)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(), gtk.Label(self.my_subs_tab.get_label()))

        self.glade.signal_autoconnect(
            {
                "on_register_menu_item_activate": self._register_item_clicked,
                "on_unregister_menu_item_activate": self._unregister_item_clicked,
                "on_import_cert_menu_item_activate": self._import_cert_item_clicked,
                "on_view_facts_menu_item_activate": self._facts_item_clicked,
                "on_proxy_config_menu_item_activate": self._proxy_config_item_clicked,
                "on_redeem_menu_item_activate": self._redeem_item_clicked,
                "on_preferences_menu_item_activate": self._preferences_item_clicked,
                "on_about_menu_item_activate": self._about_item_clicked,
                "on_getting_started_menu_item_activate": self._getting_started_item_clicked,
                "on_online_docs_menu_item_activate": self._online_docs_item_clicked,
                "on_quit_menu_item_activate": gtk.main_quit,
            }
        )

        def on_identity_change(filemonitor):
            self.consumer.reload()
            self.refresh()

        self.backend.monitor_identity(on_identity_change)

        self.main_window.show_all()
        self.refresh()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)
예제 #32
0
    def __init__(self,
                 backend=None,
                 facts=None,
                 ent_dir=None,
                 prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__()

        self.backend = backend or Backend()
        self.identity = require(IDENTITY)

        self.facts = facts or Facts(self.backend.entitlement_dir,
                                    self.backend.product_dir)
        # We need to make sure facts are loaded immediately, some GUI operations
        # are done in separate threads, and if facts try to load in another
        # thread the virt guest detection code breaks due to hwprobe's use of
        # signals.
        self.facts.get_facts()

        log.debug("Client Versions: %s " % get_client_versions())
        log.debug("Server Versions: %s " % get_server_versions(
            self.backend.cp_provider.get_consumer_auth_cp()))

        settings = self.main_window.get_settings()

        # prevent gtk from trying to save a list of recently used files, which
        # as root, causes gtk warning:
        #  "Attempting to set the permissions of `/root/.local/share/recently-used.xbel'
        # The __name__ use is just for the 'origin' value gtk uses to store
        # where a Gtk.Settings value was set.
        settings.set_long_property('gtk-recent-files-max-age', 0,
                                   "%s:%s" % (__name__, type(self).__name__))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(self.facts)

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self._get_window())

        self.repos_dialog = RepositoriesDialog(self.backend,
                                               self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.saveButton.connect("clicked",
                                                      self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend)

        self.installed_tab_icon = ga_Gtk.Image()
        self.installed_tab_icon.set_from_stock(ga_Gtk.STOCK_YES,
                                               ga_Gtk.IconSize.MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.facts,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)
        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.facts,
                                                self.main_window)

        hbox = ga_Gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False, 0)
        hbox.pack_start(ga_Gtk.Label(self.installed_tab.get_label()), False,
                        False, 0)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                                  ga_Gtk.Label(self.my_subs_tab.get_label()))

        self.connect_signals({
            "on_register_menu_item_activate": self._register_item_clicked,
            "on_unregister_menu_item_activate": self._unregister_item_clicked,
            "on_import_cert_menu_item_activate":
            self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate": self._facts_item_clicked,
            "on_proxy_config_menu_item_activate":
            self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate": self._redeem_item_clicked,
            "on_preferences_menu_item_activate":
            self._preferences_item_clicked,
            "on_repos_menu_item_activate": self._repos_item_clicked,
            "on_about_menu_item_activate": self._about_item_clicked,
            "on_getting_started_menu_item_activate":
            self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate":
            self._online_docs_item_clicked,
            "on_quit_menu_item_activate": ga_Gtk.main_quit,
        })

        # TODO: why is this defined in the init scope?
        # When something causes cert_sorter to upate it's state, refresh the gui
        # The cert directories being updated will cause this (either noticed
        # from a timer, or via cert_sort.force_cert_check).
        def on_cert_sorter_cert_change():
            # Update installed products
            self.installed_tab.update_products()
            self.installed_tab._set_validity_status()
            # Update attached subs
            self.my_subs_tab.update_subscriptions()
            # Update main window
            self.refresh()
            # Reset repos dialog, see bz 1132919
            self.repos_dialog = RepositoriesDialog(self.backend,
                                                   self._get_window())

        self.backend.cs.add_callback(on_cert_sorter_cert_change)

        self.main_window.show_all()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        # Update everything with compliance data
        self.backend.cs.notify()

        # managergui needs cert_sort.cert_monitor.run_check() to run
        # on a timer to detect cert changes from outside the gui
        # (via rhsmdd for example, or manually provisioned).
        ga_GLib.timeout_add(2000, self._on_cert_check_timer)

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)
예제 #33
0
 def log_server_version(self, uep):
     server_versions = get_server_versions(uep)
     log.debug("Server Versions: %s" % server_versions)
     # Remove this from the GTK main loop
     return False
예제 #34
0
 def log_server_version(self, uep):
     server_versions = get_server_versions(uep)
     log.debug("Server Versions: %s" % server_versions)
     # Remove this from the GTK main loop
     return False
예제 #35
0
    def __init__(self, backend=None, facts=None, ent_dir=None, prod_dir=None, auto_launch_registration=False):
        super(MainWindow, self).__init__()

        self.backend = backend or Backend()
        self.identity = require(IDENTITY)

        self.facts = facts or Facts(self.backend.entitlement_dir, self.backend.product_dir)
        # We need to make sure facts are loaded immediately, some GUI operations
        # are done in separate threads, and if facts try to load in another
        # thread the virt guest detection code breaks due to hwprobe's use of
        # signals.
        self.facts.get_facts()

        log.debug("Client Versions: %s " % get_client_versions())
        log.debug("Server Versions: %s " % get_server_versions(self.backend.cp_provider.get_consumer_auth_cp()))

        settings = self.main_window.get_settings()

        # prevent gtk from trying to save a list of recently used files, which
        # as root, causes gtk warning:
        #  "Attempting to set the permissions of `/root/.local/share/recently-used.xbel'
        # The __name__ use is just for the 'origin' value gtk uses to store
        # where a Gtk.Settings value was set.
        settings.set_long_property("gtk-recent-files-max-age", 0, "%s:%s" % (__name__, type(self).__name__))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(self.facts)

        self.registration_dialog = registergui.RegisterDialog(self.backend, self.facts)

        self.preferences_dialog = PreferencesDialog(self.backend, self._get_window())

        self.repos_dialog = RepositoriesDialog(self.backend, self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.saveButton.connect("clicked", self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend)

        self.installed_tab_icon = ga_Gtk.Image()
        self.installed_tab_icon.set_from_stock(ga_Gtk.STOCK_YES, ga_Gtk.IconSize.MENU)

        self.installed_tab = InstalledProductsTab(
            self.backend,
            self.facts,
            self.installed_tab_icon,
            self,
            ent_dir=self.entitlement_dir,
            prod_dir=self.product_dir,
        )
        self.my_subs_tab = MySubscriptionsTab(
            self.backend, self.main_window, ent_dir=self.entitlement_dir, prod_dir=self.product_dir
        )

        self.all_subs_tab = AllSubscriptionsTab(self.backend, self.facts, self.main_window)

        hbox = ga_Gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False, 0)
        hbox.pack_start(ga_Gtk.Label(self.installed_tab.get_label()), False, False, 0)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(), ga_Gtk.Label(self.my_subs_tab.get_label()))

        self.connect_signals(
            {
                "on_register_menu_item_activate": self._register_item_clicked,
                "on_unregister_menu_item_activate": self._unregister_item_clicked,
                "on_import_cert_menu_item_activate": self._import_cert_item_clicked,
                "on_view_facts_menu_item_activate": self._facts_item_clicked,
                "on_proxy_config_menu_item_activate": self._proxy_config_item_clicked,
                "on_redeem_menu_item_activate": self._redeem_item_clicked,
                "on_preferences_menu_item_activate": self._preferences_item_clicked,
                "on_repos_menu_item_activate": self._repos_item_clicked,
                "on_about_menu_item_activate": self._about_item_clicked,
                "on_getting_started_menu_item_activate": self._getting_started_item_clicked,
                "on_online_docs_menu_item_activate": self._online_docs_item_clicked,
                "on_quit_menu_item_activate": ga_Gtk.main_quit,
            }
        )

        # TODO: why is this defined in the init scope?
        # When something causes cert_sorter to upate it's state, refresh the gui
        # The cert directories being updated will cause this (either noticed
        # from a timer, or via cert_sort.force_cert_check).
        def on_cert_sorter_cert_change():
            # Update installed products
            self.installed_tab.update_products()
            self.installed_tab._set_validity_status()
            # Update attached subs
            self.my_subs_tab.update_subscriptions()
            # Update main window
            self.refresh()
            # Reset repos dialog, see bz 1132919
            self.repos_dialog = RepositoriesDialog(self.backend, self._get_window())

        self.backend.cs.add_callback(on_cert_sorter_cert_change)

        self.main_window.show_all()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        # Update everything with compliance data
        self.backend.cs.notify()

        # managergui needs cert_sort.cert_monitor.run_check() to run
        # on a timer to detect cert changes from outside the gui
        # (via rhsmdd for example, or manually provisioned).
        ga_GLib.timeout_add(2000, self._on_cert_check_timer)

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)
예제 #36
0
    def __init__(self, backend=None, facts=None,
                 ent_dir=None, prod_dir=None,
                 auto_launch_registration=False):
        super(MainWindow, self).__init__('mainwindow.glade')

        self.backend = backend or Backend()
        self.identity = require(IDENTITY)

        self.facts = facts or Facts(self.backend.entitlement_dir,
                self.backend.product_dir)
        # We need to make sure facts are loaded immediately, some GUI operations
        # are done in separate threads, and if facts try to load in another
        # thread the virt guest detection code breaks due to hwprobe's use of
        # signals.
        self.facts.get_facts()

        log.debug("Client Versions: %s " % get_client_versions())
        log.debug("Server Versions: %s " % get_server_versions(self.backend.cp_provider.get_consumer_auth_cp()))

        self.product_dir = prod_dir or self.backend.product_dir
        self.entitlement_dir = ent_dir or self.backend.entitlement_dir

        self.system_facts_dialog = factsgui.SystemFactsDialog(self.backend,
                                                              self.facts)

        self.registration_dialog = registergui.RegisterScreen(self.backend, self.facts,
                                                              self._get_window())

        self.preferences_dialog = PreferencesDialog(self.backend,
                                                    self._get_window())

        self.import_sub_dialog = ImportSubDialog()

        self.network_config_dialog = networkConfig.NetworkConfigDialog()
        self.network_config_dialog.xml.get_widget("closeButton").connect("clicked", self._config_changed)

        self.redeem_dialog = redeem.RedeemDialog(self.backend)

        self.installed_tab_icon = gtk.Image()
        self.installed_tab_icon.set_from_stock(gtk.STOCK_YES,
                gtk.ICON_SIZE_MENU)

        self.installed_tab = InstalledProductsTab(self.backend,
                                                  self.facts,
                                                  self.installed_tab_icon,
                                                  self,
                                                  ent_dir=self.entitlement_dir,
                                                  prod_dir=self.product_dir)
        self.my_subs_tab = MySubscriptionsTab(self.backend,
                                              self.main_window,
                                              ent_dir=self.entitlement_dir,
                                              prod_dir=self.product_dir)

        self.all_subs_tab = AllSubscriptionsTab(self.backend,
                                                self.facts,
                                                self.main_window)

        hbox = gtk.HBox(spacing=6)
        hbox.pack_start(self.installed_tab_icon, False, False)
        hbox.pack_start(gtk.Label(self.installed_tab.get_label()), False, False)
        self.notebook.append_page(self.installed_tab.get_content(), hbox)
        hbox.show_all()

        self.notebook.append_page(self.my_subs_tab.get_content(),
                gtk.Label(self.my_subs_tab.get_label()))

        self.glade.signal_autoconnect({
            "on_register_menu_item_activate": self._register_item_clicked,
            "on_unregister_menu_item_activate": self._unregister_item_clicked,
            "on_import_cert_menu_item_activate": self._import_cert_item_clicked,
            "on_view_facts_menu_item_activate": self._facts_item_clicked,
            "on_proxy_config_menu_item_activate": self._proxy_config_item_clicked,
            "on_redeem_menu_item_activate": self._redeem_item_clicked,
            "on_preferences_menu_item_activate": self._preferences_item_clicked,
            "on_about_menu_item_activate": self._about_item_clicked,
            "on_getting_started_menu_item_activate": self._getting_started_item_clicked,
            "on_online_docs_menu_item_activate": self._online_docs_item_clicked,
            "on_quit_menu_item_activate": gtk.main_quit,
        })

        def on_cert_change():
            # Update installed products
            self.installed_tab.update_products()
            self.installed_tab._set_validity_status()
            # Update attached subs
            self.my_subs_tab.update_subscriptions()
            # Update main window
            self.refresh()

        self.backend.cs.add_callback(on_cert_change)

        self.main_window.show_all()

        # Check to see if already registered to old RHN/Spacewalk
        # and show dialog if so
        self._check_rhn_classic()

        # Update everything with compliance data
        self.backend.cs.notify()

        if auto_launch_registration and not self.registered():
            self._register_item_clicked(None)