def generate_dh_param(self): reserved = queue.reserve('pooled_dh_params', svr=self) if not reserved: reserved = queue.reserve('queued_dh_params', svr=self) if reserved: queue.start('dh_params', dh_param_bits=self.dh_param_bits, priority=LOW) return self.queue_dh_params()
def new_user(self, type=CERT_CLIENT, block=True, **kwargs): # First attempt to get user from pool then attempt to get # unfinished queued user in pool then queue a new user init if type in (CERT_SERVER, CERT_CLIENT): usr = user.reserve_pooled_user(org=self, type=type, **kwargs) if not usr: usr = queue.reserve('queued_user', org=self, type=type, block=block, **kwargs) if usr: logger.debug('Reserved queued user', 'organization', org_id=self.id, user_id=usr.id, ) else: logger.debug('Reserved pooled user', 'organization', org_id=self.id, user_id=usr.id, ) if usr: user.new_pooled_user(org=self, type=type) return usr usr = user.User(org=self, type=type, **kwargs) usr.queue_initialize(block=block, priority=HIGH if type in (CERT_SERVER, CERT_CLIENT) else None) logger.debug('Queued user init', 'organization', org_id=self.id, user_id=usr.id, ) return usr
def generate_dh_param(self): doc = queue.find({"type": "dh_params", "server_id": self.id}) if doc: if doc["dh_param_bits"] != self.dh_param_bits: queue.stop(doc["_id"]) else: return reserved = queue.reserve("pooled_dh_params", svr=self) if not reserved: reserved = queue.reserve("queued_dh_params", svr=self) if reserved: queue.start("dh_params", dh_param_bits=self.dh_param_bits, priority=LOW) return self.queue_dh_params()
def generate_dh_param(self): doc = queue.find({ 'type': 'dh_params', 'server_id': self.id, }) if doc: if doc['dh_param_bits'] != self.dh_param_bits: queue.stop(doc['_id']) else: return reserved = queue.reserve('pooled_dh_params', svr=self) if not reserved: reserved = queue.reserve('queued_dh_params', svr=self) if reserved: queue.start('dh_params', dh_param_bits=self.dh_param_bits, priority=LOW) return self.queue_dh_params()
def new_org(type=ORG_DEFAULT, block=True, **kwargs): if type == ORG_DEFAULT: org = reserve_pooled(type=type, **kwargs) if not org: org = queue.reserve('queued_org', block=block, type=type, **kwargs) if org: logger.debug( 'Reserved queued org', 'organization', org_id=org.id, ) else: logger.debug( 'Reserved pooled org', 'organization', org_id=org.id, ) if org: new_pooled() return org org = Organization(type=type, **kwargs) org.initialize() org.commit() logger.debug( 'Org init', 'organization', org_id=org.id, ) return org else: org = Organization(type=type, **kwargs) org.queue_initialize(block=block) logger.debug( 'Queue org init', 'organization', org_id=org.id, ) return org
def new_user(self, type=CERT_CLIENT, block=True, pool=True, **kwargs): # First attempt to get user from pool then attempt to get # unfinished queued user in pool then queue a new user init if type in (CERT_SERVER, CERT_CLIENT) and pool: usr = user.reserve_pooled_user(org=self, type=type, **kwargs) if not usr: usr = queue.reserve('queued_user', org=self, type=type, block=block, **kwargs) if usr: user.new_pooled_user(org=self, type=type) return usr usr = user.User(org=self, type=type, **kwargs) usr.queue_initialize(block=block, priority=HIGH if type in (CERT_SERVER, CERT_CLIENT) else None) return usr
def new_org(type=ORG_DEFAULT, block=True, **kwargs): if type == ORG_DEFAULT: org = reserve_pooled(type=type, **kwargs) if not org: org = queue.reserve('queued_org', block=block, type=type, **kwargs) if org: new_pooled() return org org = Organization(type=type, **kwargs) org.initialize() org.commit() return org else: org = Organization(type=type, **kwargs) org.queue_initialize(block=block) return org
def new_org(type=ORG_DEFAULT, block=True, **kwargs): if type == ORG_DEFAULT: org = reserve_pooled(type=type, **kwargs) if not org: org = queue.reserve("queued_org", block=block, type=type, **kwargs) if org: new_pooled() return org org = Organization(type=type, **kwargs) org.initialize() org.commit() return org else: org = Organization(type=type, **kwargs) org.queue_initialize(block=block) return org
def new_org(type=ORG_DEFAULT, block=True, **kwargs): if type == ORG_DEFAULT: org = reserve_pooled(type=type, **kwargs) if not org: org = queue.reserve('queued_org', block=block, type=type, **kwargs) if org: logger.debug('Reserved queued org', 'organization', org_id=org.id, ) else: logger.debug('Reserved pooled org', 'organization', org_id=org.id, ) if org: new_pooled() return org org = Organization(type=type, **kwargs) org.initialize() org.commit() logger.debug('Org init', 'organization', org_id=org.id, ) return org else: org = Organization(type=type, **kwargs) org.queue_initialize(block=block) logger.debug('Queue org init', 'organization', org_id=org.id, ) return org