Blog

Automate vSphere Tags on multiple VMs with VMware PowerCLI!!

Hi All,

I want to introduce Aman Sapra VMware TAM as a Guest blogger for this post. Aman has helped us to automate creation of Categories and tags for multiple virtual machines for one of the customers.

The ask was to associate VMs with multiple tags and later call the same tags in vROPs to create custom groups.

The script worked like a charm and we were able to meet all the customer requirements.

I want to use my blog as a platform to share this script created by Aman.

Thanks Aman. Appreciate your efforts in helping us with this powerful script.

—————————————————————————————————————————————-

Connect-viserver vCenterServerName -user username -pass password

Write-Host “`n”

#Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false

#//Import the CMDB CSV file//

$CMDBInfo = Import-CSV “filepath\cmdb.csv”

#//Get list of VMs from the file//

$listVMs= $CMDBInfo.Name

# //Get the header names to use as Tag Category Names//

$TagCatNames = $cmdbinfo | Get-Member | Where {$_.MemberType -eq “NoteProperty”} | Select -Expand Name

$Categories = $TagCatNames | Where {$_ -ne “Name”}

#//Fetch list of Tag Categories which already exist in vCenter//

$vCenterTagCats= Get-TagCategory

Write-Host “////////////////////////////////////////////////////////////////////////////////////////////////////” -ForegroundColor White

Write-Host “Tag Category Creation Section:” -ForegroundColor Cyan

Write-Host “////////////////////////////////////////////////////////////////////////////////////////////////////`n” -ForegroundColor White

#//Create Tag Category if it does not exist//

foreach ($Categorie in $Categories)

{

foreach ($vCenterTagCat in $vCenterTagCats)

{

if ($vCenterTagCat.Name -eq $Categorie)

{

$printTagCat= 1

}

}

if($printTagCat -eq “1”)

{

#//Tag Category with the specified name already exists in vCenter//

Write-Host “Tag category with name $Categorie already exists`n” -ForegroundColor Red

}

else

{

#//Creating a new Tag Category in vCenter//

Write-Host “Creating Tag Catergory $Categorie `n” -ForegroundColor Green

New-TagCategory -Name $Categorie -Description “$Categorie from CMDB” | Out-Null

}

$printTagCat=””

}

Write-Host “////////////////////////////////////////////////////////////////////////////////////////////////////” -ForegroundColor White

Write-Host “Tag Creation Section:” -ForegroundColor Cyan

Write-Host “////////////////////////////////////////////////////////////////////////////////////////////////////`n” -ForegroundColor White

#//Create Tag if it does not exist//

foreach ($Categorie in $Categories)

{

$vCenterTags= Get-Tag -Category $Categorie | Select Name

 

#//Get the list of Unique Tags from the $CMDBInfo Variable//

$listCMDBTags = $CMDBInfo.$Categorie | Get-Unique

foreach ($listCMDBTag in $listCMDBTags)

{

foreach ($vCenterTag in $vCenterTags)

{

if($listCMDBTag -eq $vCenterTag.Name)

{

$printTag=1

}

}

if($printTag -eq “1”)

{

#//A Tag with the specified name already exists in vCenter//

Write-Host “Tag with name $listCMDBTag already exists`n” -ForegroundColor Red

}

else

{

#//Creating a New Tag in vCenter//

 

Write-Host “Creating New Tag $listCMDBTag of Category $Categorie`n” -ForegroundColor Green

New-Tag -Name $listCMDBTag -Category $Categorie -Description “$listCMDBTag from CMDB” | Out-Null

}

$printTag=””

}

}

Write-Host “////////////////////////////////////////////////////////////////////////////////////////////////////” -ForegroundColor White

Write-Host “Tag Assignment Section:” -ForegroundColor Cyan

Write-Host “////////////////////////////////////////////////////////////////////////////////////////////////////`n” -ForegroundColor White

#//Assigning Tag to VM if the Tag of same category is not already assigned//

foreach ($listVM in $listVMs)

{

#//Fetch the list of Tag values for each VM in the CSV file//

$linevalue = $CMDBInfo | where{$_.Name -eq $listVM}

foreach ($Categorie in $Categories)

{

#//Fetch Tag Value for each Category//

$TagValue = $linevalue.$Categorie

$ExistingVMTags = (Get-VM $listVM | Get-TagAssignment).Tag

foreach ($ExistingVMTag in $ExistingVMTags)

{

#//Check if VM already has a Tag of the specified Category Assigned to it//

if ($Categorie -eq $ExistingVMTag.Category.Name)

{

$setvalue=1

Write-Host “VM $listVM already has a Tag of Category $Categorie assigned`n” -ForegroundColor Red

}

}

#//If VM does not have the Tag of specified Category, Assign the Tag to the VM//

if($setvalue -ne “1”)

{

Write-Host “Assigning Tag $TagValue of Category $Categorie to VM $listVM`n” -ForegroundColor Green

$TagAssignment = Get-Tag -Category $Categorie -Name $TagValue

New-TagAssignment -entity $listVM -Tag $Tagassignment | Out-Null

}

$setvalue=””

}

}

Disconnect-VIServer -Confirm:$false

—————————————————————————————————————————————-

Thanks again!

Hope this helps!

Upgrade vRealize Operations Manager from 6.6.1 to 7.5

Hello,

We recently upgraded vRealize Operations Manager at one of my customers environment from 6.6.1 to 7.5.

There has been a 6.7 and 7.0 version released before but since allocation model was discontinued in both the versions we decided to hold on to the upgrade until allocation model is back.

The customer was using a lot of allocation based metrics to perform capacity planning in advance and just using the utilization metrics was not viable.

Once the 7.5 version was out and the allocation model was brought in after hearing feedback from lot of customers we decided to upgrade our vROPs version.

Before you start, it is important to perform an interoperability check of vROPs 7.5 version with all the other solutions integrated with vROPs.

It is very important to run the pre-assessment upgrade pak to know the dashboards, reports, MPs, metrics and super metrics which will be impacted and what are the alternate metrics available if there are any.

In our case listed below metrics were impacted and we managed to find out some alternate metrics against it to minimize the impact.

I was working with vROPs Engineering team to work on this and find out a metric which does not have a replacement metric available.

You may also have to create a super metric where there is no replacement metric against it.

Metric Name Metric Key Replacement Metric Name Replacement Metric Key
CPU|Allocation|Computed Demand cpu|alloc|base.demand vCPUs Allocated on all Powered On VMs N/A
Memory|Total Capacity mem|actual.capacity.normalized Memory|Total Capacity mem|guest_provisioned
Memory|Total Capacity mem|actual.capacity.normalized Memory|Total Capacity mem|guest_provisioned
Summary|Number of Datastores summary|number_datastore Disabled, Can be enabled N/A
CPU|Demand|Provisioned cpu|demand|consumer.capacity.background CPU|vCPUS Allocated on all Powered On VMs N/A
Memory|Demand Reclaimable|Provisioned mem|demand-waste|consumer.capacity.background Memory|Memory Allocated on All VMs mem|memory_allocated_on_all_vms
CPU|Idle time cpu|idletimepercent Use Reclaimable Idle N/A
Datastore I/O|Reads per second|Idle time datastore|number_read|idletimepercent N/A
Datastore I/O|Writes per second|Idle time datastore|number_write|idletimepercent N/A
Network IO|Data Receive Rate|Idle time net|received|idletimepercent N/A
Network IO|Data Transmit Rate|Idle time net|transmitted|idletimepercent N/A
Memory|Total Capacity mem|actual.capacity.normalized Memory|Total Capacity mem|guest_provisioned
Summary|Number of Datastores summary|number_datastore Disabled, Can be enabled N/A
Summary|Number of Networks summary|number_network Summary|Configuration|No of NICs summary|config|numEthernetCards
CPU|Allocation|Total Capacity cpu|alloc|actual.capacity.normalized Number of physical Cores (CPUs)
CPU|Allocation|Usable Capacity cpu|alloc|object.capacity CPU|Allocation|UsableCapacity This is the number of vCPUs multipled by overcommit ratio setting defined in policy, and MINUS vsphere HA
CPU|Demand|Provisioned cpu|demand|consumer.capacity.background CPU|vCPUS Allocated on all Powered On VMs
Memory|Allocation|Total Capacity mem|alloc|actual.capacity.normalized Memory|Total Capacity (KB) mem|host_provisioned
Memory|Allocation|Computed Demand mem|alloc|base.demand Memory Allocated on all Powered On VMs (KB)
Memory|Allocation|Usable Capacity mem|alloc|object.capacity Memory|Allocation|Usable Capacity

Once you have this sorted the next step is to download the OS and the VA upgrade pak file from here

https://my.vmware.com/web/vmware/details?downloadGroup=VROPS-750&productId=875&rPId=32115

vRealize Operations Manager – Virtual Appliance Operating System upgrade
File size: 2.31 GB
File type: pak

vRealize Operations Manager – Virtual Appliance upgrade
File size: 1.82 GB
File type: pak

The first step is to peform a OS upgrade and then the VA upgrade.

Before you initiate the upgrade ensure you have necessary backup available to return to the original state in case it is required.

Logon to the management interface of vROps using https://<vrops>/admin URL:

Screenshot 2019-09-03 at 10.53.39 AM

 

The next step is to take the cluster offline.

Screenshot 2019-09-03 at 11.07.01 AM

Select Software update, Install a software update and first upload the OS update PAK file.

Screenshot 2019-09-03 at 11.11.54 AM

 

Screenshot 2019-09-03 at 11.14.27 AM

Upload the OS update PAK file.The upload will begin staging and then let the upload 100% complete.

Screenshot 2019-09-03 at 11.15.26 AM

Select I accept the terms of the agreement

Screenshot 2019-09-03 at 11.16.52 AM

Read the update and release information before you click on Next

Screenshot 2019-09-03 at 11.19.23 AM

To start the update click Next

Screenshot 2019-09-03 at 11.20.57 AM

The installation of the OS upgrade is now in progress.

Screenshot 2019-09-03 at 11.22.29 AM

The upgrade for vRealize Operations Manager Enterprise OS update is now complete. You can now see the new version 7.5.0 build number 13165947

Screenshot 2019-09-03 at 11.24.25 AM

 

Now the next step is to follow the same process for the vROPs 7.5 application PAK file.

Click on Install Software Update and then upload the vRealize Operations Manager – Virtual Appliance upgrade PAK file.

Let the PAK file 100% upload.

Beginning-the-upload-of-the-vRealize-Operations-Manager-7.5-application-upgrade-PAK-file Upgrade to VMware vRealize Operations Manager 7.5

Once the PAK file is 100% uploaded, validate it and then click Next.

Accept the terms and conditions and click Next.

Accept-the-EULA-for-the-vROPs-7.5-application-PAK-file-upgrade Upgrade to VMware vRealize Operations Manager 7.5

Review the update and release information and click Next.

Update-recommendations-before-running-the-vRealize-Operations-Manager-7.5-application-PAK-update-file Upgrade to VMware vRealize Operations Manager 7.5

Now click Install to start the update.

Ready-to-install-the-vRealize-Operations-Manager-7.5-appication-PAK-update Upgrade to VMware vRealize Operations Manager 7.5

The application upgrade is now in progress and the vRealize Operations Manager admin UI becomes unavailable for a small moment.

Once the UI is back login to the admin portal again and check the current progress and monitor the upgrade to complete successfully.

 

Logging-back-into-the-vRealize-Operations-Manager-Admin-interface Upgrade to VMware vRealize Operations Manager 7.5

 

Once the upgrade is completed successfully login to vROPs main UI and validate the current installed version.

Post the validation is successful do remember to delete the snapshots from all the nodes that you would have taken before initiating the upgrade.

Hope this helps!

 

 

From VMworld: Introducing Project Pacific!

From VMworld: Introducing Project Pacific!

Today VMware announced Project Pacific, what I believe to be the biggest evolution of vSphere in easily the last decade. Simply put, we are rearchitecting vSphere to deeply integrate and embed Kubernetes. Project Pacific evolves vSphere to be a native Kubernetes platform. What’s driving this shift? Fundamentally it goes to what constitutes a modern application. The post Introducing Project Pacific appeared first on VMware vSphere Blog.


VMware Social Media Advocacy

The vMotion Process Under the Hood

The vMotion Process Under the Hood

The vMotion Process Under the Hood

The VMware vSphere vMotion feature is one of the most important capabilities in today’s virtual infrastructures. Since its inception in 2002 and the release in 2003, it allows us to migrate the active state of a virtual machines from one physical ESXi host to another. Today, the ability to seamlessly migrate virtual machines is an integral The post The vMotion Process Under the Hood appeared first on VMware vSphere Blog.


VMware Social Media Advocacy

VMware to Acquire Bitnami

VMware announces intent to acquire Bitnami, a leader in application packaging for multi-cloud environments. Find out how #Bitnami will help #VMware accelerate our #multi-cloud and #Kubernetes offerings and efforts!

VMware to Acquire Bitnami

Organizations today are on a multi-cloud journey, and VMware is committed to investing in solutions that address the core needs of our customers. In that spirit, VMware is announcing its intent to acquire Bitnami, a leader in application packaging solutions providing the largest catalog of click-to-deploy applications and development stacks for major cloud and Kubernetes The post VMware to Acquire Bitnami appeared first on VMware Cloud Community.


VMware Social Media Advocacy