Creating vSphere Cluster with HA & DRS Enabled

240 views
Skip to first unread message

chinna

unread,
Dec 5, 2012, 5:39:14 AM12/5/12
to pysp...@googlegroups.com
Hi Seba,

Thank you very much for coming up with this library.

Is there a working example to create a Cluster with HA/DRS enabled ? 

Thanks, Siva

Seba

unread,
Jan 2, 2013, 9:23:35 AM1/2/13
to pysp...@googlegroups.com
Hi Siva,

  I'm sorry I didn't reply before, I've been on holidays. Check the following code snippet, tweak the parameters to your needs:

Regards,

Seba.


new_cluster_name = "test"
datacenter = "MyDatacenter"

from pysphere import VIServer, VIProperty
from pysphere.resources import VimService_services as VI

server = VIServer()
server.connect(HOST, USER, PASSWORD)

dc_mor = [mor for mor, name in server.get_datacenters().items()
            if name==datacenter][0]

dc_props = VIProperty(server, dc_mor)

folder = dc_props.hostFolder._obj


req = VI.CreateClusterExRequestMsg()
_this = req.new__this(folder)
_this.set_attribute_type(folder.get_attribute_type())

req.set_element__this(_this)
req.set_element_name(new_cluster_name)

spec = req.new_spec()

spec.VmSwapPlacement = "vmDirectory"


drs_config = spec.new_drsConfig()
drs_config.Enabled = True
drs_config.DefaultVmBehavior = "fullyAutomated"
drs_config.VmotionRate = 3
spec.DrsConfig = drs_config

das_config = spec.new_dasConfig()
das_config.Enabled = True
das_config.HostMonitoring = "enabled"
das_config.FailoverLevel = 1
das_config.AdmissionControlEnabled = True
default_vm_settings = das_config.new_defaultVmSettings()
default_vm_settings.RestartPriority = "medium"
default_vm_settings.IsolationResponse = "shutdown"
vm_tools_monitoring = default_vm_settings.new_vmToolsMonitoringSettings()
vm_tools_monitoring.Enabled = True
vm_tools_monitoring.FailureInterval = 30
vm_tools_monitoring.MinUpTime = 120
vm_tools_monitoring.MaxFailures = 3
vm_tools_monitoring.MaxFailureWindow = 3600
default_vm_settings.VmToolsMonitoring = vm_tools_monitoring
das_config.DefaultVmSettings = default_vm_settings
spec.DasConfig = das_config

dpm_config = spec.new_dpmConfig()
dpm_config.Enabled = False
dpm_config.HostPowerActionRate = 3
spec.DpmConfig = dpm_config

req.set_element_spec(spec)

mor = server._proxy.CreateClusterEx(req)._returnval

print "created cluster with mor:", mor
 
server.disconnect()

Siva Krishna Kumar Balijepalli

unread,
Jan 2, 2013, 8:54:32 PM1/2/13
to pysp...@googlegroups.com
Thank you very much Seba. Hope you had great holidays and am happy to see you back.

This problem along with others, I solved myself. But I am stuck at generating client side bindings for vSphere 51. SDK. I tried ZSI's wsdl2py but it gave an error.

I am trying to automate creating a vDS. Current bindings with the latest version of pysphere do not have some of the new APIs that are in vSphere 51.

If would be nice of you if you can help me out generating these.

Thanks a lot for the help.

Regards, Siva

Siva Krishna Kumar Balijepalli

unread,
Jan 3, 2013, 8:26:18 AM1/3/13
to pysp...@googlegroups.com
Hi Seba,

Please let me know If I need to start a new discussion for generating ZSI client stubs for vSphere 51 SDK.

Thank you very much for the help.

Regards, Siva

Seba

unread,
Jan 3, 2013, 8:33:46 AM1/3/13
to pysp...@googlegroups.com
Hi Siva,

  Please add a new issue here: https://code.google.com/p/pysphere/issues/list
  Asking for sdk 5.1 support. Generating the bindings can be tricky, I'll post a how-to guide along with the new bindings when I can.


Regards,

Seba

Sebastian Tiedtke

unread,
Apr 9, 2013, 6:32:40 PM4/9/13
to pysp...@googlegroups.com
Hi Seba,

I'm keen to understand if there's any info on how to generate the client bindings using ZSI?

I'd like to check out the ZSI twisted support. Using the plain vimService.wsdl (+ supporting files) gives me a bunch of errors.
Did you have to massage the wsdl to get it working?

Thanks,
Sebastian

lilong

unread,
Oct 29, 2018, 10:53:32 PM10/29/18
to pysphere
hi,teacher
i want to set drs enabled or disenabled use pysphere, how to do it?
ths
Reply all
Reply to author
Forward
0 new messages