Checking for VM Memory Limits

Here is a quick one liner I found to check for any VMs which had memory limits set on them:

Get-VM | Get-VMResourceConfiguration | where {$_.MemlimitMB -ne -1}

If you want to target a specific cluster, just add Get-Cluster “clustername” to the beginning:

Get-Cluster “Clustername” | Get-VM | Get-VMResourceConfiguration | where {$_.MemlimitMB -ne -1}

Now if you want to get rid of the memory limits, add the following:

Set-VMResourceConfiguration -MemlimitMB $null

Final script for all VMs to find and remove limits:

Get-VM | Get-VMResourceConfiguration | where {$_.MemlimitMB -ne -1} | Set-VMResourceConfiguration -MemlimitMB $null

Next step…setting this as a scheduled workflow in Orchestrator to run every night/week and send a report out of any limits discovered.

 

 

VCAP-ICD – Objective 1.1

Objective 1.1 – Create a Conceptual Design Based on Business Requirements

Skills and Abilities 

  • Distinguish between virtualization, automation and cloud computing.
  • Distinguish between private, public, hybrid and community cloud computing.
  • Analyze a customer use case to determine how cloud computing can satisfy customerrequirements.
  • Given a customer use case, determine the appropriate cloud computing model.

Distinguish between virtualization, automation and cloud computing.

First paragraph taken from the VCAT 3.1 Toolkit (Service Definitions PDF): http://www.vmware.com/cloud-computing/cloud-architecture/vcat-toolkit3.html

Virtualization has reduced costs and increased server efficiency, often dramatically, but it does not, by itself, deliver the level of automation and control required to achieve the efficiencies or agility associated with cloud computing. Cloud computing offers the opportunity to further improve cost efficiency, quality of service, and business agility. It enables IT to support a wide range of changing business objectives, from deployment of new tools, products, and services to expansion into new markets. Cloud computing transforms IT from a cost center into a service provider.

Virtualization:  

Essentially allows us to consolidate and become much more efficient with the resources we have. Instead of multiple physical servers we can now use 1 physical server to host multiple workloads. I still think of virtualization as a technology which helps to enable the Cloud framework. At the end of the day, if you virtualized 100% of your apps, this does not mean you have a Cloud, only that you are 100% virtualized, but no doubt have saved your company a lot of money.

Automation:  

Automation helps us to do things better by making us more efficient. Here the emphasis is on scripting, workflow design, configuration management tools, and any other methods to reduce the amount of human touch to make things work. It is an essential skill required to enable any serious Cloud delivery.

Cloud Computing: 

Key Terms: Business Agility, Quality, Cost efficiency

Automation and Virtualization help us get there. Business Agility is key, as by fully embracing a cloud model it enables IT to respond quickly to changing business demands. As VMware states above, this transforms IT from a cost center, into a service provider. The way our customers consume resources is radically changed when we use a cloud model.

Again keep in mind, if you just virtualized your environments and then put in automation, you are efficient, but you haven’t changed the entire process.

Distinguish between private, public, hybrid and community cloud computing.  

Taken from the VCAT 3.1 Toolkit (Service Definitions PDF): http://www.vmware.com/cloud-computing/cloud-architecture/vcat-toolkit3.html 

The following are the commonly accepted definitions for cloud computing deployment models:

  • Private vCloud – The vCloud infrastructure is operated solely for an organization and can be managed by the organization or a third party. The infrastructure can be located on-premises or off- premises.
  • Public vCloud – The vCloud infrastructure is made available to the general public or to a large industry group and is owned by an organization that sells vCloud services.
  • Hybrid vCloud – The vCloud infrastructure is a composite of two or more vCloud instances (private and public) that remain unique entities but are bound together by standardized technology. This enables data and application portability, for example, cloud bursting for load balancing between vCloud instances. With a hybrid vCloud, an organization gets the advantages of both, with the ability to burst into the public vCloud when needed while maintaining critical assets on-premises.
  • Community vCloud – The vCloud infrastructure is shared by several organizations and supports a specific community that has shared concerns, such as mission, security requirements, policy, and compliance considerations. It can be managed by the organizations or a third party, and can be located on-premises or off-premises.

At this time I think it is also worth mentioning the 3 service models.

  • Software as a Service (SaaS) – Business-focused services are presented directly to the consumer from a service catalog.
  • Platform as a Service (PaaS) – Technology-focused services are presented for application development and deployment to application developers from a service catalog.
  • Infrastructure as a Service (IaaS) – Infrastructure containers are presented to consumers to provide agility, automation, and delivery of components.

Analyze a customer use case to determine how cloud computing can satisfy customer requirements.

Given a customer use case, determine the appropriate cloud computing model.

These last 2 objectives are covered very well in the Service Definitions PDF which lists a number of use case examples. I’m going to revisit this section after I finish going through all the objectives to see what examples I have found.

 

Cloud thoughts…and Operations 101

Cloud/VCAP-ICD Studying

My usual mentality is to fully understand the technology before trying to get others to buy in on the ideas. This way I know if it is vendor’s lying, or whether or not a suite like vCloud Director can actually make a lasting impact on the business.

So my focus over the next few months is going to be ensuring I know enough about how something like vCloud Director can work in practice. I will be developing sample policies and procedures to further enhance my understanding of what this might actually look like in practice. I will start this by going through the VCAP-ICD Exam Blueprint and working through every topic. You will see a new menu bar for VCAP-ICD very soon.

VMware is also releasing a new exam around governance, so it will be very interesting to see what extra material they bring to the table there.

For more information on the VCAP-ICD check out: http://mylearn.vmware.com/mgrReg/plan.cfm?plan=32565&ui=www_cert 

Operations 101

One thing has become clear to me as I’ve been reading books on the subject…If you don’t have basic blocking and tackling right in a static environment, your cloud ideas are bound to fail.

So in addition to learning about Cloud and studying for my VCAP-ICD I will be documenting all the core essentials I believe need to be in place before going to Cloud, or in some cases may be solved by going to a Cloud type model.

So what then are the core essentials BEFORE starting on a cloud journey.

My experience working in an enterprise has taught me that attitudes to operations matter far more than the technologies which enable them.  I’ve had the pleasure of working with some people that really care about their environments, and others that just come to do the bare minimum.

Operations must work. We can go and read ITIL books etc. but what is the reality, and how does operations work for the day to day VMware Admin…How do we get to that well oiled machine, and what does it take to keep it there…?

As I begin this section I am going to be covering the following solutions as they relate to VMware Environments:

1. VM Monitoring

I have a lot of experience now with nWorks, vKernel, SCOM, vCOPs…I will be discussing the very quick and easy way I was able to reduce noise, get relevant tickets, and get lower level engineers able to take over support for our day to day activities. Keep it simple and don’t over complicate your monitoring.

2. Performance Troubleshooting/VM Environment Recovery

If we can’t free ourselves up from bridge calls where infrastructure has to be checked and rechecked for performance we can never work on the things we need to work on. How do we quickly and effectively deal with these situations.

3. Capacity Planning

Divided up between Compute and Storage…how do you ensure you have the capacity you need all the time? Again I have created very simple ideas which can be modified to work in any environment.

4. Inventory/Tagging

This is an area I’m working on right now…would love to hear how other people are doing this in their virtual environments.

5. Automation/Configuration Management

Automation skills, be it scripting, config management with puppet/sccm, orchestration tools, are essential not just to Cloud but I believe Operations.

Standards are so important here…you can’t automate or maintain configurations, if you don’t even have a set of documented standards for your environment.

The 3 main areas I will cover here are ESXi Host standards, vCenter Standards, and VM Standards.

6. Disaster Recovery/Bacups

This journey is only beginning…I’m looking forward to thinking through all the challenges here.

7. More to be determined..

In closing, I believe this still comes back to standards. Someone once told me “There’s a standard for everything, and everything has a standard” and this in itself really helps guide the thoughts for the above.

How to correlate Windows Disks with VMDKs

This post comes from a colleague of mine who couldn’t find a great resource on how to correlate the Windows Disk in Disk Management, with the Virtual Disk presented by VMware.

When all the disks are different sizes it is easy, but sometimes they are the same…how can you be sure you are expanding the right disk?

These instructions/steps should allow you to correlate Windows Disks to VMDK Disks.

  1. RDP  to the Windows server in question and run this powershell script
Get-WmiObject Win32_DiskDrive | select-object DeviceID,{$_.size/1024/1024/1024},scsiport,scsibus,scsitargetid,scsilogicalunit | out-file -FilePath c:\OutputPhysicalDrive.txt

This script should allow you to match the OS disks to the VMDK Disks. The output will be referenced in later steps.

Example output

DeviceID : \\.\PHYSICALDRIVE3
$_.size/1024/1024/1024 : 9.99680757522583
scsiport : 3
scsibus : 0
scsitargetid : 0
scsilogicalunit : 0

DeviceID : \\.\PHYSICALDRIVE6
$_.size/1024/1024/1024 : 49.9993586540222
scsiport : 5
scsibus : 0
scsitargetid : 1
scsilogicalunit : 0

DeviceID : \\.\PHYSICALDRIVE4
$_.size/1024/1024/1024 : 19.9936151504517
scsiport : 4
scsibus : 0
scsitargetid : 0
scsilogicalunit : 0

DeviceID : \\.\PHYSICALDRIVE0
$_.size/1024/1024/1024 : 59.996166229248
scsiport : 2
scsibus : 0
scsitargetid : 0
scsilogicalunit : 0

DeviceID : \\.\PHYSICALDRIVE1
$_.size/1024/1024/1024 : 19.9936151504517
scsiport : 2
scsibus : 0
scsitargetid : 1
scsilogicalunit : 0

DeviceID : \\.\PHYSICALDRIVE2
$_.size/1024/1024/1024 : 19.9936151504517
scsiport : 2
scsibus : 0
scsitargetid : 2
scsilogicalunit : 0

DeviceID : \\.\PHYSICALDRIVE5
$_.size/1024/1024/1024 : 49.9993586540222
scsiport : 5
scsibus : 0
scsitargetid : 0
scsilogicalunit : 0

The second step is to get a list of your VMDK disk information by editing the virtual machine in question. 

The information you will be retrieving is the
Disk Name: “Hard disk 1”
Size: “60 GB”
Bus ID: 0
Disk ID: 0

SCSI (X:Y) Hard Disk under Virtual Device Node. The X:Y values are:

X = Bus ID
Y = Disk ID

Enter the Disk information for all VMDK disks into a table like the one below:

Reference OutputPhysicalDrive.txt and match up any OS disks to VMDK disk that have a unique size.

For the non unique drives you will need to match the Windows disk scsitargetid with the VMDK Disk ID.

The first 2 in the example below are both 50GB Drives.

DeviceID : \\.\PHYSICALDRIVE6
$_.size/1024/1024/1024 : 49.9993586540222
scsiport : 5
scsibus : 0
scsitargetid : 1
scsilogicalunit : 0

DeviceID : \\.\PHYSICALDRIVE5
$_.size/1024/1024/1024 : 49.9993586540222
scsiport : 5
scsibus : 0
scsitargetid : 0
scsilogicalunit : 0

The next 3 are all 20GB drives.

DeviceID : \\.\PHYSICALDRIVE2
$_.size/1024/1024/1024 : 19.9936151504517
scsiport : 2
scsibus : 0
scsitargetid : 2

DeviceID : \\.\PHYSICALDRIVE1
$_.size/1024/1024/1024 : 19.9936151504517
scsiport : 2
scsibus : 0
scsitargetid : 1
scsilogicalunit : 0

DeviceID : \\.\PHYSICALDRIVE4
$_.size/1024/1024/1024 : 19.9936151504517
scsiport : 4
scsibus : 0
scsitargetid : 0
scsilogicalunit : 0

As you see following the steps above will allow you to correlate the OS disks to the VMDK Disks.

Thank you vRad for this great guide!

Automating HA and DRS settings in multiple clusters using VMware vRealize Orchestrator (#vRO)

Have you ever opened up the settings on one of your vSphere Clusters, only to find HA wasn’t configured to your standards? Did someone do some work during the day and forget to put the settings right after their change?

After encountering this scenario far too many times, I decided to automate the problem away using vCenter Orchestrator. I created a workflow that runs every night to ensure all settings are correct.

Goal: Create an automated workflow that sets the following

HA Settings

  • Enable HA
  • Enable Host Monitoring
  • Enable Admission Control
  • Calculate the correct HA percentages based on the amount of hosts in the cluster (I’ll discuss this more later).

DRS Settings

  • Enable DRS
  • Set DRS to Fully Automated.

In addition, we need to ensure no other custom settings get overwritten (For example VM specific DRS/HA settings)

A quick note about HA admission control options:

The choice really comes down to three policies for enforcing admission control when it is enabled.

  • Host failures the cluster tolerates
  • Percentage of cluster resources reserved as failover spare capacity
  • Specify failover hosts

I won’t go into a deep discussion on each one now, but if you select Host failures the cluster tolerates, and say you select 1 host, which is fairly common, then the HA calculations are completely based off the slot size. The problem here is that if you have very large VMs, then the slot size gets skewed. It is possible to manually override the slot size that vCenter calculates, but then this means you are constantly having to maintain and update that new setting.

Duncan Epping has a great article on this at http://www.yellow-bricks.com/vmware-high-availability-deepdiv/#HA-admission

I decided to calculate my HA Admission control percentage for CPU and Memory based on the resources of a single host failing.

var HApercent = ((1/Hosts.length)*100);
HApercent = HApercent.toFixed(0);

I decided to round the value to the nearest whole number. It could be argued that if you have 3 hosts, and you use this formula you will end up with 33% (not 34%) of resources reserved. Either way I don’t think the 1% is going to be a huge problem in an HA event.

How to automate using vCenter Orchestrator:

Now we know what we are going to do, how do we automate it in Orchestrator?

1. Create the workflow to configure these settings on a specific cluster.

Make sure to add the general attributes for drsBehaviour, haHostMonitoring, and HApercent. You can do this now, or you can create them when you create the inputs for each custom script. vCO gives you the option to create a new general attribute with exactly the same name when you do this. This is my personal preferred way to do this, as it ensures your naming is consistent throughout your sub workflows.

2. Create the first scriptable task to calculate your HA % value.

var Hosts = System.getModule("com.vmware.library.vc.cluster").getAllHostSystemsOfCluster(cluster);
System.log("Number of Hosts in Cluster: " + Hosts.length);
var HApercent = ((1/Hosts.length)*100);
HApercent = HApercent.toFixed(0);
System.log("HA Percent which will be used for cluster is: " + HApercent);

Quick description of variables used:

Cluster – For this custom script object I pass the input “cluster” which is also passed as the input to the main workflow. This is of type VC:ClusterComputeResource

HApercent – This is an output variable of the custom script which maps back to the HApercent general attribute so it can be used later on in the main workflow

Basically all this script does is take the cluster, find out how many hosts there are, then use this number to calculate the percentage of host resources to reserve when configuring admission control.

3. Create the scriptable task to configure all the relevant settings on the cluster (This is the main piece)

//Check for HA Enabled
haEnabled = System.getModule("com.vmware.library.vc.cluster").haEnabledCluster(cluster);
if (haEnabled)
{
System.log(cluster.name + " is already HA enabled");
}
else
{
System.log("HA DISABLED - " + cluster.name + " will be enaled for HA");
}
//Check for DRS Enabled
drsEnabled = System.getModule("com.vmware.library.vc.cluster").drsEnabledCluster(cluster);
if (drsEnabled)
{
System.log(cluster.Name + " is already DRS enabled");
}
else
{
System.log("HA DISABLED - " + cluster.name + " will be enaled for HA");

}

System.log("Creating HA/DRS specifications");

var clusterConfigSpec = new VcClusterConfigSpecEx();
clusterConfigSpec.drsConfig = new VcClusterDrsConfigInfo();
clusterConfigSpec.dasConfig = new VcClusterDasConfigInfo();

//Enable DRS/HA
System.log("Setting HA and DRS to Enabled (even if they were already)");
clusterConfigSpec.dasConfig.enabled = true;
clusterConfigSpec.drsConfig.enabled = true;

//Set DRS to FullyAutomated
System.log("Setting DRS to Fully Automated");
clusterConfigSpec.drsConfig.defaultVmBehavior = drsBehaviour;

System.log("Updating HA Admission Control policy for " + cluster.name);
clusterConfigSpec.dasConfig.admissionControlPolicy = new VcClusterFailoverResourcesAdmissionControlPolicy();
clusterConfigSpec.dasConfig.admissionControlEnabled = true;
clusterConfigSpec.dasConfig.hostMonitoring = haHostMonitoring;
clusterConfigSpec.dasConfig.admissionControlPolicy.cpuFailoverResourcesPercent = HApercent;
clusterConfigSpec.dasConfig.admissionControlPolicy.memoryFailoverResourcesPercent = HApercent;

System.log("Executing Cluster Reconfiguration for " + cluster.name);

//Reconfigure the cluster, by adding the True parameter this ensures any previous settings remain
task = cluster.reconfigureComputeResource_Task(clusterConfigSpec, true);

The most important part is right at the bottom

task=cluster.reconfigureComputeResource_Task(clusterConfigSpec,true)

If you do not specify the true option, then it will not leave other settings you may have intact. An example might be a specific VM DRS rule you had configured. Essentially, without true, it wipes all settings to defaults and then changes only the settings specified above.

4. Now run this workflow against a cluster and check you get the desired result! Change a few settings, and run it again. Hopefully you should see everything configured to your liking again.

How do I get this to run against my entire environment?

Simple! Create another workflow which has all your clusters stored as general attributes. Then have this new workflow pass through all your clusters, calling the workflow you created above.

Schedule this in vCO to run every night and you can know comfortably that all your settings are as they should be.

If someone adds a new host to a cluster, there is no need to check the HA settings, they will be corrected that night.

If you need to say keep a cluster in partially automated mode for a while, then simply remove that cluster’s object from the general attribute. When you are ready to add it back, just click it back in.

This is just one way to keep your environment in check. My next post will be around VCAP topics, and then I will be writing another workflow on creating a Self Service Snapshot portal.

Finally, if anyone wants the actual workflow files for the above workflows, I am more than happy to get them uploaded for you.

Welcome to v(NIC)k…a virtualization blog about Automation, Orchestration and VMWare Certifications

Hello VMware Community and welcome to my first Virtualization Blog.

I will be primarily covering these 3 topics:

  • VCAP  – Study notes for the VCAP exam which I am studying for
  • vCenter Orchestrator Workflows including full Windows System Provisioning
  • Datacenter Automation with PowerCLI and vCenter Orchestrator – The goal is to create a self healing VMware Datacenter

Please feel free to comment on any of my topics and please let me know if you find any of my work useful.

Nick Colyer