Set CPU affinity for specific VM on VMware ESXI using govc CLI - vmware

I have shell scripts that I use to programmatically configure my virtual machines (VMs) on my VMware ESXi host. I use the "govc" command-line-interface (CLI) which provides a suite of commands to configure my VMs that run on my ESXI (i.e., powering on, setting ram, etc...)
I am trying now to set the CPU affinity for some of my virtual machines (i.e., VM #2 should use CPUs 9-16 whereas VM#1 should use CPU 2-8). However, I cannot find any govc command to do this programmatically, though I can very clearly see how to do this within the ESXI web-based GUI:
I reference the govc API for commands here, but again, I could not find anything. The CPU affinity should be set for a specific VM, and there should be an argument of CPU numbers separated by comma or with hyphen (-) for a range, I would imagine:
govc usage
How can I fix this problem with VMware ESXi and govc?

That's not a configuration that's been enabled at the govc level, as Doug mentioned in your issue.
Alternatively, you could use other CLIs, like PowerCLI which is PowerShell based, and has a lot more coverage area for more in-depth tasks like this, or the govmomi SDK, which has full API coverage.

As Kyle Ruddy stated, it couldn't be done via govc, but it can be done by finding your .VMX file for your respective VM on the ESXi datastore and simply add this line to your .vmx file.
sched.cpu.affinity = 1,2,3,4,5 // Values are separated by commas
You can double check your ESXi, by selecting the VM and going into its settings and you will see the CPU Scheduled Affinity Range that you set via the VMX file.
Of course , if you have a lot of CPUs, you can have some script (Bash, etc.) with a for loop populate the comma-delimited CPU values.

Related

Does Google not allow to change CPU Frequency Governor on Google Cloud instances?

I want to change the CPU frequency scaling governor on my Google Cloud instance running Linux.
The usual way of setting it
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
Doesn't work because the cpufreq folder does not exist (Inside cpu0/cpu1/cpu2/cpu3/cpu).
Tried installing cpufrequtils but still the folder did not show up. So is it that Google doesn't want too much power consumption from high CPU usage and disables it?
You are running in a virtualized environment. You cannot control the underlying hardware.

Is there a way to test the PsExec tool on a single machine?

I want to run a PsExec demo, that simulates running a command on multiple machines in a network
Would I need a VMWare tool? I'm looking at Workstation 12 at the moment.
No, just ensure your firewall rules are correct and sysinternal tools are installed on each machine, file and printer sharing are enabled and that your antivirus product does not block psexec.
VMTools gives you things like drag and drop, shared drives, improved graphics and code wise PowerCli. That can do things like Invoke-script which allows you to run commands on other machines this might be alternative you want to use.

How do you deploy VirtualSystemCollection enabled OVF/OVAs to ESXi?

When building an OVF, you can specify a tag for VirtualSystemCollection that allows you to have multiple VMs to share the same base disk image, but any changes that the individual machines make are Copy-On-Write into a private disk area for each specific VM.
When you try to deploy images setup this way to EXSi, it complains Unsupported element 'VirtualSystemCollection'. It would appear that you need the commercial vCenter or vApp servers from VMWare to utilize this feature. (From what I've been able to grok so far)
Is there a way to do this through free software (Free like ESXi, or opensource)
The ultimate goal is that I want to have a single disk image that's used as a base - and to bring up a cluster of VMs that are then individually configured so that for a VM with a 500 meg disk, I only need '500M + (num_vms * delta_per_vm)' rather than '500M * num_vms'
An ESXi connected to a vCenter should support this via vApps but since you wanted a non-commercial solution, the closest things is to use VirtualBox.
The open source VirtualBox has multi-attach support to achieve this with different disk formats and it works very well. It also has special qcow, qemu copy on write disk support. Basically, you create a master disk and attach to multiple VMs. (Huge disk space saving.)
It can also happily import multiple VMs from a single OVA file with VirtualSystemCollection but unfortunately, it still requires manual intervention to tell VirtualBox that disks are shared after importing all the VMs. (Well, it defeats the appliance deployement in the first place...)
After creating master disk (or after deployment), attaching to multiple VMs can be done with GUI or with the following command:
VBoxManage storageattach "vm-name" --storagectl "sata1" --port 0 --device 0 --type hdd --medium base.vdi --mtype multiattach
For more information, see http://www.electricmonk.nl/log/2011/09/24/multiple-virtualbox-vms-using-one-base-image-copy-on-write/ and http://virtbjorn.blogspot.com.tr/2012/12/virtualbox-multi-attach-disk.html
If you really want to use VMWare ESXi, you can use data deduplication to achieve the same task on block level. (which is generally used with cloud hosting companies). You can see the deduplication success rates with open source tools here: http://opendedup.org/deduprates
In VMware products, a multi-tier appliance (VirtualSystemCollection) is called a vApp. In vSphere, vApps live in vCenter and not ESX. So yes, you need vCenter to import a VirtualSystemCollection.
If you are using Workstation, you can also try the free vApprun tool:
https://labs.vmware.com/flings/vapprun
Here is what I did successfully to have such OVF images imported into my free ESXi server.
In the OVF file a XML element VirtualSystemCollection defines the vApp.
You can manually edit the OVF file and remove or comment this part as shown bellow. This will allow to import the VM into ESXi without vCenter once the OVF image is converted using VMware OVF Tool.
<!-- ovf:VirtualSystemCollection ovf:id="dummy-id">
<ovf:Info>A collection of virtual machines</ovf:Info>
<ovf:Name>dummy-name</ovf:Name>
<ovf:StartupSection>
<ovf:Info>VApp startup section</ovf:Info>
<ovf:Item ovf:id="dummy-id" ovf:order="0" ovf:startAction="powerOn" ovf:startDelay="0" ovf:stopAction="powerOff" ovf:stopDelay="0"/>
</ovf:StartupSection-->
Keep the remaining part intact and remove the following line at the end.
</ovf:VirtualSystemCollection>
Also make sure you have the last ESXi Embedded Host Client installed to avoid other bug related problems during import.
https://labs.vmware.com/flings/esxi-embedded-host-client
Converting OVF to VMX can be done using VMWare OVF Tool. In command line it looks simply as following:
ovftool <path_to_source>/<myvm>.ovf <path_to_target>/<myvm>.vmx

Amazon EC2 usable as a VMware testing platform?

We have the need to perform tests on localized platforms that put some burden on our hardware resources because for just a few weeks we might need plenty of servers and clients (Windows 2003 and Windows 2008, Vista, XP, Red Hat, etc) in multiple languages.
We typically have relied on blades with Windows 2003 and VMWare, but sometimes these are overgrown by punctual needs and also have the issue that the acquisition and deployment process is quite slow if the environment needs to grow.
Is Amazon EC2/S3 usable in the following scenario?
Install VMWare (Desktop because we need the ability to have snapshots) on an Amazon AMI.
Load existing VMWare images from S3 and run them on EC2 instances (perhaps 3 or 4 server or client OSes on each EC2 instance.
We are more interested in the ability to very easily start or stop VMware snaphsots for relatively short tests. This is just for testing configurations, not a production environment to actually serve a user workload. The only real user is the tester. These configurations might be required for just a few weeks and then turned off for a few months until the next release requires them again.
Is EC2/S3 a viable alternative for this type of testing purpose?
Do you actually need VMWare, or are you testing software that runs in the VMWare VMs? You might actually need VMWare if you are testing e.g. VMWare deployment policy, or are running code that tests the VMWare APIs. Examples of the latter might be you are testing an application server stack and currently using VMWare to test on many platforms.
If you actually need VMWare, I do not believe that you can install VMWare in EC2. Someone will correct & enlighten me if this is not the case.
If you don't actually need VMWare, you have more options. If you can use one of the zillion public AMIs as a baseline, clone the appropriate AMIs and customize them to suit your needs (save the customized version as a private AMI for your team). Then, you can use as many of them as you like. Perhaps you already have a bunch of VMWare images that you need to use in your testing. In that case, you can migrate your VMWare image to an EC2 AMI as described in various places in Google, for example:
http://thewebfellas.com/blog/2008/9/1/creating-an-new-ec2-ami-from-within-vmware-or-from-vmdk-files
(Apologies to the SO censors for not pasting the entire article here. It's pretty long.) But that's a shortcut; you can always use the documented AMI creation process to convert any machine (VMWare or not) to an AMI. Perform that process for each VMWare VM you have, and you'll be all set. Just keep in mind that when you create an AMI, you have to upload it to S3, and that will take a lot of time for large VMs.
This is a bit of a shameless plug, but we have a new startup that may deal with exactly your problem. Amazon EC2 is excellent for on-demand computing, but is really targeted at just a single user launching production servers. We've extended EC2 to make it a Virtual Lab Management environment, with self-service, policies and VM sharing. You can check it out at http://LabSlice.com and see if it meets your needs.
Amazon provides a solution themselves now: http://aws.typepad.com/aws/2010/12/amazon-vm-import-bring-your-vmware-images-to-the-cloud.html

Replacing Virtual PC/Server with VMWare Fusion/Server for Development Environments

I develop exclusively on VMs. I currently run Boot Camp on a MacBook Pro and do all my development on a series of Virtual PC VMs for many different environments. This post by Andrew Connell litterally changed the way I work.
I'm thinking about switching to Fusion and running everything in OS X but I wasn't able to answer the following questions about VM Fusion/Workstation/Server. I need to know if the following features from Virtual PC/Server exist in their VMWare counter parts.
Differencing Disks (ability to create a Base VM and provision new VMs which just add deltas on top of the base [saves a ton of disk space, and makes it easy to spin up new VMs with a base set of funcitonality]). (Not available with Fusion, need Workstation [$189])
Undo disks (ability to rollback all changes to the VM within a session). (Available in both Workstation and Fusion [$189/$79.99 respectively])
Easily NAT out a different subnet for the VM to sit in. (In both Fusion/Workstation).
Share VMs between VM Player and VM Server. I'd like to build up a VM locally (on OS X/Fusion) and then move it to some server (Win2k3/Win2k8 and VM Server) and host it there but with VM Server. (In both Fusion/Workstation).
An equivalent to Hyper-V. (Both Fusion and Workstation take advantage of type-2 hypervisor a for 64x VMs, neither do for 32 bit VMs. VMWare claims they're no slower as a result some benchmarks corroborate this assertion).
Ability to Share disks between multiple VMs. If I have a bunch of databases on a virtual disk and want them to appear on more than one VM I should be able to just attach them. (Available in both Fusion and Workstation)
(Nice to have) Support for multiple processors assigned to a VM (Available in both Fusion and Workstation).
Is there a VMWare guru out there who knows for sure that the above features are available on the other side?
Also the above has been free (as long as you have licenses for Windows machines), besides buying Fusion are there any other costs?
The end result of my research, thanks so much!
You can only create Linked clones and Full Clones (which are close to differencing disks) in VMWare Workstation (not Fusion). Workstation also has at better snapshot management in addition to other features which are difficult to enumerate. That being said Workstation is $189 (as opposed to $79) and not available on OS X. In addition Fusion 1.1 (current release) has a bunch of display bugs on OS X 10.5 (works well on 10.4). These will be remedied in Fusion 2.0 which is currently in (RC1). I'll probably wait until v2.0 comes out and then use both Workstation/Fusion to provision and use these VMs on OS X.
I've not used Fusion, just workstation and server
1) Yes, you can create a linked clone from current vm state, or from a saved state (snapshot) in VMware Workstation
2) Yes, revert to snapshots
3) There's a number of different network setups, NAT's one of them
4) VMware virtual machines created with VMware Fusion are fully compatible with VMware’s latest products.
5) ?
6) You can add pre-existing to disks to other vm's
7) Yup, you create multi-cpu vm's
Workstation costs, but VMWare Server is free
It doesn't have #1, at least.
VMWare server is free, but only allows for one snapshot, a serious deficiency. VMWare Workstation allows multiple snapshots and can perform most of the same functionality.
VMWare has a Hypervisior which is equivalent to Hyper-V in Virtual PC.
You can not share a VM that was created in Fusion with Windows VMWare Server (free version) you'll need the paid version to be able to share amongst both.
I'd also take a look at Sun's xVM VirtualBox for Mac. It runs Windows XP and Vista quite swift on my Mac.
1 and 2) VirtualBox has snapshots that branch off from the base VM like a tree. You can revert to any previous snapshots and name them.
3) It has NAT support and bridged networking like the VMWare and Microsoft products.
4) There is no server version of VirtualBox, but I know it shares an engine with Qemu, so it may be possible to host your VBox images on Qemu.
5) VirtualBox does have a hypervisor if your Mac has VT-x enabled.
6) Sure, you can add existing disks to other VMs. But you can't run the same disk in multiple VMs at once. (Isn't that a restriction of all virtualization hosts, though?)
7) No. VirtualBox will give each image one CPU and spread them out.