Aviz Networks AIMS SONIC Ruby API Library

Overview

The Ruby Client for Azure SONIC REST API provides a native Ruby implementation for programming Aviz Networks SONIC network devices using AIMS. The Ruby client provides the ability to build native applications in Ruby that can communicate with SONIC remotely over a HTTP transport protocol.

The Ruby API implemenation also provides an API layer for building native Ruby objects that allow for configuration and management of Aviz Networks SONIC switches using AIMS.

Requirements

  • Aviz Networks SONIC switches
  • Ruby 2.2.3 or later

SONIC Ruby APIs

The SONIC Ruby Client was designed to be easy to use and develop plugins or tools that interface with the Aviz Networks SONIC switches.

Using the API

See the below example for using the API. Also refer test/ directory for more details.

Switch Configuration file

This configuration file is used to define the configuration options or model for switches (switch.yml or any xxx.yml)

protocol : 'http' # protocol (HTTP)
port : '8090' # HTTP(s) port number (8090 - HTTP)
ip : 'switch ip address' # Switch IP address
user : 'username'  # Switch Credentials
password : 'password' #switch credentials 

Creating connection and sending configurations

Below demonstrates a basic connection using the API. For more examples please see the examples folder

#### import the libraries
require 'sonic-rbapi/connect'
require 'sonic-rbapi/vlan'

##### create connection to the node using the configuration file
conn = Connect.new(param) 

where param is a dictionary formed either from the config file or hardcoded 
with the following key value pairs 

protocol => 'http' # protocol (HTTP) 
port => '8090' # HTTP(s) port number (8090 - HTTP)
ip => 'switch ip address' # Switch IP address 
user => 'username' #Switch Credentials
password => 'password' #Switch Credentials

##### Use VLAN APIs to retrieve all VLAN information
Vlan.get_all_vlan(conn)

##### Use VLAN APIs to create VLANs
vlan_id = 10
dhcp_servers =  ["10.10.10.1", "10.10.10.2"]
resp = Vlan.create_vlan(conn, vlan_id, dhcp_servers)

##### Use VLAN APIs to retrieve specific VLAN information
resp = Vlan.get_vlan(conn, 20)

##### Use VLAN APIs to delete VLANs
Vlan.delete_vlan(conn, 20)