Exemplo n.º 1
0
    def scp(self, src, dst):
        vm = Vmrun(self.vmx)
        ip = vm.ip()
        user = self.user
        if ip:
            src_is_host = src.startswith(":")
            dst_is_host = dst.startswith(":")

            if src_is_host and dst_is_host:
                puts(colored.red("Both src and host are host destinations"))
                exit()

            if dst_is_host:
                dst = dst[1:]
                puts("Sending {src} to {user}@{ip}:{dst}".format(
                    user=colored.green(user),
                    ip=colored.green(ip),
                    src=src,
                    dst=dst,
                ))
                os.system('scp {} {}@{}:{}'.format(src, user, ip, dst))
            else:
                src = src[1:]
                puts("Getting {user}@{ip}:{src} and saving in {dst}".format(
                    user=colored.green(user),
                    ip=colored.green(ip),
                    src=src,
                    dst=dst,
                ))
                os.system('scp {}@{}:{} {}'.format(user, ip, src, dst))
        else:
            puts(colored.red("IP not found"))
            return
Exemplo n.º 2
0
 def stop(self):
     vm = Vmrun(self.vmx)
     if vm.check_tools() is True:
         vm.stop()
     else:
         vm.stop(mode='hard')
     puts(colored.green("Stopped", vm))
Exemplo n.º 3
0
 def ssh(self):
     vm = Vmrun(self.vmx)
     ip = vm.ip()
     if ip:
         puts("Connecting to {}".format(colored.green(ip)))
         os.system('ssh {}@{}'.format(self.user, ip))
     else:
         puts(colored.red("IP not found"))
Exemplo n.º 4
0
 def get_vmrun(self, vmx_path):
     '''Returns an Vmrun objects using a vmx file path'''
     attributes = self.get_attributes()
     return Vmrun(user=attributes.guest_username,
                  password=attributes.guest_password,
                  vmx=vmx_path,
                  debug=True,
                  vmrun=VMRUN)
Exemplo n.º 5
0
 def ip(self):
     vm = Vmrun(self.vmx)
     print self.vmx
     ip = vm.ip()
     if ip:
         puts(colored.green(ip))
     else:
         puts(colored.red("IP not found"))
     return ip
    def do_use(self, args):
        """use specified vmx file, and initialize vmrun.

        Usage:
            use vmx-name
        """
        VmxUI.do_use(self, args)
        if ( self.vmx is not None and
             self.vmx_admin is not None and
             self.vmx_pass is not None ):
            self.vmrun = Vmrun( self.vmx, self.vmx_admin, self.vmx_pass, debug=self.debug )
Exemplo n.º 7
0
 def start(self):
     vm = Vmrun(self.vmx)
     if self.gui:
         vm.start(gui=True)
     else:
         vm.start()
     puts(colored.yellow("Getting IP address..."))
     ip = vm.ip()
     puts(colored.green("VM started on {}".format(ip)))
     puts(colored.yellow("Sharing current folder..."))
     vm.enableSharedFolders()
     vm.addSharedFolder('mech', os.getcwd())
     puts(colored.green("VM started on {}".format(ip)))
Exemplo n.º 8
0
 def ip(self):
     vm = Vmrun(self.vmx)
     return vm.ip()
Exemplo n.º 9
0
 def suspend(self):
     vm = Vmrun(self.vmx)
     vm.suspend()
     puts(colored.green("Suspended", vm))
Exemplo n.º 10
0
 def pause(self):
     vm = Vmrun(self.vmx)
     vm.pause()
     puts(colored.yellow("Paused", vm))
Exemplo n.º 11
0
 def stop(self):
     vm = Vmrun(self.vmx)
     vm.stop()
     puts(colored.green("Stopped", vm))
Exemplo n.º 12
0
 def status(self):
     vm = Vmrun('')
     puts("".join(vm.list()))
Exemplo n.º 13
0
 def ip(self):
     vm = Vmrun(self.vmx)
     print self.vmx
     ip = vm.ip()
     puts(colored.green(ip))
     return ip