A widely used feature in VMware's hosted products (Fusion & Workstation) is the shared folders capabilities which allows you to easily share files between the host system and your Virtual Machines. With the latest release of VMware's AppCatalyst TP2, shared folders is now officially supported and can be configured using the AppCatalyst's REST API. Below are the instructions on setting up shared folders for your VMs running in AppCatalyst. Thanks to Fabio for sharing the details.
I will assume that you already have a VM that is running under AppCatalyst. If you do not, you can run the following commands to quickly deploy a new VM called "photon" from the default VMware Photon OS template and retrieve the IP Address assigned to the VM (which we will make use later).
/opt/vmware/appcatalyst/bin/appcatalyst vm create photon
/opt/vmware/appcatalyst/bin/appcatalyst vmpower on photon
/opt/vmware/appcatalyst/bin/appcatalyst guest getip photon
If you have not used AppCatalyst before, be sure to check out this getting started guide here.
Step 1 - Open a terminal and start the AppCatalyst Daemon by running the following command:
/opt/vmware/appcatalyst/bin/appcatalyst-daemon
Step 2 - Open a browser to connect to the following URL https://localhost:8080 to access the REST API explorer provided by Swagger.
Step 3 - Expand the POST /vms/{id}/folders which is the API to configure shared folders for a particular VM. You will need to fill in the id property which specifies the name of the VM and the state property defines the shared folder configuration.
Here is an example for creating a shared folder in the guest called "shared-folder" and mapping that to the host folder under /Users/lamw/Development. The flags property specifies how the folder will be accessed by the VM. Currently, there is only one flag implemented which is "4" and means read/write access. In the future there maybe more flags implemented for different types of access.
{
"guestPath":"shared-folder",
"hostPath":"/Users/lamw/Development",
"flags":4
}
Once you have entered the information into the UI, to execute the API request you just need to click on the "Try it out" button at the bottom. If the operation was successful, you should get back a 200 response from the UI.
Note: The guestPath property is not actually a path in the VM but rather the name of the directory which will map to the host shared folder.
Step 4 - We can now login to our VM to confirm that the shared folder has been configured. If you are using the default Photon template, you can login by specifying the default SSH keys included with AppCatalyst and the IP Address of the Photon VM we deployed earlier.
Here is the command to login (be sure to replace with the IP Address from your enviornment):
ssh -i /opt/vmware/appcatalyst/etc/appcatalyst_insecure_ssh_key [email protected]
Step 5 - Once logged in, if we now look under /mnt/hgfs directory, we should now see the shared directory automatically created and mapped to the host shared folder we created earlier.
If you wish to remove shared folders from a VM, you can do so by executing the DELETE /vms/{id}/folders/{folderId} API and specifying the id for both the VM and folder. Hopefully in the future, shared folders can also be easily consumed through the simple AppCatalyst CLI, but for now you can do so using the REST API.
Thanks for the comment!