html table search with pure javascript

The below javascript method searches through all the <td> elements and hides <tr> that do not have it. function search() { // Declare variables var input, filter, table, tr, td, i, j, tds, ths, matched; input = document.getElementById("searchInput"); filter…

configuring a secure front-end for a non-secure service

The goal is to enable https only access for a pre-existing http service. Let us assume that a service is running on http://myserver.com:8000/service. The goal is to make no changes to the pre-existing service and still allow https only access to it. One way this can be accomplished, is using apache…

ansible - pretty printing errors

Ansible does not do a great job at pretty printing exceptions/errors. There are plugins available that make this easy. mkdir -p ~/ansible/plugins/callback cd ~/ansible/plugins/callback wget https://raw.githubusercontent.com/marcosdiez/ansible_human_log.py/master/human_log.py create/edit ~/.ansible.c…

Using Yum on RHEL without RHN subscription

Disable the rhn yum plugin, /etc/yum/pluginconf.d/rhnplugin.conf [main] enabled = 0 gpgcheck = 1 Install the epel-repo for the version of redhat you have, RHEL 5.x wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-5.noarch.rpm sudo rpm -Uvh epel-release-5*.rpm RHEL 6.x wget https://dl.f…

Running multiple versions of python

You can generally run multiple version of Python minor release 2.7 vs 2.6. These are symlinks created in /usr/bin/. But how do you go about running multiple versions of the the same minor release - 2.7.9 vs 2.7.10. I wrote a small script that downloads, builds python from source and installs it in a…

Python and state of SSL/TLS

Python 2.7.9 introduces a ssl.SSLContext object to make selecting SSL version easier. Since using SSLv2 or SSLv3 is a crime, most systems rely on TLSv1, TLSv1.1 or TLSv1.2. The SSLContext obect makes it easier to define the generic subset of protocol one desires and then individually turnoff some of…

Python and Ctags

You want to jump to definition of a method, but ctags keep taking you to the import line of that method? add the following to ~/.ctags --python-kinds=-i…

Auto-generate python script for tasks done on UI

Welcome the convert_to_ucs_python API. Assumption: User knows to do an operation via the JAVA based UCSM GUI UCSM UI and convert_to_ucs_python should be launched on the same client machine. Basic Idea: launch the JAVA based UCSM UI launch the python shell and invoke convert_to_ucs_python perform the…

watch for ucs server events - ucsmsdk

Starting 0.9.1.1 we have simplified the code required to wait for an event. The below code creates a Service Profile Mo org-root/ls-eventhandle We then create two threads each thread invokes a wait_for_event method to wait for a specific condition Here, we wait for the descr property to change to sp…

metadata and MO information - ucsmsdk

ucsmsdk now has helper methods to help figure out MO names and dig into the properties and other metadata provided by an object. from ucsmsdk.ucscoreutils import search_class_id from ucsmsdk.ucscoreutils import get_meta_info search_class_id is a case-insensitive grep method that searches all MO…

Multiple parallel transactions - ucsmsdk 0.9.1.1

Until ucsmsdk 0.9.1.0 everything until a handle.commit was a single transaction, handle.add_mo(mo1) handle.add_mo(mo2) handle.remove_mo(mo3) handle.commit() Starting 0.9.1.1 there is an optional tag parameter added to add_mo,set_mo,remove_mo,commit. tag is the scope of a transaction. So, her…

Polling for a specific event ucsmsdk.

Optional poll mode is added to wait_for_event API The below code will wait for the usr_lbl property of the service profile org-root/ls-demo-sp to change to demo_label. It will poll the server every poll_sec=10 here. It will timeout after 600 seconds. wait_for_event will keep the script alive until (…

docker - failed to set link up: address already in use

Noticed the following error message while trying to bring up Docker DTR container. FATA[0003] Error response from daemon: subnet sandbox join failed for "10.1.0.0/24": vxlan interface creation failed for subnet "10.1.0.0/24": failed to set link up: address already in use I went…

ucsmsdk offline pip install with dependencies

The server you want to install the SDK on sometimes might not have internet connectivity. The following facilitate a offline install, On a machine with internet connectivity (this could be your PC or Mac), pip install --download /path/to/save/dependencies Now copy /path/to/save/dependencies to the…

checking if a docker container is running

The following will return true if the container is running and false otherwise. docker inspect -f {{.State.Running}} "$container_id" The following fetches container id based on it's name, name=alpine count=$(docker ps | grep "$name" | wc -l) if [ $count == 1 ]; then id=…

Ucs config backup to Python script - ucsmsdk

ucmsdk in version 0.9.2.0 will add the ability of being able to generate a python script for configuring Ucs server based on a config state backup XML. convert_from_backup(backup_file, output_file=None) backup_file - needs to a config backup XML downloaded from a UCS server. output_file - file where…

Contiv Volplugin Rate limiting - Runtime

One of the coolest features of Contiv volplugin is the ability to modify volume iops,bps resource restrictions on the fly. This is facilitated by, volcli volume runtime upload policy/volume < restrictions.json policy/volume - policy name /volume name restrictions.json - JSON file with resource re…

vagrant 1.8.5 ssh failures!

Vagrant 1.8.5 throws the below error when doing a vagrant up default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default: Warning: Authentication failure. Retrying... default…

vim plugins

My goto vim plugins, set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' Plugin 'mileszs/ack.vim' Plugin 'vim-scripts/delimitMate.vim' Plugin 'scrooloose/syntastic' Plugin 'godlygeek/tabular' Plugin 'bling/vim-airlin…

Python - deprecating APIs

Decorators facilitate an easy way to let users know that a given method is deprecated. You can even point users to the method they should be using instead. This is done by using decorators that accept arguments. The code below demonstrates this, import warnings def deprecated(replaced_by_func):…