text
stringlengths
0
152
('HOTDESK_1',1),
('HOTDESK_2',1);
Notice that we’ve told these two endpoints to enter the dialplan at a context named
[hotdesk]. We’ll define that shortly.
That’s all for our endpoint configuration. We’ve got a few slices of bread, which is
hardly a sandwich yet.
Now let’s get the custom database built that we’re going to use for this.
Connect to your MySQL console as root:
$ mysql -u root -p
First we want a new schema to put all this in. It’s technically possible to put this in the
asterisk schema, but we prefer to leave that schema alone, reserved only for what‐
ever Asterisk’s Alembic scripts do with it during upgrades.
MySQL> CREATE SCHEMA pbx;
MySQL> GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW ON pbx.* TO 'asterisk'@'::1';
MySQL> GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW ON pbx.* TO \
'asterisk'@'127.0.0.1';
MySQL> GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW ON pbx.* TO \
'asterisk'@'localhost';
MySQL> GRANT SELECT,INSERT,UPDATE,DELETE,EXECUTE,SHOW VIEW ON pbx.* TO \
'asterisk'@'localhost.localdomain';
Getting Funky with func_odbc: Hot-Desking
|
265
MySQL> FLUSH PRIVILEGES;
Then create the table with the following bit of SQL:
CREATE TABLE pbx.ast_hotdesk
(
id serial NOT NULL,
extension text,
first_name text,
last_name text,
cid_name text,
cid_number varchar(10),
pin int,
status bool DEFAULT false,
endpoint text,
CONSTRAINT ast_hotdesk_id_pk PRIMARY KEY (id)
);
After that, populate the database with the following information (some of the values
that you see actually will change only after the dialplan work is done, but we include
it here by way of example).
At the MySQL console, run the following command:
MySQL> INSERT INTO pbx.ast_hotdesk
(extension, first_name, last_name, cid_name, cid_number, pin, status)
VALUES
('1101','Herb','Tarlek','WKRP','1101','110111',0)
('1102','Al','Bundy','Garys','1102','110222',0),
('1103','Willy','Loman','','1103','110333',0),
('1104','Jerry','Lundegaard','Gustafson','1104','110444',0),
('1105','Moira','Brown','Craterside','1105','110555',0);
Repeat these commands, changing the VALUES as needed, for all entries you wish to
have in the database.4 After you’ve input your sample data, you can view the data in
the ast_hotdesk table by running a simple SELECT statement from the database
console:
MySQL> SELECT * FROM pbx.ast_hotdesk;
Which might give you something like the following output:
+--+---------+----------+----------+----------+----------+------+------+--------+
|id|extension|first_name|last_name |cid_name |cid_number|pin |status|endpoint|
+--+---------+----------+----------+----------+----------+------+------+--------+
| 1|1101 |Herb |Tarlek |WKRP |1101 |110111| 0|NULL |
| 2|1102 |Al |Bundy |Garys |1102 |110222| 0|NULL |
| 3|1103 |Willy |Loman | |1103 |110333| 0|NULL |
| 4|1104 |Jerry |Lundegaard|Gustafson |1104 |110444| 0|NULL |
| 5|1105 |Moira |Brown |Craterside|1105 |110555| 0|NULL |
+--+---------+----------+----------+----------+----------+------+------+--------+
4 Note that in the first example user, we are assigning a status of 1 and a location, whereas for the second exam‐
ple user, we are not defining a value for these fields.
266
|
Chapter 15: Relational Database Integration