Wednesday, 6 March 2019

MerakiBeats


Installing GO

Download and Install Go Language

  • Update your system using the following command.
### Debian 9 / Ubuntu 16.04 / 14.04 ###

# apt-get update

### CentOS / RHEL / Fedora ###

# yum -y update

  • Install wget package
### Debian 9 / Ubuntu 16.04 / 14.04 ###

# apt-get install wget

### CentOS / RHEL / Fedora ###

# yum -y install wget
  • Download the Go language binary package 
# wget https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz
  • Extract the archive and move it to /usr/local
# tar -zxvf  go1.9.2.linux-amd64.tar.gz -C /usr/local/
  • Setup Go Environment variables
    • temporary
export PATH=$PATH:/usr/local/go/bin
    • permanent
place the above command in /etc/profile or $HOME/.profile file for persistent across sessions
  • install gcc (this is generally required)
yum install gcc
  • Verify Go Installation
# go version
go version go1.9.2 linux/amd64

# go env

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/work"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

Build the binary for merakibeat

To clone merakibeat from the git repository, run the following commands


mkdir -p ${GOPATH}/src/github.com/CiscoDevNet/merakibeat

git clone https://github.com/CiscoDevNet/merakibeat.git ${GOPATH}/src/wwwin-github.cisco.com/DevNet/merakibeat
  • Build
To build the binary for merakibeat run the command below. This will generate a binary in the same directory with the name merakibeat.

make
  • Run
To run merakibeat with debugging output enabled, run

./merakibeat -c merakibeat.yml -e -d "*"



    Friday, 17 June 2016

    Contrail Analytics Application Programming Interfaces (API) -UVE


    Contrail Analytics collects information from the various components of the system, and provides the visibility into flows, logs and UVEs that is needed to operate this system. This information is provided via a REST API, which can be used to build management and analytics applications and dashboards. The Contrail UI uses this REST API as well.


    To get information about a UVE, you must have the UVE type and the UVE key. In Contrail, UVEs are identified by type, such as virtual network, virtual machine, vRouter, and so on. A system-wide unique key is associated with each UVE. The key type could be different, based on the UVE type

    First we need to get the correct UVE key like below:


    Then after selecting the required UVE key(vRouter in the below example) we can get the required information:


    Selecting the particular vRouter we can get the detailed information:
    http://172.16.5.93:8081/analytics/uves/vrouter/vm-hyper3?flat




    Thursday, 16 June 2016

    installing VMwareTools

    First download the VMwareTools file from the below location:


    https://my.vmware.com/group/vmware/details?productId=529&downloadGroup=VMTOOLS1006

    Now follow these steps after copying the VMWareTools file to  /tmp directory

    tar -xvzf VMwareTools-xxxxxx.tar.gz

    cd vmware-tools-distrib/

    ./vmware-install.pl


    at this point just follow the instructions till you get this message



    Enjoy,
    
    --the VMware team

    Sunday, 5 June 2016

    updating python script to SSH with and without Enable password for Cisco devices

    python script to SSH with and without Enable password for Cisco devices
    i have tried this on Cisco IOS, IOS-XE and NX-OS and works for me.

    Without enable password requirement to print 'Show hostname' and 'Show version'(you can change that to whatever CLI you need to print.

    import paramiko

    def sshCall(host,port,user,passw):
      dssh = paramiko.SSHClient()
      dssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
      dssh.connect(hostname=host,port=port,username=user,password=passw)
      dssh.exec_command('term len 0')
      stdin, stdout, stderr = dssh.exec_command('show hostname')
      bc=stdout.read()
      print bc
      # b=bc.strip('\n')
      stdin, stdout, stderr = dssh.exec_command('show version')
      a= stdout.read()
      print a
      f = open('/output.txt', 'a')

      f.write(bc)

      f.write(a)
      f.close()
      dssh.close()

    sshCall('1.1.1.1',22,"username","password)

    With enable password

    import paramiko
    import time

    def sshCall(host,port,user,passw):
      dssh = paramiko.SSHClient()
      dssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
      dssh.connect(hostname=host,port=port, username=user,password=passw)
      shell = dssh.invoke_shell()
      time.sleep(1)
      shell.send('enable\n')
      shell.send('FixStream123!\n')
      time.sleep(1)
      shell.send('term len 0\n')

      shell.send('show version\n')
      time.sleep(2)
      resp = shell.recv(9999)
      print resp
      dssh.close()

    sshCall('1.1.1.1',22,"usr","pwd")

    Saturday, 4 June 2016

    Juniper Contrail Python API


    You can download the Contrail python API Bindings from here

    https://github.com/Juniper/contrail-python-api

    Install instructions

    git clone https://github.com/Juniper/contrail-python-api
    cd contrail-python-api
    python setup.py install

    So the basic example explains how to connect using the Client Method and list Virtual_Networks


    import pycontrail.client as client
    conn = client.Client(url='http://10.84.34.141:8082',
            auth_params={'type':'keystone',
            'auth_url':'http://10.84.34.141:5000/v2.0',
            'username':'admin',
            'password':'secret',
            'tenant_name':'admin'})

    conn.virtual_networks_list()

    I am going to explain how to collect Data that will make some sense, although a lot of python enthusiasts will figure it out but if this is any help id be happy
    reason why i wanted to share this script is that i had taken time to write the loops to get all the dict data within lists etc. 

    I printed all the output in JSON format as final output

    from pycontrail import client
    import jsonpickle

    import jsonpickle
    conn = client.Client(
            url='http://1.1.1.1:8082',auth_params={'type':'keystone','auth_url':'http://2.2.2.2:5000/v2.0','username':'admin','password':'password','tenant_name':'admin'})

    route_instance_uuid_list=[]
    bb = conn.routing_instances_list()
    for each_route_instance in bb['routing-instances']:
        route_instance_uuid_list.append(each_route_instance['uuid'])


    route_instance_detail_list=[]
    for each_route_instance in route_instance_uuid_list:
        vn_detail_dict={'name':None,'route_instance':[],'route_target':[]}
        aa= conn.routing_instance_read(id=each_route_instance)
        vn_detail_dict['name'] =aa.name
        # print aa.name


        #route_instance
        try:
            route_instance=[]


            for each_routing in aa.routing_instance_refs:
                route_instance_dict={}
                route_instance_dict['route_instance']= dict(zip(range(0,len(each_routing['to'])), each_routing['to']))
                route_instance.append(route_instance_dict)
        except:
            pass
        vn_detail_dict['route_instance']=route_instance
        #route_instance

        #route_targets
        try:
            route_target=[]

            for each_routetarget in aa.route_target_refs:
                route_target_dict={}
                route_target_dict['route_target']= dict(zip(range(0,len(each_routetarget['to'])), each_routetarget['to']))
                route_target.append(route_target_dict)
        except:
            pass
        vn_detail_dict['route_target']=route_target
        #route_targets

        route_instance_detail_list.append(vn_detail_dict)



    vn_instance_uuid_list=[]
    vn=conn.virtual_networks_list()
    for each_vn in vn['virtual-networks']:
        vn_instance_uuid_list.append(each_vn['uuid'])








    vn_instance_detail_list=[]
    for each_vn_instance in vn_instance_uuid_list:

        vn_instance_detail_dict={}
        gg=conn.virtual_network_read(id=each_vn_instance)
        vn_instance_detail_dict['virtual_network_network_id']= gg.virtual_network_network_id
        vn_instance_detail_dict['uuid']= gg.uuid
        vn_instance_detail_dict['name']= gg.name
        vn_instance_detail_dict['parent_name']= gg.parent_name
        vn_instance_detail_dict['parent_uuid']= gg.parent_uuid
        try:
            vn_instance_detail_dict['forwarding_mode']= gg.virtual_network_properties.forwarding_mode

            for each_ipam in gg.network_ipam_refs:
                ipam_subnet_list=[]
                for each_ipam_subnet in each_ipam['attr'].ipam_subnets:
                    ipam_subnet_dict={}
                    ipam_subnet_dict['default_gateway']= each_ipam_subnet.default_gateway
                    ipam_subnet_dict['dns_server_address']= each_ipam_subnet.dns_server_address
                    ipam_subnet_dict['subnet_uuid']= each_ipam_subnet.subnet_uuid
                    ipam_subnet_dict['subnet_name'] =each_ipam_subnet.subnet_name
                    ipam_subnet_dict['ip_prefix_len']= each_ipam_subnet.subnet.ip_prefix_len
                    ipam_subnet_dict['ip_prefix']= each_ipam_subnet.subnet.ip_prefix
                    ipam_subnet_list.append(ipam_subnet_dict)
                    allocation_pool_list=[]
                    for each_allocation_pool in  each_ipam_subnet.allocation_pools:
                        allocation_pool_dict={}
                        allocation_pool_dict['start'] =each_allocation_pool.start
                        allocation_pool_dict['end']= each_allocation_pool.end
                        allocation_pool_list.append(allocation_pool_dict)
                    ipam_subnet_dict['allocation_pool']=allocation_pool_list

            vn_instance_detail_dict['ipam']=ipam_subnet_list

            network_policy_list=[]
            for each_network_policy in gg.network_policy_refs:
                network_policy_dict={}
                network_policy_dict['uuid']= each_network_policy['uuid']
                network_policy_dict['network_policy'] =dict(zip(range(0,len(each_network_policy['to'])), each_network_policy['to']))
                network_policy_list.append(network_policy_dict)
                vn_instance_detail_dict['network_policy']=network_policy_list

        except:
            pass
        vn_instance_detail_list.append(vn_instance_detail_dict)



    np_uuid_list=[]
    np_list = conn.network_policys_list()
    for each_np in np_list['network-policys']:
        np_uuid_list.append(each_np['uuid'])


    each_np_detail_list=[]
    for each_np_uuid in np_uuid_list:
        each_np_detail_dict={'policy':[]}
        nppp = conn.network_policy_read(id=each_np_uuid)
        each_np_detail_dict['uuid']= nppp.uuid
        each_np_detail_dict['name']=  nppp.name
        each_np_detail_dict['parent_name']=  nppp.parent_name
        try:
            each_policy_list=[]
            for each_policy_entry in nppp.network_policy_entries.policy_rule:
                each_policy_dict={'dst_addresses':[],'src_addresses':[]}
                each_policy_dict['protocol']= each_policy_entry.protocol
                each_policy_dict['ethertype']= each_policy_entry.ethertype
                each_policy_dict['direction']= each_policy_entry.direction
                each_policy_dict['rule_uuid']= each_policy_entry.rule_uuid
                each_policy_dict['simple_action']=  each_policy_entry.action_list.simple_action
                each_policy_dict['gateway_name']=  each_policy_entry.action_list.gateway_name

                dst_address_list=[]
                for each_dst_address in each_policy_entry.dst_addresses:
                    dst_address_dict={}
                    dst_address_dict['network_policy']= each_dst_address.network_policy
                    dst_address_dict['security_group']= each_dst_address.security_group
                    dst_address_dict['subnet']= each_dst_address.subnet
                    dst_address_dict['virtual_network']= each_dst_address.virtual_network
                    dst_address_list.append(dst_address_dict)

                each_policy_dict['dst_addresses']=dst_address_list
                src_address_list=[]
                for each_src_address in each_policy_entry.src_addresses:
                    src_address_dict={}
                    src_address_dict['network_policy']= each_src_address.network_policy
                    src_address_dict['security_group']=  each_src_address.security_group
                    src_address_dict['subnet']=  each_src_address.subnet
                    src_address_dict['virtual_network']=  each_src_address.virtual_network
                    src_address_list.append(src_address_dict)
                each_policy_dict['src_addresses']=src_address_list
                each_policy_list.append(each_policy_dict)
            each_np_detail_dict['policy']=each_policy_list

        except:
            pass
        each_np_detail_list.append(each_np_detail_dict)



    final_output = {
        'virtual_network_instance':vn_instance_detail_list,
        'route_instance':route_instance_detail_list,
        'network_policy':each_np_detail_list
    }

    print jsonpickle.pickler.encode(final_output)

        

    Thursday, 11 February 2016

    mapping dataStores NAA identifier from a host like VMware to NetApp LUN serial number

    what is LUN NAA

    A LUN Network Address Authority (NAA) number is a globally unique identifier for a LUN. The NAA number can be used to determine a LUN's serial number and vice-versa.

    Method

    Data ONTAP operating in 7-Mode or clustered Data ONTAP 8.3 or later include a LUN command to obtain the LUN serial number in the hexadecimal format:
    lun serial -x /vol/test/lun
    Serial (hex)#: 0x486e542d4f5a2f47694d684b
    Take the example of a LUN with the following NAA number:

    naa.60a98000486e542d4f5a2f47694d684b

    Remove the NAA string and the first 8 characters. In this example, naa.60a98000 (this is one of the NetApp vendor identifiers).
    The remaining value (486e542d4f5a2f47694d684b) is the hexadecimal string which, when converted from HEX to ASCII, will be the LUN serial number. There are many Web-based tools to convert HEX to ASCII and vice-versa if you are using a version of Data ONTAP that does not have the lun serial -x command available.
    486e542d4f5a2f47694d684b in HEX converts to an ASCII value of HnT-OZ/GiMhK

    You can use either the output of the command lun show –v, or review the 'LUN CONFIGURATION' section of a storage system’s autosupport output to determine which is the LUN, based on the LUN serial number in the ASCII format.
    The following is an example of the output of the lun show –v command:

    Filer1> lun show -v /vol/test/lun
    /vol/test/lun  5g (5368709120)(r/w, online, mapped)
    Serial#: HnT-OZ/GiMhK
    Share: none
    Space Reservation: disabled
    Multiprotocol Type: vmware
    Maps: test=0


    after taking the serial number convert the string value to Hex value using any online tool 


    append the NAA prefix based on the table below:

    so the result is naa.60a98000486e542d4f5a2f47694d684b

    Note the LUN serial number above (HnT-0Z/GiMhK). The LUN with naa.60a98000486e542d4f5a2f47694d684b is /vol/test/lun.

    NAA prefixes:
    Clustered Data ONTAP and Data ONTAP 7-Mode   naa.60a98000
    Clustered Data ONTAP                                           naa.600a0980
    E-Series                                                                   naa.60080e50

    Monday, 15 September 2014

    UCS deep dive

    just a visual of the UCS B-series deep dive
    this is what how i look at a low level of a B-series blade server.