Script rhn_profile_sync_py
[hide private]
[frames] | no frames]

Source Code for Script script-rhn_profile_sync_py

 1  #!/usr/bin/python2 
 2  # 
 3  # Spacewalk registration tool 
 4  # Adapted from wrapper.py 
 5  # Copyright (c) 1999--2018 Red Hat, Inc.  Distributed under GPLv2. 
 6  # 
 7  # Authors: 
 8  #       Adrian Likins <alikins@redhat.com> 
 9  #       Preston Brown <pbrown@redhat.com> 
10  #       James Bowes <jbowes@redhat.com> 
11   
12  import sys 
13   
14  import gettext 
15  t = gettext.translation('rhn-client-tools', fallback=True) 
16  # Python 3 translations don't have a ugettext method 
17  if not hasattr(t, 'ugettext'): 
18      t.ugettext = t.gettext 
19  _ = t.ugettext 
20   
21   
22  from up2date_client import up2dateAuth 
23  from up2date_client import rhncli 
24  from up2date_client import rhnPackageInfo 
25  from up2date_client import rhnHardware 
26   
27  try: 
28      from virtualization import support 
29  except ImportError: 
30      support = None 
31   
32 -class ProfileCli(rhncli.RhnCli):
33
34 - def main(self):
35 if not up2dateAuth.getSystemId(): 36 needToRegister = \ 37 _("You need to register this system by running " \ 38 "`rhn_register` before using this option") 39 print(needToRegister) 40 sys.exit(1) 41 42 if not self._testRhnLogin(): 43 sys.exit(1) 44 45 print(_("Updating package profile...")) 46 rhnPackageInfo.updatePackageProfile() 47 48 print(_("Updating hardware profile...")) 49 rhnHardware.updateHardware() 50 51 if support is not None: 52 print(_("Updating virtualization profile...")) 53 support.refresh(True)
54 55 56 if __name__ == "__main__": 57 cli = ProfileCli() 58 cli.run() 59