VCSA API and plugin commands
When I first logged in to the appliance I noticed there is a complete list of API’s and plugins.
The complete list and description can be found here:
Plug-Ins in the vCenter Server Appliance Shell
API Commands in the vCenter Server Appliance Shell
So let’s play a bit :
Command> help pi com.vmware.vimtop top Display vSphere processes information.
Wonder if that will display a top view, let’s hit it !
Command> pi com.vmware.vimtop
Nice, but it also possible just to hit “vimtop” from command.
What more do we have :
Looks that besides the root account there will be a user
Command> com.vmware.appliance.version1.localaccounts.user.list Config: Configuration: Username: root Status: enabled Role: superAdmin Passwordstatus: valid Fullname: root Email: Configuration: Username: postgres Status: disabled Role: Passwordstatus: notset Fullname: Email:
Mm strange, this doesn’t look like the complete list, when I look to the users from a shell environment I see the users below:
localhost:~ # cut -d: -f1 /etc/passwd bin daemon dhcpd haldaemon ldap mail man messagebus nobody ntp polkituser postfix root sshd stunnel uuidd wwwrun nginx tcserver cm netdumper vapiEndpoint postgres mbcs eam deploy vdcs vpx-workflow vsm vsphere-client perfcharts vpostgres
Like you probably noticed in the normal mode you only can do some API and plugin calls. But you can switch to shell.
Switching to shell
Connected to service * List APIs: "help api list" * List Plugins: "help pi list" * Enable BASH access: "shell.set --enabled True" * Launch BASH: "shell"
Standard shell access is disabled, this can be seen by using shell.get
Command> shell.get Config: Enabled: False Timeout: 0
Now let’s enable the access :
Command> shell.set --enabled True Command> shell.get Config: Enabled: True Timeout: 3597
Once we entered shell, we can use some basic linux commands
localhost:/ # df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 11G 3.7G 6.6G 36% / udev 4.0G 164K 4.0G 1% /dev tmpfs 4.0G 32K 4.0G 1% /dev/shm /dev/sda1 128M 38M 84M 31% /boot /dev/mapper/core_vg-core 25G 173M 24G 1% /storage/core /dev/mapper/log_vg-log 9.9G 1.1G 8.3G 12% /storage/log /dev/mapper/db_vg-db 9.9G 199M 9.2G 3% /storage/db /dev/mapper/dblog_vg-dblog 5.0G 171M 4.5G 4% /storage/dblog /dev/mapper/seat_vg-seat 9.9G 188M 9.2G 2% /storage/seat /dev/mapper/netdump_vg-netdump 1001M 18M 932M 2% /storage/netdump /dev/mapper/autodeploy_vg-autodeploy 9.9G 151M 9.2G 2% /storage/autodeploy /dev/mapper/invsvc_vg-invsvc 5.0G 157M 4.6G 4% /storage/invsvc localhost:/ # mount /dev/sda3 on / type ext3 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) udev on /dev type tmpfs (rw,mode=0755) tmpfs on /dev/shm type tmpfs (rw,mode=1777) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) /dev/sda1 on /boot type ext3 (rw,noexec,nosuid,nodev,noacl) /dev/mapper/core_vg-core on /storage/core type ext3 (rw) /dev/mapper/log_vg-log on /storage/log type ext3 (rw) /dev/mapper/db_vg-db on /storage/db type ext3 (rw,noatime,nodiratime) /dev/mapper/dblog_vg-dblog on /storage/dblog type ext3 (rw,noatime,nodiratime) /dev/mapper/seat_vg-seat on /storage/seat type ext3 (rw,noatime,nodiratime) /dev/mapper/netdump_vg-netdump on /storage/netdump type ext3 (rw) /dev/mapper/autodeploy_vg-autodeploy on /storage/autodeploy type ext3 (rw) /dev/mapper/invsvc_vg-invsvc on /storage/invsvc type ext3 (rw,noatime,nodiratime) none on /var/lib/ntp/proc type proc (ro,nosuid,nodev) localhost:/var/log # tail -f messages.log 2015-04-28T12:51:30.980333+00:00 localhost kernel: [1652125.714038] IPfilter Dropped: IN=eth0 OUT= MAC=01:00:5e:00:00:01:00:22:bd:37:fc:00:08:00 SRC=145.70.12.252 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=61046 PROTO=2 2015-04-28T12:51:42.931041+00:00 localhost su: (to vpostgres) root on none 2015-04-28T12:51:50.860391+00:00 localhost kernel: [1652145.593672] IPfilter Dropped: IN=eth0 OUT= MAC=01:00:5e:00:00:01:00:22:bd:37:fc:00:08:00 SRC=145.70.12.252 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=5260 PROTO=2 2015-04-28T12:51:51.044384+00:00 localhost kernel: [1652145.777641] IPfilter Dropped: IN=eth0 OUT= MAC=01:00:5e:00:00:01:00:22:bd:37:fc:00:08:00 SRC=145.70.12.252 DST=224.0.0.1 LEN=36 TOS=0x00 PREC=0xC0 TTL=1 ID=5416 PROTO=2 2015-04-28T12:52:15.344457+00:00 localhost su: (to vpostgres) roo
Something else I noticed when enabling shell access the timeout starts counting down. As soon as I keep hitting
Command> shell.get Config: Enabled: True Timeout: 3597 Command> shell.get Config: Enabled: True Timeout: 3596 Command> shell.get Config: Enabled: True Timeout: 3596 Command> shell.get Config: Enabled: True Timeout: 3596 Command> shell.get Config: Enabled: True Timeout: 3595
You see the timeout decrease I guess it’s in seconds so 3600 seconds = 60 minutes = 1 hour.
It’s possible to change the timeout using the shell.set command
Command> shell.set -help shell.set: error: unrecognized arguments: -help Command> shell.set --help Usage: shell.set [--help/-h] --enabled BOOL --timeout INT Description: Set enabled state of BASH, that is, access to BASH from within the controlled CLI. Input Arguments: --enabled BOOL Enabled can be set to true or false --timeout INT The timeout (in seconds) specifies how long you enable the Shell access.