accessing VMware through java code - virtual-machine

Is there a way that a virtual machine (.vmx) file be opened in VMware workstation through a java code

If you want to edit the .vmx file, then the answer is no. There is currently no API available for VMware Workstation to let you programmatically change values in vmx file.
EDIT:
If VMPlayer can be invoked command line and an agrument vmx file can be passwd to it, then yes. Run the command via java using Process object.

Related

Access WSL2 java vm through IDEA

I have setup GraalVM by downloading it through oracle page and extracting the tar file in drive E:/ ("E:\Programs\Java\graalvm-ee-java17-22.0.0.2\bin").
Then I log into WSL2 (ubuntu) bash and setup the environment variables in bashrc.
now I can execute the VM through command line...
However my IDEA Community could not load this JVM into my project. When I try to manually add JDK, it would not allow to open mnt folder and specify the path.
I can't expand the e directory. How can I overcome this issue and allow IDEA to recognize the WSL instance JDK?
It's a Windows limitation, if you open \\wsl$\Ubuntu-20.04\mnt in File Explorer, you will not be able to browse the drives. I'd recommend you install JDK in another browsable place under WSL.

Mount VHDX within WSL Ubuntu 18.04 to edit Linux files

I'm looking to change a process (which currently is an elevated PowerShell script running in Windows 10, and I want to keep it close to that) I have that currently uses Paragon Linux Filesystem for Windows tool. While it does work, it doesn't work consistently. What I'd like to do instead is to use WSL on Windows 10, 1909 currently (will go to 2004 when available), to mount a VHDX which contains to partitions, /dev/sda1 for /boot, and /dev/sda2 another for an Linux LVM. The OS within this VHDX is CentOS 7.5, and the filesystem I want to modify is formatted in ext4. I need to edit some files within a logical volume within the group.
Currently, I'm running into an issue where qemu-nbd doesn't help, as there doesn't appear to be an NBD kernel mode driver provided by the Microsoft Linux kernel in Ubuntu 18.04 image from the Windows Store. I've tried guestfish (using guestmount), but it is unable to find an operating system and fails to mount any of the volumes.
Is this possible? Am I going down the wrong path, and is this not possible?
As I understand your question...
Seems to me that you want to offline access a .vhdx containing Linux
using powershell to manipulate some files...
(I think the issue here is ext4 and file rights)
1. Mount the .vhdx you want to '''work''' in a linux virtual machine as second disk
2. Install Powershell 7 in linux VM
3. Configure Powershell remote in the Linux VM (via SSH)
4. Access the Linux VM from Windows Powershell 7 and execute your scripts.
there are other ways using VMs+NBD or using WSL and mounted
drives... but this seems to be the most practical end efficient!
as you for sure know you can start/stop the VMs from Powershell

What is the best way to remotely edit a file using VS code?

Currently, I have two machines, one with Ubuntu in the company and one with Mac OS at home. Sometimes I would like to work at home while accessing the Ubuntu machine in the company. I can ssh into the Ubuntu machine and navigate and compile there. However, when I actually want to edit some cpp source codes, I realize that the editor (VS code) is actually opened in the Ubuntu machine, so I cannot view it from Mac. What should I do if want to edit files remotely on my Mac through VS code?
Though many of the answers mention using version control tools like git, it can be hard to use in my specific case. The problem is that the building environment of my company is Linux, so most of the building tools I have can only run on Linux. This means that I can only compile my source codes in Linux. If I use git, then every time I want to compile and debug my codes, I have to commit and push with my Mac, and then pull and test on Linux. This can be time consuming if want to incrementally modify, test and debug my codes.
Use some version control system like git. Then you might edit and compile at home (provided your code is portable between Linux & MacOSX, e.g. because it is POSIX compliant).
You could install some X11 server on your Mac and use ssh -X to access the remote Ubuntu machine (then run a GUI or editor remotely, e.g. ssh -X remotelinuxhost.company.com emacs). However, that requires good bandwidth and latency between your home computer and the remote one.
BTW, you might use some other source code editor, like emacs (it is capable of remote editing) or vim.
Since Linux and MacOSX are both POSIX systems, it is usually (but not always) easy to port source code from Linux to MacOSX and write source code compilable on both systems. BTW, many Linux frameworks (e.g. Qt, GTK, POCO, Boost, etc...) and build systems are usable and ported to MacOSX. Some Linux system calls (listed in syscalls(2)) are not available on MacOSX (e.g. signalfd(2)...)
Of course you could install Linux (perhaps inside some VM) on your Apple laptop.

Automate/Script Building a Virtual Image

I would like to script a build of a virtual machine from a base image, with a number of files and folders being copied across to the target machine, and some software also installed on it. Is this possible? Which technology is best suited to this - VMWare, Virtual PC/Server or Virtual Box? The solution has to run on WS2003 or WS2008, so the new Windows Virtual PC is not an option for me.
Thanks, MagicAndi.
I've used VMWare for this in the past, particularly the free VMWare Server product. Create a VM and install the OS as usual, then use sysprep to package the machine and feed it an unattend file. After sysprep shuts the machine down, save it off as your base image.
When you want to create a new image, make a copy of your base image, then use the vmware-mount tool to mount the newly copied image as a drive letter. Open up the unatend file and change out the machine name, etc, and added any additional commands you want to run after the machine is powered on. Then vmware-mount /d and power on the virtual machine.
Script all this together and you've got a one-click machine generator.
I'm a fan of VWmare server -- it's free, and the vmx file format is easily understood.
The solution I have came up is to bake all the changes I need to make to the virtual machine into a custom MSI, built up using the Windows Installer XML (WiX) toolset. To install third-party software on the virtual machine, I can either track the changes to the OS by each application installer (using Process Monitor from SysInternal Software) and replicate them into my own custom MSI, or I can use a script (like this AutoIt script) to install the software from a shared directory. I also am looking into using White and PowerShell for scripting.
It look like it may be possible to automate the creation of virtual images using MS Virtual Server 2005. The following articles detail the use of PowerShell scripts to automate the creation of virtual images:
Configuration Testing With Virtual Server, Part 1
Configuration Testing With Virtual Server, Part 2
From part 2, in the section Configuration Tests on a Virtual Machine, it seems possible to transfer files and schedule scripts to run. Using these articles as a basis, it should be possible to automate the building of a MS virtual image in the same way as lordbrain described for a VMware image.

Automate CentOS installation with VMware for testing

Is is possible to automate the installation of an OS using VMware or any other virtualization product?
One of our products consists of a customized version of CentOS that installs the OS and our application on a server. It's much like any CentOS/RHEL installation where you choose a mode that corresponds to different kickstart options, and then you choose your keyboard type. The rest of the installation is automatic.
What I'd like to have is an automated system that will create a new guest VM, boot it with the ISO image of our product, start the installation (including choosing the keyboard), wait for the reboot, and then launch a set of automated tests.
I know that there are plenty of ways to automate the creation of new VM guests from existing templates/images, and I know you can use the VIX API to interact with virtual machines, but the VIX API seems to require that VMware tools is already running (which won't be the case when you're booting from the CentOS install disk).
This answer (Automating VMWare or VirtualPC) indicates that you can script VMware to boot from an ISO that does an unattended installation, but I would really like to test the same process that our customers will be using.
Another option might be to use Xen's fully-virtualized mode and see if scripting it over the serial port will work.
TIA,
Jason
I have a very very similar question, it is on superuser:
https://superuser.com/questions/36047/moving-vmware-os-image-as-primary-os-on-a-system
You can also use VirtualBox instead of VMWare. The VirtualBox SDK allows you to directly control the keyboard, the mouse the serial port and the parallel port of the guest without the virtualbox guest tools installed.
Unfortunately it doesn't offer a text console interface but the serial port can be connected to a local pipe file and that can probably be worked with just as well.
This may not be exactly what you need:
I have done something similar with a Ubuntu-based install. We used preseeding (Debian's form of kickstart), to answer all the questions during the install - providing the preseed file and the installer via tftp.
In addition to the official Ubuntu mirror we added the apt-server with our own packages in the preseed file. We put a .deb version of vmware-tools on the apt-server and added it to the packages to be installed.
The .deb of vmware tools just contained the .tar.gz and a postinstall script that would extract it to /tmp and run the vmware install script (which has a switch to be run unnattended, so it does not ask any questions).
So after the reboot vmware-tools were up and running and we could use vix to script the rest (which was not very reliable).
If you should encounter problems with running vmware-config.pl during boot, you could make a custom package that just extracts the tools and an init script that installs them on first boot, disables itself and reboots.
Maybe you can use this strategy (replacing apt by yum, preseed by kickstart and tftp by a remastered iso). If you really need to test that your users choose a keyboard in the installer (which is not very different from kickstart) this would obviously not work for you..