Code Monkey home page Code Monkey logo

govc-scripts's Introduction

Simple scripts to manage vsphere from command line

govc.sh

govc.sh - wrapper which sets VSphere specific settings and runs govc.

Other things to install:

Installation

  • git clone libshell, install shell-* files to /usr/local/bin or somewhere in $PATH
  • install govc binary to dir within $PATH
  • install govc.sh wrapper to dir within $PATH
  • create minimal cofiguration with vsphere login/passwd:
cat ~/.terraformware.conf
....
vsphere_username = <user>@<domain>

vsphere_password = <base64 encoded password string>
  • create Vsphere DC layout:
cat ~/.vs-dc.ini
# global settings are not really needed
# but ease the usage
[global]
location=ams

[ams]
url=ams-prd-vc01.xxxxx
dc=AMS-PRD-DC01

[brq]
url=brq-prd-vc02.xxxxx
dc=BRQ-PRD-DC01

Example of use:

$ govc.sh --help
Usage: Usage: govc.sh [-l DC] [options] <cmd> <vm>

Options:

  -l, --location=<FRA|PAR>      VSphere DC location (FRA or PAR);
  -V, --version                 print program version and exit;
  -h, --help                    show this text and exit;
  -j, --json                    use json output.

Command shortcuts (takes VM as last argument):

  poweron
  poweroff
  suspend
  pstate                        Shows current VM power state
  info
  disk_info
  disk_shrink
  disk_extend <size>
  disk_change <mode>
  memory_extend <size>Mb
  memory_hotadd_check
  memory_hotadd_enable
  cpu_add <nr>
  cpu_remove <nr>
  cpu_hotadd_check
  cpu_hotadd_enable
  cpu_hotremove_check
  cpu_hotremove_enable
  ls_snapshot
  create_snapshot
  delete_snapshot <name>        Delete defined snapshot
  revert_snapshot <name>        Revert to defined snapshot

Advanced usage:

govc.sh [options] -- <govc direct cmd>

Find vm:

$ govc.sh -l fra -- find vm -name wiki*
vm/AMS_UBUNTU/<vmname>

Query vm config option (via direct option):

$ govc.sh -l fra -- object.collect -s vm/AMS_UBUNTU/<vmname> config.memoryHotAddEnabled
false

Enable memory hotadd (by using shortcut):

$ govc.sh -l fra poweroff test-nginx01-fra
$ govc.sh -l fra memory_hotadd_enable test-nginx01-fra
$ govc.sh -l fra poweron test-nginx01-fra
$ govc.sh -l fra memory_hotadd_check test-nginx01-fra
govc.sh: Enabled

CPU hotadd/hotremove:

$ govc.sh -l fra cpu_hotremove_check test-nginx01-fra
govc.sh: Enabled

$ govc.sh -l fra cpu_remove 1 test-nginx01-fra
govc.sh: Cannot remove CPUs from a running VM

$ govc.sh -l fra poweroff test-nginx01-fra
Shutdown guest VirtualMachine:vm-5749... OK

$ govc.sh -l fra cpu_remove 1 test-nginx01-fra
govc.sh: Changing CPU count 4->3 ..

$ govc.sh -l fra poweron test-nginx01-fra
...

$ govc.sh -l fra cpu_add 1 test-nginx01-fra
govc.sh: Changing CPU count 3->4 ..

govc-scripts's People

Contributors

lakostis avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.