示例#1
0
 def activate(self):
     rhn = RHNTransport()    
     satClient = getRhnApi(self.baseURL + "/SAT", 
         verbose=self.verbose, transport=rhn)
     # First check if we are active
     active = False
     retval = satClient.authentication.check(self.systemid)
     LOG.debug("AUTH CHECK: %s " % str(retval))
     if (retval == 1):
         LOG.debug("We are activated ... continue!")
         active = True
     else:
         LOG.debug("Not active")
         
     if (not active): 
         if(not self.username or not self.password):
             raise SystemNotActivatedException()
         SATELLITE_URL = "%s/rpc/api" % (self.baseURL)
         client = RhnApi(SATELLITE_URL, verbose=0)
         key = client.auth.login(self.username, self.password)
         retval = client.satellite.activateSatellite(self.systemid, self.cert)
         LOG.debug("retval from activation: %s"  % retval)
         if (retval != 1):
             raise CantActivateException()
         client.auth.logout(key)        
         LOG.debug("Activated!")
示例#2
0
 def deactivate(self):
     SATELLITE_URL = "%s/rpc/api" % (self.baseURL)
     client = getRhnApi(SATELLITE_URL, verbose=0)
     key = client.auth.login(self.username, self.password)
     retval = client.satellite.deactivateSatellite(self.systemid)
     print "retval from deactivation: %s"  % retval
     client.auth.logout(key)        
     print "Deactivated!"