def GetOrgs(self, username, password, connection_options, locale): """ This method tries to return list of organization user belongs to. This method also uses basic authentication method (using username and password). :param username: string with username used for connection to candlepin server :param password: string with password :param connection_options: dictionary with connection options :param locale: string with locale :return: string with json returned by candlepin server """ connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) connection_options['username'] = dbus_utils.dbus_to_python( username, expected_type=str) connection_options['password'] = dbus_utils.dbus_to_python( password, expected_type=str) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(connection_options, basic_auth_method=True) owners = cp.getOwnerList(connection_options['username']) return json.dumps(owners)
def PoolAttach(self, pools, quantity, proxy_options, locale, sender=None): self.ensure_registered() pools = dbus_utils.dbus_to_python(pools, expected_type=list) quantity = dbus_utils.dbus_to_python(quantity, expected_type=int) proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) if quantity < 1: raise dbus.DBusException("Quantity must be a positive number.") cp = self.build_uep(proxy_options, proxy_only=True) attach_service = AttachService(cp) try: results = [] for pool in pools: resp = attach_service.attach_pool(pool, quantity) results.append(json.dumps(resp)) except Exception as e: log.exception(e) raise dbus.DBusException(str(e)) # TODO Likely should only call this if something is actually attached entcertlib.EntCertActionInvoker().update() return results
def RegisterWithActivationKeys(self, org, activation_keys, options, connection_options, locale): """ Note this method is registration ONLY. Auto-attach is a separate process. """ connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) options = dbus_utils.dbus_to_python(options, expected_type=dict) options["activation_keys"] = dbus_utils.dbus_to_python( activation_keys, expected_type=list) org = dbus_utils.dbus_to_python(org, expected_type=str) locale = dbus_utils.dbus_to_python(locale, expected_type=str) with DBusSender() as dbus_sender: dbus_sender.set_cmd_line(sender=self.sender, cmd_line=self.cmd_line) Locale.set(locale) cp = self.build_uep(connection_options) register_service = RegisterService(cp) consumer = register_service.register(org, **options) log.debug("System registered, updating entitlements if needed") ent_cert_lib = EntCertActionInvoker() ent_cert_lib.update() dbus_sender.reset_cmd_line() return json.dumps(consumer)
def ListInstalledProducts(self, filter_string, proxy_options, locale, sender=None): # We reinitialize dependency injection here for following reason. When new product # certificate is installed (or existing is removed), then this change is not propagated to # CertSorter and other caches. Calling installed_products.list(filter_string) without # reinitialization of dependency injection would return old (cached) list of installed # products. init_dep_injection() filter_string = dbus_utils.dbus_to_python(filter_string, expected_type=str) proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(proxy_options, proxy_only=True) installed_products = InstalledProducts(cp) try: response = installed_products.list(filter_string) except Exception as err: raise dbus.DBusException(str(err)) return json.dumps(response)
def AutoAttach(self, service_level, proxy_options, locale, sender=None): self.ensure_registered() service_level = dbus_utils.dbus_to_python(service_level, expected_type=str) or None proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(proxy_options, proxy_only=True) # TODO: Change log.info() to: # raise dbus.DBusException('Auto-attaching is not allowed in simple content access mode') # in the next minor release of subscription-manager if is_simple_content_access(uep=cp) is True: log.info( "Calling D-Bus method AutoAttach() is deprecated, when Simple Content Access mode " "is used and it will be not be supported in the next minor release of " "subscription-manager") attach_service = AttachService(cp) try: resp = attach_service.attach_auto(service_level) except Exception as e: log.exception(e) raise dbus.DBusException(str(e)) # TODO Likely should only call this if something is actually attached entcertlib.EntCertActionInvoker().update() return json.dumps(resp)
def Unregister(self, proxy_options, locale, sender=None): """ Definition and implementation of D-Bus method :param proxy_options: Definition of proxy settings :param locale: String with locale (e.g. de_DE.UTF-8) :param sender: Not used argument """ proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) self.ensure_registered() uep = self.build_uep(proxy_options, proxy_only=True) try: UnregisterService(uep).unregister() except Exception as err: raise dbus.DBusException(str(err)) # The system is unregistered now, restart virt-who to stop sending # host-to-guest mapping. restart_virt_who()
def Register(self, org, username, password, options, connection_options, locale): """ This method registers the system using basic auth (username and password for a given org). For any option that is required but not included the default will be used. Options is a dict of strings that modify the outcome of this method. Note this method is registration ONLY. Auto-attach is a separate process. """ if self.is_registered(): raise dbus.DBusException("This system is already registered") org = dbus_utils.dbus_to_python(org, expected_type=str) connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) connection_options['username'] = dbus_utils.dbus_to_python( username, expected_type=str) connection_options['password'] = dbus_utils.dbus_to_python( password, expected_type=str) options = dbus_utils.dbus_to_python(options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(connection_options) register_service = RegisterService(cp) consumer = register_service.register(org, **options) return json.dumps(consumer)
def GetStatus(self, on_date, locale, sender=None): """ Get status of entitlements :param on_date: Date :param locale: String with locale (e.g. de_DE.UTF-8) :param sender: Not used argument :return: String with JSON dump """ on_date = dbus_utils.dbus_to_python(on_date, expected_type=str) locale = dbus_utils.dbus_to_python(locale, expected_type=str) if on_date == "": on_date = None else: on_date = self._parse_date(on_date) Locale.set(locale) try: # get_status doesn't need a Candlepin connection status = EntitlementService(None).get_status(on_date) except Exception as e: log.exception(e) raise dbus.DBusException(str(e)) return json.dumps(status)
def RemoveEntitlementsBySerials(self, serials, proxy_options, locale, sender=None): """ Try to remove entitlements (subscriptions) by serials :param serials: List of serial numbers of subscriptions :param proxy_options: Settings of proxy :param locale: String with locale (e.g. de_DE.UTF-8) :param sender: Not used argument :return: Json string representing list of serial numbers """ serials = dbus_utils.dbus_to_python(serials, expected_type=list) proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(proxy_options, proxy_only=True) entitlement_service = EntitlementService(cp) removed_serials, unremoved_serials = entitlement_service.remove_entitlements_by_serials( serials) return json.dumps(removed_serials)
def GetPools(self, options, proxy_options, locale, sender=None): """ Try to get pools installed/available/consumed at this system :param options: D-Bus object storing options of query :param proxy_options: D-Bus object with proxy configuration :param locale: String with locale (e.g. de_DE.UTF-8) :param sender: Not used argument :return: String with JSON dump """ options = dbus_utils.dbus_to_python(options, expected_type=dict) proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) on_date = options.setdefault('on_date', "") if on_date != "": options['on_date'] = self._parse_date(on_date) after_date = options.setdefault("after_date", "") if after_date != "": options["after_date"] = self._parse_date(after_date) future = options.setdefault("future", "") if future != "": options["future"] = future cp = self.build_uep(proxy_options, proxy_only=True) entitlement_service = EntitlementService(cp) pools = entitlement_service.get_pools(**options) return json.dumps(pools)
def SetSyspurpose(self, syspurpose_values, locale, sender): """ Set syspurpose values :param syspurpose_values: Dictionary with all syspurpose values :param locale: String with locale :param sender: Object representing client application that called this method :return: String with successfully set syspurpose values """ syspurpose_values = dbus_utils.dbus_to_python(syspurpose_values, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep({}) system_purpose = syspurpose.Syspurpose(cp) new_syspurpose_values = system_purpose.set_syspurpose_values( syspurpose_values) # Check if there was any conflict during three-way merge conflicts = {} for key, value in new_syspurpose_values.items(): if key in syspurpose_values and syspurpose_values[key] != value: conflicts[key] = value if len(conflicts) > 0: raise ThreeWayMergeConflict(conflict_fields=conflicts) return json.dumps(new_syspurpose_values)
def Register(self, org, username, password, options, connection_options, locale): """ This method registers the system using basic auth (username and password for a given org). For any option that is required but not included the default will be used. Options is a dict of strings that modify the outcome of this method. Note this method is registration ONLY. Auto-attach is a separate process. """ if self.is_registered(): raise dbus.DBusException("This system is already registered") org = dbus_utils.dbus_to_python(org, expected_type=str) connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) connection_options['username'] = dbus_utils.dbus_to_python(username, expected_type=str) connection_options['password'] = dbus_utils.dbus_to_python(password, expected_type=str) options = dbus_utils.dbus_to_python(options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(connection_options) register_service = RegisterService(cp) consumer = register_service.register(org, **options) return json.dumps(consumer)
def Get(self, property_name, locale, sender=None): locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) section, _dot, property_name = property_name.partition('.') if property_name: return self.config[section][property_name] else: return dbus.Dictionary(self.config[section], signature='sv')
def GetAll(self, locale, sender=None): locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) d = dbus.Dictionary({}, signature='sv') for k, v in six.iteritems(self.config): d[k] = dbus.Dictionary({}, signature='ss') for kk, vv in six.iteritems(v): d[k][kk] = vv return d
def Stop(self, locale, sender=None): locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) with self.lock: if self.server: self.server.shutdown() self.server = None log.debug("Stopped DomainSocketServer") return True else: raise exceptions.Failed("No domain socket server is running")
def GetOrg(self, locale, sender=None): """ D-Bus method for getting current organization (owner) :param locale: string with locale :param sender: not used :return: """ locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) org = get_current_owner() return json.dumps(org)
def GetSyspurposeStatus(self, locale, sender=None): """ D-Bus method for getting system purpose status :param locale: string representing locale :param sender: object representing application which called this method :return: """ locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep({}) system_purpose = syspurpose.Syspurpose(cp) syspurpose_status = system_purpose.get_syspurpose_status()["status"] return system_purpose.get_overall_status(syspurpose_status)
def Set(self, property_name, new_value, locale, sender=None): property_name = dbus_utils.dbus_to_python(property_name, expected_type=str) new_value = dbus_utils.dbus_to_python(new_value, expected_type=str) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) section, _dot, property_name = property_name.partition('.') if not property_name: raise DBusException("Setting an entire section is not supported. Use 'section.property' format.") self.config[section][property_name] = new_value self.config.persist()
def Start(self, locale, sender=None): locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) with self.lock: if self.server: return self.server.address log.debug('Attempting to create new domain socket server') self.server = server.DomainSocketServer( object_classes=[DomainSocketRegisterDBusObject], ) address = self.server.run() log.debug('DomainSocketServer created and listening on "%s"', address) return address
def RemoveAllEntitlements(self, proxy_options, locale, sender=None): """ Try to remove all entitlements (subscriptions) from the system :param proxy_options: Settings of proxy :param locale: String with locale (e.g. de_DE.UTF-8) :param sender: Not used argument :return: Json string containing response """ proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) cp = self.build_uep(proxy_options, proxy_only=True) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) entitlement_service = EntitlementService(cp) result = entitlement_service.remove_all_entitlements() return json.dumps(result)
def RegisterWithActivationKeys(self, org, activation_keys, options, connection_options, locale): """ Note this method is registration ONLY. Auto-attach is a separate process. """ connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) options = dbus_utils.dbus_to_python(options, expected_type=dict) options['activation_keys'] = dbus_utils.dbus_to_python(activation_keys, expected_type=list) org = dbus_utils.dbus_to_python(org, expected_type=str) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(connection_options) register_service = RegisterService(cp) consumer = register_service.register(org, **options) return json.dumps(consumer)
def Set(self, property_name, new_value, locale, sender=None): property_name = dbus_utils.dbus_to_python(property_name, expected_type=str) new_value = dbus_utils.dbus_to_python(new_value, expected_type=str) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) section, _dot, property_name = property_name.partition('.') if not property_name: raise DBusException( "Setting an entire section is not supported. Use 'section.property' format." ) self.config[section][property_name] = new_value self.config.persist()
def Register(self, org, username, password, options, connection_options, locale): """ This method registers the system using basic auth (username and password for a given org). For any option that is required but not included the default will be used. Options is a dict of strings that modify the outcome of this method. Note this method is registration ONLY. Auto-attach is a separate process. """ if self.is_registered(): raise dbus.DBusException("This system is already registered") org = dbus_utils.dbus_to_python(org, expected_type=str) connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) connection_options['username'] = dbus_utils.dbus_to_python( username, expected_type=str) connection_options['password'] = dbus_utils.dbus_to_python( password, expected_type=str) options = dbus_utils.dbus_to_python(options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(connection_options) register_service = RegisterService(cp) # Try to get organization from the list available organizations, when the list contains # only one item, then register_service.determine_owner_key will return this organization if not org: org = register_service.determine_owner_key( username=connection_options['username'], get_owner_cb=self._get_owner_cb, no_owner_cb=self._no_owner_cb) # When there is more organizations, then signal was triggered in callback method # _get_owner_cb, but some exception has to be raised here to not try registration process if not org: raise OrgNotSpecifiedException( username=connection_options['username']) consumer = register_service.register(org, **options) return json.dumps(consumer)
def GetAll(self, locale, sender=None): """ Method for getting whole configuration :param locale: string with locale :param sender: not used :return: D-bus dictionary with configuration """ locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) d = dbus.Dictionary({}, signature="sv") for k, v in self.config.items(): d[k] = dbus.Dictionary({}, signature="ss") for kk, vv in v.items(): d[k][kk] = vv return d
def Set(self, property_name, new_value, locale, sender=None): """ Method used for setting only one value. When more than one value is going to be set, then it is strongly recomended to use method SetAll(), because configuration is saved to the configuration file at the end of method Set() :param property_name: string with property e.g. server.hostname :param new_value: string with new value :param locale: string with locale :param sender: not used :return: None """ property_name = dbus_utils.dbus_to_python(property_name, expected_type=str) new_value = dbus_utils.dbus_to_python(new_value, expected_type=str) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) section, _dot, property_name = property_name.partition(".") if not property_name: raise DBusException( "Setting an entire section is not supported. Use 'section.property' format." ) self.config[section][property_name] = new_value if section == "logging": logging_changed = True else: logging_changed = False # Try to temporary disable dir watcher, because 'self.config.persist()' writes configuration # file and it would trigger file system monitor callback function and saved values would be # read again. It can cause race conditions, when Set() is called multiple times Server.temporary_disable_dir_watchers({CONFIG_WATCHER}) # Write new config value to configuration file self.config.persist() Server.enable_dir_watchers({CONFIG_WATCHER}) # When anything in logging section was just chnaged, then we have to re-initialize logger if logging_changed is True: parser = rhsm.config.get_config_parser() self.config = Config(parser) rhsm.logutil.init_logger(parser)
def SetAll(self, configuration, locale, sender=None): """ Method for setting multiple configuration options. Of course all of them could be set. :param configuration: d-bus dictionary with configuration. Keys have to include section. e.g. server.hostname. Configuration file is saved to the file at the end of method. :param locale: string with locale :param sender: not used :return: None """ configuration = dbus_utils.dbus_to_python(configuration, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) log.debug("Setting new configuration values: %s" % str(configuration)) logging_changed = False for property_name, new_value in configuration.items(): section_name, _dot, property_name = property_name.partition(".") if not property_name: raise DBusException( "Setting an entire section is not supported. Use 'section.property' format." ) self.config[section_name][property_name] = new_value if section_name == "logging": logging_changed = True # Try to temporary disable dir watcher, because 'self.config.persist()' writes configuration # file and it would trigger file system monitor callback function and saved values would be # read again. It can cause race conditions, when SetAll() is called multiple times Server.temporary_disable_dir_watchers({CONFIG_WATCHER}) # Write new config value to configuration file self.config.persist() Server.enable_dir_watchers({CONFIG_WATCHER}) # When anything in logging section was just changed, then we have to re-initialize logger if logging_changed is True: parser = rhsm.config.get_config_parser() self.config = Config(parser) rhsm.logutil.init_logger(parser)
def Get(self, property_name, locale, sender=None): """ D-Bus method for getting one configuration property or one section :param property_name: string with name of property e.g. server.hostname or section e.g. server :param locale: string with locale :param sender: not used :return: string with value of property or dictionary with dictionary of one section """ locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) section, _dot, property_name = property_name.partition(".") if property_name: return self.config[section][property_name] else: return dbus.Dictionary(self.config[section], signature="sv")
def GetUuid(self, locale, sender=None): """ D-Bus method for getting current consumer UUID :param locale: string with locale :param sender: :return: string with UUID """ locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) consumer = Consumer() try: uuid = consumer.get_consumer_uuid() except Exception as err: raise dbus.DBusException(str(err)) return str(uuid)
def Start(self, locale, sender=None): locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) with self.lock: if self.server: return self.server.address log.debug("Attempting to create new domain socket server") cmd_line = DBusSender.get_cmd_line(sender) self.server = server.DomainSocketServer( object_classes=[DomainSocketRegisterDBusObject], sender=sender, cmd_line=cmd_line) address = self.server.run() log.debug( 'DomainSocketServer for sender %s created and listening on "%s"' % (sender, address)) return address
def RegisterWithActivationKeys(self, org, activation_keys, options, connection_options, locale): """ Note this method is registration ONLY. Auto-attach is a separate process. """ connection_options = dbus_utils.dbus_to_python(connection_options, expected_type=dict) options = dbus_utils.dbus_to_python(options, expected_type=dict) options['activation_keys'] = dbus_utils.dbus_to_python( activation_keys, expected_type=list) org = dbus_utils.dbus_to_python(org, expected_type=str) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(connection_options) register_service = RegisterService(cp) consumer = register_service.register(org, **options) return json.dumps(consumer)
def AutoAttach(self, service_level, proxy_options, locale, sender=None): self.ensure_registered() service_level = dbus_utils.dbus_to_python(service_level, expected_type=str) or None proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(proxy_options, proxy_only=True) attach_service = AttachService(cp) try: resp = attach_service.attach_auto(service_level) except Exception as e: log.exception(e) raise dbus.DBusException(str(e)) # TODO Likely should only call this if something is actually attached entcertlib.EntCertActionInvoker().update() return json.dumps(resp)
def GetSyspurpose(self, locale, sender=None): """ D-Bus method for getting current system purpose :param locale: string with locale :param sender: :return: json representation of system purpose contents """ syspurpose_path = "/etc/rhsm/syspurpose/syspurpose.json" locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) syspurpose_store = SyspurposeStore.read(syspurpose_path) try: contents = syspurpose_store.contents except Exception as err: raise dbus.DBusException(str(err)) return json.dumps(contents)
def RemoveEntitlementsBySerials(self, serials, proxy_options, locale, sender=None): """ Try to remove entitlements (subscriptions) by serials :param serials: List of serial numbers of subscriptions :param proxy_options: Settings of proxy :param locale: String with locale (e.g. de_DE.UTF-8) :param sender: Not used argument :return: Json string representing list of serial numbers """ serials = dbus_utils.dbus_to_python(serials, expected_type=list) proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(proxy_options, proxy_only=True) entitlement_service = EntitlementService(cp) removed_serials, unremoved_serials = entitlement_service.remove_entitlements_by_serials(serials) return json.dumps(removed_serials)
def GetSyspurpose(self, locale, sender=None): """ D-Bus method for getting current system purpose :param locale: string with locale :param sender: :return: json representation of system purpose contents """ syspurpose_path = '/etc/rhsm/syspurpose/syspurpose.json' locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) syspurpose_store = SyspurposeStore.read(syspurpose_path) try: contents = syspurpose_store.contents except Exception as err: raise dbus.DBusException(str(err)) return json.dumps(contents)
def AutoAttach(self, service_level, proxy_options, locale, sender=None): self.ensure_registered() service_level = dbus_utils.dbus_to_python(service_level, expected_type=str) proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) cp = self.build_uep(proxy_options, proxy_only=True) attach_service = AttachService(cp) try: resp = attach_service.attach_auto(service_level) except Exception as e: log.exception(e) raise dbus.DBusException(str(e)) # TODO Likely should only call this if something is actually attached entcertlib.EntCertActionInvoker().update() return json.dumps(resp)
def PoolAttach(self, pools, quantity, proxy_options, locale, sender=None): self.ensure_registered() pools = dbus_utils.dbus_to_python(pools, expected_type=list) quantity = dbus_utils.dbus_to_python(quantity, expected_type=int) proxy_options = dbus_utils.dbus_to_python(proxy_options, expected_type=dict) locale = dbus_utils.dbus_to_python(locale, expected_type=str) Locale.set(locale) if quantity < 1: raise dbus.DBusException("Quantity must be a positive number.") cp = self.build_uep(proxy_options, proxy_only=True) # TODO: Change log.info() to: # raise dbus.DBusException('Attaching of pool(s) is not allowed in simple content access mode') # in the next minor release of subscription-manager if is_simple_content_access(uep=cp) is True: log.info( "Calling D-Bus method PoolAttach() is deprecated, when Simple Content Access mode " "is used and it will be not be supported in the next minor release of " "subscription-manager") attach_service = AttachService(cp) try: results = [] for pool in pools: resp = attach_service.attach_pool(pool, quantity) results.append(json.dumps(resp)) except Exception as e: log.exception(e) raise dbus.DBusException(str(e)) # TODO Likely should only call this if something is actually attached entcertlib.EntCertActionInvoker().update() return results