Git Product home page Git Product logo

csr_aws_guestshell's Introduction

Scripts for guestshell on Cisco CSR1000V on AWS

Introduction

This repository contains a library (csr_aws_guestshell) that has helper functions to make script writing a bit easier for AWS.

Installation

To enable guestshell on CSR on AWS:

ios-prompt#  guestshell enable VirtualPortGroup 0 guest-ip 192.168.35.2 name-server 8.8.8.8
Please wait for completion
ios-prompt# guestshell

To install csr_aws_guestshell:

[guestshell@guestshell ~]$ sudo pip install csr_aws_guestshell

Alternatively, you can install to your user directory:

[guestshell@guestshell ~]$ pip install --user csr_aws_guestshell

Running scripts

Scripts will be copied to the guestshell $PATH where they can then be run.

List of scripts to be installed:

Example output from running via IOS shell:

ip-172-31-52-111#guestshell run get-metadata.py
{
    "ami-id": "ami-1234abcd", 
    "ami-launch-index": "0", 
    "ami-manifest-path": "(unknown)", 
    "block-device-mapping": {
        "ami": "/dev/xvda", 
        "root": "/dev/xvda"
    }, 
    "hostname": "ip-XXX-XX-XX-XXX.ec2.internal", 

     ... <snip> ...

Example output from running via guestshell prompt:

[guestshell@guestshell ~]$ get-metadata.py
{
    "ami-id": "ami-1234abcd", 
    "ami-launch-index": "0", 
    "ami-manifest-path": "(unknown)", 
    "block-device-mapping": {
        "ami": "/dev/xvda", 
        "root": "/dev/xvda"
    }, 
    "hostname": "ip-XXX-XX-XX-XXX.ec2.internal", 

     ... <snip> ...

Examples using cli module

These scripts make use of the cli.py script pre-installed to guestshell. there are 4 main functions to use with the cli module:

import cli
show_run_output = cli.execute("show run")

Alternatively, you can print the result to stdout:

import cli
cli.executep("show run")
import cli
file = my_file.py
cron_entry="\"*/%d * * * *\"" % (seconds)
gs_cmd="\"guestshell run %s\"" % (file)

configuration = '''event manager applet %s
                        action 1.0 cli command %s
                        event timer cron cron-entry %s''' % (file,gs_cmd,cron_entry)
result= cli.configure(configuration)
import cli
cli.configurep("copy running-config startup-config")

Library "helpers"

These scripts contain the following functions to assist in script development:

  • download_file -- called with bucket name, filename and optional directory for the destination on the CSR1000V
  • upload_file -- called with bucket name, filename and optional directory for the location on the CSR1000V
  • save_cmd_output -- called with command list via python list, filename to save to, optional bucket if uploading file, and flag to print to stdout

Examples using csr_aws_guestshell

from csr_aws_guestshell import cag

cag().upload_file(my_bucket, my_filename)

cmdlist = \
    [
        "show interfaces",
        "show version",
        "show ip route",
        "show platform hardware qfp active statistics drop",
        "show platform hardware qfp active datapath utilization",
        "show interfaces gigabitEthernet 1 | incl drops|pack|err",
        "show platform hardware throughput level",
    ]
cag().save_cmd_output(cmdlist, my_filename, my_bucket)

csr_aws_guestshell's People

Contributors

avanivyas avatar croopa avatar hpreston avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csr_aws_guestshell's Issues

PyPi Package Outdated

Given the updates to master to work with Python3, can you publish a new release to PyPi?

Save-config-to-s3 wrong bootflash path

The script save-config-to-s3 as is won't work, as bootflash is not available from guestshell if not via "guest-share". The correct command to execute the script is: save-config-to-s3.py bucket name, guest-share/configfile

You should either update the documentation or the script.

Can't run guestshell on CSR1000v in AWS

Hi,

I can't run guestshell on AWS. version 16.5.1b (latest)

hr01-us(config)#iox
^
% Invalid input detected at '^' marker.

hr01-us(config)#
hr01-us#gues
hr01-us#guestshell ena
hr01-us#guestshell enable
iox feature is not enabled
hr01-us#

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.