1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-26 19:29:58 -05:00

folder change vsphere/samples -> samples/vsphere

This commit is contained in:
Tianhao He 2017-01-23 13:28:22 -08:00
parent 9b630f7ba2
commit 2a40af9dd2
118 changed files with 417 additions and 428 deletions

View File

@ -138,28 +138,28 @@ The following table shows the sample sub-directories and their contents.
<table border="1" cellpadding="5"> <table border="1" cellpadding="5">
<tr><th>Directory</th><th>Description</th></tr> <tr><th>Directory</th><th>Description</th></tr>
<tr><td>vsphere.samples.common</td><td>Samples common classes and abstractions; This package does NOT contain any sample</td></tr> <tr><td>samples.vsphere.common</td><td>Samples common classes and abstractions; This package does NOT contain any sample</td></tr>
<tr><td>vsphere.samples.vim.helpers</td><td>Samples and utilities for accessing and manipulating VC objects using pyVmomi</td></tr> <tr><td>samples.vsphere.vim.helpers</td><td>Samples and utilities for accessing and manipulating VC objects using pyVmomi</td></tr>
<tr><td>vsphere.samples.lookupservice</td><td>Service discovery sample using lookup service APIs</td></tr> <tr><td>samples.vsphere.lookupservice</td><td>Service discovery sample using lookup service APIs</td></tr>
<tr><td>vsphere.samples.vcenter</td><td>vAPI samples for managing vSphere infrastructure and virtual machines</td></tr> <tr><td>samples.vsphere.vcenter</td><td>vAPI samples for managing vSphere infrastructure and virtual machines</td></tr>
<tr><td>vsphere.samples.workflow</td><td>Various vAPI work flow samples</td></tr> <tr><td>samples.vsphere.workflow</td><td>Various vAPI work flow samples</td></tr>
<tr><td>vsphere.samples.inventory</td><td>Samples for inventory APIs for retrieving information about vCenter datastore and network objects.</td></tr> <tr><td>samples.vsphere.inventory</td><td>Samples for inventory APIs for retrieving information about vCenter datastore and network objects.</td></tr>
</table> </table>
<a name="vcentersample"></a> <a name="vcentersample"></a>
<h2>vAPI Samples for Managing vSphere Infrastructure and Virtual Machines</h2> <h2>vAPI Samples for Managing vSphere Infrastructure and Virtual Machines</h2>
<p> <p>
The directory vsphere.samples.vcenter contains samples for the vSphere infrastructure and virtual machine APIs. The directory samples.vsphere.vcenter contains samples for the vSphere infrastructure and virtual machine APIs.
You have two options to run samples inside this package: You have two options to run samples inside this package:
<ol> <ol>
<li> <li>
Run the whole sample suite which contains all vCenter samples using main.py in vsphere.samples.vcenter.setup package. Please see the README in the setup package for detailed steps. Run the whole sample suite which contains all vCenter samples using main.py in samples.vsphere.vcenter.setup package. Please see the README in the setup package for detailed steps.
</li> </li>
<li> <li>
Run an individual sample in an existing environment. You can either pass the environment parameters through command line arguments or specify them in setup.py in the setup package. Run an individual sample in an existing environment. You can either pass the environment parameters through command line arguments or specify them in setup.py in the setup package.
<br/> <br/>
For example, to run the create_default_vm sample in the vsphere.samples.vcenter.vm.create package: For example, to run the create_default_vm sample in the samples.vsphere.vcenter.vm.create package:
<ul> <ul>
<li><code>$ cd /path/to/VMware-vSphere-Automation-SDK-Python-&lt;version&gt;/client/bin</code></li> <li><code>$ cd /path/to/VMware-vSphere-Automation-SDK-Python-&lt;version&gt;/client/bin</code></li>
<li>Run the sample with the testbed settings specified in setup.py in a Linux machine:<br/> <li>Run the sample with the testbed settings specified in setup.py in a Linux machine:<br/>
@ -363,7 +363,7 @@ When there is more than one management node, the user MUST specify the managemen
Example of a multiple management node exception: Example of a multiple management node exception:
<pre> <pre>
raise MultipleManagementNodeException(MultipleManagementNodeException.format(result)) raise MultipleManagementNodeException(MultipleManagementNodeException.format(result))
vsphere.samples.common.lookup_service_helper.MultipleManagementNodeException: Multiple Management Node Found on server samples.vsphere.common.lookup_service_helper.MultipleManagementNodeException: Multiple Management Node Found on server
Node name: vcenter-1.example.com uuid: de2afd86-790e-11e4-9c20-0200087f55c6 Node name: vcenter-1.example.com uuid: de2afd86-790e-11e4-9c20-0200087f55c6
Node name: vcenter-2.example.com uuid: 545da868-7910-11e4-81e1-020008e89d83 Node name: vcenter-2.example.com uuid: 545da868-7910-11e4-81e1-020008e89d83
</pre> </pre>

14
samples/vsphere/README.md Normal file
View File

@ -0,0 +1,14 @@
#Client Samples
The following table shows the sample sub-directories and their contents.
Directory | Description
------------------------------- | -------------
samples.vsphere.common | Samples common classes and abstractions; This package does NOT contain any sample
samples.vsphere.contentlibrary | Samples for content library APIs
samples.vsphere.inventory | Samples for inventory APIs for retrieving information about vCenter datastore and network objects.
samples.vsphere.lookupservice | Samples for lookup service APIs
samples.vsphere.tagging | Samples for tagging APIs
samples.vsphere.vcenter | Samples for managing vSphere infrastructure and virtual machines
samples.vsphere.vim | Samples and utilities for accessing and manipulating VC objects using pyVmomi
samples.vsphere.workflow | Various vAPI work flow samples (TODO)

View File

@ -15,9 +15,9 @@ __copyright__ = 'Copyright 2013 VMware, Inc. All rights reserved.'
import os import os
from suds.client import Client from suds.client import Client
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
logger = LoggingContext.get_logger('vsphere.samples.common.lookup_service_helper') logger = LoggingContext.get_logger('samples.vsphere.common.lookup_service_helper')
class LookupServiceHelper(object): class LookupServiceHelper(object):

View File

@ -14,14 +14,14 @@
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2013, 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2013, 2016 VMware, Inc. All rights reserved.'
from vsphere.samples.common import sso
from vmware.vapi.security.sso import create_saml_bearer_security_context from vmware.vapi.security.sso import create_saml_bearer_security_context
from vsphere.samples.common.lookup_service_helper import LookupServiceHelper from samples.vsphere.common import sso
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.common.ssl_helper import get_unverified_context from samples.vsphere.common.lookup_service_helper import LookupServiceHelper
logger = LoggingContext.get_logger('vsphere.samples.common.platform_service_controller') from samples.common.ssl_helper import get_unverified_context
logger = LoggingContext.get_logger('samples.vsphere.common.platform_service_controller')
class PlatformServiceController(object): class PlatformServiceController(object):

View File

@ -16,9 +16,9 @@ __copyright__ = 'Copyright 2013, 2016 VMware, Inc. All rights reserved.'
import argparse import argparse
import traceback import traceback
from vsphere.samples.common.service_manager_factory import ServiceManagerFactory from samples.vsphere.common.service_manager_factory import ServiceManagerFactory
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.common.sample_config import SampleConfig from samples.vsphere.common.sample_config import SampleConfig
logger = LoggingContext.get_logger(__name__) logger = LoggingContext.get_logger(__name__)

View File

@ -13,8 +13,8 @@
from six.moves import cStringIO from six.moves import cStringIO
from vmware.vapi.bindings.struct import PrettyPrinter from vmware.vapi.bindings.struct import PrettyPrinter
from vsphere.samples.common import sample_cli from samples.vsphere.common import sample_cli
from vsphere.samples.vcenter.setup import testbed from samples.vsphere.vcenter.setup import testbed
def pp(value): def pp(value):

View File

@ -14,12 +14,12 @@ __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2013, 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2013, 2016 VMware, Inc. All rights reserved.'
from pyVim.connect import SmartConnect, Disconnect from pyVim.connect import SmartConnect, Disconnect
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.common import vapiconnect from samples.common.ssl_helper import get_unverified_context
from vsphere.samples.common.logging_context import LoggingContext
from vsphere.samples.common.ssl_helper import get_unverified_context
logger = LoggingContext.get_logger('vsphere.samples.common.service_manager') logger = LoggingContext.get_logger('samples.vsphere.common.service_manager')
class ServiceManager(object): class ServiceManager(object):

View File

@ -13,7 +13,7 @@
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2013, 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2013, 2016 VMware, Inc. All rights reserved.'
from vsphere.samples.common.service_manager import ServiceManager from samples.vsphere.common.service_manager import ServiceManager
class ServiceManagerFactory(object): class ServiceManagerFactory(object):

View File

@ -19,14 +19,14 @@ try:
import httplib import httplib
except ImportError: except ImportError:
import http.client as httplib import http.client as httplib
import re import base64
import cgi import cgi
import hashlib
import re
import sys import sys
import time import time
import base64
import hashlib
from uuid import uuid4 from uuid import uuid4
try: try:
from StringIO import StringIO from StringIO import StringIO
except ImportError: except ImportError:
@ -36,8 +36,6 @@ try:
except ImportError: except ImportError:
from urllib.parse import urlparse from urllib.parse import urlparse
from vsphere.samples.common.ssl_helper import get_unverified_context
# Third-party imports. # Third-party imports.
from lxml import etree from lxml import etree

View File

@ -14,16 +14,16 @@ except ImportError:
import urllib.request as urllib2 import urllib.request as urllib2
from com.vmware.content.library.item_client import UpdateSessionModel from com.vmware.content.library.item_client import UpdateSessionModel
from vsphere.samples.common.id_generator import generate_random_uuid from samples.vsphere.common.id_generator import generate_random_uuid
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.common.sample_base import SampleBase from samples.vsphere.common.sample_base import SampleBase
from vsphere.samples.contentlibrary.lib.cls_api_client import ClsApiClient from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from vsphere.samples.contentlibrary.lib.cls_api_helper import ClsApiHelper from samples.vsphere.contentlibrary.lib.cls_api_helper import ClsApiHelper
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.'
logger = LoggingContext.get_logger('vsphere.samples.contentlibrary.content_update') logger = LoggingContext.get_logger('samples.vsphere.contentlibrary.content_update')
class ContentUpdate(SampleBase): class ContentUpdate(SampleBase):

View File

@ -16,18 +16,18 @@
from com.vmware.content_client import LibraryModel from com.vmware.content_client import LibraryModel
from com.vmware.content.library_client import StorageBacking from com.vmware.content.library_client import StorageBacking
from vsphere.samples.common.id_generator import generate_random_uuid from samples.vsphere.common.id_generator import generate_random_uuid
from vsphere.samples.common.sample_base import SampleBase from samples.vsphere.common.sample_base import SampleBase
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.contentlibrary.lib.cls_api_client import ClsApiClient from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from vsphere.samples.vim.helpers.get_datastore_by_name import get_datastore_id from samples.vsphere.vim.helpers.get_datastore_by_name import get_datastore_id
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved. -- VMware Confidential' __copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved. -- VMware Confidential'
logger = LoggingContext.get_logger('vsphere.samples.contentlibrary') logger = LoggingContext.get_logger('samples.vsphere.contentlibrary')
class LibraryCrud(SampleBase): class LibraryCrud(SampleBase):

View File

@ -12,21 +12,18 @@
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
""" """
from samples.vsphere.common.logging_context import LoggingContext
from samples.vsphere.common.sample_base import SampleBase
from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from samples.vsphere.contentlibrary.lib.cls_api_helper import ClsApiHelper
import os from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_base import SampleBase
from vsphere.samples.common.logging_context import LoggingContext
from vsphere.samples.contentlibrary.lib.cls_api_client import ClsApiClient
from vsphere.samples.contentlibrary.lib.cls_api_helper import ClsApiHelper
from vsphere.samples.vcenter.helper.vm_helper import get_vm
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.'
logger = LoggingContext.get_logger('vsphere.samples.contentlibrary.iso_mount') logger = LoggingContext.get_logger('samples.vsphere.contentlibrary.iso_mount')
class IsoMount(SampleBase): class IsoMount(SampleBase):

View File

@ -26,14 +26,14 @@ from com.vmware.content.library.item_client import (DownloadSessionModel,
UpdateSessionModel) UpdateSessionModel)
from com.vmware.content.library.item.downloadsession_client import File as DownloadSessionFile from com.vmware.content.library.item.downloadsession_client import File as DownloadSessionFile
from com.vmware.content.library.item.updatesession_client import File as UpdateSessionFile from com.vmware.content.library.item.updatesession_client import File as UpdateSessionFile
from vsphere.samples.common.id_generator import generate_random_uuid from samples.vsphere.common.id_generator import generate_random_uuid
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.vim.helpers.get_datastore_by_name import get_datastore_id from samples.vsphere.vim.helpers.get_datastore_by_name import get_datastore_id
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.'
logger = LoggingContext.get_logger('vsphere.samples.contentlibrary.lib') logger = LoggingContext.get_logger('samples.vsphere.contentlibrary.lib')
class ClsApiHelper(object): class ClsApiHelper(object):

View File

@ -22,19 +22,19 @@ from com.vmware.vcenter.ovf_client import LibraryItem
from pyVmomi import vim from pyVmomi import vim
from vsphere.samples.common.id_generator import generate_random_uuid from samples.vsphere.common.id_generator import generate_random_uuid
from vsphere.samples.common.sample_base import SampleBase from samples.vsphere.common.sample_base import SampleBase
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.contentlibrary.lib.cls_api_client import ClsApiClient from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from vsphere.samples.contentlibrary.lib.cls_api_helper import ClsApiHelper from samples.vsphere.contentlibrary.lib.cls_api_helper import ClsApiHelper
from vsphere.samples.vim.helpers.vim_utils import ( from samples.vsphere.vim.helpers.vim_utils import (
get_obj, get_obj_by_moId, poweron_vm, poweroff_vm, delete_object) get_obj, get_obj_by_moId, poweron_vm, poweroff_vm, delete_object)
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.'
logger = LoggingContext.get_logger('vsphere.samples.contentlibrary.deploy_ovf_template') logger = LoggingContext.get_logger('samples.vsphere.contentlibrary.deploy_ovf_template')
class DeployOvfTemplate(SampleBase): class DeployOvfTemplate(SampleBase):

View File

@ -21,19 +21,19 @@ except ImportError:
from com.vmware.content_client import LibraryModel from com.vmware.content_client import LibraryModel
from com.vmware.content.library_client import ItemModel, StorageBacking from com.vmware.content.library_client import ItemModel, StorageBacking
from vsphere.samples.common.id_generator import generate_random_uuid from samples.vsphere.common.id_generator import generate_random_uuid
from vsphere.samples.common.sample_base import SampleBase from samples.vsphere.common.sample_base import SampleBase
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.contentlibrary.lib.cls_api_client import ClsApiClient from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from vsphere.samples.contentlibrary.lib.cls_api_helper import ClsApiHelper from samples.vsphere.contentlibrary.lib.cls_api_helper import ClsApiHelper
from vsphere.samples.vim.helpers.get_datastore_by_name import get_datastore_id from samples.vsphere.vim.helpers.get_datastore_by_name import get_datastore_id
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.'
logger = LoggingContext.get_logger('vsphere.samples.contentlibrary.ovef_import_export') logger = LoggingContext.get_logger('samples.vsphere.contentlibrary.ovef_import_export')
class OvfImportExport(SampleBase): class OvfImportExport(SampleBase):

View File

@ -20,18 +20,18 @@ except ImportError:
from com.vmware.content_client import LibraryModel from com.vmware.content_client import LibraryModel
from com.vmware.content.library_client import (ItemModel, PublishInfo, from com.vmware.content.library_client import (ItemModel, PublishInfo,
StorageBacking, SubscriptionInfo) StorageBacking, SubscriptionInfo)
from vsphere.samples.common.id_generator import generate_random_uuid from samples.vsphere.common.id_generator import generate_random_uuid
from vsphere.samples.common.sample_base import SampleBase from samples.vsphere.common.sample_base import SampleBase
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.contentlibrary.lib.cls_api_client import ClsApiClient from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from vsphere.samples.contentlibrary.lib.cls_api_helper import ClsApiHelper from samples.vsphere.contentlibrary.lib.cls_api_helper import ClsApiHelper
from vsphere.samples.contentlibrary.lib.cls_sync_helper import ClsSyncHelper from samples.vsphere.contentlibrary.lib.cls_sync_helper import ClsSyncHelper
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.'
logger = LoggingContext.get_logger('vsphere.samples.contentlibrary.library_publish_subscribe') logger = LoggingContext.get_logger('samples.vsphere.contentlibrary.library_publish_subscribe')
class LibraryPublishSubscribe(SampleBase): class LibraryPublishSubscribe(SampleBase):

View File

@ -17,17 +17,18 @@ try:
except ImportError: except ImportError:
import urllib.request as urllib2 import urllib.request as urllib2
from com.vmware.vcenter.ovf_client import LibraryItem from com.vmware.vcenter.ovf_client import LibraryItem
from vsphere.samples.common.id_generator import generate_random_uuid from samples.vsphere.common.id_generator import generate_random_uuid
from vsphere.samples.common.sample_base import SampleBase from samples.vsphere.common.logging_context import LoggingContext
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.sample_base import SampleBase
from vsphere.samples.contentlibrary.lib.cls_api_client import ClsApiClient from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from vsphere.samples.contentlibrary.lib.cls_api_helper import ClsApiHelper from samples.vsphere.contentlibrary.lib.cls_api_helper import ClsApiHelper
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from samples.vsphere.vcenter.helper.vm_helper import get_vm
__author__ = 'VMware, Inc.' __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2016 VMware, Inc. All rights reserved.'
logger = LoggingContext.get_logger('vsphere.samples.contentlibrary.vm_template_capture') logger = LoggingContext.get_logger('samples.vsphere.contentlibrary.vm_template_capture')
class CaptureVMTemplateToContentLibrary(SampleBase): class CaptureVMTemplateToContentLibrary(SampleBase):

View File

@ -17,11 +17,11 @@ __copyright__ = 'Copyright 2014, 2016 VMware, Inc. All rights reserved.'
import pyVmomi import pyVmomi
from com.vmware.content_client import Library from com.vmware.content_client import Library
from com.vmware.vcenter.inventory_client import Datastore from com.vmware.vcenter.inventory_client import Datastore
from vsphere.samples.vim.helpers.vim_utils import get_obj_by_moId from samples.vsphere.vim.helpers.vim_utils import get_obj_by_moId
from vsphere.samples.common.sample_base import SampleBase from samples.vsphere.common.sample_base import SampleBase
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
logger = LoggingContext.get_logger('vsphere.samples.inventory.find_cl_datastore') logger = LoggingContext.get_logger('samples.vsphere.inventory.find_cl_datastore')
class FindClDatastore(SampleBase): class FindClDatastore(SampleBase):
@ -31,7 +31,7 @@ class FindClDatastore(SampleBase):
Step 2: Find out the content library storage backing. Step 2: Find out the content library storage backing.
Step 3: Find out the vCenter object from the storage ID using datastore inventory API. Step 3: Find out the vCenter object from the storage ID using datastore inventory API.
Note: This sample needs an existing content library on the server Note: This sample needs an existing content library on the server
(Please refer to vsphere.samples.contentlibrary.library_crud for details on how to create a content library) (Please refer to samples.vsphere.contentlibrary.library_crud for details on how to create a content library)
""" """
def __init__(self): def __init__(self):
SampleBase.__init__(self, self.__doc__) SampleBase.__init__(self, self.__doc__)

View File

@ -14,11 +14,11 @@ __author__ = 'VMware, Inc.'
__copyright__ = 'Copyright 2014 VMware, Inc. All rights reserved.' __copyright__ = 'Copyright 2014 VMware, Inc. All rights reserved.'
import argparse import argparse
from vsphere.samples.common.sample_config import SampleConfig from samples.vsphere.common.sample_config import SampleConfig
from vsphere.samples.common.lookup_service_helper import LookupServiceHelper from samples.vsphere.common.lookup_service_helper import LookupServiceHelper
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
logger = LoggingContext.get_logger('vsphere.samples.lookupservice.print_services') logger = LoggingContext.get_logger('samples.vsphere.lookupservice.print_services')
class PrintServices(object): class PrintServices(object):

View File

@ -19,11 +19,11 @@ import time
from com.vmware.vapi.std_client import DynamicID from com.vmware.vapi.std_client import DynamicID
from com.vmware.cis.tagging_client import ( from com.vmware.cis.tagging_client import (
Category, CategoryModel, Tag, TagAssociation) Category, CategoryModel, Tag, TagAssociation)
from vsphere.samples.vim.helpers.get_cluster_by_name import get_cluster_id from samples.vsphere.vim.helpers.get_cluster_by_name import get_cluster_id
from vsphere.samples.common.sample_base import SampleBase from samples.vsphere.common.sample_base import SampleBase
from vsphere.samples.common.logging_context import LoggingContext from samples.vsphere.common.logging_context import LoggingContext
logger = LoggingContext.get_logger('vsphere.samples.workflow.tagging_workflow') logger = LoggingContext.get_logger('samples.vsphere.workflow.tagging_workflow')
class TaggingWorkflow(SampleBase): class TaggingWorkflow(SampleBase):

View File

@ -12,7 +12,7 @@
from com.vmware.vcenter_client import Cluster from com.vmware.vcenter_client import Cluster
from vsphere.samples.vcenter.helper import datacenter_helper from samples.vsphere.vcenter.helper import datacenter_helper
def get_cluster(stub_config, datacenter_name, cluster_name): def get_cluster(stub_config, datacenter_name, cluster_name):

View File

@ -12,7 +12,7 @@
from com.vmware.vcenter_client import Datastore from com.vmware.vcenter_client import Datastore
from vsphere.samples.vcenter.helper import datacenter_helper from samples.vsphere.vcenter.helper import datacenter_helper
def get_datastore(stub_config, datacenter_name, datastore_name): def get_datastore(stub_config, datacenter_name, datastore_name):

View File

@ -12,7 +12,7 @@
from com.vmware.vcenter_client import Folder from com.vmware.vcenter_client import Folder
from vsphere.samples.vcenter.helper import datacenter_helper from samples.vsphere.vcenter.helper import datacenter_helper
def get_folder(stub_config, datacenter_name, folder_name): def get_folder(stub_config, datacenter_name, folder_name):

View File

@ -12,7 +12,7 @@
from com.vmware.vcenter_client import Network from com.vmware.vcenter_client import Network
from vsphere.samples.vcenter.helper import datacenter_helper from samples.vsphere.vcenter.helper import datacenter_helper
def get_standard_network_backing(stub_config, def get_standard_network_backing(stub_config,

View File

@ -12,7 +12,7 @@
from com.vmware.vcenter_client import ResourcePool from com.vmware.vcenter_client import ResourcePool
from vsphere.samples.vcenter.helper import datacenter_helper from samples.vsphere.vcenter.helper import datacenter_helper
def get_resource_pool(stub_config, datacenter_name): def get_resource_pool(stub_config, datacenter_name):

View File

@ -12,9 +12,9 @@
from com.vmware.vcenter_client import VM from com.vmware.vcenter_client import VM
from vsphere.samples.vcenter.helper import datastore_helper from samples.vsphere.vcenter.helper import datastore_helper
from vsphere.samples.vcenter.helper import folder_helper from samples.vsphere.vcenter.helper import folder_helper
from vsphere.samples.vcenter.helper import resource_pool_helper from samples.vsphere.vcenter.helper import resource_pool_helper
def get_placement_spec_for_resource_pool(stub_config, def get_placement_spec_for_resource_pool(stub_config,

View File

@ -10,7 +10,7 @@
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
""" """
from vsphere.samples.vim.file import (detect_directory, from samples.vsphere.vim.file import (detect_directory,
create_directory, create_directory,
delete_directory) delete_directory)

View File

@ -14,7 +14,7 @@ import pyVim.task
from com.vmware.vcenter_client import Cluster from com.vmware.vcenter_client import Cluster
from pyVmomi import vim from pyVmomi import vim
from vsphere.samples.vcenter.helper import cluster_helper from samples.vsphere.vcenter.helper import cluster_helper
def detect_cluster(context): def detect_cluster(context):

View File

@ -10,10 +10,10 @@
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
""" """
from vsphere.samples.vim import datastore_file from samples.vsphere.vim import datastore_file
from vsphere.samples.vim.file import (detect_file, delete_file, from samples.vsphere.vim.file import (detect_file, delete_file,
parse_datastore_path) parse_datastore_path)
from vsphere.samples.vim.inventory import get_datastore_mo from samples.vsphere.vim.inventory import get_datastore_mo
def setup_floppy_image(context): def setup_floppy_image(context):

View File

@ -14,7 +14,7 @@ import pyVim.task
from com.vmware.vcenter_client import (Folder) from com.vmware.vcenter_client import (Folder)
from pyVmomi import vim from pyVmomi import vim
from vsphere.samples.vcenter.helper import datacenter_helper from samples.vsphere.vcenter.helper import datacenter_helper
def detect_vm_folder(context, datacenter_name, folder_name): def detect_vm_folder(context, datacenter_name, folder_name):

View File

@ -10,10 +10,10 @@
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
""" """
from vsphere.samples.vim import datastore_file from samples.vsphere.vim import datastore_file
from vsphere.samples.vim.file import (detect_file, delete_file, from samples.vsphere.vim.file import (detect_file, delete_file,
parse_datastore_path) parse_datastore_path)
from vsphere.samples.vim.inventory import get_datastore_mo from samples.vsphere.vim.inventory import get_datastore_mo
def setup_iso_image(context): def setup_iso_image(context):

View File

@ -18,17 +18,17 @@ Script that runs through all the setup and samples.
""" """
import pyVim.connect import pyVim.connect
from samples.vsphere.common import sample_util
from samples.vsphere.common import vapiconnect
from samples.vsphere.vcenter.setup import testbed
from samples.vsphere.vcenter.setup.setup_cli import build_arg_parser
from samples.vsphere.vcenter.setup.testbed_setup import cleanup as testbed_cleanup
from samples.vsphere.vcenter.setup.testbed_setup import setup as testbed_setup
from samples.vsphere.vcenter.setup.testbed_setup import validate as testbed_validate
from samples.vsphere.vcenter.vm.main import cleanup as sample_cleanup
from samples.vsphere.vcenter.vm.main import run as sample_run
from vsphere.samples.common import sample_util from samples.common.ssl_helper import get_unverified_context
from vsphere.samples.common import vapiconnect
from vsphere.samples.common.ssl_helper import get_unverified_context
from vsphere.samples.vcenter.setup import testbed
from vsphere.samples.vcenter.setup.setup_cli import build_arg_parser
from vsphere.samples.vcenter.setup.testbed_setup import cleanup as testbed_cleanup
from vsphere.samples.vcenter.setup.testbed_setup import setup as testbed_setup
from vsphere.samples.vcenter.setup.testbed_setup import validate as testbed_validate
from vsphere.samples.vcenter.vm.main import cleanup as sample_cleanup
from vsphere.samples.vcenter.vm.main import run as sample_run
# Parse command line params for setup script # Parse command line params for setup script

View File

@ -10,15 +10,15 @@
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
""" """
import vsphere.samples.vcenter.setup.backend_directory as backend_directory import samples.vsphere.vcenter.setup.backend_directory as backend_directory
import vsphere.samples.vcenter.setup.cluster as cluster import samples.vsphere.vcenter.setup.cluster as cluster
import vsphere.samples.vcenter.setup.datacenter as datacenter import samples.vsphere.vcenter.setup.datacenter as datacenter
import vsphere.samples.vcenter.setup.datastore as datastore import samples.vsphere.vcenter.setup.datastore as datastore
import vsphere.samples.vcenter.setup.floppy_image as floppy_image import samples.vsphere.vcenter.setup.floppy_image as floppy_image
import vsphere.samples.vcenter.setup.folder as folder import samples.vsphere.vcenter.setup.folder as folder
import vsphere.samples.vcenter.setup.host as host import samples.vsphere.vcenter.setup.host as host
import vsphere.samples.vcenter.setup.iso_image as iso_image import samples.vsphere.vcenter.setup.iso_image as iso_image
import vsphere.samples.vcenter.setup.network as network import samples.vsphere.vcenter.setup.network as network
""" """
Setup Simple Testbed: Which provides the prerequisites for using the VM API Setup Simple Testbed: Which provides the prerequisites for using the VM API

View File

@ -25,14 +25,14 @@ This directory contains samples for vCenter virtual machine APIs:
You have two options to run samples inside this package: You have two options to run samples inside this package:
1. Run the whole sample suite which contains all vcenter samples using main.py 1. Run the whole sample suite which contains all vcenter samples using main.py
in vsphere.samples.vcenter.setup package. in samples.vsphere.vcenter.setup package.
Please see the README in the setup package for detailed steps. Please see the README in the setup package for detailed steps.
2. Run an individual sample in an existing environment. 2. Run an individual sample in an existing environment.
You can either pass the testbed settings through command line You can either pass the testbed settings through command line
arguments or specify them in setup.py in the setup package. arguments or specify them in setup.py in the setup package.
For example, to run the create_default_vm sample in the vsphere.samples.vcenter.vm.create package: For example, to run the create_default_vm sample in the samples.vsphere.vcenter.vm.create package:
* $ cd /path/to/VMware-vSphere-Automation-SDK-Python-<version>/client/bin * $ cd /path/to/VMware-vSphere-Automation-SDK-Python-<version>/client/bin

View File

@ -18,14 +18,14 @@ from com.vmware.vcenter.vm.hardware_client import (
from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec
from com.vmware.vcenter.vm_client import (Power) from com.vmware.vcenter.vm_client import (Power)
from com.vmware.vcenter_client import VM from com.vmware.vcenter_client import VM
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.helper import network_helper
from samples.vsphere.vcenter.helper import vm_placement_helper
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper import network_helper
from vsphere.samples.vcenter.helper import vm_placement_helper
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to create a basic VM with following configuration: Demonstrates how to create a basic VM with following configuration:

View File

@ -14,13 +14,13 @@
from com.vmware.vcenter.vm_client import Power from com.vmware.vcenter.vm_client import Power
from com.vmware.vcenter_client import VM from com.vmware.vcenter_client import VM
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.helper import vm_placement_helper
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper import vm_placement_helper
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to create a VM with system provided defaults Demonstrates how to create a VM with system provided defaults

View File

@ -18,14 +18,14 @@ from com.vmware.vcenter.vm.hardware_client import (
from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec from com.vmware.vcenter.vm.hardware_client import ScsiAddressSpec
from com.vmware.vcenter.vm_client import (Hardware, Power) from com.vmware.vcenter.vm_client import (Hardware, Power)
from com.vmware.vcenter_client import VM from com.vmware.vcenter_client import VM
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.helper import network_helper
from samples.vsphere.vcenter.helper import vm_placement_helper
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper import network_helper
from vsphere.samples.vcenter.helper import vm_placement_helper
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to create a exhaustive VM with the below configuration: Demonstrates how to create a exhaustive VM with the below configuration:

View File

@ -13,12 +13,12 @@
""" """
from com.vmware.vcenter.vm.hardware.adapter_client import Sata from com.vmware.vcenter.vm.hardware.adapter_client import Sata
from samples.vsphere.common import vapiconnect
from vsphere.samples.common import vapiconnect from samples.vsphere.common.sample_util import pp, \
from vsphere.samples.common.sample_util import pp, \
parse_cli_args_vm parse_cli_args_vm
from vsphere.samples.vcenter.helper.vm_helper import get_vm from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.vcenter.setup import testbed
from samples.vsphere.vcenter.helper.vm_helper import get_vm
""" """
Demonstrates how to configure virtual SATA adapters of a virtual machine. Demonstrates how to configure virtual SATA adapters of a virtual machine.

View File

@ -13,12 +13,12 @@
""" """
from com.vmware.vcenter.vm.hardware.adapter_client import Scsi from com.vmware.vcenter.vm.hardware.adapter_client import Scsi
from samples.vsphere.common import vapiconnect
from vsphere.samples.common import vapiconnect from samples.vsphere.common.sample_util import pp, \
from vsphere.samples.common.sample_util import pp, \
parse_cli_args_vm parse_cli_args_vm
from vsphere.samples.vcenter.helper.vm_helper import get_vm from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.vcenter.setup import testbed
from samples.vsphere.vcenter.helper.vm_helper import get_vm
""" """
Demonstrates how to configure virtual SCSI adapters of a virtual machine. Demonstrates how to configure virtual SCSI adapters of a virtual machine.

View File

@ -13,12 +13,12 @@
""" """
from com.vmware.vcenter.vm.hardware_client import Boot from com.vmware.vcenter.vm.hardware_client import Boot
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to configure the settings used when booting a virtual machine. Demonstrates how to configure the settings used when booting a virtual machine.

View File

@ -14,12 +14,12 @@
from com.vmware.vcenter.vm.hardware.boot_client import Device as BootDevice from com.vmware.vcenter.vm.hardware.boot_client import Device as BootDevice
from com.vmware.vcenter.vm.hardware_client import (Disk, Ethernet) from com.vmware.vcenter.vm.hardware_client import (Disk, Ethernet)
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to modify the boot devices used by a virtual machine, and in Demonstrates how to modify the boot devices used by a virtual machine, and in

View File

@ -17,12 +17,12 @@ from com.vmware.vcenter.vm.hardware_client import (Cdrom,
IdeAddressSpec, IdeAddressSpec,
SataAddressSpec) SataAddressSpec)
from com.vmware.vcenter.vm_client import Power from com.vmware.vcenter.vm_client import Power
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to configure CD-ROM devices for a VM. Demonstrates how to configure CD-ROM devices for a VM.

View File

@ -13,12 +13,12 @@
""" """
from com.vmware.vcenter.vm.hardware_client import Cpu from com.vmware.vcenter.vm.hardware_client import Cpu
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to configure CPU settings for a VM. Demonstrates how to configure CPU settings for a VM.

View File

@ -13,23 +13,22 @@
""" """
import atexit import atexit
from pyVim.connect import SmartConnect, Disconnect
from com.vmware.vcenter.vm.hardware.adapter_client import Sata from com.vmware.vcenter.vm.hardware.adapter_client import Sata
from com.vmware.vcenter.vm.hardware_client import Disk from com.vmware.vcenter.vm.hardware_client import Disk
from com.vmware.vcenter.vm.hardware_client import (IdeAddressSpec, from com.vmware.vcenter.vm.hardware_client import (IdeAddressSpec,
SataAddressSpec, SataAddressSpec,
ScsiAddressSpec) ScsiAddressSpec)
from pyVim.connect import SmartConnect, Disconnect
from vsphere.samples.common import vapiconnect from samples.vsphere.common import vapiconnect
from vsphere.samples.common.sample_util import parse_cli_args_vm from samples.vsphere.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp from samples.vsphere.common.sample_util import pp
from vsphere.samples.common.ssl_helper import get_unverified_context from samples.vsphere.common.ssl_helper import get_unverified_context
from vsphere.samples.vcenter.helper.vm_helper import get_vm from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.vcenter.setup import testbed from samples.vsphere.vim.inventory import \
from vsphere.samples.vim.inventory import \
(get_datacenter_for_datastore, get_datastore_mo) (get_datacenter_for_datastore, get_datastore_mo)
from vsphere.samples.vim.vmdk import (create_vmdk, delete_vmdk, detect_vmdk) from samples.vsphere.vim.vmdk import (create_vmdk, delete_vmdk, detect_vmdk)
from samples.vsphere.vcenter.helper.vm_helper import get_vm
""" """
Demonstrates how to configure disk settings for a VM. Demonstrates how to configure disk settings for a VM.

View File

@ -14,13 +14,13 @@
from com.vmware.vcenter.vm.hardware_client import Ethernet from com.vmware.vcenter.vm.hardware_client import Ethernet
from com.vmware.vcenter.vm_client import Power from com.vmware.vcenter.vm_client import Power
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.helper import network_helper
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper import network_helper
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to configure virtual ethernet adapters of a virtual machine. Demonstrates how to configure virtual ethernet adapters of a virtual machine.

View File

@ -14,12 +14,12 @@
from com.vmware.vcenter.vm.hardware_client import Floppy from com.vmware.vcenter.vm.hardware_client import Floppy
from com.vmware.vcenter.vm_client import Power from com.vmware.vcenter.vm_client import Power
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to configure Floppy settings for a VM. Demonstrates how to configure Floppy settings for a VM.

View File

@ -0,0 +1,127 @@
"""
* *******************************************************
* Copyright (c) VMware, Inc. 2016. All Rights Reserved.
* *******************************************************
*
* 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.
"""
import samples.vsphere.vcenter.vm.hardware.adapter.sata
import samples.vsphere.vcenter.vm.hardware.adapter.scsi
import samples.vsphere.vcenter.vm.hardware.boot
import samples.vsphere.vcenter.vm.hardware.boot_device
import samples.vsphere.vcenter.vm.hardware.cdrom
import samples.vsphere.vcenter.vm.hardware.cpu
import samples.vsphere.vcenter.vm.hardware.disk
import samples.vsphere.vcenter.vm.hardware.ethernet
import samples.vsphere.vcenter.vm.hardware.floppy
import samples.vsphere.vcenter.vm.hardware.memory
import samples.vsphere.vcenter.vm.hardware.parallel
import samples.vsphere.vcenter.vm.hardware.serial
from samples.vsphere.vcenter.setup import testbed
from samples.vsphere.vcenter.helper.vm_helper import get_vm
def setup(context):
print('Setup vcenter.vm.hardware Samples Started')
samples.vcenter.vm.hardware.cpu.setup(context)
samples.vcenter.vm.hardware.memory.setup(context)
samples.vcenter.vm.hardware.disk.setup(context)
samples.vcenter.vm.hardware.adapter.sata.setup(context)
samples.vcenter.vm.hardware.adapter.scsi.setup(context)
samples.vcenter.vm.hardware.boot.setup(context)
samples.vcenter.vm.hardware.boot_device.setup(context)
samples.vcenter.vm.hardware.cdrom.setup(context)
samples.vcenter.vm.hardware.ethernet.setup(context)
samples.vcenter.vm.hardware.floppy.setup(context)
samples.vcenter.vm.hardware.serial.setup(context)
samples.vcenter.vm.hardware.parallel.setup(context)
print('Setup vcenter.vm.hardware Samples Complete\n')
def cleanup():
print('Cleanup vcenter.vm.hardware Samples Started')
samples.vcenter.vm.hardware.cpu.cleanup()
samples.vcenter.vm.hardware.memory.cleanup()
samples.vcenter.vm.hardware.disk.cleanup()
samples.vcenter.vm.hardware.adapter.sata.cleanup()
samples.vcenter.vm.hardware.adapter.scsi.cleanup()
samples.vcenter.vm.hardware.boot.cleanup()
samples.vcenter.vm.hardware.boot_device.cleanup()
samples.vcenter.vm.hardware.cdrom.cleanup()
samples.vcenter.vm.hardware.ethernet.cleanup()
samples.vcenter.vm.hardware.floppy.cleanup()
samples.vcenter.vm.hardware.serial.cleanup()
samples.vcenter.vm.hardware.parallel.cleanup()
print('Cleanup vcenter.vm.hardware Samples Complete\n')
def validate(context):
print('Validating and Detecting Resources in vcenter.vm.hardware Samples')
names = set([testbed.config['VM_NAME_DEFAULT'],
testbed.config['VM_NAME_BASIC'],
testbed.config['VM_NAME_EXHAUSTIVE']])
valid = True
for name in names:
if not get_vm(context.stub_config, name):
valid = False
if not valid:
exit('==> Samples Setup validation failed: '
'Missing VMs required to run hardware samples')
print('==> Samples Setup validated')
def run():
###########################################################################
# Incremental device CRUDE + connect/disconnect samples
#
# Choose any combination of the following incremental hardware examples.
# Each one will return the VM to its original configuration.
#
# * CPU update sample
# * Memory update sample
# * Disk CRUD sample
# * Ethernet CRUD sample
# * CDROM CRUD sample
# * SCSI adapter sample
# * SATA adapter sample
# * Serial Port CRUD sample
# * Parallel Port CRUD sample
# * Floppy CRUD sample
# * Boot configuration sample
# * Boot Device configuration sample
###########################################################################
print('#' * 79)
print('# vcenter.vm.hardware Samples')
print('#' * 79)
samples.vcenter.vm.hardware.cpu.run()
samples.vcenter.vm.hardware.memory.run()
samples.vcenter.vm.hardware.disk.run()
samples.vcenter.vm.hardware.adapter.sata.run()
samples.vcenter.vm.hardware.adapter.scsi.run()
samples.vcenter.vm.hardware.boot.run()
samples.vcenter.vm.hardware.boot_device.run()
samples.vcenter.vm.hardware.cdrom.run()
samples.vcenter.vm.hardware.ethernet.run()
samples.vcenter.vm.hardware.floppy.run()
samples.vcenter.vm.hardware.serial.run()
samples.vcenter.vm.hardware.parallel.run()
###########################################################################
# Virtual Hardware Upgrade Sample
#
# TODO Not implemented
###########################################################################
###########################################################################
# Hot Add Samples
# * Hot add disk
# * Hot add cdrom
# * ...
# TODO Not implemented
###########################################################################

View File

@ -13,12 +13,12 @@
""" """
from com.vmware.vcenter.vm.hardware_client import Memory from com.vmware.vcenter.vm.hardware_client import Memory
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.vcenter.setup import testbed
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
""" """
Demonstrates how to configure the memory related settings of a virtual machine. Demonstrates how to configure the memory related settings of a virtual machine.

View File

@ -15,14 +15,14 @@
from com.vmware.vcenter.vm.hardware_client import Parallel from com.vmware.vcenter.vm.hardware_client import Parallel
from com.vmware.vcenter.vm_client import Power from com.vmware.vcenter.vm_client import Power
from pyVim.connect import SmartConnect, Disconnect from pyVim.connect import SmartConnect, Disconnect
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.common.ssl_helper import get_unverified_context
from samples.vsphere.vcenter.setup import testbed
from samples.vsphere.vim.file import delete_file
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.common.ssl_helper import get_unverified_context
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
from vsphere.samples.vim.file import delete_file
""" """
Demonstrates how to configure Parallel ports for a VM. Demonstrates how to configure Parallel ports for a VM.

View File

@ -15,14 +15,14 @@
from com.vmware.vcenter.vm.hardware_client import Serial from com.vmware.vcenter.vm.hardware_client import Serial
from com.vmware.vcenter.vm_client import Power from com.vmware.vcenter.vm_client import Power
from pyVim.connect import SmartConnect, Disconnect from pyVim.connect import SmartConnect, Disconnect
from samples.vsphere.common import vapiconnect
from samples.vsphere.common.sample_util import parse_cli_args_vm
from samples.vsphere.common.sample_util import pp
from samples.vsphere.common.ssl_helper import get_unverified_context
from samples.vsphere.vcenter.setup import testbed
from samples.vsphere.vim.file import delete_file
from vsphere.samples.common import vapiconnect from samples.vsphere.vcenter.helper.vm_helper import get_vm
from vsphere.samples.common.sample_util import parse_cli_args_vm
from vsphere.samples.common.sample_util import pp
from vsphere.samples.common.ssl_helper import get_unverified_context
from vsphere.samples.vcenter.helper.vm_helper import get_vm
from vsphere.samples.vcenter.setup import testbed
from vsphere.samples.vim.file import delete_file
""" """
Demonstrates how to configure Serial ports for a VM. Demonstrates how to configure Serial ports for a VM.

View File

@ -10,15 +10,15 @@
* NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE.
""" """
import vsphere.samples.vcenter.helper.network_helper import samples.vsphere.vcenter.helper.network_helper
import vsphere.samples.vcenter.vm.hardware.main import samples.vcenter.vm.hardware.main
import vsphere.samples.vcenter.vm.placement import samples.vsphere.vcenter.vm.placement
import vsphere.samples.vcenter.vm.power import samples.vsphere.vcenter.vm.power
from vsphere.samples.common.sample_util import pp from samples.vsphere.common.sample_util import pp
from vsphere.samples.vcenter.setup import testbed_setup from samples.vsphere.vcenter.setup import testbed_setup
from vsphere.samples.vcenter.vm.create import create_basic_vm from samples.vsphere.vcenter.vm.create import create_basic_vm
from vsphere.samples.vcenter.vm.create import create_default_vm from samples.vsphere.vcenter.vm.create import create_default_vm
from vsphere.samples.vcenter.vm.create import create_exhaustive_vm from samples.vsphere.vcenter.vm.create import create_exhaustive_vm
def setup(context): def setup(context):
@ -63,7 +63,7 @@ def run(context):
########################################################################### ###########################################################################
# Getting a PlacementSpec # Getting a PlacementSpec
########################################################################### ###########################################################################
placement_spec = vsphere.samples.vcenter.vm.placement \ placement_spec = samples.vsphere.vcenter.vm.placement \
.get_placement_spec_for_resource_pool(context) .get_placement_spec_for_resource_pool(context)
print('=' * 79) print('=' * 79)
print('= Resource selection') print('= Resource selection')
@ -76,14 +76,14 @@ def run(context):
# 1. STANDARD_PORTGROUP on DATACENTER2 # 1. STANDARD_PORTGROUP on DATACENTER2
# 2. DISTRIBUTED_PORTGROUP on DATACENTER2 # 2. DISTRIBUTED_PORTGROUP on DATACENTER2
########################################################################### ###########################################################################
standard_network = vsphere.samples.vcenter.helper\ standard_network = samples.vsphere.vcenter.helper\
.network_helper.get_standard_network_backing( .network_helper.get_standard_network_backing(
context.stub_config, context.stub_config,
context.testbed.config['STDPORTGROUP_NAME'], context.testbed.config['STDPORTGROUP_NAME'],
context.testbed.config['VM_DATACENTER_NAME']) context.testbed.config['VM_DATACENTER_NAME'])
print('standard_network={}'.format(standard_network)) print('standard_network={}'.format(standard_network))
distributed_network = vsphere.samples.vcenter.helper\ distributed_network = samples.vsphere.vcenter.helper\
.network_helper.get_distributed_network_backing( .network_helper.get_distributed_network_backing(
context.stub_config, context.stub_config,
context.testbed.config['VDPORTGROUP1_NAME'], context.testbed.config['VDPORTGROUP1_NAME'],
@ -118,20 +118,20 @@ def run(context):
# resume (start), stop # resume (start), stop
# #
########################################################################### ###########################################################################
vsphere.samples.vcenter.vm.power.setup(context) samples.vsphere.vcenter.vm.power.setup(context)
vsphere.samples.vcenter.vm.power.run() samples.vsphere.vcenter.vm.power.run()
vsphere.samples.vcenter.vm.power.cleanup() samples.vsphere.vcenter.vm.power.cleanup()
########################################################################### ###########################################################################
# Incremental device CRUDE + connect/disconnect samples # Incremental device CRUDE + connect/disconnect samples
# #
########################################################################### ###########################################################################
if context.option['DO_SAMPLES_INCREMENTAL']: if context.option['DO_SAMPLES_INCREMENTAL']:
vsphere.samples.vcenter.vm.hardware.main.setup(context) samples.vcenter.vm.hardware.main.setup(context)
vsphere.samples.vcenter.vm.hardware.main.validate(context) samples.vcenter.vm.hardware.main.validate(context)
vsphere.samples.vcenter.vm.hardware.main.run() samples.vcenter.vm.hardware.main.run()
if context.option['DO_SAMPLES_CLEANUP']: if context.option['DO_SAMPLES_CLEANUP']:
vsphere.samples.vcenter.vm.hardware.main.cleanup() samples.vcenter.vm.hardware.main.cleanup()
# Sample cleanup # Sample cleanup

View File

@ -15,7 +15,7 @@ from com.vmware.vcenter_client import (Cluster, Datastore, Folder, ResourcePool,
from vsphere.samples.vcenter.helper import vm_placement_helper from samples.vsphere.vcenter.helper import vm_placement_helper
##################################################################### #####################################################################
# Placement samples: How to get a valid PlacementSpec to create a VM # Placement samples: How to get a valid PlacementSpec to create a VM

Some files were not shown because too many files have changed in this diff Show More