def setup(self):
        parser = sample_cli.build_arg_parser()
        parser.add_argument('-n',
                            '--vm_name',
                            action='store',
                            help='Name of the testing vm')
        parser.add_argument('-clustername',
                            '--clustername',
                            help='The name of the cluster to be used.')
        parser.add_argument('-libitemname',
                            '--libitemname',
                            help='The name of the library item to deploy.'
                            'The library item should contain an OVF package.')
        args = sample_util.process_cli_args(parser.parse_args())
        self.lib_item_name = args.libitemname
        self.cluster_name = args.clustername
        self.vm_name = args.vm_name

        self.servicemanager = ServiceManager(args.server, args.username,
                                             args.password,
                                             args.skipverification)
        self.servicemanager.connect()
        atexit.register(self.servicemanager.disconnect)

        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, args.skipverification)

        # Default VM name
        self.vm_name = 'vm-' + str(generate_random_uuid())
Exemple #2
0
    def _setup(self):
        self.datastore_name = self.args.datastorename
        assert self.datastore_name is not None

        self.servicemanager = self.get_service_manager()
        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, self.skip_verification)
    def _setup(self):
        if not self.datastore_name:
            self.datastore_name = self.args.datastorename
        assert self.datastore_name is not None

        if not self.servicemanager:
            self.servicemanager = self.get_service_manager()

        self.client = ClsApiClient(self.servicemanager)
Exemple #4
0
    def _setup(self):
        self.cluster_name = self.args.clustername
        assert self.cluster_name is not None

        self.lib_item_name = self.args.libitemname
        assert self.lib_item_name is not None

        self.servicemanager = self.get_service_manager()
        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, self.skip_verification)
        # Default VM name
        self.vm_name = 'vm-' + str(generate_random_uuid())
Exemple #5
0
    def _setup(self):
        # Required arguments
        self.vm_name = self.args.vmname
        self.datastore_name = self.args.datastorename

        # Optional arguments
        self.item_name = (self.args.itemname if self.args.itemname
                          else rand('vmtx-item-'))

        self.servicemanager = self.get_service_manager()
        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, self.skip_verification)
    def _setup(self):
        # Required arguments
        self.item_name = self.args.itemname
        self.datacenter_name = self.args.datacentername
        self.folder_name = self.args.foldername
        self.resource_pool_name = self.args.resourcepoolname
        self.datastore_name = self.args.datastorename

        # Optional arguments
        self.vm_name = self.args.vmname if self.args.vmname else rand('vm-')

        self.servicemanager = self.get_service_manager()
        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, self.skip_verification)
    def _setup(self):
        self.datastore_name = self.args.datastorename
        assert self.datastore_name is not None

        self.vm_name = self.args.vmname
        assert self.vm_name is not None

        self.servicemanager = self.get_service_manager()

        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, self.skip_verification)

        session = get_unverified_session() if self.skip_verification else None
        self.vsphere_client = create_vsphere_client(server=self.server,
                                                    username=self.username,
                                                    password=self.password,
                                                    session=session)
Exemple #8
0
    def _setup(self):
        # Required arguments
        self.datacenter_name = self.args.datacentername
        self.resource_pool_name = self.args.resourcepoolname
        self.item_name = self.args.itemname

        # Optional arguments
        self.vm_name = (self.args.vmname
                        if self.args.vmname else rand('checked-out-vm-'))

        self.servicemanager = self.get_service_manager()
        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, self.skip_verification)

        session = get_unverified_session() if self.skip_verification else None
        self.vsphere_client = create_vsphere_client(server=self.server,
                                                    username=self.username,
                                                    password=self.password,
                                                    session=session)
    def setup(self):
        parser = sample_cli.build_arg_parser()
        parser.add_argument('-n',
                            '--vm_name',
                            action='store',
                            help='Name of the testing vm')
        parser.add_argument('-resourcepoolname',
                            '--resourcepoolname',
                            help='The name of the resource pool to be used.')
        parser.add_argument('-libitemname',
                            '--libitemname',
                            help='The name of the library item to deploy.'
                            'The library item should contain an OVF package.')
        parser.add_argument(
            '-vm_count',
            '--vm_count',
            help='Number of VMs to be created. By default is 1',
            type=int,
            default=1)
        args = sample_util.process_cli_args(parser.parse_args())
        self.lib_item_name = args.libitemname
        self.resource_pool_name = args.resourcepoolname
        self.vm_name = args.vm_name
        self.vm_count = args.vm_count

        self.servicemanager = ServiceManager(args.server, args.username,
                                             args.password,
                                             args.skipverification)
        self.servicemanager.connect()
        atexit.register(self.servicemanager.disconnect)

        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, args.skipverification)

        # Default VM name
        if not self.vm_name:
            self.vm_name = 'vm-' + str(generate_random_uuid())
    def _setup(self):
        self.datastore_name = self.args.datastorename
        self.cluster_name = self.args.clustername
        self.folder_name = self.args.foldername
        self.datacenter_name = self.args.datacentername
        self.servicemanager = self.get_service_manager()

        self.datastore_id = get_datastore_id(
            service_manager=self.servicemanager,
            datastore_name=self.datastore_name)
        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, self.skip_verification)
        session = get_unverified_session() if self.skip_verification else None
        self.vsphere_client = create_vsphere_client(server=self.server,
                                                    username=self.username,
                                                    password=self.password,
                                                    session=session)
        self.folder_id = get_folder(self.vsphere_client, self.datacenter_name,
                                    self.folder_name)
        self.storage_backings = self.helper.create_storage_backings(
            self.servicemanager, self.datastore_name)
        cluster_obj = get_obj(self.servicemanager.content,
                              [vim.ClusterComputeResource], self.cluster_name)
        self.resource_pool_id = cluster_obj.resourcePool._GetMoId()
    def _setup(self):
        self.servicemanager = self.get_service_manager()

        self.client = ClsApiClient(self.servicemanager)
        self.helper = ClsApiHelper(self.client, self.skip_verification)
Exemple #12
0
from pyVmomi import vim
from samples.vsphere.common.service_manager import ServiceManager
from samples.vsphere.contentlibrary.lib.cls_api_client import ClsApiClient
from samples.vsphere.common.vim.helpers.vim_utils import get_obj
from com.vmware.content.library_client import Item
from com.vmware.vcenter.ovf_client import LibraryItem

vm_name = ''
rp_name = ''
template_name = ''
esx_host = ''
api_host = ''
api_user = ''
api_pass = ''

service_manager = ServiceManager(api_host, api_user, api_pass, True)
service_manager.connect()
client = ClsApiClient(service_manager)
find_spec = Item.FindSpec(name=template_name)
ovf_template_id = client.library_item_service.find(find_spec)[0]
target = get_obj(service_manager.content, [vim.HostSystem], esx_host)
rp = get_obj(service_manager.content, [vim.ResourcePool], rp_name)
deployment_target = LibraryItem.DeploymentTarget(
    host_id=target._GetMoId(), resource_pool_id=rp._GetMoId())
deployment_spec = LibraryItem.ResourcePoolDeploymentSpec(name=template_name +
                                                         '_deployed',
                                                         accept_all_eula=True)
client.ovf_lib_item_service.deploy(ovf_template_id, deployment_target,
                                   deployment_spec)