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())
    def setup(self):
        parser = sample_cli.build_arg_parser()
        args = sample_util.process_cli_args(parser.parse_args())

        self.service_manager = ServiceManager(args.server,
                                              args.username,
                                              args.password,
                                              args.skipverification)
        self.service_manager.connect()
        atexit.register(self.service_manager.disconnect)
    def setup(self):
        # Create argument parser for standard inputs:
        # server, username, password, cleanup and skipverification
        parser = sample_cli.build_arg_parser()

        args = sample_util.process_cli_args(parser.parse_args())

        self.service_manager = ServiceManager(args.server, args.username,
                                              args.password,
                                              args.skipverification)
        self.service_manager.connect()
        atexit.register(self.service_manager.disconnect)
Пример #4
0
    def setup(self):
        parser = sample_cli.build_arg_parser()
        parser.add_argument('-n', '--vm_name',
                            action='store',
                            default='Sample_Default_VM_for_Simple_Testbed',
                            help='Name of the testing vm')
        args = sample_util.process_cli_args(parser.parse_args())
        self.vm_name = args.vm_name

        self.service_manager = ServiceManager(args.server,
                                              args.username,
                                              args.password,
                                              args.skipverification)
        self.service_manager.connect()
        atexit.register(self.service_manager.disconnect)
Пример #5
0
    def setup(self):
        parser = sample_cli.build_arg_parser()
        parser.add_argument('-n', '--vm_name',
                            action='store',
                            help='Name of the testing vm')
        args = sample_util.process_cli_args(parser.parse_args())
        if args.vm_name:
            self.vm_name = args.vm_name
        self.cleardata = args.cleardata

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

        self.stub_config = self.service_manager.stub_config
    def setup(self):
        # Create argument parser for standard inputs:
        # server, username, password, cleanup and skipverification
        parser = sample_cli.build_arg_parser()

        parser.add_argument(
            '-o',
            '--operation',
            action='store',
            default='status',
            choices=['status', 'start', 'pause', 'resume', 'cancel'],
            help='Operation to execute')

        args = sample_util.process_cli_args(parser.parse_args())
        self.operation = args.operation

        self.service_manager = ServiceManager(args.server, args.username,
                                              args.password,
                                              args.skipverification)
        self.service_manager.connect()
        atexit.register(self.service_manager.disconnect)
    def setup(self):
        # Create argument parser for standard inputs:
        # server, username, password, cleanup and skipverification
        parser = sample_cli.build_arg_parser()

        # Add your custom input arguments
        parser.add_argument('-n',
                            '--vm_name',
                            action='store',
                            default='Sample_Default_VM_for_Simple_Testbed',
                            help='Name of the testing vm')

        args = sample_util.process_cli_args(parser.parse_args())
        self.vm_name = args.vm_name
        self.cleardata = args.cleardata

        # Connect to both Vim and vAPI services
        self.service_manager = ServiceManager(args.server, args.username,
                                              args.password,
                                              args.skipverification)
        self.service_manager.connect()
        atexit.register(self.service_manager.disconnect)
    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())
Пример #9
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)
 def get_service_manager(cls, server, username, password,
                         skip_verification):
     cls.service_manager = ServiceManager(server, username, password,
                                          skip_verification)
     cls.service_manager.connect()
     return cls.service_manager