Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
324a943e
Commit
324a943e
authored
Mar 18, 2014
by
James Tanner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #6548 correct issues from rhn_register refactoring
parent
8899c74a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
+19
-13
library/packaging/rhn_register
+19
-13
No files found.
library/packaging/rhn_register
View file @
324a943e
...
@@ -84,10 +84,14 @@ try:
...
@@ -84,10 +84,14 @@ try:
except
ImportError
,
e
:
except
ImportError
,
e
:
module
.
fail_json
(
msg
=
"Unable to import up2date_client. Is 'rhn-client-tools' installed?
\n
%s"
%
e
)
module
.
fail_json
(
msg
=
"Unable to import up2date_client. Is 'rhn-client-tools' installed?
\n
%s"
%
e
)
# INSERT REDHAT SNIPPETS
from
ansible
.
module_utils
.
redhat
import
*
# INSERT COMMON SNIPPETS
from
ansible
.
module_utils
.
basic
import
*
class
Rhn
(
RegistrationBase
)
:
class
Rhn
(
RegistrationBase
)
:
def
__init__
(
self
,
module
,
username
=
None
,
password
=
None
)
:
def
__init__
(
self
,
username
=
None
,
password
=
None
)
:
RegistrationBase
.
__init__
(
self
,
username
,
password
)
RegistrationBase
.
__init__
(
self
,
username
,
password
)
self
.
config
=
self
.
load_config
()
self
.
config
=
self
.
load_config
()
...
@@ -193,21 +197,26 @@ class Rhn(RegistrationBase):
...
@@ -193,21 +197,26 @@ class Rhn(RegistrationBase):
Register
system
to
RHN
.
If
enable_eus
=
True
,
extended
update
Register
system
to
RHN
.
If
enable_eus
=
True
,
extended
update
support
will
be
requested
.
support
will
be
requested
.
'''
'''
register_cmd
=
"/usr/sbin/rhnreg_ks --username '%s' --password '%s' --force"
%
(
self
.
username
,
self
.
password
)
register_cmd
=
"/usr/sbin/rhnreg_ks --username='%s' --password='%s' --force"
%
(
self
.
username
,
self
.
password
)
if
self
.
module
.
params
.
get
(
'
server_url
'
,
None
)
:
register_cmd
+=
" --serverUrl=%s"
%
self
.
module
.
params
.
get
(
'
server_url
'
)
if
enable_eus
:
if
enable_eus
:
register_cmd
+=
" --use-eus-channel"
register_cmd
+=
" --use-eus-channel"
if
activationkey
is
not
None
:
if
activationkey
is
not
None
:
register_cmd
+=
" --activationkey '%s'"
%
activationkey
register_cmd
+=
" --activationkey '%s'"
%
activationkey
# FIXME - support --profilename
# FIXME - support --profilename
# FIXME - support --systemorgid
# FIXME - support --systemorgid
rc
,
stdout
,
stderr
=
self
.
module
.
run_command
(
register_c
ommand
,
check_rc
=
True
)
rc
,
stdout
,
stderr
=
self
.
module
.
run_command
(
register_c
md
,
check_rc
=
True
,
use_unsafe_shell
=
True
)
def
api
(
self
,
method
,
*
args
)
:
def
api
(
self
,
method
,
*
args
)
:
'''
'''
Convenience
RPC
wrapper
Convenience
RPC
wrapper
'''
'''
if
not
hasattr
(
self
,
'
server
'
)
or
self
.
server
is
None
:
if
not
hasattr
(
self
,
'
server
'
)
or
self
.
server
is
None
:
url
=
"https://xmlrpc.%s/rpc/api"
%
self
.
hostname
if
self
.
hostname
!=
'
rhn
.
redhat
.
com
'
:
url
=
"https://%s/rpc/api"
%
self
.
hostname
else
:
url
=
"https://xmlrpc.%s/rpc/api"
%
self
.
hostname
self
.
server
=
xmlrpclib
.
Server
(
url
,
verbose
=
0
)
self
.
server
=
xmlrpclib
.
Server
(
url
,
verbose
=
0
)
self
.
session
=
self
.
server
.
auth
.
login
(
self
.
username
,
self
.
password
)
self
.
session
=
self
.
server
.
auth
.
login
(
self
.
username
,
self
.
password
)
...
@@ -270,6 +279,7 @@ def main():
...
@@ -270,6 +279,7 @@ def main():
rhn
.
configure
(
module
.
params
[
'
server_url
'
])
rhn
.
configure
(
module
.
params
[
'
server_url
'
])
activationkey
=
module
.
params
[
'
activationkey
'
]
activationkey
=
module
.
params
[
'
activationkey
'
]
channels
=
module
.
params
[
'
channels
'
]
channels
=
module
.
params
[
'
channels
'
]
rhn
.
module
=
module
# Ensure system is registered
# Ensure system is registered
if
state
==
'
present
'
:
if
state
==
'
present
'
:
...
@@ -288,10 +298,10 @@ def main():
...
@@ -288,10 +298,10 @@ def main():
rhn
.
enable
()
rhn
.
enable
()
rhn
.
register
(
module
.
params
[
'
enable_eus
'
]
==
True
,
activationkey
)
rhn
.
register
(
module
.
params
[
'
enable_eus
'
]
==
True
,
activationkey
)
rhn
.
subscribe
(
channels
)
rhn
.
subscribe
(
channels
)
except
Command
Exception
,
e
:
except
Exception
,
e
:
module
.
fail_json
(
msg
=
"Failed to register with '%s': %s"
%
(
rhn
.
hostname
,
e
))
module
.
fail_json
(
msg
=
"Failed to register with '%s': %s"
%
(
rhn
.
hostname
,
e
))
else
:
module
.
exit_json
(
changed
=
True
,
msg
=
"System successfully registered to '%s'."
%
rhn
.
hostname
)
module
.
exit_json
(
changed
=
True
,
msg
=
"System successfully registered to '%s'."
%
rhn
.
hostname
)
# Ensure system is *not* registered
# Ensure system is *not* registered
if
state
==
'
absent
'
:
if
state
==
'
absent
'
:
...
@@ -300,14 +310,10 @@ def main():
...
@@ -300,14 +310,10 @@ def main():
else
:
else
:
try
:
try
:
rhn
.
unregister
()
rhn
.
unregister
()
except
Command
Exception
,
e
:
except
Exception
,
e
:
module
.
fail_json
(
msg
=
"Failed to unregister: %s"
%
e
)
module
.
fail_json
(
msg
=
"Failed to unregister: %s"
%
e
)
else
:
module
.
exit_json
(
changed
=
True
,
msg
=
"System successfully unregistered from %s."
%
rhn
.
hostname
)
module
.
exit_json
(
changed
=
True
,
msg
=
"System successfully unregistered from %s."
%
rhn
.
hostname
)
# import module snippets
from
ansible
.
module_utils
.
basic
import
*
from
ansible
.
module_utils
.
redhat
import
*
main
()
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment