Nexus Application Development - SDK

Similar documents
SDK. About the Cisco SDK. Installing the SDK. Procedure. This chapter contains the following sections:

Building RPMs for Native Application Hosting

Linux Essentials Objectives Topics:

COUCHDB - INSTALLATION

Bring order into packaging madness. Marcela Mašláňová Supervisor Software Engineer, Red Hat May 2013

Unzip command in unix

Ganglia is monitring system for high performance computing systems. We have two node potter.isb.ots.com and harry.isb.ots.com both are HPC nodes.

RPM Package Building & Automated Package Manager

Tool installation for PMC-MC-X2/X4 with P2020 series processor

Introduction To Linux. Rob Thomas - ACRC

Akamai Connector for Varnish Installation Guide

L.A.M.P. Stack Part I

Linux Software Installation Exercises 2 Part 1. Install PYTHON software with PIP

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

CS 460 Linux Tutorial

RHEL Packaging. (making life easier with RPM) Jindr ich Novy Ph.D., June 26, 2012

Working with Basic Linux. Daniel Balagué

Perl and R Scripting for Biologists

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Intel Do-It-Yourself Challenge Compile C/C++ for Galileo Nicolas Vailliet

swiftenv Documentation

Manual Install Package Rpm Linux Command Line

Platform Migrator Technical Report TR

Zend Server Community Edition 5.1. Installation Guide. By Zend Technologies.

CS197U: A Hands on Introduction to Unix

Unix/Linux Operating System. Introduction to Computational Statistics STAT 598G, Fall 2011

Compiling Software on UNIX. System Administration Decal Spring 2009 Lecture #4 George Wu Slides prepared by Joshua Kwan

COURIER IMAP + COURIERPASSD for Qmail

Introduction to the shell Part II

Lab Working with Linux Command Line

Computer Systems and Architecture

If you had a freshly generated image from an LCI instructor, make sure to set the hostnames again:

a. puppet should point to master (i.e., append puppet to line with master in it. Use a text editor like Vim.

Php Scripts If Then Else Linux Bash Shell

Building Linux Packages with RPM

BUILDING YOUR OWN RPMS

Article Number: 569 Rating: 2.7/5 from 3 votes Last Updated: Tue, Sep 12, 2017 at 2:54 AM

Setting up an SDK for Secondo

Android SDK under Linux

3 Installation from sources

~]# uname -a Linux app el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Running Blockchain in Docker Containers Prerequisites Sign up for a LinuxONE Community Cloud trial account Deploy a virtual server instance

Computer Systems and Architecture

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

R- installation and adminstration under Linux for dummie

Custom RPMs. For system configuration. Tim Klemz. Presented by. Unix Admin(RHCE), Lifetouch Inc.

Communications Library Manual

MariaDB ColumnStore C++ API Building Documentation

TrinityCore Documentation

Introduction to Linux

APEX Installation Guide. Sven van der Meer, Liam Fallon, John Keeney. Version SNAPSHOT, T16:01:13Z

Zephyr Kernel Installation & Setup Manual

CS197U: A Hands on Introduction to Unix

4 Installation from sources

Yocto Project components

4 Installation from sources

Dockerfile Best Practices

Singularity: container formats

3 Installation from sources

Installation Manual InfraManage.NET Installation Instructions for Ubuntu

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Moab HPC Suite. Installation and Configuration Guide for SUSE 12- Based Systems. January 2017

Bitnami JRuby for Huawei Enterprise Cloud

Metasploit. Installation Guide Release 4.4

Be smart. Think open source.

The Rockefeller University I NFORMATION T ECHNOLOGY E DUCATION & T RAINING. VPN Configuration Guide for Unix/Linux

RHCE BOOT CAMP. Various Additional Topics

Recap From Last Time:

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

TNM093 Practical Data Visualization and Virtual Reality Laboratory Platform

BGGN 213 Working with UNIX Barry Grant

Linux Command Line Interface. December 27, 2017

Vaango Installation Guide

Installing Lemur on Mac OS X and CSE Systems

Drupal Command Line Instructions Windows 7 List All Files >>>CLICK HERE<<<

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Unix / Linux Overview

Intel Software Guard Extensions SDK for Linux* OS. Installation Guide

CSCI 201 Lab 1 Environment Setup

Network Management with Nagios

Introduction to Linux

Optimizing Docker Images

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Centreon SSH Connector Documentation

Intel Accelerator Functional Unit (AFU) Simulation Environment (ASE) Quick Start User Guide

Method of Procedure to Upgrade RMS OS to Red Hat Enterprise Linux 6.7

02. At the command prompt, type usermod -l bozo bozo2 and press Enter to change the login name for the user bozo2 back to bozo. => steps 03.

010 Server Setup Notes

Real-Time Monitoring Configuration Utility

Bitnami Pimcore for Huawei Enterprise Cloud

How much memory users uses in GNU / Linux and FreeBSD - Commands and Scripts to find user memory usage on Linux

cgatools Installation Guide

EE516: Embedded Software Project 1. Setting Up Environment for Projects

Real-Time Monitoring Configuration Utility

MAKING CONTAINERS EASIER WITH HPC CONTAINER MAKER. Scott McMillan September 2018

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

About the Tutorial. Audience. Prerequisites. Copyright and Disclaimer. Logstash

Manual Java Update Mac Developer Package

DEVELOPMENT GUIDE AMOS-820. Linux BSP v

Introduction of Linux

Transcription:

This chapter contains the following sections: About the Cisco SDK, page 1 Installing the SDK, page 1 Procedure for Installation and Environment Initialization, page 2 Using the SDK to Build Applications, page 2 Using RPM to Package an Application, page 4 Creating an RPM Build Environment, page 4 Using General RPM Build Procedure, page 5 Example to Build RPM for collectd with No Optional Plugins, page 5 Example to Build RPM for collectd with Optional Curl Plugin, page 6 About the Cisco SDK The Cisco SDK is a development kit based on Yocto 1.2. It contains all of the tools needed to build applications for execution on a Cisco Nexus switch running the NX-OS Release 7.0(3)I2(1). The basic components are the C cross-compiler, linker, libraries, and header files that are commonly used in many applications. The list is not exhaustive, and it might be required that the you download and build any dependencies needed for any particular application. that some applications are ready to be downloaded and used from the Cisco devhub website and do not require building. The SDK can be used to build RPM packages which may be directly installed on a switch. Installing the SDK The following lists the system requirements: The SDK should run on most modern 64-bit x86_64 Linux systems. It has been verified on Centos 7 and Ubuntu 14.04. It should be installed and run under the bash shell. 1

Procedure for Installation and Environment Initialization The SDK includes binaries built for both 32-bit and 64-bit architectures, so it needs to be run on an x86_64 Linux system that also has 32-bit libraries installed. The following command may be used to check if the 32-bit libraries are installed: bash$ ls /lib/ld-linux.so.2 If this file exists, then 32-bit libraries should already be installed. Otherwise, install 32-bit libraries as follows: For Centos 7: bash$ sudo yum install glibc.i686 For Ubuntu 14.04: bash$ sudo apt-get install gcc-multilib Procedure for Installation and Environment Initialization The SDK is available for download at: http://devhub.cisco.com/artifactory/simple/open-nxos/7.0-3-i2-1/ x86_64/wrlinux-5.0.1.13-eglibc-x86_64-n9000-nxos-image-rpm-sdk-sdk.sh This file is a self-extracting archive that installs the SDK into a directory of your choice. You are prompted for a path to an SDK installation directory. bash$./wrlinux-5.0.1.13-eglibc-x86_64-n9000-nxos-image-rpm-sdk-sdk.sh Enter target directory for SDK (default: /opt/windriver/wrlinux/5.0-n9000): /path/to/sdk_install_directory You are about to install the SDK to "/path/to/sdk_install_directory". ProceedY/n?Y Extracting SDK...done Setting it up...done SDK has been successfully set up and is ready to be used. bash$ Use the source environment-setup-x86_64-wrs-linux command to add the SDK-specific paths to your shell environment. This must be done for each shell you intend to use with the SDK. This is the key to setting up the SDK in order to use the correct versions of the build tools and libraries. Procedure Step 1 Step 2 Browse to the installation directory. Enter the following command at the Bash prompt: bash$ source environment-setup-x86_64-wrs-linux Using the SDK to Build Applications Many of the common Linux build processes work for this and you should use the techniques that are best suited for your situation. The source code for an application package can be retrieved in various ways, for example either in tar file form or by downloading from a git repository where the package resides. Below are examples of some of the most common cases. 2

Using the SDK to Build Applications (Optional) Verify the application package builds using standard configure/make/make install bash$ tar --xvzf example-app.tgz bash$ mkdir example-lib-install bash$ cd example-app/ bash$./configure --prefix=/path/to/example-app-install install In some cases, it might be necessary to pass extra options to the./configure script, for example to specify which optional components and dependencies are needed. This depends entirely on the application being built. Example - Build ganglia and its dependencies In this example, we will build ganglia, along with the third-party libraries that it requires - libexpat, libapr and libconfuse. libexpat bash$ wget 'http://downloads.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz' bash$ mkdir expat-install bash$ tar xvzf expat-2.1.0.tar.gz bash$ cd expat-2.1.0 bash$./configure --prefix=/home/sdk-user/expat-install install libapr bash$ wget 'http://www.eu.apache.org/dist/apr/apr-1.5.2.tar.gz' bash$ mkdir apr-install bash$ tar xvzf apr-1.5.2.tar.gz bash$ cd apr-1.5.2 bash$./configure --prefix=/home/sdk-user/apr-install install libconfuse confuse requires the extra --enable-shared option to./configure, otherwise it will build a statically linked library instead of the required shared library. bash$ wget 'http://savannah.nongnu.org/download/confuse/confuse-2.7.tar.gz' bash$ mkdir confuse-install bash$ tar xvzf confuse-2.7.tar.gz bash$ cd confuse-2.7 bash$./configure --prefix=/home/sdk-user/confuse-install --enable-shared install ganglia The locations to all the required libraries are passed to./configure. bash$ wget 'http://downloads.sourceforge.net/project/ganglia/ganglia%20monitoring%20core/3.7.2/ganglia-3.7.2.tar.gz' bash$ mkdir ganglia-install bash$ tar xvzf ganglia-3.7.2.tar.gz bash$ cd ganglia-3.7.2 bash$./configure --with-libexpat=/home/sdk-user/expat-install 3

Using RPM to Package an Application --with-libapr=/home/sdk-user/apr-install/bin/apr-1-config --with-libconfuse=/home/sdk-user/confuse-install --prefix=/home/sdk-user/ganglia-install install Using RPM to Package an Application If the application successfully builds using "make", then it can be packaged into an RPM. RPM and spec files The RPM package format is designed to package up all files (binaries, libraries, configurations, documents, etc) that are needed for a complete install of the given application. The process of creating an RPM file is therefore somewhat non-trivial. To aid in the RPM build process, a.spec file is used that controls everything about the build process. Many third-party applications are available on the internet in the form of source code packaged into tarballs. In many cases, these tarballs will include a.spec file to help with RPM build process. Unfortunately, many of these.spec files are not updated as frequently as the source code itself. Even worse, sometimes there is no spec file at all. In these cases the spec file may need editing or even creating from scratch so that RPMs can be built. Creating an RPM Build Environment Before using the SDK to build RPMs, an RPM build directory structure must be created, and some RPM macros set. Procedure Step 1 Step 2 Step 3 Create the directory structure: bash$ mkdir rpmbuild bash$ cd rpmbuild bash$ mkdir BUILD RPMS SOURCES SPECS SRPMS Set the topdir macro to point to the directory structure created above: bash$ echo "_topdir ${PWD}" > ~/.rpmmacros This assumes the current user does not already have a.rpmmacros file already set up. If it is inconvenient to alter an existing.rpmmacros file, then the following may be added to all rpmbuild command lines: --define "_topdir ${PWD}" Refresh the RPM DB: bash$ rm /path/to/sdk/sysroots/x86_64-wrlinuxsdk-linux/var/lib/rpm/ db.* bash$ rpm --rebuilddb 4

Using General RPM Build Procedure The rpm and rpmbuild tools in the SDK have been modified to use /path/to/sdk/sysroots/x86_64-wrlinuxsdk-linux/var/lib/rpm as the RPM database instead of the normal /var/lib/rpm. This prevents any conflicts with the RPM database for the host when not using the SDK and obviates the need for root access. After SDK installation, the SDK RPM database must be rebuilt as above. Using General RPM Build Procedure General RPM Build procedure is as follows: bash$ wget --no-check-certificate --directory-prefix=sources http://<url of example-app tarball> bash$ # determine location of spec file in tarball: bash$ tar tf SOURCES/example-app.tar.bz2 grep '.spec$' bash$ tar xkvf SOURCES/example-app.tar.bz2 example-app/example-app.spec bash$ mv example-app/example-app.spec SPECS/ bash$ rm -rf example-app bash$ rpmbuild -v --bb SPECS/example-app.spec The result is a binary RPM in RPMS/ that can be copied to the switch and installed. Installation and configuration of applications can vary. Refer to the application documents for those instructions. This rpmbuild and installation on the switch is required for every software package needed to support the application. If a software dependency is required that is not already included in the SDK, the source code must be obtained and the dependencies built. On the build machine, the package can be built manually for verification of dependencies. The following example is the most common procedure: bash$ tar xkzf example-lib.tgz bash$ mkdir example-lib-install bash$ cd example-lib/ bash$./configure --prefix=/path/to/example-lib-install install These commands place the build files (binaries, headers, libraries, etc.) into the installation directory. From here you can use standard compiler and linker flags to pick up the location to these new dependencies. Any runtime code such as libraries are required to be installed on the switch as well, so packaging this into an RPM is also needed. There are many support libraries already in RPM form on the Cisco devhub website. Example to Build RPM for collectd with No Optional Plugins Download source tarball and extract spec file: bash$ wget --no-check-certificate --directory-prefix=sources https://collectd.org/files/collectd-5.5.0.tar.bz2 bash$ tar tf SOURCES/collectd-5.5.0.tar.bz2 grep '.spec$' collectd-5.5.0/contrib/redhat/collectd.spec collectd-5.5.0/contrib/aix/collectd.spec collectd-5.5.0/contrib/sles10.1/collectd.spec collectd-5.5.0/contrib/fedora/collectd.spec bash$ tar xkvf SOURCES/collectd-5.5.0.tar.bz2 collectd-5.5.0/contrib/redhat/collectd.spec 5

Example to Build RPM for collectd with Optional Curl Plugin bash$ mv collectd-5.5.0/contrib/redhat/collectd.spec SPECS/ bash$ rm -rf collectd-5.5.0 There are 4 spec files in this tarball. The redhat spec file is the most comprehensive and is the only one to contain the correct collectd version, so we pick that one here. This spec file will set the RPM up to use /sbin/chkconfig to install collectd. However on an Nexus switch, /usr/sbin/chkconfig needs to be used instead, so this can be edited in the spec file: bash$ sed -r -i.bak 's%(^ \s)/sbin/chkconfig%\1/usr/sbin/chkconfig%' SPECS/collectd.spec collectd has numerous optional plugins. This spec file enables a lot of them by default, but many have external dependencies, so options to disable these plugins will be passed to the rpmbuild command line. Instead of typing out one long command line, we may manage the options in a bash array as follows: bash$ rpmbuild_opts=() bash$ for rmdep in \ > amqp apache ascent bind curl curl_xml dbi ipmi java memcachec mysql nginx \ > notify_desktop notify_email nut openldap perl pinba ping postgresql python \ > rrdtool sensors snmp varnish virt write_http write_riemann > do > rpmbuild_opts+=("--without") > rpmbuild_opts+=(${rmdep}) > done bash$ rpmbuild_opts+=(--nodeps) bash$ rpmbuild_opts+=(--define) bash$ rpmbuild_opts+=("_unpackaged_files_terminate_build 0") This is then passed to rpmbuild as follows to start the entire build and RPM package process: bash$ rpmbuild "${rpmbuild_opts[@]}" -bb SPECS/collectd.spec You should then find the resulting RPMs for collectd in the RPMS directory. These.rpm files can now be copied to the switch and installed from the switch bash shell: bash$ rpm --noparentdirs -i /bootflash/collectd-5.5.0-1.ia32e.rpm Example to Build RPM for collectd with Optional Curl Plugin The collectd curl plugin has libcurl as a dependency. In order to satisfy this link dependency during the RPM build process, it is necessary to download and build curl under the SDK: bash$ wget --no-check-certificate http://curl.haxx.se/download/curl-7.24.0.tar.gz bash$ tar xkvf curl-7.24.0.tar.gz bash$ cd curl-7.24.0 bash$./configure --without-ssl --prefix /path/to/curl-install install The curl binaries and libraries will be installed to /path/to/curl-install. This directory will be created if it does not already exist, so you must have write permissions for the current user. Next, download source tarball and extract spec file. This step is exactly the same as in the collectd example for no plugins. bash$ wget --no-check-certificate --directory-prefix=sources https://collectd.org/files/collectd-5.5.0.tar.bz2 bash$ tar tf SOURCES/collectd-5.5.0.tar.bz2 grep '.spec$' collectd-5.5.0/contrib/redhat/collectd.spec 6

Example to Build RPM for collectd with Optional Curl Plugin collectd-5.5.0/contrib/aix/collectd.spec collectd-5.5.0/contrib/sles10.1/collectd.spec collectd-5.5.0/contrib/fedora/collectd.spec bash$ tar xkvf SOURCES/collectd-5.5.0.tar.bz2 collectd-5.5.0/contrib/redhat/collectd.spec bash$ mv collectd-5.5.0/contrib/redhat/collectd.spec SPECS/ bash$ rm -rf collectd-5.5.0 There are 4 spec files in this tarball. The redhat spec file is the most comprehensive and is the only one to contain the correct collectd version, so you pick that one here. This spec file will set the RPM up to use /sbin/chkconfig to install collectd. However on an Nexus switch, /usr/sbin/chkconfig needs to be used instead, so this can be edited in the spec file: bash$ sed -r -i.bak 's%(^ \s)/sbin/chkconfig%\1/usr/sbin/chkconfig%' SPECS/collectd.spec Here a deviation from the previous example is encountered. The collectd rpmbuild process will now need to know the location of libcurl. The collectd spec file can be edited to add this: Find the string %configure in SPECS/collectd.spec. This line and those following it define the options that rpmbuild will pass to the./configure script. Add the following option: --with-libcurl=/path/to/curl-install/bin/curl-config \ Next a bash array is built again to contain the rpmbuild command options. the following differences: curl is removed from the list of plugins not to be built The addition of --with curl=force bash$ rpmbuild_opts=() bash$ for rmdep in \ > amqp apache ascent bind curl_xml dbi ipmi java memcachec mysql nginx \ > notify_desktop notify_email nut openldap perl pinba ping postgresql python \ > rrdtool sensors snmp varnish virt write_http write_riemann > do > rpmbuild_opts+=("--without") > rpmbuild_opts+=(${rmdep}) > done bash$ rpmbuild_opts+=("--with") bash$ rpmbuild_opts+=("curl=force")bash$ rpmbuild_opts+=(--nodeps) bash$ rpmbuild_opts+=(--define) bash$ rpmbuild_opts+=("_unpackaged_files_terminate_build 0") This is then passed to rpmbuild as follows to start the entire build and RPM package process: bash$ rpmbuild "${rpmbuild_opts[@]}" -bb SPECS/collectd.spec The resulting RPMs in the RPMS directory will now also include collectd-curl. These.rpm files can now be copied to the switch and installed from the switch bash shell: bash$ rpm --noparentdirs -i /bootflash/collectd-5.5.0-1.ia32e.rpm bash$ rpm --noparentdirs -i /bootflash/collectd-curl-5.5.0-1.ia32e.rpm 7

Example to Build RPM for collectd with Optional Curl Plugin 8