StanMandela / cisco-CUBE

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Logo

Best-README-Template

About The Project

Product Name Screen Shot

Description

A Python script to automate assignment of preference to voice dial peers based on the calling rate of a specific destination for each SIP Trunk provider in an enterprise and therefore achieving least cost routing.

Use

Reduce cost of calling charges by routing to use the dial peer that has the fairest charges.

Built With

  • Python 3.9

Libraries

  • Paramiko
  • http.client

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

Install the following libraries pip

pip install pip --upgrade --user

Installation

  1. Clone the repo

    git clone https://github.com/finsysadmin/Cisco-CUBE.git
  2. Edit Database credentials accordingly to connect to your DB on func dbconnect

  3. Install paramiko

pip install paramiko
  1. install pydoc
pip install pydoc

6.install http client library

pip install http.client
  1. Run the program main

Usage

Automating dial peer preferences assignment. Lower rates of calling incured as the dial peer will be configured to use the prefernces with the least cost.

Code Samples

DB connect function

def dbconnect(self, server=None):
        server = "10.244.0.5"
        database = "DevNet"
        tcon = "yes"
        uname = "sa"
        pword = "K0Junga#"
        conn = pyodbc.connect(driver='{SQL Server Native Client 11.0}', host=server, database=database,
                              user=uname, password=pword)
        self.connection = conn

Write config to cisco device

 def write_config(self):
        preference = 0
        for dial_peer in self.preferences:
            # Create dial peer
            peer = str(1) + str(dial_peer.AREA) + str(dial_peer.SPCODE) + str(dial_peer.GW)
            # write dial peer and preference
            self.connection.send("dial-peer voice " + peer + " voip\n")  # dial-peer voice 1 254 3 voip
            self.connection.send("preference " + str(preference) + "\n")  # preference 0
            preference = preference + 1
            time.sleep(1)

        router_output = self.connection.recv(65535)
        # Test for reading command output
        print(str(router_output) + "\n")

For more examples, please refer to the Documentation

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Project Link: https://github.com/finsysadmin/Cisco-CUBE

Acknowledgements

About

License:MIT License