mirror of
https://github.com/vmware/vsphere-automation-sdk-python.git
synced 2024-11-29 20:09:58 -05:00
aae89a9af0
* Support VMware Cloud on AWS Networking APIs and add a few samples. * Added vsphere_client module to simplify login and API invocation. * Modified existing samples to use vsphere_client. * Update on vm template APIs. Signed-off-by: Tianhao He <het@vmware.com>
52 lines
2.0 KiB
Python
52 lines
2.0 KiB
Python
"""
|
|
* *******************************************************
|
|
* Copyright (c) VMware, Inc. 2016-2018. All Rights Reserved.
|
|
* SPDX-License-Identifier: MIT
|
|
* *******************************************************
|
|
*
|
|
* DISCLAIMER. THIS PROGRAM IS PROVIDED TO YOU "AS IS" WITHOUT
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, WHETHER ORAL OR WRITTEN,
|
|
* EXPRESS OR IMPLIED. THE AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED
|
|
* WARRANTIES OR CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY,
|
|
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
"""
|
|
|
|
__author__ = 'VMware, Inc.'
|
|
__vcenter_version__ = '6.5+'
|
|
|
|
from com.vmware.vcenter_client import VM
|
|
|
|
from samples.vsphere.vcenter.helper import datastore_helper
|
|
from samples.vsphere.vcenter.helper import folder_helper
|
|
from samples.vsphere.vcenter.helper import resource_pool_helper
|
|
|
|
|
|
def get_placement_spec_for_resource_pool(client,
|
|
datacenter_name,
|
|
vm_folder_name,
|
|
datastore_name):
|
|
"""
|
|
Returns a VM placement spec for a resourcepool. Ensures that the
|
|
vm folder and datastore are all in the same datacenter which is specified.
|
|
"""
|
|
resource_pool = resource_pool_helper.get_resource_pool(client,
|
|
datacenter_name)
|
|
|
|
folder = folder_helper.get_folder(client,
|
|
datacenter_name,
|
|
vm_folder_name)
|
|
|
|
datastore = datastore_helper.get_datastore(client,
|
|
datacenter_name,
|
|
datastore_name)
|
|
|
|
# Create the vm placement spec with the datastore, resource pool and vm
|
|
# folder
|
|
placement_spec = VM.PlacementSpec(folder=folder,
|
|
resource_pool=resource_pool,
|
|
datastore=datastore)
|
|
|
|
print("get_placement_spec_for_resource_pool: Result is '{}'".
|
|
format(placement_spec))
|
|
return placement_spec
|