[asterisk-dev] [Code Review] Group Variables

Russell Bryant russell at digium.com
Thu Jan 28 11:36:39 CST 2010


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/464/
-----------------------------------------------------------

(Updated 2010-01-28 11:36:38.675984)


Review request for Asterisk Developers.


Changes
-------

added bug number


Summary
-------

This patch allows for setting variables on a group of channels.
First a channel is assigned a group via dialplan GROUP() or GroupSet via the ami (new command)
Then, variables can be set on that group with the GROUP_VAR() dialplan function, or GroupVarSet in the manager

This patch also adds manager events for channel group changes, and variable updates

When a group is no longer used (all channels referencing the group are hung up, or all channels referencing the group have their group changed/unset), variables are destroyed

new manager commands:
GroupSet - adds functionality to the manager to be able to set a GROUP() on a channel.
GroupsShowChannels - show each channel and it's associated groups (a channel will be repeated for each group at category it's a member of)
GroupsShowVariables - show variables in each group at category, one event per group, all variables are contained in each group at category event
GroupVarSet - set a group variable (the group has to exist)
GroupVarGet - get a group variable

new manager events:
GroupCreate
GroupChannelAdd
GroupChannelRemove
GroupDestroy
GroupVarSet

Example AMI:
Action: GroupVarSet
Group: 1000
Category: ConferenceBridge
Variable: LastUpdateCheck
Value: 1263502512

Example CLI:
demo1*CLI> group show variables
Group    Variables    Category
1000            ConferenceBridge
    LastUpdateCheck=1263502512
1000            ConferenceModerator
2 active groups


Adds support for:
  Group variables
     dialplan access: GROUP_VAR()
     cli access: group show variables
     manager access: GroupVarSet GroupVarGet
  Group information: 
     manager access: GroupSet GroupsShow GroupsShowChannels GroupsShowVariables
  


This addresses bug 16614.
    https://issues.asterisk.org/view.php?id=16614


Diffs
-----

  /trunk/include/asterisk/channel.h 240226 
  /trunk/main/app.c 240226 
  /trunk/main/cli.c 240226 
  /trunk/include/asterisk/app.h 240226 
  /trunk/funcs/func_groupcount.c 240226 

Diff: https://reviewboard.asterisk.org/r/464/diff


Testing
-------

dialplan:
    Set(GROUP()=foo);
    Set(GROUP()=foobar at foocat);

    Set(GROUP_VAR(foo,myvar)=123);
    Set(GROUP_VAR(foo,myvar2)=456);
    NoOp(${GROUP_VAR(foo,myvar)});
    NoOp(${GROUP_VAR(foo,myvar2)});

    Set(GROUP_VAR(foobar at foocat,myvar)=123);
    NoOp(${GROUP_VAR(foobar at foocat,myvar)});

    Set(GROUP_VAR(something,myvar)=123);
    NoOp(${GROUP_VAR(something,myvar)});

    Wait(10000);
    Hangup();


CLI:
-------------------
> group show channels
-------------------
channel                    Group                 Category
IAX2/branch-15569          foo                   (default)
IAX2/branch-15569          foobar                foocat
2 active channels

-------------------
> group show variables
-------------------
Group    Variables    Category
foo                   (Default)
     myvar2=456
     myvar=123
foobar                foocat
     myvar=123
2 active groups


AMI:
-------------------
Action: GroupsShow
-------------------
Response: Success
Eventlist: start
Message: Groups will follow

Event: GroupsShow
Group: foo
Category:

Event: GroupsShow
Group: foobar
Category: foocat

Event: GroupsShowComplete
EventList: Complete
ListItems: 2


-------------------
Action: GroupsShowChannels
-------------------
Response: Success
Eventlist: start
Message: Group channels will follow

Event: GroupsShowChannels
Group: foo
Category:
Channel: IAX2/branch-14981

Event: GroupsShowChannels
Group: foobar
Category: foocat
Channel: IAX2/branch-14981

Event: GroupsShowChannelsComplete
EventList: Complete
ListItems: 2


-------------------
Action: GroupsShowVariables
-------------------
Response: Success
Eventlist: start
Message: Group variables will follow

Event: GroupsShowVariables
Group: foo
Category:
VariablesStart: Variables will follow
myvar2: 456
myvar: 123


Event: GroupsShowVariables
Group: foobar
Category: foocat
VariablesStart: Variables will follow
myvar: 123

Event: GroupsShowVariablesComplete
EventList: Complete
ListItems: 2


-------------------
Action: GroupVarGet
Group: foo
Variable: myvar
-------------------
Response: Success
Message: Result will follow

Event: GroupVarGetResponse
Group: foo
Category:
Variable: myvar
Value: 123


-------------------
Action: GroupVarSet
Group: foobar
Category: foocat
Variable: something
Value: 1238091283123
-------------------

Response: Success
Message: Variable Set


-------------------
Action: GroupVarSet
Group: doesntexist
Category: foocat
Variable: something
Value: 1238091283123
-------------------

Response: Error
Message: Variable set failed (group doesn't exist)


Thanks,

kobaz




More information about the asterisk-dev mailing list