Skip to content

Latest commit

 

History

History
295 lines (222 loc) · 10.6 KB

README.md

File metadata and controls

295 lines (222 loc) · 10.6 KB

govc.el

Interface to govc for managing VMware ESXi and vCenter.

The goal of this package is to provide a simple interface for commonly used govc commands within Emacs. This includes table based inventory/state modes for vms, hosts, datastores and pools. The keymap for each mode provides shortcuts for easily feeding the data in view to other govc commands.

Within the various govc modes, press ? to see a popup menu of options. A menu bar is enabled for certain modes, such as govc-vm-mode and govc-host-mode. There is also a govc menu at all times under the Tools menu.

The recommended way to install govc.el is via MELPA (http://melpa.org/).

govc-mode

Running govc-global-mode creates key bindings to the various govc modes. The default prefix is C-c ; and can be changed by setting govc-keymap-prefix.

govc-command-map

Keybinding Description
h Host info via govc
p Pool info via govc
v VM info via govc
s Datastore info via govc

govc-urls

List of URLs for use with govc-session. The govc-session-name displayed by govc-mode-line uses url-target (anchor) if set, otherwise url-host is used.

Example:

  (setq govc-urls `("root:vagrant@localhost:18443#Vagrant-ESXi"
                    "root:password@192.168.1.192#Intel-NUC"
                    "Administrator@vsphere.local:password!@vcva-clovervm"))

To enter a URL that is not in the list, prefix universal-argument, for example:

C-u M-x govc-vm

To avoid putting your credentials in a variable, you can use the auth-source search integration.

  (setq govc-urls `("myserver-vmware-2"))

And then put this line in your auth-sources (e.g. ~/.authinfo.gpg):

    machine myserver-vmware-2 login tzz password mypass url "myserver-vmware-2.some.domain.here:443?insecure=true"

Which will result in the URL "tzz:mypass@myserver-vmware-2.some.domain.here:443?insecure=true". For more details on auth-sources, see Info node (auth) Help for users.

When in govc-vm or govc-host mode, a default URL is composed with the current session credentials and the IP address of the current vm/host and the vm/host name as the session name. This makes it easier to connect to nested ESX/vCenter VMs or directly to an ESX host.

govc-session-url

ESX or vCenter URL set by govc-session via govc-urls selection.

govc-session-insecure

Skip verification of server certificate when true. This variable is set to the value of the GOVC_INSECURE env var by default. It can also be set per-url via the query string (insecure=true). For example:

  (setq govc-urls `("root:password@hostname?insecure=true"))

govc-session-datacenter

Datacenter to use for the current govc-session. If the endpoint has a single Datacenter it will be used by default, otherwise govc-session will prompt for selection. It can also be set per-url via the query string. For example:

  (setq govc-urls `("root:password@hostname?datacenter=dc1"))

govc-session-datastore

Datastore to use for the current govc-session. If the endpoint has a single Datastore it will be used by default, otherwise govc-session will prompt for selection. It can also be set per-url via the query string. For example:

  (setq govc-urls `("root:password@hostname?datastore=vsanDatastore"))

govc-session-network

Network to use for the current govc-session.

govc-tabulated-list-mode

Generic table bindings to mark/unmark rows.

In addition to any hooks its parent mode tabulated-list-mode might have run, this mode runs the hook govc-tabulated-list-mode-hook, as the final step during initialization.

govc-tabulated-list-mode-map

Keybinding Description
m Mark and move to the next line
u Unmark and move to the next line
t Toggle mark
U Unmark all
M-& Shell CMD in BUFFER with current govc-session exported as GOVC_ env vars
M-w Copy current selection or region to the kill ring
M-E Export session to process-environment and kill-ring

govc-host-mode

Major mode for handling a list of govc hosts.

In addition to any hooks its parent mode govc-tabulated-list-mode might have run, this mode runs the hook govc-host-mode-hook, as the final step during initialization.

govc-host-mode-map

Keybinding Description
E Events via govc events -n govc-max-events
L Logs via govc logs -n govc-max-events
J JSON via govc host
M Metrics info
N Netstat via govc-esxcli-netstat-info with current host id
O Object browser via govc object
T Tasks via govc tasks
c Connect new session for the current govc mode
p Pool-mode with current session
s Datastore-mode with current session
v VM-mode with current session

govc-pool-mode

Major mode for handling a list of govc pools.

In addition to any hooks its parent mode govc-tabulated-list-mode might have run, this mode runs the hook govc-pool-mode-hook, as the final step during initialization.

govc-pool-mode-map

Keybinding Description
D Destroy via govc-pool-destroy on the pool selection
E Events via govc events -n govc-max-events
J JSON via govc pool
M Metrics info
O Object browser via govc object
T Tasks via govc tasks
c Connect new session for the current govc mode
h Host-mode with current session
s Datastore-mode with current session
v VM-mode with current session

govc-datastore-mode

Major mode for govc datastore.info.

In addition to any hooks its parent mode tabulated-list-mode might have run, this mode runs the hook govc-datastore-mode-hook, as the final step during initialization.

govc-datastore-mode-map

Keybinding Description
J JSON via govc datastore
M Metrics info
O Object browser via govc object
RET Browse datastore
c Connect new session for the current govc mode
h Host-mode with current session
p Pool-mode with current session
v VM-mode with current session

govc-datastore-ls-mode

Major mode govc datastore.ls.

In addition to any hooks its parent mode govc-tabulated-list-mode might have run, this mode runs the hook govc-datastore-ls-mode-hook, as the final step during initialization.

govc-datastore-ls-mode-map

Keybinding Description
I Info datastore disk
J JSON via govc datastore
S Search via govc datastore
D Delete selected datastore paths
T Tail datastore FILE
+ Mkdir via govc datastore
DEL Up to parent folder
RET Open datastore folder or file

govc-vm-mode

Major mode for handling a list of govc vms.

In addition to any hooks its parent mode govc-tabulated-list-mode might have run, this mode runs the hook govc-vm-mode-hook, as the final step during initialization.

govc-vm-mode-map

Keybinding Description
E Events via govc events -n govc-max-events
L Logs via govc-datastore-tail with logDirectory of current selection
J JSON via govc vm
O Object browser via govc object
T Tasks via govc tasks
X ExtraConfig via govc-vm-extra-config on the current selection
RET Devices via govc-device on the current selection
C Console via govc-vm-console on the current selection
V VNC via govc-vm-vnc on the current selection
D Destroy via govc-vm-destroy on the current selection
^ Start via govc-vm-start on the current selection
! Shutdown via govc-vm-shutdown on the current selection
@ Reboot via govc-vm-reboot on the current selection
& Suspend via govc-vm-suspend on the current selection
H Host info via govc-host with host(s) of current selection
M Metrics info
P Ping VM
S Datastore via govc-datastore-ls with datastore of current selection
c Connect new session for the current govc mode
h Host-mode with current session
p Pool-mode with current session
s Datastore-mode with current session

govc-device-mode

Major mode for handling a govc device.

In addition to any hooks its parent mode govc-tabulated-list-mode might have run, this mode runs the hook govc-device-mode-hook, as the final step during initialization.

govc-device-mode-map

Keybinding Description
J JSON via govc device
RET Tabulated govc device

govc-object-mode

Major mode for handling a govc object.

In addition to any hooks its parent mode govc-tabulated-list-mode might have run, this mode runs the hook govc-object-mode-hook, as the final step during initialization.

govc-object-mode-map

Keybinding Description
J JSON object selection via govc object
N Next managed object reference
O Object browser via govc object
DEL Parent object selection if reachable, otherwise prompt with govc-object-history
RET Expand object selection via govc object

govc-metric-mode

Major mode for handling a govc metric.

In addition to any hooks its parent mode govc-tabulated-list-mode might have run, this mode runs the hook govc-metric-mode-hook, as the final step during initialization.

govc-metric-mode-map

Keybinding Description
RET Sample metrics
P Plot metric sample
s Select metric names