예제 #1
0
class CandlepinConnection():

    def getOwners(self):
        return self.cp.getOwnerList(self.username)

    def __init__(self):
        self.conn_username = "******"
        self.owner = "admin"
        self.cp = UEPConnection(username=self.conn_username, password="******",
                    host="localhost", ssl_port=8443,
                    handler="/candlepin", insecure=True)

    def createConsumer(self, name, facts, installed_products):
        consumer = self.cp.registerConsumer(name=name, facts=facts, owner=self.owner, installed_products=installed_products)
        print "created consumer with uuid %s. binding.." % consumer['uuid']
        self.cp.bind(consumer['uuid'], entitle_date=datetime.now())
        print "bind complete"
        self.cp.checkin(consumer['uuid'])
        return consumer['uuid']

    def updateConsumer(self, uuid, facts, installed_products):
        self.cp.updateConsumer(uuid, facts=facts, installed_products=installed_products)
        self.cp.checkin(uuid)