ESXi python module

In this blog, I will be discussing about vmsupport python module, and will be writing simple program to list powered on and regisered vm.

Below is pydoc output.


Help on module vmsupport.vmutils in vmsupport:
 Parses the .vmx file and adds any directories specified by a ‘.*filename = ‘ line
 Ignores the fileSearchPath config option (and all that other crazy stuff that we don’t actually use [i hope]).
 listVMs() List the running VMs.
    knownVMs = {}
    vmPaths = {}

Help on module vmsupport.performance in vmsupport:

gatherPerfSnapshots(manifestLoader, tarObj, interval, duration)
 Gather periodic vsi snapshots (eventually) markLogFiles(snapshotNumber, state)

import sys
import os
import vmsupport
from vmsupport import vmutils
from vmsupport.vmutils import listVMs


/vmfs/volumes/527e924d-b01c68e8-9c00-18a8056626de/VC/VC.vmx (Running)
/vmfs/volumes/527e924d-b01c68e8-9c00-18a8056626de/node/node.vmx (Registered)

Create our own bridge for containers (rhel7 Dockers)

For creating our own bridge on containers in rhel7 docker host, follow the below steps:

# service docker stop

# ip link add br0 type bridge

# ip addr add dev br0

# ip link set br0 up

# docker -d -b br0

 #docker -d -b br0


INFO[0000] Listening for HTTP on unix (/var/run/docker.sock)

INFO[0000] [graphdriver] using prior storage driver “devicemapper”

INFO[0000] Firewalld running: false

INFO[0000] Loading containers: start.

INFO[0000] Loading containers: done.

INFO[0000] Daemon has completed initialization


#echo ‘DOCKER_OPTS=”-b=br0″‘ >> /etc/sysconfig/docker

#service docker start

#docker run -it rhel6 /bin/bash

#docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

705c6943782a        d5b570729de6        “/bin/bash”         59 seconds ago      Up 58 seconds                           modest_bateek

# docker inspect 705c6943782a|grep –I “IPADDRESS”

 “IPAddress”: “”,

Fetch system information using esxtop

System information can be fetched from esxtop command as well, without login to VC .

esxtop is one of the command which gives many information about esx hypervisor. A good system admin can get information system health, issues, system important information from esxtop.

By default in we run esxtop command, it shows CPU information.

9:36:32am up 24 days  1:13, 579 worlds, 5 VMs, 20 vCPUs; CPU load average: 0.01, 0.01, 0.01

PCPU USED(%): 2.7  0.3  0.4  0.0  0.4  0.9  0.4  0.3  1.5  0.1  0.5  0.3  0.6  0.4  0.2  0.4  AVG: 0.6

PCPU UTIL(%):  4.8  1.2  1.5  0.4  0.9  1.7  0.9  1.4  2.7  0.2  1.0  0.5  1.0  0.9  0.6  0.7  AVG: 1.3

CORE UTIL(%): 5.2     1.3     2.5     1.7     2.9     1.4     1.8     1.1     AVG: 2.3

Check the uptime:

up 24 days  1:13

 Total number of LCPU: Count the number [16], means system has 16 Logical CPU

PCPU USED(%): 2.7  0.3  0.4  0.0  0.4  0.9  0.4  0.3  1.5  0.1  0.5  0.3  0.6  0.4  0.2  0.4

PCPU UTIL(%):  4.8  1.2  1.5  0.4  0.9  1.7  0.9  1.4  2.7  0.2  1.0  0.5  1.0  0.9  0.6  0.7  

Total number of Cores: total core in this hypervisor is 8

CORE UTIL(%): 5.2     1.3     2.5     1.7     2.9     1.4     1.8     1.1  

We can easily make it out, that system is hyper threading enable, since LCPU is 16 and cores are 8.

 Number of powered on vm and consumed total number of vcpu by powered on vm:

5 VMs, 20 vCPUs

If you want to fetch the memory information: run esxtop and press m

Total physical memory in hypervisor [24GB]:

PMEM  /MB: 24565

Memory assigned to powered-on vm:


 AD          8192.00

Which vm is connected to which nic port: esxtop and press n


 AD                       vmnic1           vSwitch0


Package Bash/Perl script in Rpm Format

Package Bash/Perl script in Rpm Format:

Recently  I was working for one of the Script development. The automation package supposed to delivered on rhel6.
In process of roll out, I thought of using yum, It would be easy to install.
In this blog we will be creating a sample script and package it RPM format.


Note: Save the script named as
Below are the steps I followed.

  • Install rpmbuild package, so we can get rpm build command.
     yum install rpmbuild
  • Create a directory structure, We need a directory structure for rpm buildmkdir /root/rpmbuild
    mkdir -p /root/rpmbuild/{RPMS,SRPMS,SPEC,SOURCE,BUILD,tmp}
  • Create a folder in SOURCEcd /root/rpmbuild/SOURCE
    mkdir test ; cp /root/ /root/rpmbuild/SOURCE/test/
  • Create a tar folder :tar -czvf  test.tar.gz test
  • create a SPEC file in SPEC folder
    test.spec [Content of spec file]
    Summary: This is rpm development
    Buildroot:%{_tmppath}/%{Name}-%{Version}-%{Release}-root-%{%{__id_u} -n}
    This is rpm development
    %setup -q
    mkdir -p “$RPM_BUILD_ROOT/opt/test”
    cp -R * “$RPM_BUILD_ROOT/opt/test”
    rm -rf $RPM_BUILD_ROOt
    chmod 775 /opt/test
    *Save the spec file in /root/rpmbuild/SPEC folder
  • Now we will build the rpm
    rpmbuild -v -bb /root/rpmbuild/SPEC/test.spec
    /* rpm will build and saved in /root/rpmbuild/RPMS/noarch folder
  • Now we can install rpm using command
    rpm -ivh test.rpm
    %files in spec file specified installation location.After that we can check the file  /opt/test folder

Dockers Installation and Commands for centos7

As per wiki:
Docker is an opensource project that automates the deployment of applications inside software containers,by providing an additional layer of abstraction and automation of operating system-level virtualization on linux.

Does it runs only on Linux??
The Docker daemon uses Linux-specific kernel features, you can’t run Docker natively in Windows. Instead, you must use docker-machine to create and
attach to a Docker VM on your machine. This VM hosts Docker for you on your Windows system.The Docker VM is lightweight Linux virtual machine made specifically to run the Docker daemon on Windows. The VirtualBox VM runs completely from RAM, is a small ~24MB download, and boots in approximately 5s.

Dockers Installation:
In this section we will be installing dockers on centos 7.

– Install epel pakage , for epel repository.
yum install epel-release
 – Update the packages
 yum update
– Install the docker pakcage, Incase of centos its “docker-io”
yum install docker-io
-Start and configure the service
service docker start
ps aux |grep docker
chkconfig docker on

-Check Docker Version

docker version
<command output>
Client version: 1.7.1
Client API version: 1.19
Package Version (client): docker-1.7.1-108.el7.centos.x86_64
Go version (client): go1.4.2
Git commit (client): 3043001/1.7.1
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Package Version (server): docker-1.7.1-108.el7.centos.x86_64
Go version (server): go1.4.2
Git commit (server): 3043001/1.7.1
OS/Arch (server): linux/amd64

docker info
#Below is command output
Containers: 0
Images: 0
Storage Driver: devicemapper
 Pool Name: docker-202:1-75739270-pool
 Pool Blocksize: 65.54 kB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 307.2 MB
 Data Space Total: 107.4 GB
 Data Space Available: 16.05 GB
 Metadata Space Used: 729.1 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.93-RHEL7 (2015-01-28)
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.10.0-229.11.1.el7.x86_64
Operating System: CentOS Linux 7 (Core)
CPUs: 1
Total Memory: 992.1 MiB

– Pull ubuntu image using docker command line:
docker pull ubuntu:latest

<output>latest: Pulling from
d3a1f33e8a5a: Pull complete
c22013c84729: Pull complete
d74508fb6632: Pull complete
91e54dfb1179: Pull complete The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:73fbe2308f5f5cb6e343425831b8ab44f10bbd77070ecdfbe4081daa4dbe3ed1
Status: Downloaded newer image for

-List the Docker images

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE    latest              91e54dfb1179        3 weeks ago         188.3 MB

-Run the container image

docker run -i -t  ubuntu /bin/bash
root@a165ac32dec0:/# uname -a
Linux a165ac32dec0 3.10.0-229.11.1.el7.x86_64 #1 SMP Thu Aug 6 01:06:18 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
root@a1d068a9c409:/# ps aux
root         1  0.2  0.1  18164  1880 ?        Ss   04:58   0:00 /bin/bash
root        15  0.0  0.1  15564  1144 ?        R+   04:58   0:00 ps aux

In next segment we will see some advance level of command !!

Create Local yum repository using Linux DVD

Lot of time we face the issue of dependency while installing the package from DVD.
Its bit difficult to solve the dependency, In these kind of scenario if we can create a yum repository using Linux Dvd, will solve lot of issues.
In this post, I am going to explain how to create a local yum repository

Note: Using RHEL 6.3
Steps: [commands are mentioned in Italic]

  1.  Mount the DVDRom.
    mount /dev/cdrom /root/cdrom
  2.  Go in the yum directory :
    cd /etc/yum.repos.d
  3.  open a new file local.repo
    vi local.repo
  4.  Make changes in the file
    name = local repository
    baseurl = file:///cdrom
  5.  Save the changes and Perform below command
    yum clean all
    yum install or yum update