Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove artifacts of removed commands #3476

Merged
merged 6 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions etc-conf/dbus/system.d/com.redhat.RHSM1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
<allow send_destination="com.redhat.RHSM1"
send_interface="com.redhat.RHSM1"/>

<allow send_destination="com.redhat.RHSM1"
send_interface="com.redhat.RHSM1.Attach"/>

<allow send_destination="com.redhat.RHSM1"
send_interface="com.redhat.RHSM1.Products"/>

Expand Down
6 changes: 0 additions & 6 deletions example-plugins/dbus_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,3 @@ def pre_subscribe_hook(self, conduit):

def post_subscribe_hook(self, conduit):
self._dbus_event("post_subscribe", conduit)

def pre_auto_attach_hook(self, conduit):
self._dbus_event("pre_auto_attach", conduit)

def post_auto_attach_hook(self, conduit):
self._dbus_event("post_auto_attach", conduit)
6 changes: 0 additions & 6 deletions example-plugins/subscribe.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,3 @@ def post_subscribe_hook(self, conduit):
conduit: A PostSubscriptionConduit()
"""
conduit.log.debug("post subscribe called")

def pre_auto_attach_hook(self, conduit):
conduit.log.debug("pre auto attach called")

def post_auto_attach_hook(self, conduit):
conduit.log.debug("post auto attach called")
2 changes: 1 addition & 1 deletion man/rhsm.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ daemon
.PP
splay
.RS 4
1 to enable splay. 0 to disable splay. If enabled, this feature delays the initial auto attach and cert check by an amount between 0 seconds and the interval given for the action being delayed. For example if the
1 to enable splay. 0 to disable splay. If enabled, this feature delays the initial cert check by an amount between 0 seconds and the interval given for the action being delayed. For example if the
.B certCheckInterval
were set to 3 minutes, the initial cert check would begin somewhere between 2 minutes after start up (minimum delay) and 5 minutes after start up. This is useful to reduce peak load on the Satellite or entitlement service used by a large number of machines.
.RE
Expand Down
6 changes: 0 additions & 6 deletions src/plugins/libdnf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,6 @@ To use testing repository you have to do several steps:
subscription-manager register --username admin --password admin --org admin
```

* Attach some subscription:

```
subscription-manager attach --pool <pool_id>
```

* Choose some repository from output of `subscription-manager repos --list` and
enable the repository:

Expand Down
73 changes: 0 additions & 73 deletions src/rhsm/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1903,63 +1903,6 @@ def getAccessibleContent(self, consumerId: str, if_modified_since: datetime.date
method, headers=headers, description=_("Fetching content for a certificate")
)

def bindByEntitlementPool(self, consumerId: str, poolId: str, quantity: int = None) -> List[dict]:
"""
Subscribe consumer to a subscription by pool ID
:param consumerId: consumer UUID
:param poolId: pool ID
:param quantity: the desired quantity of subscription to be consumed
"""
method = "/consumers/%s/entitlements?pool=%s" % (self.sanitize(consumerId), self.sanitize(poolId))
if quantity:
method = "%s&quantity=%s" % (method, quantity)
return self.conn.request_post(method, description=_("Updating subscriptions"))

def bind(self, consumerId: str, entitle_date: datetime.datetime = None) -> List[dict]:
"""
Same as bindByProduct, but assume the server has a list of the
system's products. This is useful for autosubscribe. Note that this is
done on a best-effort basis, and there are cases when the server will
not be able to fulfill the client's product certs with entitlements
:param consumerId: consumer UUID
:param entitle_date: The date, when subscription will be valid
"""
method = "/consumers/%s/entitlements" % (self.sanitize(consumerId))

# add the optional date to the url
if entitle_date:
method = "%s?entitle_date=%s" % (method, self.sanitize(entitle_date.isoformat(), plus=True))

return self.conn.request_post(method, description=_("Updating subscriptions"))

def unbindBySerial(self, consumerId: str, serial: str) -> bool:
"""
Try to remove consumed pool by serial number
:param consumerId: consumer UUID
:param serial: serial number of consumed pool
"""
method = "/consumers/%s/certificates/%s" % (self.sanitize(consumerId), self.sanitize(str(serial)))
return self.conn.request_delete(method, description=_("Unsubscribing")) is None

def unbindByPoolId(self, consumer_uuid: str, pool_id: str) -> bool:
"""
Try to remove consumed pool by pool ID
:param consumer_uuid: consumer UUID
:param pool_id: pool ID
:return: None
"""
method = "/consumers/%s/entitlements/pool/%s" % (self.sanitize(consumer_uuid), self.sanitize(pool_id))
return self.conn.request_delete(method, description=_("Unsubscribing")) is None

def unbindAll(self, consumerId: str) -> dict:
"""
Try to remove all consumed pools
:param consumerId: consumer UUID
:return: Dictionary containing statistics about removed pools
"""
method = "/consumers/%s/entitlements" % self.sanitize(consumerId)
return self.conn.request_delete(method, description=_("Unsubscribing"))

def getPoolsList(
self,
consumer: str = None,
Expand Down Expand Up @@ -2152,22 +2095,6 @@ def deleteContentOverrides(self, consumerId: str, params: List[dict] = None) ->
params = []
return self.conn.request_delete(method, params, description=_("Removing content overrides"))

def activateMachine(self, consumerId: str, email: str, lang: str = None) -> Union[dict, None]:
"""
Activate a subscription by machine, information is located in the consumer facts
:param consumerId: consumer UUID
:param email: The email for sending notification. The notification will be sent by candlepin server
:param lang: The locale specifies the language of notification email
:return When activation was successful, then dictionary is returned. Otherwise, None is returned.
"""
method = "/subscriptions?consumer_uuid=%s" % consumerId
method += "&email=%s" % self.sanitize(email)
if (not lang) and (locale.getdefaultlocale()[0] is not None):
lang = locale.getdefaultlocale()[0].lower().replace("_", "-")
if lang:
method += "&email_locale=%s" % self.sanitize(lang)
return self.conn.request_post(method, description=_("Activating"))

# used by virt-who
def getJob(self, job_id: str) -> str:
"""
Expand Down
2 changes: 1 addition & 1 deletion src/rhsmlib/client_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""
This module holds information about current state of client application
like sender of D-bus method, current subscription-manager command (register,
ptoscano marked this conversation as resolved.
Show resolved Hide resolved
attach, ...), dnf command, etc.
status...), dnf command, etc.
"""

import logging
Expand Down
5 changes: 0 additions & 5 deletions src/rhsmlib/dbus/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"UNREGISTER_DBUS_PATH",
"CONFIG_INTERFACE",
"CONFIG_DBUS_PATH",
"ATTACH_INTERFACE",
"ATTACH_DBUS_PATH",
"PRODUCTS_INTERFACE",
"PRODUCTS_DBUS_PATH",
"ENTITLEMENT_INTERFACE",
Expand Down Expand Up @@ -69,9 +67,6 @@
CONFIG_INTERFACE = "%s.%s" % (INTERFACE_BASE, "Config")
CONFIG_DBUS_PATH = "%s/%s" % (ROOT_DBUS_PATH, "Config")

ATTACH_INTERFACE = "%s.%s" % (INTERFACE_BASE, "Attach")
ATTACH_DBUS_PATH = "%s/%s" % (ROOT_DBUS_PATH, "Attach")

PRODUCTS_INTERFACE = "%s.%s" % (INTERFACE_BASE, "Products")
PRODUCTS_DBUS_PATH = "%s/%s" % (ROOT_DBUS_PATH, "Products")

Expand Down
104 changes: 1 addition & 103 deletions src/rhsmlib/dbus/objects/entitlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
import datetime
from typing import List, Union
from typing import Union

import dbus
import json
Expand Down Expand Up @@ -65,35 +65,6 @@ def get_pools(self, options: dict, proxy_options: dict) -> dict:

return pools

def remove_all_entitlements(self, proxy_options: dict) -> dict:
uep: UEPConnection = self.build_uep(proxy_options, proxy_only=True)
service = EntitlementService(uep)
result: dict = service.remove_all_entitlements()

return result

def remove_entitlements_by_pool_ids(self, pool_ids: List[str], proxy_options: dict) -> List[str]:
"""Remove entitlements by Pool IDs

:return: List of removed serials.
"""
uep: UEPConnection = self.build_uep(proxy_options, proxy_only=True)
service = EntitlementService(uep)
_, _, removed_serials = service.remove_entitlements_by_pool_ids(pool_ids)

return removed_serials

def remove_entitlements_by_serials(self, serials: List[str], proxy_options: dict) -> List[str]:
"""Remove entitlements by serials.

:return: List of removed serials.
"""
uep: UEPConnection = self.build_uep(proxy_options, proxy_only=True)
service = EntitlementService(uep)
removed_serials, _ = service.remove_entitlements_by_serials(serials)

return removed_serials

def _parse_date(self, date_string: str) -> datetime.datetime:
"""
Return new datetime parsed from date.
Expand Down Expand Up @@ -187,79 +158,6 @@ def GetPools(self, options, proxy_options, locale, sender=None):
pools: dict = self.impl.get_pools(options, proxy_options)
return json.dumps(pools)

@util.dbus_service_method(
constants.ENTITLEMENT_INTERFACE,
in_signature="a{sv}s",
out_signature="s",
)
@util.dbus_handle_sender
@util.dbus_handle_exceptions
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)
locale = dbus_utils.dbus_to_python(locale, expected_type=str)

Locale.set(locale)

result: dict = self.impl.remove_all_entitlements(proxy_options)
return json.dumps(result)

@util.dbus_service_method(
constants.ENTITLEMENT_INTERFACE,
in_signature="asa{sv}s",
out_signature="s",
)
@util.dbus_handle_sender
@util.dbus_handle_exceptions
def RemoveEntitlementsByPoolIds(self, pool_ids, proxy_options, locale, sender=None):
"""
Try to remove entitlements (subscriptions) by pool_ids
:param pool_ids: List of pool IDs
: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
"""
pool_ids = dbus_utils.dbus_to_python(pool_ids, 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)

removed_serials = self.impl.remove_entitlements_by_pool_ids(pool_ids, proxy_options)
return json.dumps(removed_serials)

@util.dbus_service_method(
constants.ENTITLEMENT_INTERFACE,
in_signature="asa{sv}s",
out_signature="s",
)
@util.dbus_handle_sender
@util.dbus_handle_exceptions
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)

removed_serials = self.impl.remove_entitlements_by_serials(serials, proxy_options)
return json.dumps(removed_serials)

@staticmethod
def reload():
entitlement_service = EntitlementService()
Expand Down
73 changes: 1 addition & 72 deletions src/rhsmlib/services/entitlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import datetime
import logging
import time
from typing import Union, Callable
from typing import Union

from subscription_manager import injection as inj
from subscription_manager.i18n import ugettext as _
Expand Down Expand Up @@ -518,77 +518,6 @@ def validate_options(self, options: dict) -> None:
elif not self.identity.is_valid() and "available" in options["pool_subsets"]:
raise exceptions.ValidationError(_("Error: this system is not registered"))

def _unbind_ids(self, unbind_method: Callable, consumer_uuid: str, ids: list) -> tuple:
"""
Method for unbinding entitlements
:param unbind_method: unbindByPoolId or unbindBySerial
:param consumer_uuid: UUID of consumer
:param ids: List of serials or pool_ids
:return: Tuple of two lists containing unbinded and not-unbinded subscriptions
"""
success = []
failure = []
for id_ in ids:
try:
unbind_method(consumer_uuid, id_)
success.append(id_)
except connection.RestlibException as re:
if re.code == 410:
raise
failure.append(id_)
log.error(re)
return success, failure

def remove_all_entitlements(self) -> dict:
"""
Try to remove all entitlements
:return: Result of REST API call
"""

response = self.cp.unbindAll(self.identity.uuid)
self.entcertlib.update()

return response

def remove_entitlements_by_pool_ids(self, pool_ids: list) -> tuple:
"""
Try to remove entitlements by pool IDs
:param pool_ids: List of pool IDs
:return: List of serial numbers of removed subscriptions
"""

removed_serials = []
_pool_ids = utils.unique_list_items(pool_ids) # Don't allow duplicates
# FIXME: the cache of CertificateDirectory should be smart enough and refreshing
# should not be necessary. I vote for i-notify to be used there somehow.
self.entitlement_dir.refresh()
pool_id_to_serials = self.entitlement_dir.list_serials_for_pool_ids(_pool_ids)
removed_pools, unremoved_pools = self._unbind_ids(
self.cp.unbindByPoolId, self.identity.uuid, _pool_ids
)
if removed_pools:
for pool_id in removed_pools:
removed_serials.extend(pool_id_to_serials[pool_id])
self.entcertlib.update()

return removed_pools, unremoved_pools, removed_serials

def remove_entitlements_by_serials(self, serials: list) -> tuple:
"""
Try to remove pools by Serial numbers
:param serials: List of serial numbers
:return: Tuple of two items: list of serial numbers of already removed subscriptions and list
of not removed serials
"""

_serials = utils.unique_list_items(serials) # Don't allow duplicates
removed_serials, unremoved_serials = self._unbind_ids(
self.cp.unbindBySerial, self.identity.uuid, _serials
)
self.entcertlib.update()

return removed_serials, unremoved_serials

@staticmethod
def reload() -> None:
"""
Expand Down
3 changes: 1 addition & 2 deletions src/subscription_manager/action_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def _get_libset(self) -> List["BaseActionInvoker"]:
self.syspurposelib = SyspurposeSyncActionInvoker()

# WARNING: order is important here, we need to update a number
# of things before attempting to autoheal, and we need to autoheal
# before attempting to fetch our certificates:
# of things before attempting to fetch our certificates:
lib_set: List[BaseActionInvoker] = [
self.entcertlib,
self.idcertlib,
Expand Down
Loading
Loading