bigbluemike

All about VMware

vCO – Configure vMotion with Virtual Distributed Virtual Switch

leave a comment »

Here is some code how to configure the vMotion address with a distributed virtual switch. Input parameter are my host and dvSwitch. I go through all portgroups and compare if it is called vmotion. If so I set IP and subnet. Hard coded so it is easier to understand, you probably want this also as input parameter or use some algorithm. For instance user last octet from MGT IP to have same last octet.

//myhost is input parameter of type VcHostSystem
//dvSwitch is input parameter of type...
 
var networkSystem = myhost.configManager.networkSystem;
var vMotionSystem = myhost.configManager.vmotionSystem;
var pgs = dvSwitch.portgroup;

for each (var pg in pgs)
{
	if (pg.name.toLowerCase() == "vmotion")
	{
		System.log("vMotion PG name: " + pg.name);
		var nic = new VcHostVirtualNicSpec();
		nic.ip = new VcHostIpConfig();
		nic.ip.dhcp = false;
		nic.ip.ipAddress = "192.168.1.10"; 
		nic.ip.subnetMask = "255.255.255.0";
		nic.distributedVirtualPort = new VcDistributedVirtualSwitchPortConnection();
		nic.distributedVirtualPort.switchUuid = dvSwitch.uuid;
		nic.distributedVirtualPort.portgroupKey = pg.key;

		networkSystem.addVirtualNic("", nic);  // HostNetworkSystem
		vMotionSystem.selectVnic("vmk1");  //enable vMotion
	}
	
}

Written by bigbluemike

July 27, 2012 at 3:59 pm

vCO – Configure ESXi Syslog Server and more

leave a comment »

In this example I configure some advanced setting on an ESXi host. Syslog server is just one of the.
First I create a for loop to create my hostSetting array objects. Then late I fill them. Always the key and a value. You can check the ESXi host advanced setting in GUI for parameters. You need to watch the type. For instance the port for the syslog server is of type value_IntValue. There are also float and long. I have to say I don’t know why it say deprecated for value. Maybe I have to come back on that.

http://www.vmware.com/support/orchestrator/doc/vco_vsphere41_api/index.html

//myhost is input parameter of type VcHostSystem
var hostSetting = new Array();

for (i=0; i<=3; i++)
{
	hostSetting[i] = new VcOptionValue();
}
hostSetting[0].key = "Syslog.Remote.Hostname";
hostSetting[0].value = "mysyslog.bigbluemike.com";

hostSetting[1].key = "Syslog.Remote.Port";
hostSetting[1].value_IntValue = 514;

hostSetting[2].key = "Config.Defaults.security.host.ruissl";
hostSetting[2].value = true;

hostSetting[3].key = "Annotations.WelcomeMessage";
hostSetting[3].value = "Welcome to this nice an shiny ESXi host.";

host.configManager.advancedOption.updateOptions(hostSetting);

Written by bigbluemike

July 27, 2012 at 3:58 pm

Posted in VMware vCenter Orchestrator - vCO

Tagged with , ,

vCO – Configure NTP on ESX

leave a comment »

In this example I set the NTP Server and then check if the NTP Service is running. If not I start it.

//myhost is input parameter of type VcHostSystem
//ntpServer is input parameter of type String[] (string array)

var hostDateTimeConfig = new VcHostDateTimeConfig();
hostDateTimeConfig.ntpConfig = new VcHostNtpConfig();
hostDateTimeConfig.ntpConfig.server = ntpServer;

//Set the ntp servers
myhost.configManager.dateTimeSystem.updateDateTimeConfig(hostDateTimeConfig);

//Check if the service is already running
var hostServiceInfo = myhost.configManager.serviceSystem.serviceInfo;
for each (var hostService in hostServiceInfo.service)
{
if (hostService.label == “NTP Daemon”)
{
//if the service is not running start it
if (hostService.running == false)
{
System.log(“Starting service ” + hostService.label + ” now”);
var ntpID = myhost.configManager.dateTimeSystem.id;
host.configManager.serviceSystem.startService(“ntpd”);
}
else
{
System.log(“Service ” + hostService.label + ” is already running”);
}
}
}

Written by bigbluemike

July 27, 2012 at 3:42 pm

Posted in VMware vCenter Orchestrator - vCO

Tagged with , ,

vCO – Remove default portgroup

leave a comment »

This is another simple one. In my eyes useful if you want to use vCO to configure your ESX.
I go through all port groups on the host and compare if one is name “VM Network” if this is so then I remove it.

//myhost is input parameter of type VcHostSystem

var netSystem = myhost.configManager.networkSystem;
var pgs = myhost.configManager.networkSystem.networkConfig.portgroup
for each (var pg in pgs)
{
	if (pg.spec.name == "VM Network")
	{
		netSystem.removePortGroup(pg.spec.name);
	}
}

Written by bigbluemike

July 27, 2012 at 3:30 pm

vCO – Enable vMotion

leave a comment »

Well it took me a while to figure this one out but once you know, it is really simple. Isn’t it?

//myhost is the input parameter of type VcHostSystem
//Enable vMotion on vmk1

var vMotionSystem = myhost.configManager.vmotionSystem;
vMotionSystem.selectVnic("vmk1");

Written by bigbluemike

July 27, 2012 at 3:08 pm

vCO – Many new workflows in Release 4.2.1

leave a comment »

If you are using and older version of vCO you probably have not noticed that VMware has put a lot of work into new workflows. In my eyes VMware has learned their lesson. In vSphere 4 and vSphere 4.1 VMware had not released any workflows for their premium functions like Distributed Virtual Switches and Host Profiles, not even vmxnet3 virtual network adapters were included. They were not lacking behind they were basically ignoring it. Which seems silly since vCO is more addressing enterprise customers that would more likely use those enterprise plus versions. Now in vCO release 4.2.1 which comes with vCenter 5.0.1 they have included the new featured like storage drs but also caught up on the features that were new to vSphere 4.

All workflows are documented in the document from VMware Using “VMware vCenter Orchestrator Plug-Ins vCenter Orchestrator 4.2.1″

http://pubs.vmware.com/vsphere-50/topic/com.vmware.ICbase/PDF/vcenter-orchestrator-421-using-plugins-guide.pdf

Using the vCenter Server 5.0.1 Plug-In – vCenter Server Plug-In Workflow Library Page 17.

Here is the list of workflows so you get an idea what vCenter Orchestrator is capable of doing out of the box. For more detail also on other libraries I recommend read the VMware document.

Cluster and Compute Resource Workflows

  • Add DRS virtual machine
  • Add virtual machines to DRS group
  • Create cluster
  • Delete cluster
  • Disable DRS on cluster
  • Disable HA on cluster
  • Enable DRS on cluster
  • Enable HA on cluster
  • Remove virtual machine DRS group from cluster
  • Remove virtual machines from DRS group
  • Rename cluster

Custom Attributes Workflows

  • Add custom attribute to a virtual machine
  • Add custom attribute to multiple virtual machines
  • Get custom attribute

Datacenter Workflows

  • Create datacenter
  • Delete datacenter
  • Reload datacenter
  • Rename datacenter
  • Rescan datacenter HBAs

Datastore and Files Workflows

  • Delete all files
  • Delete all unused datastore files
  • Export unused datastore files
  • Find unused files in datastores
  • Get all configuration, template, and disk files from virtual machines
  • Log all datastore files
  • Log unused datastore files

Datacenter Folder Management Workflows

  • Create datacenter folder
  • Delete datacenter folder
  • Rename datacenter folder

Host Folder Management Workflows

  • Create host folder
  • Delete host folder
  • Rename host folder

Virtual Machine Folder Management Workflows

  • Create virtual machine folder
  • Delete virtual machine folder
  • Rename virtual machine folder

Basic Host Management Workflows

  • Enter maintenance mode
  • Exit maintenance mode
  • Move host into cluster
  • Move host to folder
  • Reload host

Power Host Management Workflows

  • Reboot host
  • Shut down host

Host Management Registration Workflows

  • Add host to cluster
  • Add standalone host
  • Disconnect host
  • Reconnect host
  • Reconnect host with all information
  • Remove host

Networking Workflows

  • Add port group to distributed virtual switch
  • Attach host system to distributed virtual switch
  • Create distributed virtual switch with port group

Distributed Virtual Port Group Workflows

  • Connect virtual machine NIC number to distributed virtual port group
  • Delete distributed virtual port group
  • Set teaming options
  • Update distributed virtual port group

Distributed Virtual Switch Workflows

  • Create distributed virtual switch
  • Create private VLAN
  • Delete distributed virtual switch
  • Delete private VLAN
  • Update distributed virtual switch

Standard Virtual Switch Workflows

  • Add port group in standard virtual switch
  • Create standard virtual switch
  • Delete port group from standard virtual switch
  • Delete standard virtual switch
  • Retrieve all standard virtual switches
  • Update port group in standard virtual switch
  • Update standard virtual switch
  • Update VNIC for port group in standard virtual switch

Resource Pool Workflows

  • Create resource pool
  • Create resource pool with specified values
  • Delete resource pool
  • Get resource pool information
  • Reconfigure resource pool
  • Rename resource pool

Storage Workflows

  • Add datastore on iSCSI/FC/local SCSI
  • Add datastore on NFS
  • Add iSCSI target
  • Create VMFS for all available disks
  • Delete datastore
  • Delete iSCSI target
  • Disable iSCSI adapter
  • Display all datastores and disks
  • Enable iSCSI adapter
  • List all storage adapters

Storage DRS Workflows

  • Add datastore to cluster
  • Change Storage DRS per virtual machine configuration
  • Configure datastore cluster
  • Create simple datastore cluster
  • Create Storage DRS scheduled task
  • Create virtual machine anti-affinity rule
  • Create VMDK anti-affinity rule
  • Remove datastore cluster
  • Remove datastore from cluster
  • Remove Storage DRS scheduled task
  • Remove virtual machine anti-affinity rule
  • Remove VMDK anti-affinity rule

Basic Virtual Machine Management Workflows

  • Create custom virtual machine
  • Create simple dvPortGroup virtual machine
  • Create simple virtual machine
  • Delete virtual machine
  • Mark as template
  • Mark as virtual machine
  • Move virtual machine to folder
  • Move virtual machine to resource pool
  • Move virtual machines to folder
  • Move virtual machines to resource pool
  • Register virtual machine
  • Reload virtual machine
  • Rename virtual machine
  • Set virtual machine performance
  • Unregister virtual machine
  • Upgrade VM Hardware (force if required)
  • Upgrade virtual machine
  • Wait for task and answer virtual machine question

Clone Workflows

  • Clone virtual machine from properties
  • Clone virtual machine, no customization
  • Customize virtual machine from properties

Linked Clone Workflows

  • Restore virtual machine from linked clone
  • Set up virtual machine for linked clone
  • Linked clone, Linux with multiple NICs
  • Linked clone, Linux with single NIC
  • Linked clone, Windows with multiple NICs and credential
  • Linked clone, Windows with single NIC and credential
  • Linked clone, no customization

Linux Customization Clone Workflows

  • Clone, Linux with multiple NICs
  • Clone, Linux with single NIC

Tools Clone Workflows

  • Get Linux customization
  • Get NIC setting map
  • Get Windows customization, Sysprep with Unattended.txt
  • Get Windows customization, Sysprep with credentials
  • Get Windows customization for Sysprep
  • Get a VirtualEthernetCard to change the network
  • Get multiple VirtualEthernetCard device changes

Windows Customization Clone Workflows

  • Customize, Windows with single NIC and credential
  • Clone thin provisioned, Windows with single NIC and credential
  • Clone, Windows Sysprep with single NIC and credential
  • Clone, Windows with multiple NICs and credential
  • Clone, Windows with single NIC
  • Clone, Windows with single NIC and credential

Device Management Workflows

  • Add CD-ROM
  • Add disk
  • Change RAM
  • Convert disks to thin provisioning
  • Convert independent disks
  • Disconnect all detachable devices from a running virtual machine
  • Mount floppy disk drive

Move and Migrate Workflows

  • Mass migrate virtual machines with storage vMotion
  • Mass migrate virtual machines with vMotion
  • Migrate virtual machine with vMotion
  • Move virtual machine to another vCenter Server
  • Quick migrate multiple virtual machines
  • Quick migration of virtual machine
  • Relocate virtual machine disks

Other Workflows

  • Disable FT
  • Enable FT
  • Extract virtual machine information
  • Find orphaned virtual machines

Power Management Workflows

  • Power off virtual machine and wait
  • Reboot guest OS
  • Reset virtual machine and wait
  • Resume virtual machine and wait
  • Set guest OS to standby
  • Shut down and delete virtual machine
  • Shut down guest OS and wait
  • Start virtual machine and wait
  • Suspend virtual machine and wait

Snapshot Workflows

  • Create a snapshot
  • Create snapshots of all virtual machines in a resource pool
  • Remove all snapshots
  • Remove excess snapshots
  • Remove old snapshots
  • Remove snapshots of a given size
  • Revert to current snapshot
  • Revert to snapshot and wait

VMware Tools Workflows

  • Mount tools installer
  • Set console screen resolution
  • Turn on time synchronization
  • Unmount tools installer
  • Upgrade tools
  • Upgrade tools at next reboot

Written by bigbluemike

June 7, 2012 at 9:08 am

vCO – Create Distributed Virtual Port Group

leave a comment »

Here is the code for creating a distributed virtual port group. Input is of type VC:VmwareDistributedVirtualSwitch

//New port group basics like name and port numbers
var dvPortgroupConfigSpec = new Array();
dvPortgroupConfigSpec[0] = new VcDVPortgroupConfigSpec();
dvPortgroupConfigSpec[0].name = "vMotion";
dvPortgroupConfigSpec[0].numPorts = 32;
//Supported in vSphere 4.1: earlyBinding, ephemeral, lateBinding
dvPortgroupConfigSpec[0].type = "earlyBinding";

//Create vlan id
dvPortgroupConfigSpec[0].defaultPortConfig = new VcVMwareDVSPortSetting();
dvPortgroupConfigSpec[0].defaultPortConfig.vlan = new VcVmwareDistributedVirtualSwitchVlanIdSpec();
dvPortgroupConfigSpec[0].defaultPortConfig.vlan.inherited = false;
dvPortgroupConfigSpec[0].defaultPortConfig.vlan.vlanId = 0;

//Create Load Balancing Policy
dvPortgroupConfigSpec[0].defaultPortConfig.uplinkTeamingPolicy = new VcVmwareUplinkPortTeamingPolicy();
dvPortgroupConfigSpec[0].defaultPortConfig.uplinkTeamingPolicy.policy = new VcStringPolicy();
//Supported in vSphere 4.1: loadbalance_ip, loadbalance_loadbased, loadbalanced_srcid, loadbalanced_srcmac
dvPortgroupConfigSpec[0].defaultPortConfig.uplinkTeamingPolicy.policy.value = "loadbalance_loadbased";

//Security Policy all to reject
var reject = new VcBoolPolicy();
reject.value = false;
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy = new VcDVSSecurityPolicy();
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy.allowPromiscuous = reject;
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy.forgedTransmits = reject;
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy.macChanges = reject;
dvPortgroupConfigSpec[0].defaultPortConfig.securityPolicy.inherited = false;

//myDVS is input parameter of type VC:VmwareDistributedVirtualSwitch
task = myDVS.addDVPortgroup_Task(dvPortgroupConfigSpec);

Written by bigbluemike

May 28, 2012 at 2:13 pm

Follow

Get every new post delivered to your Inbox.