def voip_address_delete(self, operator, designation): """Delete a voip_address from Cerebrum. This is useful as a precursor to removing a service. """ self.ba.can_alter_voip_address(operator.get_entity_id()) address = self._get_voip_address(designation) # Without this check users risk seeing an internal error, rather than # a detailed error message. client = VoipClient(self.db) clients = list(client.search(voip_address_id=address.entity_id)) if clients: raise CerebrumError("Won't delete address id=%s: " "it has %d voip_client(s)" % (address.entity_id, len(clients))) address_id = address.entity_id owner = address.get_owner() address.delete() return "OK, deleted voip_address id=%s (owned by %s id=%s)" % ( address_id, text_type(self.const.EntityType(owner.entity_type)), owner.entity_id)
def voip_address_info(self, operator, designation): """Display information about ... ? The spec says 'all attributes': uname, cn, all URIs, e-mail, etc. @param designation: uid, id, fnr -- some way of identifying the proper voip-address. FIXME: Should be split designation into key:value, where key is one of (uname, cn, phone, entity_id/id) and value is the string interpreted according to the meaning of the first key. """ address = self._get_voip_address(designation) owner = address.get_owner() # find the clients client = VoipClient(self.db) client_ids = sorted([ text_type(x["entity_id"]) for x in client.search(voip_address_id=address.entity_id) ]) attrs = address.get_voip_attributes() result = { "entity_id": address.entity_id, "owner_entity_id": owner.entity_id, "owner_entity_type": text_type(self.const.EntityType(owner.entity_type)), "cn": attrs["cn"], "sip_uri": attrs["voipSipUri"], "sip_primary_uri": attrs["voipSipPrimaryUri"], "e164_uri": attrs["voipE164Uri"], "extension_uri": attrs["voipExtensionUri"], "traits": self._typeset_traits(address.get_traits()), "clients": client_ids, } return result
def _create_default_softphone_client(self, voip_address_id): """Help function to create default softphone client for all addresses and services. """ # # If it exists, we are done... client = VoipClient(self.db) if client.search(voip_address_id=voip_address_id, client_type=self.const.voip_client_type_softphone): return client.populate(voip_address_id, self.const.voip_client_type_softphone, True, # sip_enabled by default None, # softphones don't have MACs self.const.voip_client_info_softphone) client.write_db() client.set_auth_data(self.const.voip_auth_sip_secret, client.generate_sip_secret()) self.logger.debug("Automatically generated softphone " "client id=%s for address %s", client.entity_id, voip_address_id)
def voip_address_info(self, operator, designation): """Display information about ... ? The spec says 'all attributes': uname, cn, all URIs, e-mail, etc. @param designation: uid, id, fnr -- some way of identifying the proper voip-address. FIXME: Should be split designation into key:value, where key is one of (uname, cn, phone, entity_id/id) and value is the string interpreted according to the meaning of the first key. """ address = self._get_voip_address(designation) owner = address.get_owner() # find the clients client = VoipClient(self.db) client_ids = sorted( [text_type(x["entity_id"]) for x in client.search(voip_address_id=address.entity_id)]) attrs = address.get_voip_attributes() result = { "entity_id": address.entity_id, "owner_entity_id": owner.entity_id, "owner_entity_type": text_type(self.const.EntityType(owner.entity_type)), "cn": attrs["cn"], "sip_uri": attrs["voipSipUri"], "sip_primary_uri": attrs["voipSipPrimaryUri"], "e164_uri": attrs["voipE164Uri"], "extension_uri": attrs["voipExtensionUri"], "traits": self._typeset_traits(address.get_traits()), "clients": client_ids, } return result
def _create_default_softphone_client(self, voip_address_id): """Help function to create default softphone client for all addresses and services. """ # # If it exists, we are done... client = VoipClient(self.db) if client.search(voip_address_id=voip_address_id, client_type=self.const.voip_client_type_softphone): return client.populate( voip_address_id, self.const.voip_client_type_softphone, True, # sip_enabled by default None, # softphones don't have MACs self.const.voip_client_info_softphone) client.write_db() client.set_auth_data(self.const.voip_auth_sip_secret, client.generate_sip_secret()) self.logger.debug( "Automatically generated softphone " "client id=%s for address %s", client.entity_id, voip_address_id)
def voip_address_delete(self, operator, designation): """Delete a voip_address from Cerebrum. This is useful as a precursor to removing a service. """ self.ba.can_alter_voip_address(operator.get_entity_id()) address = self._get_voip_address(designation) # Without this check users risk seeing an internal error, rather than # a detailed error message. client = VoipClient(self.db) clients = list(client.search(voip_address_id=address.entity_id)) if clients: raise CerebrumError("Won't delete address id=%s: " "it has %d voip_client(s)" % (address.entity_id, len(clients))) address_id = address.entity_id owner = address.get_owner() address.delete() return "OK, deleted voip_address id=%s (owned by %s id=%s)" % ( address_id, self.const.EntityType( owner.entity_type), owner.entity_id)