def setup(context=None):
    global vm_name, stub_config, service_instance, cleardata
    if context:
        # Run sample suite via setup script
        stub_config = context.stub_config
        vm_name = testbed.config['VM_NAME_DEFAULT']
        service_instance = context.service_instance
    else:
        # Run sample in standalone mode
        server, username, password, cleardata, skip_verification, vm_name = \
            parse_cli_args_vm(testbed.config['VM_NAME_DEFAULT'])
        stub_config = vapiconnect.connect(server, username, password,
                                          skip_verification)
        atexit.register(vapiconnect.logout, stub_config)

        context = None
        if skip_verification:
            context = get_unverified_context()
        service_instance = SmartConnect(host=server,
                                        user=username,
                                        pwd=password,
                                        sslContext=context)
        atexit.register(Disconnect, service_instance)
示例#2
0
    def run(self):
        print('\n\n#### Example: Login to vCenter server with '
              'Valid Cert Verification')
        # Connect to VAPI
        self.stub_config = vapiconnect.connect(self.server,
                                               self.username,
                                               self.password,
                                               self.skip_verification,
                                               cert_path=self.cert_path)
        atexit.register(vapiconnect.logout, self.stub_config)

        # Create and Delete TagCategory to Verify connection is successful
        print('\nStep 3: Creating and Deleting Tag Category...\n')
        self.category_svc = Category(self.stub_config)

        self.category_id = self.create_tag_category(
            'TestTagCat', 'TestTagDesc', CategoryModel.Cardinality.MULTIPLE)
        assert self.category_id is not None
        print('Tag category created; Id: {0}\n'.format(self.category_id))

        # Delete TagCategory
        self.category_svc.delete(self.category_id)

        print('VAPI session disconnected successfully...')
示例#3
0

print(_testbed.to_config_string())

# Connect to VIM API Endpoint on vCenter system
context = None
if args.skipverification:
    context = get_unverified_context()
service_instance = pyVim.connect.SmartConnect(host=_testbed.config['SERVER'],
                                              user=_testbed.config['USERNAME'],
                                              pwd=_testbed.config['PASSWORD'],
                                              sslContext=context)

# Connect to vAPI Endpoint on vCenter system
stub_config = vapiconnect.connect(host=_testbed.config['SERVER'],
                                  user=_testbed.config['USERNAME'],
                                  pwd=_testbed.config['PASSWORD'],
                                  skip_verification=args.skipverification)

context = sample_util.Context(_testbed, service_instance, stub_config)

context.option['DO_TESTBED_SETUP'] = args.testbed_setup
context.option['DO_TESTBED_VALIDATE'] = args.testbed_validate
context.option['DO_TESTBED_CLEANUP'] = args.testbed_cleanup
context.option['DO_TESTBED_ISO_CLEANUP'] = args.iso_cleanup
context.option['DO_SAMPLES_SETUP'] = args.samples_setup
context.option['DO_SAMPLES'] = args.samples
context.option['DO_SAMPLES_INCREMENTAL'] = args.samples_incremental
context.option['DO_SAMPLES_CLEANUP'] = args.samples_cleanup
context.option['SKIP_VERIFICATION'] = args.skipverification
print(context.to_option_string())
示例#4
0
    def __init__(self):
        parser = argparse.ArgumentParser()

        parser.add_argument('-s',
                            '--server',
                            required=True,
                            help='vSphere service IP to connect to')

        parser.add_argument('-u',
                            '--username',
                            required=True,
                            help='Username to use when connecting to vc')

        parser.add_argument('-p',
                            '--password',
                            required=True,
                            help='Password to use when connecting to vc')

        parser.add_argument('--foreignhost',
                            required=True,
                            help='FOREIGN PSC HOSTNAME.')

        parser.add_argument(
            '--foreignusername',
            required=True,
            help='Administrator username for the foreign domain. '
            'Eg - Administrator')

        parser.add_argument(
            '--foreignpassword',
            required=True,
            help='Administrator password for the foreign domain.')

        parser.add_argument(
            '--foreigndomain',
            required=True,
            help='SSO Domain name for the foreign PSC. Eg - vsphere.local')

        parser.add_argument(
            '--foreignport',
            required=False,
            default='443',
            help='SSO Domain name for the foreign PSC. Eg - vsphere.local')

        parser.add_argument('-v',
                            '--skipverification',
                            action='store_true',
                            help='OPTIONAL: Foreign HTTPS Port. Default: 443')

        parser.add_argument('-c',
                            '--cleardata',
                            action='store_true',
                            help='Clean up after sample run')

        args = parser.parse_args()

        # Login to vCenter
        stub_config = vapiconnect.connect(host=args.server,
                                          user=args.username,
                                          pwd=args.password)

        # Create links stub
        self.links_client = Links(stub_config)

        self.foreignhost = args.foreignhost
        self.foreignusername = args.foreignusername
        self.foreignpassword = args.foreignpassword
        self.foreigndomain = args.foreigndomain
        self.foreignport = args.foreignport
        self.cleanup = args.cleardata
        self.linked_domain_id = None
示例#5
0
    def setup(self):
        parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)

        parser.add_argument('--server',
                            required=True,
                            action='store',
                            help='FQDN of the VCSA')

        parser.add_argument('--server-user',
                            required=True,
                            action='store',
                            help='Username for the VCSA')

        parser.add_argument('--server-password',
                            required=True,
                            action='store',
                            help='Password for the VCSA')

        parser.add_argument('-v', '--skipverification',
                            required=False,
                            action='store_true',
                            help='Skip SSL Verification')

        parser.add_argument('--location',
                            required=False,
                            action='store',
                            help='URL of the backup location')

        parser.add_argument('--location-user',
                            required=False,
                            action='store',
                            help='Username for the given location')

        parser.add_argument('--location-password',
                            required=False,
                            action='store',
                            help='Password for the given location')

        parser.add_argument('--backup-password',
                            required=False,
                            action='store',
                            help='Password for the backup')

        parser.add_argument('--backup-comment',
                            required=False,
                            action='store',
                            help='Comment for the backup')

        parser.add_argument('-lb', '--list-backup',
                    required=False,
                    action='store_true',
                    help='Switch to list backup jobs')

        parser.add_argument('-gb', '--get-backup',
                    required=False,
                    action='store',
                    help='Backup Job ID to Get Information About')

        parser.add_argument('-nb', '--create-backup',
                    required=False,
                    action='store_true',
                    help='Switch to create backup job')                    

        parser.add_argument('-cb', '--cancel-backup',
                    required=False,
                    action='store',
                    help='Backup Job ID to Cancel Job')

        args = parser.parse_args()

        self.server = args.server
        self.server_user = args.server_user
        self.server_password = args.server_password
        self.location = args.location
        self.location_user = args.location_user
        self.location_password = args.location_password
        self.backup_password = args.backup_password
        self.backup_comment = args.backup_comment
        self.list_backup = args.list_backup
        self.get_backup = args.get_backup
        self.create_backup = args.create_backup
        self.cancel_backup = args.cancel_backup

        # Connect to vAPI services
        self.stub_config = vapiconnect.connect(
                                    host=self.server,
                                    user=self.server_user,
                                    pwd=self.server_password,
                                    skip_verification="TRUE")

        self.job_client = Job(self.stub_config)
def setup(context=None):
    global stub_config, cleardata
    server, username, password, cleardata, skip_verification = parse_cli_args()
    stub_config = vapiconnect.connect(server, username, password,
                                      skip_verification)
    atexit.register(vapiconnect.logout, stub_config)