pjsip: Add Alembic for PUBLISH support.
authorJoshua Colp <jcolp@digium.com>
Fri, 7 Apr 2017 13:35:33 +0000 (13:35 +0000)
committerJoshua Colp <jcolp@digium.com>
Fri, 7 Apr 2017 13:44:49 +0000 (08:44 -0500)
This change adds database tables for the PUBLISH support so it
can be configured using realtime. A minor fix to the
res_pjsip_publish_asterisk module was done so that it read the
sorcery configuration from the correct section. Finally the
sample configuration files have been updated.

ASTERISK-26928

Change-Id: I81991ae5c75af98d247f7eacd1c0b0a763675952

configs/samples/extconfig.conf.sample
configs/samples/sorcery.conf.sample
contrib/ast-db-manage/config/versions/2da192dbbc65_add_publish_tables.py [new file with mode: 0644]
res/res_pjsip_publish_asterisk.c

index 8fb6cac..0f347a6 100644 (file)
@@ -84,6 +84,9 @@
 ;ps_aors => odbc,asterisk
 ;ps_domain_aliases => odbc,asterisk
 ;ps_endpoint_id_ips => odbc,asterisk
+;ps_outbound_publishes => odbc,asterisk
+;ps_inbound_publications = odbc,asterisk
+;ps_asterisk_publications = odbc,asterisk
 ;voicemail => odbc,asterisk
 ;extensions => odbc,asterisk
 ;meetme => mysql,general
index 7e95883..1e7d72a 100644 (file)
@@ -67,3 +67,12 @@ test=memory
 
 ;[res_pjsip_endpoint_identifier_ip]
 ;identify=realtime,ps_endpoint_id_ips
+
+;[res_pjsip_outbound_publish]
+;outbound-publish=realtime,ps_outbound_publishes
+
+;[res_pjsip_pubsub]
+;inbound-publication=realtime,ps_inbound_publications
+
+;[res_pjsip_publish_asterisk]
+;asterisk-publication=realtime,ps_asterisk_publications
diff --git a/contrib/ast-db-manage/config/versions/2da192dbbc65_add_publish_tables.py b/contrib/ast-db-manage/config/versions/2da192dbbc65_add_publish_tables.py
new file mode 100644 (file)
index 0000000..affdc29
--- /dev/null
@@ -0,0 +1,73 @@
+"""add publish tables
+
+Revision ID: 2da192dbbc65
+Revises: 8fce4c573e15
+Create Date: 2017-04-05 10:16:52.504699
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = '2da192dbbc65'
+down_revision = '8fce4c573e15'
+
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import ENUM
+
+YESNO_NAME = 'yesno_values'
+YESNO_VALUES = ['yes', 'no']
+
+def upgrade():
+    ############################# Enums ##############################
+
+    # yesno_values have already been created, so use postgres enum object
+    # type to get around "already created" issue - works okay with mysql
+    yesno_values = ENUM(*YESNO_VALUES, name=YESNO_NAME, create_type=False)
+
+    op.create_table(
+        'ps_outbound_publishes',
+        sa.Column('id', sa.String(40), nullable=False, unique=True),
+        sa.Column('expiration', sa.Integer),
+        sa.Column('outbound_auth', sa.String(40)),
+        sa.Column('outbound_proxy', sa.String(256)),
+        sa.Column('server_uri', sa.String(256)),
+        sa.Column('from_uri', sa.String(256)),
+        sa.Column('to_uri', sa.String(256)),
+        sa.Column('event', sa.String(40)),
+        sa.Column('max_auth_attempts', sa.Integer),
+        sa.Column('transport', sa.String(40)),
+        sa.Column('multi_user', yesno_values),
+        sa.Column('@body', sa.String(40)),
+        sa.Column('@context', sa.String(256)),
+        sa.Column('@exten', sa.String(256)),
+    )
+
+    op.create_index('ps_outbound_publishes_id', 'ps_outbound_publishes', ['id'])
+
+    op.create_table(
+        'ps_inbound_publications',
+        sa.Column('id', sa.String(40), nullable=False, unique=True),
+        sa.Column('endpoint', sa.String(40)),
+        sa.Column('event_asterisk-devicestate', sa.String(40)),
+        sa.Column('event_asterisk-mwi', sa.String(40)),
+    )
+
+    op.create_index('ps_inbound_publications_id', 'ps_inbound_publications', ['id'])
+
+    op.create_table(
+        'ps_asterisk_publications',
+        sa.Column('id', sa.String(40), nullable=False, unique=True),
+        sa.Column('devicestate_publish', sa.String(40)),
+        sa.Column('mailboxstate_publish', sa.String(40)),
+        sa.Column('device_state', yesno_values),
+        sa.Column('device_state_filter', sa.String(256)),
+        sa.Column('mailbox_state', yesno_values),
+        sa.Column('mailbox_state_filter', sa.String(256)),
+    )
+
+    op.create_index('ps_asterisk_publications_id', 'ps_asterisk_publications', ['id'])
+
+def downgrade():
+    op.drop_table('ps_outbound_publishes')
+    op.drop_table('ps_inbound_publications')
+    op.drop_table('ps_asterisk_publications')
index b32408a..7e87762 100644 (file)
@@ -863,7 +863,7 @@ static int load_module(void)
                return AST_MODULE_LOAD_DECLINE;
        }
 
-       ast_sorcery_apply_config(ast_sip_get_sorcery(), "asterisk-publication");
+       ast_sorcery_apply_config(ast_sip_get_sorcery(), "res_pjsip_publish_asterisk");
        ast_sorcery_apply_default(ast_sip_get_sorcery(), "asterisk-publication", "config", "pjsip.conf,criteria=type=asterisk-publication");
 
        if (ast_sorcery_object_register(ast_sip_get_sorcery(), "asterisk-publication", asterisk_publication_config_alloc, NULL, NULL)) {