def __init__(self,
                 client=None,
                 placement_spec=None,
                 cpu=4,
                 memory=4,
                 cap=30,
                 vm_name=None):
        self.client = client
        self.placement_spec = placement_spec
        self.vm_name = vm_name
        self.cleardata = None
        self.cpu = cpu
        self.memory = memory * 1024
        self.cap = cap * 1024 * 1024 * 1024

        # Execute the sample in standalone mode.
        if not self.client:
            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

            session = get_unverified_session(
            ) if args.skipverification else None
            self.client = create_vsphere_client(server=args.server,
                                                username=args.username,
                                                password=args.password,
                                                session=session)
Example #2
0
def parse_cli_args_vm(vm_name):
    """
    Parse the server IP, credential and vm name used by vcenter vm samples.
    Use values from command line arguments if present, otherwise use values
    from testbed.py
    """
    # parse command line
    parser = sample_cli.build_arg_parser()
    parser.add_argument('-n',
                        '--vm_name',
                        action='store',
                        help='Name of the testing vm')
    args = parser.parse_args()

    server, username, password, cleardata, skip_verification = \
        process_cli_args(args)

    if args.vm_name:
        vm_name = args.vm_name
    else:
        print("Try to use vm name({}) specified in testbed.py".format(vm_name))
    if not vm_name:
        raise Exception("vm name is required")
    print("vm name = {}".format(vm_name))

    return server, username, password, cleardata, skip_verification, vm_name
    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())
Example #4
0
 def __init__(self):
     parser = sample_cli.build_arg_parser()
     args = sample_util.process_cli_args(parser.parse_args())
     session = get_unverified_session() if args.skipverification else None
     stub_config = get_configuration(args.server, args.username,
                                     args.password, session)
     self.list_cluster = Clusters(stub_config)
    def setup(self):
        parser = sample_cli.build_arg_parser()

        parser.add_argument(
            '--loghost', required=True, action='store', help='The log host')
        parser.add_argument(
            '--port',
            required=True,
            action='store',
            help='The log host port number')
        parser.add_argument(
            '--protocol',
            required=True,
            action='store',
            help='The log host protocol (TCP/UDP/TLS)')

        args = sample_util.process_cli_args(parser.parse_args())
        self.loghost = args.loghost
        self.protocol = args.protocol
        self.port = int(args.port)

        # Connect to vAPI services
        self.stub_config = vapiconnect.connect(
            host=args.server,
            user=args.username,
            pwd=args.password,
            skip_verification=args.skipverification)

        self.log_forwarding_client = Forwarding(self.stub_config)
Example #6
0
    def __init__(self):
        parser = sample_cli.build_arg_parser()

        parser.add_argument('--resourcepoolname',
                            default='Compute-ResourcePool',
                            help='The name of the resource pool to be used.')

        parser.add_argument('--libitemname',
                            required=True,
                            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.vm_id = None
        self.vm_name = 'deployed-vm-' + str(generate_random_uuid())

        self.lib_item_name = args.libitemname
        self.resourcepoolname = args.resourcepoolname
        self.cleardata = args.cleardata

        # Connect to vAPI Endpoint on vCenter Server
        self.client = create_vsphere_client(server=args.server,
                                            username=args.username,
                                            password=args.password)
    def __init__(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

        # Skip server cert verification if needed.
        # This is not recommended in production code.
        session = get_unverified_session() if args.skipverification else None

        # Connect to vSphere client
        self.client = create_vsphere_client(server=args.server,
                                            username=args.username,
                                            password=args.password,
                                            session=session)
Example #8
0
    def __init__(self):
        parser = sample_cli.build_arg_parser()
        parser.add_argument(
            '-psc_h',
            '--psc_host_name',
            action='store',
            default='Sample_PSC_hostname',
            help='Platform Services Controller FQDN / IP as per configuration')
        parser.add_argument('-a',
                            '--sso_admin_username',
                            action='store',
                            default='Sample_PSC_username',
                            help='Platform Services Controller admin username')
        parser.add_argument('-w',
                            '--sso_admin_password',
                            action='store',
                            default='Sample_PSC_Admin_Password',
                            help='Platform Services Controller admin password')

        args = sample_util.process_cli_args(parser.parse_args())
        self.psc_hostname = args.psc_host_name
        self.username = args.username
        self.password = args.password
        self.sso_admin_username = args.sso_admin_username
        self.sso_admin_password = args.sso_admin_password
        self.server = args.server
        self.skipverification = args.skipverification
Example #9
0
 def __init__(self):
     parser = sample_cli.build_arg_parser()
     args = sample_util.process_cli_args(parser.parse_args())
     config = get_configuration(args.server, args.username,
                                args.password,
                                args.skipverification)
     self.api_client = CompatibilityData(config)
    def __init__(self,
                 client=None,
                 placement_spec=None,
                 standard_network=None,
                 distributed_network=None):
        self.client = client
        self.placement_spec = placement_spec
        self.standard_network = standard_network
        self.distributed_network = distributed_network
        self.vm_name = testbed.config['VM_NAME_EXHAUSTIVE']
        self.cleardata = None

        # Execute the sample in standalone mode.
        if not self.client:

            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

            session = get_unverified_session(
            ) if args.skipverification else None
            self.client = create_vsphere_client(server=args.server,
                                                username=args.username,
                                                password=args.password,
                                                session=session)
Example #11
0
    def setup(self):
        parser = sample_cli.build_arg_parser()

        parser.add_argument('-location',
                            '--location',
                            required=True,
                            action='store',
                            help='URL of the backup location')
        parser.add_argument('--location_user',
                            required=True,
                            action='store',
                            help='Username for the given location')
        parser.add_argument('--location_password',
                            required=True,
                            action='store',
                            help='Password for the given location')

        args = sample_util.process_cli_args(parser.parse_args())
        self.location = args.location
        self.location_user = args.location_user
        self.location_password = args.location_password

        # Connect to vAPI services
        self.stub_config = vapiconnect.connect(
            host=args.server,
            user=args.username,
            pwd=args.password,
            skip_verification=args.skipverification)

        self.schedule_client = Schedules(self.stub_config)
 def __init__(self):
     parser = sample_cli.build_arg_parser()
     args = sample_util.process_cli_args(parser.parse_args())
     session = get_unverified_session() if args.skipverification else None
     self.client = create_vsphere_client(server=args.server,
                                         username=args.username,
                                         password=args.password,
                                         session=session)
Example #13
0
 def __init__(self):
     parser = sample_cli.build_arg_parser()
     args = sample_util.process_cli_args(parser.parse_args())
     session = get_unverified_session() if args.skipverification else None
     stub_config = get_configuration(args.server, args.username,
                                     args.password, args.skipverification)
     self.pending_client = Pending(stub_config)
     self.precheck_client = PrecheckReport(stub_config)
    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)
Example #15
0
def parse_cli_args():
    """
    Parse the server IP and credential used by samples.
    Use values from command line arguments if present, otherwise use values
    from testbed.py
    """
    # parse command line
    parser = sample_cli.build_arg_parser()
    args = parser.parse_args()
    return process_cli_args(args)
    def __init__(self):
        parser = sample_cli.build_arg_parser()
        args = sample_util.process_cli_args(parser.parse_args())

        session = get_unverified_session() if args.skipverification else None
        stub_config = get_configuration(
                args.server, args.username, args.password,
                session)
        self.product_client = ProductCatalog(stub_config)
        self.associated_products_client = AssociatedProducts(stub_config)
Example #17
0
    def setup(self):
        parser = sample_cli.build_arg_parser()
        args = sample_util.process_cli_args(parser.parse_args())

        # Connect to vAPI services
        self.stub_config = vapiconnect.connect(
            host=args.server,
            user=args.username,
            pwd=args.password,
            skip_verification=args.skipverification)
 def __init__(self):
     parser = sample_cli.build_arg_parser()
     parser.add_argument(
         '-cpath',
         '--cert_path',
         action='store',
         help=
         'path to a CA_BUNDLE file or directory with certificates of trusted CAs'
     )
     args = parser.parse_args()
     self.args = process_cli_args(args)
    def __init__(self):
        self.policy_id = None
        self.vm_id = None
        self.vm_info = None

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

        parser.add_argument('-n',
                            '--name',
                            required=True,
                            help='Name of the policy')
        parser.add_argument('-d',
                            '--description',
                            required=False,
                            help='Description for the policy',
                            default='Sample policy description')
        parser.add_argument('-vn',
                            '--vmname',
                            required=True,
                            help='Name of the virtual machine')
        parser.add_argument('-hn',
                            '--hostname',
                            required=True,
                            help='Name of the host')
        parser.add_argument('-vt',
                            '--vmtag',
                            required=True,
                            help='Tag name to attach to the virtual machine')
        parser.add_argument('-ht',
                            '--hosttag',
                            required=True,
                            help='Tag name to attach to the host')

        # Parse the arguments.
        args = sample_util.process_cli_args(parser.parse_args())
        self.vm_name = args.vmname
        self.vm_tag_name = args.vmtag
        self.host_name = args.hostname
        self.host_tag_name = args.hosttag
        self.policy_name = args.name
        self.policy_desc = args.description
        self.cleardata = args.cleardata

        # Skip server cert verification if needed.
        # This is not recommended in production code.
        session = get_unverified_session() if args.skipverification else None

        # Connect to vSphere client.
        self.client = create_vsphere_client(server=args.server,
                                            username=args.username,
                                            password=args.password,
                                            session=session)
Example #20
0
 def __init__(self):
     parser = sample_cli.build_arg_parser()
     parser.add_argument('-id',
                         '--host',
                         required=True,
                         help='MOID of the source host for eg "host-13"')
     args = sample_util.process_cli_args(parser.parse_args())
     self.host_id = args.host
     config = get_configuration(args.server, args.username, args.password,
                                args.skipverification)
     self.api_client = CompatibilityReleases(config)
 def __init__(self):
     parser = sample_cli.build_arg_parser()
     parser.add_argument('-f', '--file_name',
                     help='Provide csv report file name.')
     args = sample_util.process_cli_args(parser.parse_args())
     self.csv_report = args.file_name
     session = get_unverified_session() if args.skipverification else None
     stub_config = get_configuration(
             args.server, args.username, args.password,
             session)
     self.report_client = Reports(stub_config)
Example #22
0
 def __init__(self):
     self.metadata = None
     self.userdata = None
     self.parser = sample_cli.build_arg_parser()
     self.args = sample_util.process_cli_args(self.parser.parse_args())
     self.session =\
         get_unverified_session() if self.args.skipverification else None
     self.client = create_vsphere_client(server=self.args.server,
                                         username=self.args.username,
                                         password=self.args.password,
                                         session=self.session)
     self.specs_svc = self.client.vcenter.guest.CustomizationSpecs
    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)
Example #24
0
    def __init__(self):
        parser = sample_cli.build_arg_parser()
        args = sample_util.process_cli_args(parser.parse_args())

        stub_config = get_configuration(args.server, args.username,
                                        args.password, args.skipverification)
        self.counters_client = Counters(stub_config)
        self.providers_client = Providers(stub_config)
        self.resource_types_client = ResourceTypes(stub_config)
        self.counter_metadata_client = CounterMetadata(stub_config)
        self.metrics_client = Metrics(stub_config)
        self.counter_sets_client = CounterSets(stub_config)
        self.resource_address_schemas_client = ResourceAddressSchemas(
            stub_config)
Example #25
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)
    def  __init__(self):
        # Create argument parser for standard inputs:
        # server, username, password and skipverification
        parser = sample_cli.build_arg_parser()
        args = sample_util.process_cli_args(parser.parse_args())

        # Skip server cert verification if needed.
        # This is not recommended in production code.
        session = get_unverified_session() if args.skipverification else None

        # Connect to vSphere client
        self.client = create_vsphere_client(server=args.server,
                                            username=args.username,
                                            password=args.password,
                                            session=session)
Example #27
0
    def __init__(self):
        parser = sample_cli.build_arg_parser()
        parser.add_argument(
            '--cluster',
            required=True,
            help='The MoID of the Supervisor Cluster to query.')

        args = sample_util.process_cli_args(parser.parse_args())
        session = get_unverified_session() if args.skipverification else None
        stub_config = get_configuration(args.server, args.username,
                                        args.password, session)
        self.cluster_supervisor_services = ClusterSupervisorServices(
            stub_config)
        self.versions = Versions(stub_config)
        self.cluster = args.cluster
Example #28
0
 def __init__(self):
     parser = sample_cli.build_arg_parser()
     args = sample_util.process_cli_args(parser.parse_args())
     session = get_unverified_session() if args.skipverification else None
     self.client = create_vsphere_client(server=args.server,
                                         username=args.username,
                                         password=args.password,
                                         session=session)
     self.specs_svc = self.client.vcenter.guest.CustomizationSpecs
     filePath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                             'sample_import.json')
     with open(filePath, 'r') as f:
         self.jsonDataRaw = f.read()
     self.specName = 'defaultCustSpec01'
     self.specsAdded = []
Example #29
0
    def setup(self):
        parser = build_arg_parser()
        parser.add_argument(
            '-cpath',
            '--cert_path',
            action='store',
            help=
            'path to a CA_BUNDLE file or directory with certificates of trusted CAs'
        )
        args = parser.parse_args()

        self.server, self.username, self.password, self.cleardata, self.skip_verification = \
            process_cli_args(args)

        if args.cert_path:
            self.cert_path = args.cert_path
Example #30
0
    def __init__(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

        session = get_unverified_session() if args.skipverification else None

        # Connect to vSphere client
        self.client = create_vsphere_client(server=args.server,
                                            username=args.username,
                                            password=args.password,
                                            session=session)