bosha/ptel-adapters

Adapters for PTel telnet implementation

dev-master 2015-03-18 11:50 UTC

This package is not auto-updated.

Last update: 2024-04-13 15:39:18 UTC


README

It's a small library for creating automated scripts for some devices (Cisco, DLink, etc) via telnet. All 'adapters' based on PTel library.

In most cases PTel library itself can handle all of those things, but some devices required additional setup, parameters, etc (for example: some devices does not require username, only password; privilege levels, custom string and page delimiters, and so on..). Creating your custom adapters can reduce your keystrokes and increase readablity.

I created adapters only for devices i've worked with. If you created adapters for some device - fill free to "pull". :)

Installation

Package can be easily installed via composer. Inside folder with your project simply run:

composer require bosha/ptel-adatpters

Or add to your composer.json:

"require" : {
    "bosha/ptel-adapters" : "dev-master"
}

And run:

composer update

Using

try {
    // Connect
    $cisco = new PTel_Adapters\Cisco\Catalyst();
    $cisco->connect("yoursupercisco.com");
    $cisco->login("username", "password");

    // Some helpful functions:
    $cisco->enable("enable password here");
    $cisco->saveConfiguration();
    $running_config = $cisco->getOutputOf("show running");
    $cisco->logout();
} catch (Exception $e) {
    echo "There was error while running script: " . $e->getMessage();
}

For another methods see PTel README.

Creating your own 'adapters'

Just create class, which extends PTel, setup public variables, create new methods or rewrite exists to suit your needs. Also see adapters adapters from this repo.