Difference between revisions of "SUSE Manager/ReRegisterPy"

From MicroFocusInternationalWiki
Jump to: navigation, search
(Undo revision 21914 by Gameboy974 (talk))
(Undo revision 21540 by 137.65.227.74 (talk))
 
Line 1: Line 1:
sell viagra online <a href=http://sildenafilusshop.com>Viagra Online</a> viagra premature ejaculationgeneric viagra mexico <a href=http://shopnorxmed.com>Buy Viagra Online</a> legal generic viagrabuy cialis lloyds <a href=http://fast-tadalafil.com>Buy Cialis</a> buy brand name cialisaccutane used for <a href=http://fast-isotretinoin.com>Accutane</a> acne medications containing accutanecialis effect on heart <a href=http://fastshipcialis.com>Cialis</a> cialis compared to viagra
+
<pre>
 +
#!/usr/bin/python
 +
#
 +
# Tool to re-register a server against a SUSE Manager Proxy Server
 +
# Usage: proxy_rereg.py user suman_proxy_dns
 +
#
 +
# Created by: SUSE Michael Brookhuis, August 29, 2013
 +
#
 +
import os, sys, subprocess, xmlrpclib, getpass
 +
 
 +
MANAGER_URL = "http://192.168.245.50/rpc/api"
 +
MANAGER_LOGIN = sys.argv[1]
 +
REG_SERVER = sys.argv[2]
 +
SYSTEM_ID = "/etc/sysconfig/rhn/systemid"
 +
 
 +
# Looking up server ID
 +
fin = open(SYSTEM_ID)
 +
for i in fin:
 +
    for k in i.split('>'):
 +
        if k.startswith('ID-'):
 +
          id = int(k.rsplit('-')[1].rsplit('<')[0])
 +
fin.close
 +
 
 +
# Request password admin user
 +
MANAGER_PASSWORD = getpass.getpass()
 +
 
 +
# Requesting re-activation key
 +
client = xmlrpclib.Server(MANAGER_URL, verbose=0)
 +
key = client.auth.login(MANAGER_LOGIN, MANAGER_PASSWORD)
 +
rekey = client.system.obtainReactivationKey(key, id )
 +
client.auth.logout(key)
 +
 
 +
# Re-Registering server
 +
bcmd = "rhnreg_ks --activationkey="+str(rekey)+" --serverUrl=http://"+REG_SERVER+"/XMLRPC --force"
 +
os.system(bcmd)
 +
</pre>

Latest revision as of 12:55, 16 March 2015

#!/usr/bin/python
#
# Tool to re-register a server against a SUSE Manager Proxy Server
# Usage: proxy_rereg.py user suman_proxy_dns
#
# Created by: SUSE Michael Brookhuis, August 29, 2013
#
import os, sys, subprocess, xmlrpclib, getpass

MANAGER_URL = "http://192.168.245.50/rpc/api"
MANAGER_LOGIN = sys.argv[1]
REG_SERVER = sys.argv[2]
SYSTEM_ID = "/etc/sysconfig/rhn/systemid"

# Looking up server ID
fin = open(SYSTEM_ID)
for i in fin:
    for k in i.split('>'):
        if k.startswith('ID-'):
           id = int(k.rsplit('-')[1].rsplit('<')[0])
fin.close

# Request password admin user
MANAGER_PASSWORD = getpass.getpass()

# Requesting re-activation key
client = xmlrpclib.Server(MANAGER_URL, verbose=0)
key = client.auth.login(MANAGER_LOGIN, MANAGER_PASSWORD)
rekey = client.system.obtainReactivationKey(key, id )
client.auth.logout(key)

# Re-Registering server
bcmd = "rhnreg_ks --activationkey="+str(rekey)+" --serverUrl=http://"+REG_SERVER+"/XMLRPC --force"
os.system(bcmd)