#!/usr/bin/env python
import os, sys, yaml

# Set the help menu
def getSyntax():
    return "Usage: clone-vm.py [options...] <vm_name>"

# Set arguments values
def setArguments(argv):
    opts = {}
    # Set available arguments
    valued_args = { '--username': 'username', '-u': 'username', '--password': 'password', '-p': 'password' }
    non_valued_args = { '--linked': 'linked', '-l': 'linked', '--full': 'full', '-f': 'full' }
    while argv:
        # If it's an option
        if argv[0][0] == '-':
            # if it's a valued argument we keep the value and cut 2 arguments form the list
            if argv[0] in valued_args:
                opts[valued_args[argv[0]]] = argv[1] 
                argv = argv[2:]
            # if it's not a valued argument we set it as true and cut 1 argument 
            elif argv[0] in non_valued_args:
                opts[non_valued_args[argv[0]]] = True 
                argv = argv[1:]
            # We don't have available definition for this argument, show the help
            else:
                print 'Invalid argument.'
                print getSyntax()
                exit(1)
        # New vm name
        elif len(argv) == 1:
           opts['name'] = argv[0]
           argv = argv[1:]
        # There is a problem with the syntax
        elif argv[0] != sys.argv[0]:
            print 'Invalid argument.'
            print getSyntax()
            exit(1)
        # This is the script name, we don't store it
        elif argv[0] == sys.argv[0]:
            argv = argv[1:]
    return opts

if len(sys.argv) == 1:
   print getSyntax() 
   exit(1)
else:
   args = setArguments(sys.argv)

# Load yaml file configuration
if os.path.isfile('config.yaml'):
    f = open('config.yaml')
    configMap = yaml.safe_load(f)
    f.close()
else:
    print "Config file 'config.yaml' not found"
    exit(2)

vm_dest_dir = configMap['vms']['path_dir'] + "/" + args['name'] + ".vmwarevm"
vm_dest_vmx = vm_dest_dir + '/' + args['name'] + '.vmx'

if not os.path.exists(vm_dest_dir):
  os.makedirs(vm_dest_dir)

cmd = "vmrun clone '" + configMap['vm']['source']['vmx_path'] + "' '" + vm_dest_vmx + "' linked -cloneName=" + args['name']  

print "[+] Creating new linked vm: " + args['name']
os.system(cmd)

@@ -37,16 +37,36 @@
 , yaml%0A%0A
+debug_mode = False%0A%0A
 # Set th
@@ -369,24 +369,44 @@
 ued_args = %7B
+ '--debug': 'debug',
  '--linked':
@@ -1681,16 +1681,148 @@
 ys.argv)
+%0A   try:%0A       debug_mode = args%5B'debug'%5D%0A       print %22%5B-%5D Args: %22%0A       print args%0A   except KeyError:%0A       debug_mode = False
 %0A%0A# Load
@@ -1942,16 +1942,92 @@
 load(f)%0A
+    if debug_mode:%0A        print %22%5B-%5D Config map: %22%0A        print configMap%0A
     f.cl
@@ -2425,16 +2425,78 @@
 me'%5D  %0A%0A
+if debug_mode:%0A    print %22%5B-%5D vmrun command:%22 + cmd%0Aelse:%0A    
 print %22%5B
@@ -2539,16 +2539,20 @@
 'name'%5D%0A
+    
 os.syste

Debug mode