Archive

Archive for the ‘Uncategorized’ Category

Enabling / Disabling SSH on an ESX host and limiting access to only my current IP

February 13th, 2015 No comments

Enabling / Disabling SSH on ESXi – and limiting access to current IP only.


function Set-SshOnVmHost
{
Param(
[String]
$VMHostName,
[ValidateSet('On','Off')]
[String]
$Status
)

write-host "Configuring SSH on host: $($vmHost.Name) to $Status" -fore Yellow
if((Get-VMHostService -VMHost $vmhostname | where {$_.Key -eq "TSM-SSH"}).Policy -ne "$Status"){
Write-Host "Setting SSH service policy to automatic $status $($vmHost.Name)"
Get-VMHostService -VMHost $vmhostname | where { $_.key -eq "TSM-SSH" } | Set-VMHostService -Policy "$Status" -Confirm:$false -ea 1 | Out-null
}

$vmhost = get-vmhost $vmhostname

$esxcli = Get-EsxCli -VMHost $vmhost
if($Status -eq 'On'){
if((Get-VMHostService -VMHost $vmhost | where {$_.Key -eq "TSM-SSH"}).Running -ne $true){
Write-Host "Starting SSH service on $($vmHost.Name)"
Start-VMHostService -confirm:$false  -HostService (Get-VMHost $vmHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"}) | Out-null
$ip = (Get-WmiObject -class win32_NetworkAdapterConfiguration -Filter 'ipenabled = "true"').ipaddress[0]
if($esxcli -ne $null){
if($ip.count -ne 1){
$ip = read-host "Please provide the IP address that should be to access this host via SSH"
}
try{
test-ipaddress $ip
if(($esxcli.network.firewall.ruleset.allowedip.list("sshServer") | select AllowedIPAddresses).AllowedIPAddresses -eq "All"){
Write-Host "Changing the sshServer firewall configuration"
$esxcli.network.firewall.ruleset.set($false, $true, "sshServer")
if(($esxcli.network.firewall.ruleset.allowedip.list("sshServer") | select AllowedIPAddresses).AllowedIPAddresses -notmatch "$ip"){
$esxcli.network.firewall.ruleset.allowedip.add("$ip", "sshServer")
}
$esxcli.network.firewall.refresh()
}
}
catch {
throw "Unable to configure IP restirctions on Firewall when enabling SSH $_"
}
}
}
}
else{
if((Get-VMHostService -VMHost $vmhost | where {$_.Key -eq "TSM-SSH"}).Running -ne $false){
Write-Host "Stopping SSH service on $($vmHost.Name)"
Stop-VMHostService -confirm:$false -HostService (Get-VMHost $vmHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"}) | Out-null
write-host "Set Firewall rule too allow all IPs for SSH, but disable the service"
if(($esxcli.network.firewall.ruleset.allowedip.list("sshServer") | select AllowedIPAddresses).AllowedIPAddresses -ne "All"){
Write-Host "Changing the sshServer firewall configuration"
$esxcli.network.firewall.ruleset.set($true, $true, "sshServer")
$esxcli.network.firewall.refresh()
}
}
}

# End Comment
if(($vmHost | Get-AdvancedSetting | Where {$_.Name -eq "UserVars.SuppressShellWarning"}).Value -ne "1"){
Write-Host "Suppress the SSH warning message"
$vmHost | Get-AdvancedSetting | Where {$_.Name -eq "UserVars.SuppressShellWarning"} | Set-AdvancedSetting -Value "1" -Confirm:$false | Out-null
}
}
Categories: Uncategorized Tags:

Getting up and ruinning with the vSphere SDk for c#

September 25th, 2013 No comments

Getting up and running with vSphere webservice APIs to code custom tools for VMware automation

if you are anything like me, this is something you have weanted to play with . . but every time you tried, you get stuck in the myriad of partisal information on the web. alwaysd specific to a particular version of Visual Studio, or copy of the Vmware SDKs.

This is how I got up and running:

From:
http://pubs.vmware.com/vsphere-55/index.jsp#com.vmware.wssdk.dsg.doc/sdk_c_sharp_development.5.3.html?path=7_0_0_0_2_1_0#1002780

To set up a development workstation to use C#

1 Install the Microsoft Visual programming environment, such as Microsoft Visual C# or Microsoft Visual Studio.
Use Microsoft Visual Studio 2008 or later, which includes the required .NET Framework.

2 Obtain the Microsoft .NET Framework, if it is not included in the Microsoft Visual programming environment.
Use .NET version 3.5 or later, according to your Visual Studio version.

3 Download and install the Microsoft .NET Framework 2.0 SDK (x64) from http://www.microsoft.com/en-us/download/details.aspx?id=15354
Note Virtual Studio includes a version of .NET version 2.0, but that version does not contain the tools needed to build the DLLs.

4 Find the location where the Microsoft .NET Framework 2.0 SDK (x64) files were installed. Verify that the installation directory contains a subdirectory named Bin, which contains a file named wsdl.exe. Typically, the Framework SDK is installed at C:\Program Files\Microsoft.NET\SDK\v2.0 64bit.
5 Edit your Windows registry to identify the location where the Microsoft .NET Framework 2.0 SDK (x64) was installed. Under the key HKLM\SOFTWARE\Microsoft\.NETFramework, verify that there is a string value named sdkinstallRootv2.0 with a string value of the full path name to the installation directory. If sdkinstallRootv2.0 is not present, add it.

6 Download and install Microsoft Web Services Enhancements (WSE) 3.0 from http://www.microsoft.com/en-us/download/details.aspx?id=14089.
Note The default option for the WSE installer includes only the runtime, not the WSDL tool. Select another option to include the Tools directory.

7 Download and unzip the VMware vSphere Web Services SDK package from the VMware Web site at http://www.vmware.com/download/sdk/. (actually – https://my.vmware.com/group/vmware/details?downloadGroup=WEBSDK550&productId=353)

Assuming default locations for Above installs, (again more info in above doc), launch your Visual studio command prompt (not a normal Dos / Powershell Shell, as these don’t have access to all the VS tools)

Create the WSE_HOME environment variable, setting its value to the absolute path to the directory where WSE was installed. For example:
set WSE_HOME=C:\Program Files (x86)\Microsoft WSE\v3.0
(Note the doc linked above has a spelling typo in the path – programe, not program)

Add the WSE tools directory to the PATH environment variable:
set PATH=%PATH%;%WSE_HOME%\Tools

Create the SDK_HOME environment variable, setting its value to the absolute path to the directory containing all the SDK files extracted from the zip file you downloaded. For example:
set WS_SDK_HOME=D:\vSphere5.5_SDK\SDK

Create the WSDLHOME environment variable, setting its value to the absolute path to the directory where the WSDL files were stored when you uncompressed the SDK download file. – Assuming you used the same folder as me to extract tghe SDK to (D:\vSphere5.5_SDK) you need to do the following:
set WSDLHOME=D:\vSphere5.5_SDK\SDK\vsphere-ws\wsdl\vim25

If your Microsoft development and .NET software has not been installed using default paths, create and set the VSINSTALLDIR environment variable

Now, I only wanted to manage vSphere and use the sample programs, however, it seems that the samples need a DLL created in the SSO step of this doc. so next step as follows:

### Building the vSphere DLLs
You have some automated samples available on the web here to create the DLLs:

Scripted (more or less what I’ll do below)
http://codechief.wordpress.com/2012/10/23/generating-vmware-web-service-proxies-for-net/#comments

Extraction from PowerCli (this is quick and easy)
http://codechief.wordpress.com/2013/04/24/extracting-vmware-web-service-proxies-for-net/

Navigate to the .NET subdirectory for SSO client samples.
cd %WS_SDK_HOME%\ssoclient\dotnet\cs\samples

Generate a test certificate and STSService stubs using the build.bat script.
.\build.bat

Copy the SSO DLL to the %SDK_HOME%\vsphere-ws\dotnet\cs\samples\DLLs directory.
copy lib\STSService.dll %WS_SDK_HOME%\vsphere-ws\dotnet\cs\samples\DLLs\.

# Now for the vSphere Dlls

Navigate to the .NET subdirectory for vSphere client samples.
cd D:\vSphere5.5_SDK\SDK\vsphere-ws\dotnet\cs\samples

Generate the VimService.cs file from the WSDL, using the following command syntax with the WSE WSDL tool:
wsewsdl3.exe /n:Vim25Api /type:webClient /l:CS "D:\vSphere5.5_SDK\SDK\vsphere-ws\wsdl\vim25\vim.wsdl" "D:\vSphere5.5_SDK\SDK\vsphere-ws\wsdl\vim25\vimService.wsdl"
This command generates VimService.cs, the default output file, in the current directory, using the Vim25Api namespace.

Compile VimService.cs into a library, using the following command syntax:
csc /t:library /out:Vim25Service.dll /r:"C:\Program Files (x86)\Microsoft WSE\v3.0\Microsoft.Web.Services3.dll" VimService.cs
This command generates a serializer assembly, a DLL.

Use the sgen tool to pre-generate and compile the XML serializers, using the following command syntax:
sgen /p Vim25Service.dll
This command outputs the Vim25Service.XmlSerializers.dll file in the current directory. This DLL file contains pre-generated XML serializer code.

Using a source code editor (notepad++ for me – Hit Ctrl H and do a search and replace), find occurrences of the following string in the VimService.cs file that you generated 3 steps ago (D:\vSphere5.5_SDK\SDK\vsphere-ws\dotnet\cs\samples\VimService.cs)
[System.Xml.Serialization.XmlIncludeAttribute
Replace occurrences of the string with:
// [System.Xml.Serialization.XmlIncludeAttribute
This will prevent .NET from processing the Xml.Serialization.XmlIncludeAttribute attributes that are the main cause of the slow instantiation of the Vim25Service class.

Annotate the VimService class in the VimService.cs file that you generated, adding this XmlSerializerAssemblyAttribute to point to the location of the XML serializer assembly:
[System.Xml.Serialization.XmlSerializerAssemblyAttribute(AssemblyName = “Vim25Service.XmlSerializers")]
The result should look something like the following example:
// ... Some code here ...
[System.Xml.Serialization.XmlSerializerAssemblyAttribute(AssemblyName = “Vim25Service.XmlSerializers")]
public partial class VimService : Microsoft.Web.Services3.WebServicesClientProtocol {
// ... More code here.

Save the modified VimService.cs file.

Regenerate the Vim25Service.dll library with the following command syntax:
csc /t:library /out:Vim25Service.dll /r:"C:\Program Files (x86)\Microsoft WSE\v3.0\Microsoft.Web.Services3.dll" VimService.cs

Copy the generated files Vim25Service.dll and Vim25Service.XmlSerializers.dll to the “D:\vSphere5.5_SDK\SDK\vsphere-ws\dotnet\cs\samples\DLLs” directory.
copy Vim25Service*.dll DLLs

### Generate the DLL for SSO:
In the Visual Studio command shell that you have open:

Navigate to the .NET subdirectory for SSO client samples.
cd "D:\vSphere5.5_SDK\SDK\ssoclient\dotnet\cs\samples"

# Building the samples:
Launch Visual Studio and load the solution file, Samples2008.sln.
The solution file is found in the D:\vSphere5.5_SDK\SDK\vsphere-ws\dotnet\cs\samples directory.
If you are using a version of Visual Studio later than 2008, the Visual Studio Conversion Wizard will prompt you to convert the 2008 solution file to the newer version. If you also have Visual Studio 2008, you should select Yes when the wizard offers to save a backup of the original solution file.

If you are using a version of Visual Studio later than 2008, convert each project to use .NET Framework 4.
The projects in the 2008 solution file are configured to use .NET Framework 3.5. To convert a project to use .NET Framework 4, right-click its name in the Solution Explorer and select Properties. In the Properties panel, change the Target Framework from .NET Framework 3.5 to .NET Framework 4.

From the Visual Studio menu, select Build > Build Solution.
All the sample programs build. The Output pane at the bottom of the Visual Studio window shows build errors, if any.

Correct any errors in the build, and repeat the build.

At this point, you should be able to import the solution contain all the projects from the sameples folder.

These are command line apps, but should allow you to get started,

Categories: Uncategorized Tags:

vSphere 5.5 new features and enhancements

August 29th, 2013 No comments

As usual, it is VMWorld in the US . . and I am not there.

but for my own notes (more than anyone else’s), I figured I’d run through the new features – and post them on here as a reference.

From: http://www.vmware.com/files/pdf/vsphere/VMware-vSphere-Platform-Whats-New.pdf

VMware vSphere® 5.5 introduces many new features and enhancements to further extend the core capabilities
of the vSphere platform. This paper will discuss features and capabilities of the vSphere platform,
including vSphere ESXi Hypervisor™, VMware vSphere High Availability (vSphere HA), virtual machines,
VMware vCenter Server™, storage networking and vSphere Big Data Extensions.

vSphere ESXi Hypervisor Enhancements
––Hot-Pluggable SSD PCI Express (PCIe) Devices –

This is a great addition (one of my favourites) – and should a great benefit in VDI type environments
––Support for Reliable Memory Technology –

Nice concept, using CPU to “grade” memory and commit important VMkernel and other critical component instructions. Essentially meansing that worst case, bad memory should affect VMs only and not bring the whole ESXI to its knees
––Enhancements for CPU C-States –

Effectively reduced means that CPUs are running at a lower frequency and voltage, meaning they are generally running more efficiently and cooler, potentially allowing for inherent increased performance, because turbo mode frequencies on Intel can be reached quicker on cool CPUs.
Virtual Machine Enhancements
––Virtual Machine Compatibility with VMware ESXi™ 5.5 –

new features such as LSI SAS support
for Oracle Solaris 11 OS, enablement for new CPU architectures, and a new advanced host controller interface
(AHCI).
––Expanded vGPU Support-

With vSphere 5.5, vGPU support has been expanded to include both Intel- and AMD-based GPUs hardware-accelerated 3D graphics—virtual
graphics processing unit (vGPU).

––Graphic Acceleration for Linux Guests –

With the new guest driver, modern Linux distributions are enabled to support technologies such as
the following:
• OpenGL 2.1
• DRM kernel mode setting
• Xrandr
• XRender

VMware vCenter Server Enhancements
––VMware® vCenter™ Single Sign-On

vCenter Single Sign-On
vCenter Single Sign-On server 5.5, the authentication services of the vSphere management platform, can now
be configured to connect to its Microsoft SQL Server database without requiring the customary user IDs and
passwords, as found in previous versions.

 

 
––VMware vSphere Web Client

The Web Client is becoming the defacto  method of accessing and managing your environment. Tied with SSO,it means you should be able to manage your envuironment from ANY machine on your network – and hopefully from any platform (tablets, PCs, phones?)

––VMware vCenter Server Appliance™

Appliance now uses a reengineered, embedded vPostgres database that can now support as many as 500
vSphere hosts or 5,000 virtual machines.

––vSphere App HA

This new feature works in conjunction with vSphere HA host monitoring and virtual machine
monitoring to further improve application uptime. vSphere App HA can be configured to restart an application
service when an issue is detected. It is possible to protect several commonly used, off-the-shelf applications.
vSphere HA can also reset the virtual machine if the application fails to restart.

––vSphere HA and VMware vSphere Distributed Resource Scheduler™ (vSphere DRS)

To address the need for maintaining placement of virtual machines on separate hosts—without
vSphere vMotion migration—after a host failure, vSphere HA in vSphere 5.5 has been enhanced to conform
with virtual machine–virtual machine antiaffinity rules. Application availability is maintained by controlling
the placement of virtual machines recovered by vSphere HA without migration. This capability is configured
as an advanced option in vSphere 5.5.

––vSphere Big Data Extensions

BDE performs the following functions on the virtual Hadoop clusters it manages:
• Creates, deletes, starts, stops and resizes clusters
• Controls resource usage of Hadoop clusters
• Specifies physical server topology information
• Manages the Hadoop distributions available to BDE users
• Automatically scales clusters based on available resources and in response to other workloads on the
vSphere cluster

 

• vSphere Storage Enhancements
––Support for 62TB VMDK

The previous limit
was 2TB—512 bytes. The new limit is 62TB.

––MSCS Updates

Historically, shared storage was supported in MSCS environments only if the protocol used was Fibre Channel
(FC). With the vSphere 5.5 release, this restriction has been relaxed to include support for FCoE and iSCSI. – FINALLY!!!

 
––16GB E2E support

In vSphere 5.5, VMware introduces 16Gb end-to-end FC support. Both the HBAs and array controllers can run at
16Gb as long as the FC switch between the initiator and target supports it.

––PDL AutoRemove

With vSphere 5.5, a new feature called PDL
AutoRemove is introduced. This feature automatically removes a device from a host when it enters a PDL state.

––vSphere Flash Read Cache

vSphere Flash Read Cache enables the pooling of multiple Flash-based devices into a single consumable
vSphere construct called vSphere Flash Resource, which is consumed and managed in the same way as CPU
and memory are done today in vSphere.
The vSphere Flash Read Cache infrastructure is responsible for integrating the vSphere hosts’ locally attached
Flash-based devices into the vSphere storage stack. This integration delivers a Flash management platform that
enables the pooling of Flash-based devices into a vSphere Flash Resource.

 

http://www.vmware.com/files/pdf/vsphere/VMware-vSphere-Platform-Whats-New.pdf

Categories: Uncategorized Tags:

Free TrainSignal access for vExperts

May 31st, 2013 No comments

Train Signal have very generously offered free access for 12 months to all vExperts!

http://www.trainsignal.com/blog/2013-vexperts-trainsignal

They offer training courses (over 1500 of them) and plenty video learning. The package is worth about $49 a month, so it is an extremely generous offer!

Thanks TrainSignal

 

Categories: Uncategorized Tags:

VMWorld Europe 2013

January 10th, 2013 No comments

Dates and locations have been announced.
It will be back in Barcelona – Fira Barcelona Gran Via – North Entrance, October 15-17

It is worth getting hotels and flights booked up early – they get quite expnsive at the last minute!

http://www.vmworld.com/community/conference/europe

Categories: Uncategorized Tags:

Flushing hidden devices after a P2V

October 16th, 2011 No comments

After a P2V, several hidden drivers etc are left latent on your VM.

to flush these, do the following:

Open a command prompt on the Windows VM (Start –> Run –> cmd).
set devmgr_show_nonpresent_devices=1
devmgmt.msc
In the device management console (View –> Show Hidden Devices).

Uninstall the devices that are no longer required. Such as old network devices.

Categories: Uncategorized Tags:

vExpert 2011 annouced

July 5th, 2011 No comments

Congratulations to all the new vExperts (and repeat old vExperts) – your hard work and commitment to the community is really appreciated by the many people out there that use your community posts / blog posts / books etc.

Congrats – you guys deserve the recognition.

Categories: Uncategorized Tags:

Updating vCenter from 4.0 to 4.1

May 24th, 2011 No comments

Stumbled across a really well written upgrade guide for the above process and decided to drop a post on here (to remind me where to find it)

 

I shant take any of the credit – rather just forward you straight on over there:

http://www.itbraindump.com/2011/05/23/update-vmware-esx-and-vcenter-from-4-0-to-4-1/

Categories: Uncategorized Tags:

Resolving connection / initialization problems with VCOPs

April 15th, 2011 No comments

The appliance seems to be very particular about DNS in the environment where it runs. Anything short of perfection may cause one or both of the problems below.

Problem 1: You install the appliance, but can’t connect to it. The browser returns “connection reset” or “unreachable” (depends on the browser). If you used another client system, and it worked, and you connected the appliance to your VCenter, the original system’s VCenter Client still shows that the plugin is disabled due to connection error. Network dump shows that the TCP handshake succeeds, but the appliance resets the connection after the first HTTPS packet.

Cause: The appliance is configured using default SUSE security settings, which include “ALL : KNOWN” line in /etc/hosts.allow. This line dictates that the client IP must be reverse resolvable to a name and then back from the name to the same IP. If your environment doesn’t have reverse DNS that matches exactly with direct DNS, the check may fail, and the server will close the connection.

Resolution: Use the console to connect to the command line (login as “root” / “admin”), and change the above line to “ALL : ALL”. You need to know how to use vi.

Problem 2: You have connected to the appliance, the plug-in works, but the appliance screen is stuck on initialization.

Cause: The appliance can’t resolve its own name.

Resolution: If you use DHCP for the appliance: use the admin web page to disconnect the appliance from VCenter, give the appliance a static IP, create an A record for it in your DNS system, reboot, reconnect to VCenter. If you gave the appliance a static IP: make sure the hostname you specified is resolvable to the same IP.

source : http://communities.vmware.com/message/1736069#1736069
Written by : http://communities.vmware.com/people/ynguldyn

Categories: Uncategorized Tags:

How to Install Microsoft SQL Server 2008 for VMware vCenter 4

April 14th, 2011 No comments

I don’t often duplicate work, but have stumbled across what is almost definitely the best setup guide I have seen for configuring a Virtual Center with a SQL 2008 Database – I have used this and referenced it to others several times, so figured I’d share it.

Bob Planker’s at the Lone SysAdmin says:

How to Install Microsoft SQL Server 2008 for VMware vCenter 4

I’ve had cause recently to do several new VMware vCenter installations, and I thought I’d take the opportunity to update our documentation on setting up Microsoft SQL Server 2008. Since new VMware vSphere users often find themselves unwittingly becoming DBAs I thought it might help others if I posted it.

<--more-->

Categories: Uncategorized Tags: