Pesquisar este blog

terça-feira, 20 de setembro de 2016

Multiplataform Hyper-V Manager using Python and FreeRDP

HYPY - HYper-v in PYthon

Multiplataform Hyper-V Manager using Python and FreeRDP

How HYPY works?

Hypy uses winrm to comunicate with hyper-v server shell and sends powershell commands to interact with the virtual machines. Using Powershell, HYPY can get Name, ID and state of virtual machines. Therefore, HYPY call freeRDP with vm-id and credentials, using settings in .conf file to connect the vm.

Pre-requisites

WinRM 

 

Hypy uses winrm to communicate with the hyper-v host, so it must be enabled and accepting connections. https://github.com/diyan/pywinrm has a session explaining how to Enable WinRM on the remote host.

FreeRDP

 

FreeRDP binary must be in path (windows, linux and mac). Make sure FreeRDP is working before using hypy or it will not open the session to the virtual machine. If you are using Linux, you package manager should have freerdp avaiable or look into https://github.com/FreeRDP/FreeRDP for install instructions.

Configuration

To configure Hypy, change the file 'hypy.conf'
[credentials]
host = <server name in domain>
domain = <domain name>
user = <user name in server>
pass = <password>

[options]
cache_file = <name of cache file>
sync_interval = <interval in hours to make new cache file>
You must have write permissions to the path pointed by cache_file

usage

If you don't know how to use hypy, you can use hypy.py --help
hypy.py --help
  Usage: hypy.py [OPTIONS] COMMAND [ARGS]...

  Multiplataform Hyper-V Manager using Python and FreeRDP

Options:
  --help  Show this message and exit.

Commands:
  connect  Connect to virtual machine identified by...
  create   Create a new snapshot with vm's current state
  delete   Delete a machine's snapshot by name
  list     List virtual machines and its indexes
  pause    Pause virtual machine identified by index
  restore  Restore virtual machine snapshot
  resume   Resume (paused) virtual machine identified by...
  snaps    List virtual machine snapshots
  start    Start virtual machine identified by index
  stop     Stop virtual machine identified by index
 
If you need help on any subcommand, run hypy.py COMMAND --help

Autor: Gabriel Avanzi. 
https://github.com/avanzzzi/hypy