Asterisk - The Open Source Telephony Project GIT-master-f36a736
43956d550a44_add_tables_for_pjsip.py
Go to the documentation of this file.
1"""Add tables for pjsip
2
3Revision ID: 43956d550a44
4Revises: 4da0c5f79a9c
5Create Date: 2013-09-30 13:23:59.676690
6
7"""
8
9# revision identifiers, used by Alembic.
10revision = '43956d550a44'
11down_revision = '4da0c5f79a9c'
12
13from alembic import op
14import sqlalchemy as sa
15from sqlalchemy.dialects.postgresql import ENUM
16
17
18YESNO_VALUES = ['yes', 'no']
19PJSIP_CID_PRIVACY_VALUES = ['allowed_not_screened', 'allowed_passed_screened',
20 'allowed_failed_screened', 'allowed',
21 'prohib_not_screened', 'prohib_passed_screened',
22 'prohib_failed_screened', 'prohib', 'unavailable']
23PJSIP_100REL_VALUES = ['no', 'required', 'yes']
24PJSIP_CONNECTED_LINE_METHOD_VALUES = ['invite', 'reinvite', 'update']
25PJSIP_DIRECT_MEDIA_GLARE_MITIGATION_VALUES = ['none', 'outgoing', 'incoming']
26PJSIP_DTMF_MODE_VALUES = ['rfc4733', 'inband', 'info']
27PJSIP_IDENTIFY_BY_VALUES = ['username']
28PJSIP_TIMERS_VALUES = ['forced', 'no', 'required', 'yes']
29PJSIP_MEDIA_ENCRYPTION_VALUES = ['no', 'sdes', 'dtls']
30PJSIP_T38UDPTL_EC_VALUES = ['none', 'fec', 'redundancy']
31PJSIP_DTLS_SETUP_VALUES = ['active', 'passive', 'actpass']
32PJSIP_AUTH_TYPE_VALUES = ['md5', 'userpass']
33PJSIP_TRANSPORT_METHOD_VALUES = ['default', 'unspecified', 'tlsv1', 'sslv2',
34 'sslv3', 'sslv23']
35PJSIP_TRANSPORT_PROTOCOL_VALUES = ['udp', 'tcp', 'tls', 'ws', 'wss']
36
37
38def upgrade():
39 op.create_table(
40 'ps_endpoints',
41 sa.Column('id', sa.String(40), nullable=False, unique=True),
42 sa.Column('transport', sa.String(40)),
43 sa.Column('aors', sa.String(200)),
44 sa.Column('auth', sa.String(40)),
45 sa.Column('context', sa.String(40)),
46 sa.Column('disallow', sa.String(200)),
47 sa.Column('allow', sa.String(200)),
48 sa.Column('direct_media', sa.Enum(*YESNO_VALUES, name='yesno_values')),
49 sa.Column('connected_line_method',
50 sa.Enum(*PJSIP_CONNECTED_LINE_METHOD_VALUES, name='pjsip_connected_line_method_values')),
51 sa.Column('direct_media_method',
52 sa.Enum(*PJSIP_CONNECTED_LINE_METHOD_VALUES, name='pjsip_connected_line_method_values')),
53 sa.Column('direct_media_glare_mitigation',
54 sa.Enum(*PJSIP_DIRECT_MEDIA_GLARE_MITIGATION_VALUES, name='pjsip_direct_media_glare_mitigation_values')),
55 sa.Column('disable_direct_media_on_nat', sa.Enum(*YESNO_VALUES, name='yesno_values')),
56 sa.Column('dtmf_mode', sa.Enum(*PJSIP_DTMF_MODE_VALUES, name='pjsip_dtmf_mode_values')),
57 sa.Column('external_media_address', sa.String(40)),
58 sa.Column('force_rport', sa.Enum(*YESNO_VALUES, name='yesno_values')),
59 sa.Column('ice_support', sa.Enum(*YESNO_VALUES, name='yesno_values')),
60 sa.Column('identify_by', sa.Enum(*PJSIP_IDENTIFY_BY_VALUES, name='pjsip_identify_by_values')),
61 sa.Column('mailboxes', sa.String(40)),
62 sa.Column('moh_suggest', sa.String(40)),
63 sa.Column('outbound_auth', sa.String(40)),
64 sa.Column('outbound_proxy', sa.String(40)),
65 sa.Column('rewrite_contact', sa.Enum(*YESNO_VALUES, name='yesno_values')),
66 sa.Column('rtp_ipv6', sa.Enum(*YESNO_VALUES, name='yesno_values')),
67 sa.Column('rtp_symmetric', sa.Enum(*YESNO_VALUES, name='yesno_values')),
68 sa.Column('send_diversion', sa.Enum(*YESNO_VALUES, name='yesno_values')),
69 sa.Column('send_pai', sa.Enum(*YESNO_VALUES, name='yesno_values')),
70 sa.Column('send_rpid', sa.Enum(*YESNO_VALUES, name='yesno_values')),
71 sa.Column('timers_min_se', sa.Integer),
72 sa.Column('timers', sa.Enum(*PJSIP_TIMERS_VALUES, name='pjsip_timer_values')),
73 sa.Column('timers_sess_expires', sa.Integer),
74 sa.Column('callerid', sa.String(40)),
75 sa.Column('callerid_privacy', sa.Enum(*PJSIP_CID_PRIVACY_VALUES, name='pjsip_cid_privacy_values')),
76 sa.Column('callerid_tag', sa.String(40)),
77 sa.Column('100rel', sa.Enum(*PJSIP_100REL_VALUES, name='pjsip_100rel_values')),
78 sa.Column('aggregate_mwi', sa.Enum(*YESNO_VALUES, name='yesno_values')),
79 sa.Column('trust_id_inbound', sa.Enum(*YESNO_VALUES, name='yesno_values')),
80 sa.Column('trust_id_outbound', sa.Enum(*YESNO_VALUES, name='yesno_values')),
81 sa.Column('use_ptime', sa.Enum(*YESNO_VALUES, name='yesno_values')),
82 sa.Column('use_avpf', sa.Enum(*YESNO_VALUES, name='yesno_values')),
83 sa.Column('media_encryption', sa.Enum(*PJSIP_MEDIA_ENCRYPTION_VALUES, name='pjsip_media_encryption_values')),
84 sa.Column('inband_progress', sa.Enum(*YESNO_VALUES, name='yesno_values')),
85 sa.Column('call_group', sa.String(40)),
86 sa.Column('pickup_group', sa.String(40)),
87 sa.Column('named_call_group', sa.String(40)),
88 sa.Column('named_pickup_group', sa.String(40)),
89 sa.Column('device_state_busy_at', sa.Integer),
90 sa.Column('fax_detect', sa.Enum(*YESNO_VALUES, name='yesno_values')),
91 sa.Column('t38_udptl', sa.Enum(*YESNO_VALUES, name='yesno_values')),
92 sa.Column('t38_udptl_ec', sa.Enum(*PJSIP_T38UDPTL_EC_VALUES, name='pjsip_t38udptl_ec_values')),
93 sa.Column('t38_udptl_maxdatagram', sa.Integer),
94 sa.Column('t38_udptl_nat', sa.Enum(*YESNO_VALUES, name='yesno_values')),
95 sa.Column('t38_udptl_ipv6', sa.Enum(*YESNO_VALUES, name='yesno_values')),
96 sa.Column('tone_zone', sa.String(40)),
97 sa.Column('language', sa.String(40)),
98 sa.Column('one_touch_recording', sa.Enum(*YESNO_VALUES, name='yesno_values')),
99 sa.Column('record_on_feature', sa.String(40)),
100 sa.Column('record_off_feature', sa.String(40)),
101 sa.Column('rtp_engine', sa.String(40)),
102 sa.Column('allow_transfer', sa.Enum(*YESNO_VALUES, name='yesno_values')),
103 sa.Column('allow_subscribe', sa.Enum(*YESNO_VALUES, name='yesno_values')),
104 sa.Column('sdp_owner', sa.String(40)),
105 sa.Column('sdp_session', sa.String(40)),
106 sa.Column('tos_audio', sa.Integer),
107 sa.Column('tos_video', sa.Integer),
108 sa.Column('cos_audio', sa.Integer),
109 sa.Column('cos_video', sa.Integer),
110 sa.Column('sub_min_expiry', sa.Integer),
111 sa.Column('from_domain', sa.String(40)),
112 sa.Column('from_user', sa.String(40)),
113 sa.Column('mwi_fromuser', sa.String(40)),
114 sa.Column('dtls_verify', sa.String(40)),
115 sa.Column('dtls_rekey', sa.String(40)),
116 sa.Column('dtls_cert_file', sa.String(200)),
117 sa.Column('dtls_private_key', sa.String(200)),
118 sa.Column('dtls_cipher', sa.String(200)),
119 sa.Column('dtls_ca_file', sa.String(200)),
120 sa.Column('dtls_ca_path', sa.String(200)),
121 sa.Column('dtls_setup', sa.Enum(*PJSIP_DTLS_SETUP_VALUES, name='pjsip_dtls_setup_values')),
122 sa.Column('srtp_tag_32', sa.Enum(*YESNO_VALUES, name='yesno_values')),
123 )
124
125 op.create_index('ps_endpoints_id', 'ps_endpoints', ['id'])
126
127 op.create_table(
128 'ps_auths',
129 sa.Column('id', sa.String(40), nullable=False, unique=True),
130 sa.Column('auth_type', sa.Enum(*PJSIP_AUTH_TYPE_VALUES, name='pjsip_auth_type_values')),
131 sa.Column('nonce_lifetime', sa.Integer),
132 sa.Column('md5_cred', sa.String(40)),
133 sa.Column('password', sa.String(80)),
134 sa.Column('realm', sa.String(40)),
135 sa.Column('username', sa.String(40)),
136 )
137
138 op.create_index('ps_auths_id', 'ps_auths', ['id'])
139
140 op.create_table(
141 'ps_aors',
142 sa.Column('id', sa.String(40), nullable=False, unique=True),
143 sa.Column('contact', sa.String(40)),
144 sa.Column('default_expiration', sa.Integer),
145 sa.Column('mailboxes', sa.String(80)),
146 sa.Column('max_contacts', sa.Integer),
147 sa.Column('minimum_expiration', sa.Integer),
148 sa.Column('remove_existing', sa.Enum(*YESNO_VALUES, name='yesno_values')),
149 sa.Column('qualify_frequency', sa.Integer),
150 sa.Column('authenticate_qualify', sa.Enum(*YESNO_VALUES, name='yesno_values')),
151 )
152
153 op.create_index('ps_aors_id', 'ps_aors', ['id'])
154
155 op.create_table(
156 'ps_contacts',
157 sa.Column('id', sa.String(40), nullable=False, unique=True),
158 sa.Column('uri', sa.String(40)),
159 sa.Column('expiration_time', sa.String(40)),
160 sa.Column('qualify_frequency', sa.Integer),
161 )
162
163 op.create_index('ps_contacts_id', 'ps_contacts', ['id'])
164
165 op.create_table(
166 'ps_domain_aliases',
167 sa.Column('id', sa.String(40), nullable=False, unique=True),
168 sa.Column('domain', sa.String(80)),
169 )
170
171 op.create_index('ps_domain_aliases_id', 'ps_domain_aliases', ['id'])
172
173 op.create_table(
174 'ps_endpoint_id_ips',
175 sa.Column('id', sa.String(40), nullable=False, unique=True),
176 sa.Column('endpoint', sa.String(40)),
177 sa.Column('match', sa.String(80)),
178 )
179
180 op.create_index('ps_endpoint_id_ips_id',
181 'ps_endpoint_id_ips', ['id'])
182
183
185 context = op.get_context()
186
187 op.drop_table('ps_endpoints')
188 op.drop_table('ps_auths')
189 op.drop_table('ps_aors')
190 op.drop_table('ps_contacts')
191 op.drop_table('ps_domain_aliases')
192 op.drop_table('ps_endpoint_id_ips')
193
194 enums = ['yesno_values',
195 'pjsip_100rel_values','pjsip_auth_type_values','pjsip_cid_privacy_values',
196 'pjsip_connected_line_method_values','pjsip_direct_media_glare_mitigation_values',
197 'pjsip_dtls_setup_values','pjsip_dtmf_mode_values','pjsip_identify_by_values',
198 'pjsip_media_encryption_values','pjsip_t38udptl_ec_values','pjsip_timer_values']
199
200 if context.bind.dialect.name == 'postgresql':
201 for e in enums:
202 ENUM(name=e).drop(op.get_bind(), checkfirst=False)