Friday, July 28, 2017

Get the right version of vcenter and other management tools for your esxi/vsphere

Many a times i have seen few of my colleagues trying to download the new vsphere client to manage the newer version of esxi that we are shipping with our dell emc ci/hci. They google it, log into vmware, search again, match the build number and download or sometimes just use a usb pen drive to share such files. If you are in your own environment or even home lab then it is better for your own product to guide you to download the other products which are to be used with it or can be used with it.
just click on advanced and add certification.
 Once you do this,  you will be presented with the following
click on the download vsphere client for windows to install the one which for sure will work with your esxi. It won't take you to VMware site but you will get the file itself. the link below that will launch the vsphere client. Rest of the links to other products will take you to their site and they all are self explanatory.




Thursday, July 27, 2017

Changing the vmkernel/management ip address (and subnet mask too if you want) using powercli


powercli just rox. we at dell emc today had an issue where we had
3 UCS domains and client wanted all the 110+ blades to be distributed across these 3 domains. IP addresses were not in range. We use a custom linux virtual machine which install esxi on UCS with proper vmkernel networking. However that is not designed for such scenarios. So the ip addresses how this esxi deployer assigned was not at all matching what the customer wanted. We thought by the time our storage guys assign boot luns then i could figure out a script to change the ip addresses of all these 110+ blades. I even took my buddy gowtham's data center without asking him and played around with it. It worked for the 8 blades that we had. I used plink to deliver the esxcli command as mentioned by duncan epping . Needless to say what worked on a small solution didnt work on this one for some reason. I was using a csv file to input the
old ip
new ip
username
password
vmkernel (it was vmk0)
but it failed and we as a team shared all 15 blades per head and changed the ip addresses manually. We did not have much time to play. I just reached home and so far i have this.
connect to the esxi host first

PS C:\WINDOWS\system32> Connect-VIServer 192.168.248.136 -User root -Password 'vmware1'
WARNING: There were one or more problems with the server certificate for the server 192.168.248.136:443:

* The X509 chain could not be built up to the root certificate.

* The certificate's CN name does not match the passed value.

Certificate: [Subject]
  OID.1.2.840.113549.1.9.2="1477497341,564d7761726520496e632e", CN=localhost.localdomain, E=ssl-certificates@vm
ware.com, OU=VMware ESX Server Default Certificate, O="VMware, Inc", L=Palo Alto, S=California, C=US

[Issuer]
  O=VMware Installer

[Serial Number]
  00A4602D4BBDF6

[Not Before]
  26-10-2016 9.25.42 PM

[Not After]
  26-04-2028 9.25.42 PM

[Thumbprint]
  360BDA508071AF7832778CA9C038195A14468A4F



The server certificate is not valid.
   
WARNING: THE DEFAULT BEHAVIOR UPON INVALID SERVER CERTIFICATE WILL CHANGE IN A FUTURE RELEASE. To ensure script
s are not affected by the change, use Set-PowerCLIConfiguration to set a value for the InvalidCertificateAction
 option.
      

Name                           Port  User                         
----                           ----  ----                         
192.168.248.136                443   root

Let us see to whom we are connected with
------------------
PS C:\WINDOWS\system32> Get-VMHost
 
Name                 ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz   MemoryUsageGB   MemoryTotalGB
----                 --------------- ---------- ------ ----------- -----------   -------------   -------------
192.168.248.136      Connected       PoweredOn       4          69       16000           1.418          11.718 
 
Now we should find out who this is
 
 PS C:\WINDOWS\system32> (Get-VMHost).NetworkInfo
 
HostName     DomainName   DnsFro ConsoleGateway  ConsoleGatewayD DnsAddress          
                          mDhcp                  evice                               
--------     ----------   ------ --------------  --------------- ----------          
host1        ambi.com     False                                  {192.168.248.136} 
 
 
Now change the ip address  
 
 
 PS C:\WINDOWS\system32> (Get-VMHost | Get-EsxCli).network.ip.interface.ipv4.set('vmk0','192.168.248.135', '255.255.255.0', $null, 'static')
true 
 
That true is really encouraging. I connected to the new changed ip address now.
  
 PS C:\WINDOWS\system32> Connect-VIServer 192.168.248.135 -User root -Password 'vmware1'
 
Name                           Port  User                          
----                           ----  ----                          
192.168.248.135                443   root 
 

I checked the name of this new ip.
 
 
PS C:\WINDOWS\system32> (Get-VMHost).NetworkInfo
 
HostName     DomainName   DnsFro ConsoleGateway  ConsoleGatewayD DnsAddress          
                          mDhcp                  evice                               
--------     ----------   ------ --------------  --------------- ----------          
host1        ambi.com     False                                  {192.168.248.136}   
 
 
 
PS C:\WINDOWS\system32>
------------------

Yes, you can change any vmkernel ip address like this but i am trying to figure out an esxcli -v2 version of it. Nay sayers listen to this. If you do not know how to do it then it doesn't mean it can't be done.
Now here is the esxcli -v2 version.


PS C:\WINDOWS\system32> $esxcli = Get-VMHost | Get-EsxCli -v2
$esxcliset = $esxcli.network.ip.interface.ipv4.set
$args = $esxcliset.CreateArgs()
$args.interfacename = 'vmk0'
$args.type = 'static'
$args.ipv4 = '192.168.248.136'
$args.netmask = '255.255.255.0'
$esxcliset.Invoke($args)



true

PS C:\WINDOWS\system32> disconnect-viserver * -confirm:$false
Connect-VIServer 192.168.248.136 -User root -Password 'vmware1'

WARNING: There were one or more problems with the server certificate for the server 192.168.248.136:443:

* The X509 chain could not be built up to the root certificate.

* The certificate's CN name does not match the passed value.

Certificate: [Subject]
  OID.1.2.840.113549.1.9.2="1477497341,564d7761726520496e632e", CN=localhost.localdomain, E=ssl-certificates@vmware.com, OU=VMware ESX Server Defaul
t Certificate, O="VMware, Inc", L=Palo Alto, S=California, C=US

[Issuer]
  O=VMware Installer

[Serial Number]
  00A4602D4BBDF6

[Not Before]
  26-10-2016 9.25.42 PM

[Not After]
  26-04-2028 9.25.42 PM

[Thumbprint]
  360BDA508071AF7832778CA9C038195A14468A4F



The server certificate is not valid.
    
WARNING: THE DEFAULT BEHAVIOR UPON INVALID SERVER CERTIFICATE WILL CHANGE IN A FUTURE RELEASE. To ensure scripts are not affected by the change, use
 Set-PowerCLIConfiguration to set a value for the InvalidCertificateAction option.
       

Name                           Port  User                          
----                           ----  ----                          
192.168.248.136                443   root                          



PS C:\WINDOWS\system32> $esxcli = Get-VMHost | Get-EsxCli -v2
$esxcliset = $esxcli.network.ip.interface.ipv4.set
$args = $esxcliset.CreateArgs()
$args.interfacename = 'vmk0'
$args.type = 'static'
$args.ipv4 = '192.168.248.135'
$args.netmask = '255.255.255.0'
$esxcliset.Invoke($args)



true

PS C:\WINDOWS\system32> disconnect-viserver * -confirm:$false
Connect-VIServer 192.168.248.135 -User root -Password 'vmware1'


Name                           Port  User                          
----                           ----  ----                          
192.168.248.135                443   root                          



PS C:\WINDOWS\system32> 
good night.

Wednesday, June 21, 2017

setting up your road to data science via python, numpy, scipy

so if you want to do start your journey to data science or just explore what all the fuss about and then get terrorized by math (math always hated me, even though i loved it, it was just one way love, sigh....no one loves me back if i love them..lol) and back off.
So scipy, numpy, panda and many other packages depend heavily on C, cython, fortran and that is why they are so fast too. so before you just install these packages via pip you might want to set the stage right.
install python 3.6.1 (in my case)
https://www.python.org/downloads/
install pip
https://packaging.python.org/tutorials/installing-packages/#id14
install wheel
pip install wheel (optional but you better do it)
then install specific wheels for numpy and scipy
download the relevant wheels from http://www.lfd.uci.edu/~gohlke/pythonlibs/
install as below
pip install numpy-1.13.0+mkl-cp36-cp36m-win32
pip install scipy-0.19.1-cp36-cp36m-win32
 
Now go to your favorite python IDE or console and run
import scipy, numpy and they both should not throw error.
Remember that if you just import numpy or scipy it might work but if you import both it might not. If you have followed this it should not be a problem to you.

Wednesday, May 31, 2017

Powershell : Auto Intialize, Add, Format disks at log in

There are many scenarios where you have mass deployed VMs or present disks to users in a cloud environment where it is necessary for users to initialize, add, format the drives but it won't be wise to ask all users to do this. nobody wants to. Hence this.


Get-Disk | Where partitionstyle -eq ‘raw’ | Initialize-Disk -PartitionStyle MBR -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "$env:UserName" -Confirm:$false

  1. Create your .ps1 script and place it in a folder.  The path would look something like this:
C:\script.ps1
  1. Create a .cmd file and place it in
C:\Users\<user_name>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\startup.cmd
 In this startup.cmd file
PowerShell -Command "Set-ExecutionPolicy Unrestricted" >> "%TEMP%\StartupLog.txt" 2>&1 
PowerShell C:\script.ps1 >> "%TEMP%\StartupLog.txt" 2>&1

Thursday, April 13, 2017

Dealing with snapshots on Enterprise Hybrid Cloud; selectively remove/create snapshots

So I had a situation with one of my colleague dayakar today where he was implementing an EMC EHC and we had some trouble with our standard EHC script. we had to take snapshots. We had to first remove all the snapshots on these VMs.

get-vm | Get-Snapshot | Remove-Snapshot -RunAsync -Confirm:$false

 Now we needed to create snapshots only on those VMs with certain domain name.


$cluster = "" #cluster name(put * to include all clusters)
$domainname = "" #name domain of the vms
$snapshotName = "" #name of the snapshot
get-cluster $cluster | get-vm | where name -Match $domainname | New-Snapshot -RunAsync -Name $snapshotName -Confirm:$false
 

Now we needed to get the snapshots under vapps.


$cluster = "" #cluster name(put * to include all clusters)
$vapp = "" #name of the vapp
$snapshotName = "" #name of the snapshot
get-cluster $cluster | get-vapp -Name $vapp | get-vm | New-Snapshot -RunAsync -Name $snapshotName -Confirm:$false
 In case if you are wondering what is EHC, EHC is Enterprise Hybrid Cloud which is a cloud offering build with the following
compute : Cisco
Network : Cisco
Storage : EMC
Hypervisor: VMware vSphere
Cloud/Automation/Managment layer: vRealize Automation.
If you are in the market for a top of the notch cloud platform then have a look at it. We build it and it is awesome.