CHAPTER 6

Using the V2P Utility

The V2P Package Manager Utility (v2pPkgMgr) enables the import of an application to the V2P repository VM containing one or more node package manager (NPM) or RPM package manager (RPM) modules. This utility also enables import of an application upgrade bundle, a package that combines all of the lower-level application packages needed for an upgrade into one or more compressed . files.

Note In this document, all descriptions of a “package format” refer the format of an application package and not the format of an application upgrade bundle.

After importing the application, v2pPkgMgr publishes NPM modules to the NPM registry server of the Sinopia V2P repository VM. If the application is an AIC, v2pPkgMgr also creates the corresponding application repository to allow installation or upgrade scripts running on the worker VM to directly perform YUM installations or upgrades from the V2P repository VM.

Note Always log in to the V2P repository VM as v2pc (password = v2pc) prior to running v2pPkgMgr.

Package Requirements

• The application package for a specific application version must contain the following components: – Application NPM controller (AIC/MFC/PIC) .tgz package – For AIC controllers, optional application role(s) RPM sets • The application package for a given application version must be present locally on the repository VM prior to import. • The application package must have the following format on the local file system: Source Folder /tmp/ApplicationPackageFolder/ .tgz Application NPM AIC/MFC/PIC controller

AIC Roles (Required for AIC Controllers, Optional for AICs) role1//*.rpm role1's RPM set (for role1Version1) role1//*.rpm role1's RPM set (for role1Version2) role2//*.rpm role2's RPM set (for role2Version1) … roleN//*.rpm roleN's RPM set (for roleNVersion1)

Cisco Virtualized Video Processing Controller Deployment Guide 6-1 Chapter 6 Using the V2P Package Manager Utility Package Requirements

• The .tgz file for the application must be located at the root of the application package folder and must be created using the npm pack command. For example, given an AIC application “MyApp"/v1.0.0 having two roles. "role1"/v1.0.0 and "role2" (having versions v1.0.0 & v1.0.1), the following local directory structure should be created: /tmp/MyApp/ .tgz MyApp AIC controller role1/1.0.0/*.rpm role1's v1.0.0 RPM set role2/1.0.0/*.rpm role2's v1.0.0 RPM set role2/1.0.1/*.rpm role2's v1.0.1 RPM set

• To import an application package, v2pPkgMgr must be invoked from the repository VM as follows: /opt/cisco/v2p/v2pc/python/v2pPkgMgr.py --import --pkgtype [aic | mfc | pic] --sourcepath

• The application's corresponding package.json file must provide metadata describing the application package, and specifically, must include a v2pc-packageinfo object. The following example below shows a package.json file for vendor "MyVendor" with application "MyApp"/v1.0.0 having two roles, "role1"/v1.0.0 and "role2" (having versions v1.0.0 & v1.0.1): { "name": "MyApp", "version": "1.0.0", "v2pcPackageInfo": { "vendorId": "MyVendor", "pkgType": ["aic | mfc | pic"], "roles" : [ // Relevant for pkgtype = aic (OPTIONAL) { "roleId" : "role1", "version" : "1.0.0" }, { "roleId" : "role2", "version" : "1.0.0" }, { "roleId" : "role2", "version" : "1.0.1" } ] } }

Note • After adding the v2pcPackageInfo object to the application package.json file, issue npm pack to create the corresponding .tgz file. • The roleId names must match the corresponding role names in the application template.json file. Any versions specified in template.json are ignored. Only those contained in the package.json file are enforced.

Cisco Virtualized Video Processing Controller Deployment Guide 6-2 Chapter 6 Using the V2P Package Manager Utility Importing an Application Package

Importing an Application Package

Complete the following steps to import the AIC package (all examples use cisco-vmr as the AIC):

Step 1 Log in to the V2P Repository node using SSH. Step 2 Create a top-level directory folder for the application package.

Example $ mkdir MyApp

Step 3 Move the AIC Package .tgz file to the directory just created.

Example $ mv cisco-vmr-1.0.300202.tgz MyApp/

Step 4 Use the import command to import the NPM package from VMR to the directory just created. $ /opt/cisco/v2p/v2pc/python/v2pPkgMgr.py --import --pkgtype [aic | mfc | pic] --sourcepath MyApp Importing NPM package from vmr ... Publishing /home/v2pc/v2pc-apps/npm/cisco-vmr-1.0.300202.tgz ... npm WARN using --force I sure hope you know what you are doing. + [email protected] Successfully imported NPM package from vmr Archiving application package cisco-vmr version 1.0.300202 ... Archived application package to baseurl --> http://25.52.5.42/cisco/aic/cisco-vmr/1.0.300202

Step 5 SSH into the Master Node as user v2pc.

Example $ ssh v2pc@myMaster

Step 6 Use npm show to query the repository for the application version(s):

Example $ npm show cisco-vmr versions npm http GET http://100.10.50.11:4873/cisco-vmrnpm http 200 http://100.10.50.11:4873/cisco-vmr 1.0.300202

Cisco Virtualized Video Processing Controller Deployment Guide 6-3 Chapter 6 Using the V2P Package Manager Utility Importing and Publishing an NPM Module

Importing and Publishing an NPM Module

The v2pPkgMgr utility imports the .tgz controller and publishes it to the Sinopia NPM repository server running on the V2P Repository VM. Thereafter, the application's .tgz module can be installed from any Master node as follows (example shown for MyApp/v1.0.0):

Example npm install [email protected]

If the .tgz version specified by the version field in the package.json file is imported, v2pPkgMgr first deletes the old version and then publishes (or re-publishes) the imported version.

Importing RPM Modules

If "pkgtype" = "aic" is specified in the package.json file, the v2pPkgMgr imports the RPM sets for all of the specified application roles. The v2pPkgMgr also validates package.json against the application folder role directory hierarchy and reports any missing roles as warnings. In addition, any roles found in the local application folder but not present in package.json are ignored (that is, not imported). After v2pPkgMgr imports them, the RPM set(s) are available on the Repository VM at the following URL locations: http://$repoVmIp/$vendorId/aic/$appId/$version/$roleId/$roleVersion

Deleting an Application Package

To delete an existing application package, issue the following command: /opt/cisco/v2p/v2pc/python/v2pPkgMgr.py --delete –-pkgtype [aic | mfc | pic] --vendorid --appid [--appversion ] For example, to delete version 3.1.100 of cisco-ce, issue the following command and confirm that it reports successful deletion: $ /opt/cisco/v2p/v2pc/python/v2pPkgMgr.py --delete --pkgtype aic --vendorid cisco --appid cisco-ce --appversion 3.1.100 Deleting application package cisco-ce version 3.1.100 ... Unpublishing [email protected] ... npm WARN using --force I sure hope you know what you are doing...... Successfully deleted application package cisco-ce version 3.1.100

Worker Node Installation and Upgrade Scripts

Each worker node has separate application install.sh and upgrade.sh scripts provided on a per-role basis. Both install.sh and upgrade.sh scripts are invoked identically. The only difference is that the upgrade.sh script must perform graceful cleanup of the current application prior to initiating the upgrade.

Cisco Virtualized Video Processing Controller Deployment Guide 6-4 Chapter 6 Using the V2P Package Manager Utility Worker Node Installation and Upgrade Scripts

The application upgrade.sh script must be structured as follows (the example is sampleaic master-role):

Note The install.sh script is identical, except that it need not perform graceful shutdown.

Example #!/bin/sh # # Application upgrade script template. # # Command line arguements: # # --apprepourls (Comma-separated list of URLs) # --sysrepoids (Comma-separated list of IDs) # --appver # --rolever # # Validate parameters V2PPATH="/opt/cisco/v2p/v2pc/script/v2p-vm-mgr" ${V2PPATH}/v2pValidateWorkerParams.py $@ if [ $? -ne 0 ]; then echo "ERROR: Invalid command line arguements; exiting ..." exit 1 fi

# Pickup params VENDORID=sampleVendor APPID=sampleaic ROLEID=master-role appver=$(${V2PPATH}/v2pGetWorkerParam.py "appver") rolever=$(${V2PPATH}/v2pGetWorkerParam.py "rolever")

# Extract application repo URLs. # Application URLs are formatted as follows: # http://$repoVmIp/$VENDORID/aic/$APPID/$appver/$ROLEID/$rolever # declare -a appRepoUrls=$(${V2PPATH}/v2pGetWorkerParam.py "apprepourls")

# Extract system repo IDs. # Each system repo ID corresponds to the worker node's # "imageTag" system repo list (e.g., third-party RPM list). # declare -a sysRepoIds=$(${V2PPATH}/v2pGetWorkerParam.py "sysrepoids")

# Configure yum to point to $APPID-$ROLEID repo sudo cat << app-install-repo > /tmp/$APPID-$ROLEID-install.repo [$APPID-$ROLEID] name=$APPID-$ROLEID baseurl=${appRepoUrls[0]} enabled=1 gpgcheck=0 app-install-repo sudo cp -f /tmp/$APPID-$ROLEID-install.repo /etc/yum.repos.d/ # Clean yum caches sudo yum clean all

# # Perform graceful shutdown of application. # e.g., systemctl stop #

# Upgrade sampleaic RPMs. # (NOTE: yum install will actually upgrade existing RPMs, # as well as installing new RPMs.) # sudo yum -y -v --disablerepo=* \ --enablerepo=$APPID-$ROLEID,${sysRepoIds[0]},${sysRepoIds[1]} \ install sampleworker-master

The upgrade.sh script must be invoked manually on the Worker node via SSH. The following example invokes the upgrade.sh script to upgrade "sampleaic"/v1.0.0, "master-role" to v1.0.1:

Cisco Virtualized Video Processing Controller Deployment Guide 6-5 Chapter 6 Using the V2P Package Manager Utility Importing System RPMs

upgrade.sh --apprepourls "http://$repoVmIp/sampleVendor/aic/sampleaic/1.0.0/master-role/1.0.1"-- sysrepoids "third-party-7.2.0,v2pc" --appver "1.0.0" --rolever "1.0.1"

Importing System RPMs

v2pPkgMgr can also import system RPM sets, also known as system repos, associated with a specific ImageTag, as shown below.

Syntax /opt/cisco/v2p/v2pc/python/v2pPkgMgr.py --import [--pkgtype system] --manifest

Example A sample image manifest JSON that imports two system repos having repoIds of "third-party" and "v2pc" is shown below. Both system repos have a version = "3.2.0" and an associated image tag of "cisco--7.2.0". { "image": { "vendor": "cisco", "imgTag": "cisco-centos-7.2.0", "repoIP": "172.20.207.86", "repoPort": "5001", "packages": [ { "type": "system", "repoId": "third-party", "version": "3.2.0", "src": { "format": "directory", // 'iso' can also be specified (see Restrictions below) "local_file": "/tmp/third-party" // All "third-party" RPMs must be placed herein } }, { "type": "system", "repoId": "v2pc", "version": "3.2.0", "src": { "format": "directory", "local_file": "/tmp/v2pc" // All "v2pc" RPMs must be placed herein } } ] }, "dataStores": [{"name": "datastore138", "folder": ""}], "template_node": { "masterIP": "172.20.207.82", "infraProviderName": "VMware", "vmName": "cisco-centos-7.2.0", "hostname": "na", "vmSourcePath": "/sw/v2p/master/platform/vmware/centos7/src/ova/tmpobj", "vmSourceName": "centos7-disk1.vmdk", "storeName": "datastore138", "imgTag": "cisco-centos-7.2.0", "imageDFormat":"vmdk",

Cisco Virtualized Video Processing Controller Deployment Guide 6-6 Chapter 6 Using the V2P Package Manager Utility Importing an Application Upgrade Bundle

"imageCFormat":"bare" } }

Restrictions If "format" is "iso", the corresponding ISO must be a specific (proprietary) V2PC format. The V2PC Repo ISO images themselves conform to this format.

Importing an Application Upgrade Bundle

An application upgrade bundle includes the required lower-level application components described in Package Requirements, page 6-1. Cisco makes application upgrade bundles available to update specific V2P applications when appropriate. An application upgrade bundle is currently available for Cisco Virtual Media Packager (VMP). To import the VMP application bundle:

Step 1 Download the VMP application upgrade bundle vmp-2.11.1-v2p-bundle-3.3.3-16864.tar from the Cisco VMP product support page at: http://www.cisco.com/c/en/us/support/video/media-origination-system/tsd-products-support-series-home.html Step 2 Issue the following command from the repository VM to import the VMP bundle: $ /opt/cisco/v2p/v2pc/python/v2pPkgMgr.py --import --sourcebundle /tmp/vmpBundle/vmp-2.11.1-v2p-bundle-3.3.3-16864.tar Step 3 Confirm that the process runs and reports successful completion, as show in the following example: $ /opt/cisco/v2p/v2pc/python/v2pPkgMgr.py --import --sourcebundle /tmp/vmpBundle/vmp-2.11.1-v2p-bundle-3.3.3-16864.tar Processing application upgrade bundle /tmp/vmpBundle/vmp-2.11.1-v2p-bundle-3.3.3-16864.tar ...... Successfully processed application upgrade bundle /tmp/vmpBundle/vmp-2.11.1-v2p-bundle-3.3.3-16864.tar

Cisco Virtualized Video Processing Controller Deployment Guide 6-7 Chapter 6 Using the V2P Package Manager Utility Importing an Application Upgrade Bundle

Cisco Virtualized Video Processing Controller Deployment Guide 6-8