Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Defining time intervals for each server or for each account is an option, but it's time consuming. Instead, you could consider exporting, importing, or cloning them using a script that will save you time and effort. This article details how to work with the script.

Step-by-step guide

  1. Download the script.

    Code Block
    wget -O time_interval.pl https://raw.githubusercontent.com/4psa/voipnowtoolbox/master/time_interval.pl
  2. Install the needed Perl libraries.

    Code Block
    yum install perl-DBD-mysql perl-JSON
  3. Run the script. 

    Code Block
    perl time_interval.pl

    The available options will be displayed:

    Code Block
    Usage:
    Available options:
             Share a time interval with a different account
                    perl time_interval.pl share <time_interval_id> <client_id>
                    E.G.: perl time_interval.pl share 2 4
    
             Dump a time interval to a file
                    perl time_interval.pl dump <time_interval_id> <file_name or empty>
                    E.G.: perl time_interval.pl dump 2 afterhours
    
             Restore a time interval from a file
                    perl time_interval.pl restore <client_id> <file_name or empty>
                    E.G.: perl time_interval.pl restore 2 afterhours.json
    
    

Cloning time intervals on a different account

To clone an existing time interval on a different account, you need to know the ID of the time interval and the client ID of the destination account.

Code Block
  perl time_interval.pl share <time_interval_id> <client_id>

Let's assume that the ID of the After Hours matching time interval created on the Admin level (Unified Communications >> Time Intervals) is 21, and let's copy the time interval on the Service Provider with ID  2.

Shell

 #> perl time_interval.pl share 21 2
TimeInterval AfterHours has been added on accountID: 2

Saving time intervals to a file

Assuming we want to create the same time interval on a different server, we need to save it to a file and restore it where it is needed.

In our example, we will use the same time interval with ID 21, used for After Hours matching, and we will run the following command:

Shell

#> perl time_interval.pl dump 21 afterhours
Time Interval AfterHours saved in afterhours.json

A new file similar to the one below (afterhours.json) will be created.  

Code Block
{"mod_date":"2016-01-22 09:42:36","cr_date":"2015-11-10 12:11:09","client_id":"1","name":"AfterHours","data":[{"end_day":"31","time_interval_id":"21","month":"0","start_time":"00:00:00","end_time":"09:59:00","start_wkday":"2","end_wkday":"6","start_day":"1","td_id":"40"},{"end_day":"31","time_interval_id":"21","month":"0","start_time":"17:00:00","end_time":"23:59:00","start_wkday":"2","end_wkday":"6","start_day":"1","td_id":"41"},{"end_day":"31","time_interval_id":"21","month":"0","start_time":"00:00:00","end_time":"23:59:00","start_wkday":"7","end_wkday":"1","start_day":"1","td_id":"42"}],"timezone_id":"248","id":"21","type":"day"}

Restoring time intervals from file to an existing account

Code Block
perl time_interval.pl restore <client_id> <file_name or empty>

Let's restore the time interval saved earlier to an existing account with ID 2. We will use the following command:

Shell

#> perl time_interval.pl restore 2 afterhours.json
TimeInterval AfterHours has been restored on accountID: 2

Content by Label
showLabelsfalse
max5
spacescom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@5d4a10c1
showSpacefalse
sortmodifiedshowSpacefalse
reversetrue
typepagelabelstimeinterval voipnow callrouting script Perl
cqllabel in ("perl","script","callrouting","voipnow","timeinterval") and type = "page" and space = "4PSAKB"
labelstimeinterval voipnow callrouting script Perl

Page properties
hiddentrue
Related issues 

Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.