8000 Support Red Hat subscription-manager by opoplawski · Pull Request #3540 · cobbler/cobbler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support Red Hat subscription-manager #3540

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 7 additions & 1 deletion autoinstall_snippets/redhat_register
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# begin Red Hat management server registration
#if $redhat_management_key != ""
#if $redhat_management_user != "" and $redhat_management_password != ""
# Subscribe (register) the system with username/password
subscription-manager register --autosubscribe --username=$redhat_management_user --password=$redhat_management_password
#else if $redhat_management_key != "" and $redhat_management_org != ""
# Subscribe (register) the system with activationkey/org
subscription-manager register --insecure --activationkey=$redhat_management_key --org=$redhat_management_org --proxy=$proxy_url_ext
#else if $redhat_management_key != ""
mkdir -p /usr/share/rhn/
#set $endpoint = "https://%s/XMLRPC" % $redhat_management_server
rhnreg_ks --serverUrl=$endpoint --sslCACert=$mycert --activationkey=$redhat_management_key
Expand Down
1 change: 1 addition & 0 deletions changelog.d/3539.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow registering RedHat systems with either `redhat_management_org`/`redhat_management_key` or `redhat_management_user`/`redhat_management_password`
90 changes: 90 additions & 0 deletions cobbler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,36 @@
0,
"str",
],
[
"redhat_management_org",
"",
"",
"Redhat Management Organization",
True,
"Registration organization for Red Hat subscription-manager",
0,
"str",
],
[
"redhat_management_user",
"",
"",
"Redhat Management user",
True,
"Registration user for Red Hat subscription-manager",
0,
"str",
],
[
"redhat_management_password",
"",
"",
"Redhat Management Password",
True,
"Registration password for Red Hat subscription-manager",
0,
"str",
],
[
"template_files",
{},
Expand Down Expand Up @@ -636,6 +666,36 @@
0,
"str",
],
[
"redhat_management_org",
"<<inherit>>",
"<<inherit>>",
"Red Hat Management Organization",
True,
"Registration organization for Red Hat subscription-manager",
0,
"str",
],
[
"redhat_management_user",
"<<inherit>>",
"<<inherit>>",
"Red Hat Management User",
True,
"Registration user for Red Hat subscription-manager",
0,
"str",
],
[
"redhat_management_password",
"<<inherit>>",
"<<inherit>>",
"Red Hat Management Password",
True,
"Registration password for Red Hat subscription-manager",
0,
"str",
],
[
"repos",
[],
Expand Down Expand Up @@ -1122,6 +1182,36 @@
0,
"str",
],
[
"redhat_management_org",
"<<inherit>>",
0,
"Redhat Management Organization",
True,
"Registration organization for Red Hat subscription-manager",
0,
"str",
],
[
"redhat_management_user",
"<<inherit>>",
0,
"Redhat Management User",
True,
"Registration user for Red Hat subscription-manager",
0,
"str",
],
[
"redhat_management_password",
"<<inherit>>",
0,
"Redhat Management Password",
True,
"Registration password for Red Hat subscription-manager",
0,
"str",
],
[
"server",
"<<inherit>>",
Expand Down
86 changes: 84 additions & 2 deletions cobbler/items/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* Added:
* ``find_distro_path()``
* ``link_distro()``
* ``redhat_management_org``: enums.VALUE_INHERITED
* ``redhat_management_user``: enums.VALUE_INHERITED
* ``redhat_management_password``: enums.VALUE_INHERITED
* Changed:
* Constructor: ``kwargs`` can now be used to seed the item during creation.
* ``children``: The property was moved to the base class.
Expand Down Expand Up @@ -165,6 +168,9 @@
self._mgmt_classes = []
self._os_version = ""
self._redhat_management_key = enums.VALUE_INHERITED
self._redhat_management_org = enums.VALUE_INHERITED

Check notice on line 171 in cobbler/items/distro.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cobbler/items/distro.py#L171

Unused attribute '_redhat_management_org' (unused-attribute)
self._redhat_management_user = enums.VALUE_INHERITED

Check notice on line 172 in cobbler/items/distro.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cobbler/items/distro.py#L172

Unused attribute '_redhat_management_user' (unused-attribute)
self._redhat_management_password = enums.VALUE_INHERITED

Check notice on line 173 in cobbler/items/distro.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cobbler/items/distro.py#L173

Unused attribute '_redhat_management_password' (unused-attribute)
self._source_repos = []
self._remote_boot_kernel = ""
self._remote_grub_kernel = ""
Expand Down Expand Up @@ -588,8 +594,8 @@
@InheritableProperty
def redhat_management_key(self) -> str:
r"""
Get the redhat management key. This is probably only needed if you have spacewalk, uyuni or SUSE Manager
running.
Get the redhat management key. This is probably only needed if you have spacewalk, uyuni, or SUSE Manager
running. Or if you are registering via Red Hat subscription-manager.

.. note:: This property can be set to ``<<inherit>>``.

Expand All @@ -611,6 +617,82 @@
)
self._redhat_management_key = management_key

@InheritableProperty
def redhat_management_org(self) -> str:
r"""
Get the redhat management organization. This is only needed if you are registering via Red Hat
subscription-manager.

.. note:: This property can be set to ``<<inherit>>``.

:return: The organization as a string.
"""
return self._resolve("redhat_management_org")

@redhat_management_org.setter # type: ignore[no-redef]
def redhat_management_org(self, management_org: str):
"""
Set the redhat management organization. This is only needed if you are registering via Red Hat
subscription-manager.

:param management_org: The redhat management org.
"""
if not isinstance(management_org, str): # type: ignore
raise TypeError(
"Field redhat_management_org of object distro needs to be of type str!"
)
self._redhat_management_org = management_org

Check notice on line 644 in cobbler/items/distro.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cobbler/items/distro.py#L644

Unused attribute '_redhat_management_org' (unused-attribute)

@InheritableProperty
def redhat_management_user(self) -> str:
r"""
Get the redhat management user. This is only needed if you are registering via Red Hat
subscription-manager.

.. note:: This property can be set to ``<<inherit>>``.

:return: The user as a string.
"""
return self._resolve("redhat_management_user")

@redhat_management_user.setter # type: ignore[no-redef]
def redhat_management_user(self, management_user: str):
"""
Set the redhat management user. This is only needed if you are registering via Red Hat subscription-manager.

:param management_user: The redhat management user.
"""
if not isinstance(management_user, str): # type: ignore
raise TypeError(
"Field redhat_management_user of object distro needs to be of type str!"
)
self._redhat_management_user = management_user

Check notice on line 669 in cobbler/items/distro.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cobbler/items/distro.py#L669

Unused attribute '_redhat_management_user' (unused-attribute)

@InheritableProperty
def redhat_management_password(self) -> str:
r"""
Get the redhat management password. This is only needed if you are registering via Red Hat subscription-manager.

.. note:: This property can be set to ``<<inherit>>``.

:return: The password as a string.
"""
return self._resolve("redhat_management_password")

@redhat_management_password.setter # type: ignore[no-redef]
def redhat_management_password(self, management_password: str):
"""
Set the redhat management password. This is only needed if you are registering via Red Hat subscription-manager.
running.

:param management_password: The redhat management password.
"""
if not isinstance(management_password, str): # type: ignore
raise TypeError(
"Field redhat_management_password of object distro needs to be of type str!"
)
self._redhat_management_password = management_password

Check notice on line 694 in cobbler/items/distro.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

cobbler/items/distro.py#L694

Unused attribute '_redhat_management_password' (unused-attribute)

def find_distro_path(self):
r"""
This returns the absolute path to the distro under the ``distro_mirror`` directory. If that directory doesn't
Expand Down
84 changes: 84 additions & 0 deletions cobbler/items/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
* ``children``: The property was moved to the base class.
* ``parent``: The property was moved to the base class.
* ``from_dict()``: The method was moved to the base class.
* Added:
* ``redhat_management_org``: enums.VALUE_INHERITED
* ``redhat_management_user``: enums.VALUE_INHERITED
* ``redhat_management_password``: enums.VALUE_INHERITED
V3.3.4 (unreleased):
* No changes
V3.3.3:
Expand Down Expand Up @@ -206,6 +210,9 @@ def __init__(self, api: "CobblerAPI", *args: Any, **kwargs: Any) -> None:
self._filename = ""
self._proxy = enums.VALUE_INHERITED
self._redhat_management_key = enums.VALUE_INHERITED
self._redhat_management_org = enums.VALUE_INHERITED
self._redhat_management_user = enums.VALUE_INHERITED
self._redhat_management_password = enums.VALUE_INHERITED
self._repos: Union[List[str], str] = []
self._server = enums.VALUE_INHERITED
self._menu = ""
Expand Down Expand Up @@ -833,6 +840,83 @@ def redhat_management_key(self, management_key: str):
self._redhat_management_key = enums.VALUE_INHERITED
self._redhat_management_key = management_key

@InheritableProperty
def redhat_management_org(self) -> str:
"""
Getter of the redhat management organization of the profile or it's parent.

.. note:: This property can be set to ``<<inherit>>``.

:getter: Returns the redhat_management_org of the profile.
:setter: May raise a ``TypeError`` in case of a validation error.
"""
return self._resolve("redhat_management_org")

@redhat_management_org.setter # type: ignore[no-redef]
def redhat_management_org(self, management_org: str):
"""
Setter of the redhat management organization.

:param management_org: The value may be reset by setting it to None.
"""
if not isinstance(management_org, str): # type: ignore
raise TypeError("Field management_org of object profile is of type str!")
if not management_org:
self._redhat_management_org = enums.VALUE_INHERITED
self._redhat_management_org = management_org

@InheritableProperty
def redhat_management_user(self) -> str:
"""
Getter of the redhat management user of the profile or it's parent.

.. note:: This property can be set to ``<<inherit>>``.

:getter: Returns the redhat_management_user of the profile.
:setter: May raise a ``TypeError`` in case of a validation error.
"""
return self._resolve("redhat_management_user")

@redhat_management_user.setter # type: ignore[no-redef]
def redhat_management_user(self, management_user: str):
"""
Setter of the redhat management user.

:param management_user: The value may be reset by setting it to None.
"""
if not isinstance(management_user, str): # type: ignore
raise TypeError("Field management_user of object profile is of type str!")
if not management_user:
self._redhat_management_user = enums.VALUE_INHERITED
self._redhat_management_user = management_user

@InheritableProperty
def redhat_management_password(self) -> str:
"""
Getter of the redhat management password of the profile or it's parent.

.. note:: This property can be set to ``<<inherit>>``.

:getter: Returns the redhat_management_password of the profile.
:setter: May raise a ``TypeError`` in case of a validation error.
"""
return self._resolve("redhat_management_password")

@redhat_management_password.setter # type: ignore[no-redef]
def redhat_management_password(self, management_password: str):
"""
Setter of the redhat management password.

:param management_password: The value may be reset by setting it to None.
"""
if not isinstance(management_password, str): # type: ignore
raise TypeError(
"Field management_password of object profile is of type str!"
)
if not management_password:
self._redhat_management_password = enums.VALUE_INHERITED
self._redhat_management_password = management_password

@InheritableProperty
def boot_loaders(self) -> List[str]:
"""
Expand Down
Loading
Loading
0