def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument('-v', '--vm_uuid',
                        required=True,
                        action='store',
                        help='Virtual machine uuid')

    parser.add_argument('-r', '--vm_user',
                        required=True,
                        action='store',
                        help='virtual machine user name')

    parser.add_argument('-w', '--vm_pwd',
                        required=False,
                        action='store',
                        help='virtual machine password')

    parser.add_argument('-t', '--path_to_script',
                        required=True,
                        action='store',
                        help='Local path where the script is')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
Ejemplo n.º 2
0
def get_args():
    """ Get commandline arguments from the user. """
    parser = cli.build_arg_parser()

    parser.add_argument('-v',
                        '--version',
                        required=False,
                        action='store',
                        default=None,
                        help='Virtual machine hardware version')
    parser.add_argument('-n',
                        '--name',
                        required=True,
                        action='store',
                        help='Name of the virtual machine to upgrade '
                        '(case sensitive!)')
    parser.add_argument(
        '-S',
        '--use-ssl',
        required=False,
        action='store_true',
        default=False,  # Test setups are usually self-signed
        help='Enable SSL host certificate verification')

    args = parser.parse_args()
    cli.prompt_for_password(args)
    return args
Ejemplo n.º 3
0
def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument('-v', '--vm_uuid',
                        required=False,
                        action='store',
                        help='Virtual machine uuid')

    parser.add_argument('-n', '--network_name',
                        required=False,
                        action='store',
                        help='Name of the network/portgroup')

    parser.add_argument('-d', '--is_VDS',
                        action="store_true",
                        default=False,
                        help='The provided network is in VSS or VDS')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument('-v', '--vm_uuid',
                        required=False,
                        action='store',
                        help='Virtual machine uuid')

    parser.add_argument('-n', '--network_name',
                        required=False,
                        action='store',
                        help='Name of the network/portgroup')

    parser.add_argument('-d', '--is_VDS',
                        action="store_true",
                        default=False,
                        help='The provided network is in VSS or VDS')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
Ejemplo n.º 5
0
def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument('-v', '--vm_uuid',
                        required=False,
                        action='store',
                        help='Virtual machine uuid')

    parser.add_argument('-r', '--vm_user',
                        required=False,
                        action='store',
                        help='virtual machine user name')

    parser.add_argument('-w', '--vm_pwd',
                        required=False,
                        action='store',
                        help='virtual machine password')

    parser.add_argument('-l', '--path_inside_vm',
                        required=False,
                        action='store',
                        help='Path inside VM for upload')

    parser.add_argument('-f', '--upload_file',
                        required=False,
                        action='store',
                        help='Path of the file to be uploaded from host')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument('-v', '--vm_uuid',
                        required=False,
                        action='store',
                        help='Virtual machine uuid')

    parser.add_argument('-r', '--vm_user',
                        required=False,
                        action='store',
                        help='virtual machine user name')

    parser.add_argument('-w', '--vm_pwd',
                        required=False,
                        action='store',
                        help='virtual machine password')

    parser.add_argument('-l', '--path_inside_vm',
                        required=False,
                        action='store',
                        help='Path inside VM for upload')

    parser.add_argument('-f', '--upload_file',
                        required=False,
                        action='store',
                        help='Path of the file to be uploaded from host')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
Ejemplo n.º 7
0
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-v', '--vm_name',
                        required=True,
                        action='store',
                        help='Name of the new VM')

    parser.add_argument('--template_name',
                        required=True,
                        action='store',
                        help='Name of the template/VM you are cloning from')

    parser.add_argument('--datacenter_name',
                        required=False,
                        action='store',
                        default=None,
                        help='Name of the Datacenter you wish to use.')

    parser.add_argument('--cluster_name',
                        required=False,
                        action='store',
                        default=None,
                        help='Name of the cluster you wish to use')

    parser.add_argument('--host_name',
                        required=False,
                        action='store',
                        default=None,
                        help='Name of the cluster you wish to use')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
Ejemplo n.º 8
0
def get_args():
    """Get command line args from the user.
    """
    parser = cli.build_arg_parser()
    args = parser.parse_args()
    cli.prompt_for_password(args)
    return args
def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument('-v', '--vm_uuid',
                        required=False,
                        action='store',
                        help='Virtual machine uuid')

    parser.add_argument('-r', '--vm_user',
                        required=False,
                        action='store',
                        help='virtual machine user name')

    parser.add_argument('-w', '--vm_pwd',
                        required=False,
                        action='store',
                        help='virtual machine password')

    parser.add_argument('-l', '--path_to_program',
                        required=False,
                        action='store',
                        help='Path inside VM to the program')

    parser.add_argument('-f', '--program_arguments',
                        required=False,
                        action='store',
                        help='Program command line options')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
Ejemplo n.º 10
0
def main():
    """
    Simple command-line script to listing all datastores and their free space
    """
    args = get_args()

    cli.prompt_for_password(args)

    sslContext = None

    if args.disable_ssl_verification:
        sslContext = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
        sslContext.verify_mode = ssl.CERT_NONE

    try:
        service_instance = connect.SmartConnect(host=args.host,
            user=args.user,
            pwd=args.password,
            port=int(args.port),
            sslContext=sslContext)
        if not service_instance:
            print("Could not connect to the specified host using specified "
                "username and password")
            return -1

        atexit.register(connect.Disconnect, service_instance)

        content = service_instance.RetrieveContent()
        # Search for all Datastores
        objview = content.viewManager.CreateContainerView(content.rootFolder,
            [vim.Datastore],
            True)
        datastores = objview.view
        objview.Destroy()

        datastore_space = {}
        for datastore in datastores:
            if not args.json:
                print_free(datastore)
            else:
                capacity = datastore.summary.capacity
                freeSpace = datastore.summary.freeSpace
                datastore_details = {
                    'capacity': capacity,
                    'bfree': freeSpace,
                    'pfree': "%2.2f" % (freeSpace*100.0/capacity)
                    }
                datastore_space[datastore.summary.name] = datastore_details

        if args.json:
            print(json.dumps(datastore_space))

    except vmodl.MethodFault as error:
        print("Caught vmodl fault : " + error.msg)
        return -1

    return 0
Ejemplo n.º 11
0
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n',
                        '--name',
                        required=False,
                        help="Move only from this Datastore.")
    parser.add_argument('-d',
                        '--destination',
                        required=False,
                        help="Migrate only to this datastore mask")
    parser.add_argument('-t',
                        '--target',
                        required=False,
                        help="Take only this VM mask")
    parser.add_argument(
        '-l',
        '--limit',
        required=False,
        help=
        "Do not touch datastores with free percentage above this limit. By default 11%%"
    )
    parser.add_argument('-v',
                        '--verbose',
                        required=False,
                        action='store_true',
                        help="Show what doing now.")
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
Ejemplo n.º 12
0
def get_args():
    """
    Adds additional args for deleting a fcd

    -d datastore
    -v vdisk
    -y yes
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-d',
                        '--datastore',
                        required=True,
                        action='store',
                        help='Datastore name where disk is located')

    parser.add_argument('-v',
                        '--vdisk',
                        required=True,
                        action='store',
                        help='First Class Disk name to be deleted')

    parser.add_argument('-y',
                        '--yes',
                        action='store_true',
                        help='Confirm disk deletion.')

    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
Ejemplo n.º 13
0
def get_args():
    """
    Adds additional args for detaching a disk from a vm

    -n vm_name
    -i uuid
    -d disknumber
    -l language
    """
    parser = cli.build_arg_parser()

    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n',
                       '--vm_name',
                       action='store',
                       help='Virtual Machine name where disk is attached')

    group.add_argument('-i',
                       '--uuid',
                       action='store',
                       help='Virtual Machine UUID where disk is attached')

    parser.add_argument('-d',
                        '--disknumber',
                        required=True,
                        help='HDD number to detach.',
                        type=int)

    parser.add_argument('-l',
                        '--language',
                        default='English',
                        help='Language your vcenter used.')

    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    """
    Adds additional args for deleting a snapshot of a fcd

    -d datastore
    -v vdisk
    -n snapshot
    -y yes
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-d', '--datastore',
                        required=True,
                        action='store',
                        help='Datastore name where disk is located')

    parser.add_argument('-v', '--vdisk',
                        required=False,
                        action='store',
                        help='First Class Disk name to delete snapshot for')

    # because -s is reserved for 'service', we use -n for snapshot name
    parser.add_argument('-n', '--snapshot',
                        required=True,
                        action='store',
                        help='Snapshot name to be deleted')

    parser.add_argument('-y', '--yes',
                        action='store_true',
                        help='Confirm disk deletion.')

    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
Ejemplo n.º 15
0
def get_args():
    """
    Use the tools.cli methods and then add a few more arguments.
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-c',
                        '--count',
                        type=int,
                        required=True,
                        action='store',
                        help='Number of VMs to create')

    parser.add_argument('-d',
                        '--datastore',
                        required=True,
                        action='store',
                        help='Name of Datastore to create VM in')

    parser.add_argument('--datacenter',
                        required=True,
                        help='Name of the datacenter to create VM in.')

    parser.add_argument('--folder',
                        required=True,
                        help='Name of the vm folder to create VM in.')

    parser.add_argument('--resource-pool',
                        required=True,
                        help='Name of resource pool to create VM in.')

    parser.add_argument('--opaque-network',
                        help='Name of the opaque network to add to the new VM')

    # NOTE (hartsock): as a matter of good security practice, never ever
    # save a credential of any kind in the source code of a file. As a
    # matter of policy we want to show people good programming practice in
    # these samples so that we don't encourage security audit problems for
    # people in the future.

    parser.add_argument('-k',
                        '--public_key_file',
                        required=False,
                        action='store',
                        help='Name of the file holding your marvel public key,'
                        ' the key should be the first only of the file. '
                        'Set one up at developer.marvel.com/account')

    parser.add_argument('-e',
                        '--private_key_file',
                        required=False,
                        action='store',
                        help='Name of the file holding your marvel private '
                        'key, the key should be the only line of the '
                        'file. '
                        'Set one up at developer.marvel.com/account')

    args = parser.parse_args()

    return cli.prompt_for_password(args)
Ejemplo n.º 16
0
def setup_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--property', default='runtime.powerState',
                        help='Name of the property to filter by')
    parser.add_argument('-v', '--value', default='poweredOn',
                        help='Value to filter with')
    return cli.prompt_for_password(parser.parse_args())
Ejemplo n.º 17
0
def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument('-a',
                        '--action',
                        required=True,
                        action='store',
                        help='Virtual machine action: start, stop or suspend')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
Ejemplo n.º 18
0
def get_args():
    """
    Adds additional args for creating a snapshot of a fcd

    -d datastore
    -v vdisk
    -n snapshot
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-d',
                        '--datastore',
                        required=True,
                        action='store',
                        help='Datastore name where disk is located')

    parser.add_argument('-v',
                        '--vdisk',
                        required=True,
                        action='store',
                        help='First Class Disk name to create snapshot for')

    # because -s is reserved for 'service', we use -n for snapshot name
    parser.add_argument('-n',
                        '--snapshot',
                        required=True,
                        action='store',
                        help='New snapshot name')

    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
Ejemplo n.º 19
0
def get_args():
    parser = cli.build_arg_parser()

    parser.add_argument('-d',
                        '--datastore',
                        required=True,
                        help='Name of Datastore to create VM in')

    parser.add_argument('-folder',
                        required=True,
                        help='Name of the vm folder to create VM in.')

    parser.add_argument('-Rpool',
                        required=True,
                        help='Name of resource pool to create VM in.')

    parser.add_argument('-vmname', required=True, help='Name of VM to create')

    parser.add_argument('-nw', required=True, help='Name of network.')

    parser.add_argument('-iso_path', required=True, help='ISO path.')

    args = parser.parse_args()

    return cli.prompt_for_password(args)
Ejemplo n.º 20
0
def get_args():
    """Supports the command-line arguments listed below.
    """
    parser = cli.build_arg_parser()
    parser.description = 'Set VM Home or Virtual Disk Storage Policies'
    parser.add_argument('-v',
                        '--vm_name',
                        required=True,
                        action='store',
                        metavar='string',
                        help='Get virtual machine by name')
    parser.add_argument('--strict',
                        required=False,
                        action='store_true',
                        help='Search strict virtual machine name matches')
    parser.add_argument('--set_vm_home',
                        required=False,
                        action='store_true',
                        help='Set the specified policy for vm home.')
    parser.add_argument(
        '--virtual_disk_number',
        required=False,
        nargs='+',
        metavar='int',
        help='The sequence numbers of the virtual disks for which \
                              the specified policy should be set. \
                              Space as delimiter.')
    parser.add_argument('--storage_policy_name',
                        required=True,
                        action='store',
                        metavar='string',
                        help='The name of the storage policy to be set for VM \
                              Home or Virtual Disk')
    args = parser.parse_args()
    return cli.prompt_for_password(args)
def setup_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--property', default='runtime.powerState',
                        help='Name of the property to filter by')
    parser.add_argument('-v', '--value', default='poweredOn',
                        help='Value to filter with')
    return cli.prompt_for_password(parser.parse_args())
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-d',
                        '--datastore',
                        required=True,
                        action='store',
                        help='Datastore name')
    parser.add_argument('-l',
                        '--local_file',
                        required=True,
                        action='store',
                        help='Local disk path to file')
    parser.add_argument('-r',
                        '--remote_file',
                        required=True,
                        action='store',
                        help='Path on datastore to place file')
    parser.add_argument('-S',
                        '--disable_ssl_verification',
                        required=False,
                        action='store_true',
                        help='Disable ssl host certificate verification')
    args = parser.parse_args()

    return cli.prompt_for_password(args)
Ejemplo n.º 23
0
def setup_args():
    parser = cli.build_arg_parser()
    parser.add_argument('command', help="Can be 'create', 'remove', or 'list'")
    parser.add_argument('-v',
                        '--name',
                        required=False,
                        help="dns name of the vm to get snapshotted")
    parser.add_argument(
        '-l',
        '--vmlist',
        required=False,
        help="list of DNS names for many VMs to be snapshotted")
    parser.add_argument('-i',
                        '--instance',
                        required=False,
                        action='store_true',
                        help="Flag to indicate the UUID is an instance UUID")
    parser.add_argument('-d',
                        '--description',
                        required=False,
                        help="Description for the snapshot")
    parser.add_argument('-n',
                        '--snapshotname',
                        required=False,
                        help="Name for the Snapshot")

    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    """
    Adds additional args for deleting a fcd

    -d datastore
    -v vdisk
    -y yes
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-d', '--datastore',
                        required=True,
                        action='store',
                        help='Datastore name where disk is located')

    parser.add_argument('-v', '--vdisk',
                        required=True,
                        action='store',
                        help='First Class Disk name to be deleted')

    parser.add_argument('-y', '--yes',
                        action='store_true',
                        help='Confirm disk deletion.')

    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    """
    Adds additional args for detaching a disk from a vm

    -n vm_name
    -i uuid
    -d disknumber
    -l language
    """
    parser = cli.build_arg_parser()

    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n', '--vm_name',
                       action='store',
                       help='Virtual Machine name where disk is attached')

    group.add_argument('-i', '--uuid',
                       action='store',
                       help='Virtual Machine UUID where disk is attached')

    parser.add_argument('-d', '--disknumber',
                        required=True,
                        help='HDD number to detach.',
                        type=int)

    parser.add_argument('-l', '--language',
                        default='English',
                        help='Language your vcenter used.')

    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def setup_args():
    parser = cli.build_arg_parser()
    parser.add_argument('--ova-path',
                        help='Path to the OVA file, can be local or a URL.')
    parser.add_argument('-d',
                        '--datacenter',
                        help='Name of datacenter to search on. '
                        'Defaults to first.')
    parser.add_argument('-r',
                        '--resource-pool',
                        help='Name of resource pool to use. '
                        'Defaults to largest memory free.')
    parser.add_argument('-ds',
                        '--datastore',
                        help='Name of datastore to use. '
                        'Defaults to largest free space in datacenter.')
    parser.add_argument('-network',
                        '--network',
                        required=False,
                        help='name of network to deploy')
    parser.add_argument('-defaultServerName',
                        '--defaultServerName',
                        required=True,
                        help='set the default name of server')
    return cli.prompt_for_password(parser.parse_args())
Ejemplo n.º 27
0
def setup_args():
    """Adds additional ARGS to allow the vm name or uuid to
    be set.
    """
    parser = cli.build_arg_parser()
    # using j here because -u is used for user
    parser.add_argument('-j',
                        '--uuid',
                        help='BIOS UUID of the VirtualMachine you want '
                        'to destroy.')
    parser.add_argument('-n',
                        '--name',
                        help='DNS Name of the VirtualMachine you want to '
                        'destroy.')
    parser.add_argument('-i',
                        '--ip',
                        help='IP Address of the VirtualMachine you want to '
                        'destroy')
    parser.add_argument('-v',
                        '--vm',
                        help='VM name of the VirtualMachine you want '
                        'to destroy.')

    my_args = parser.parse_args()

    return cli.prompt_for_password(my_args)
Ejemplo n.º 28
0
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n',
                        '--name',
                        required=False,
                        help="Name of the Datastore.")
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
Ejemplo n.º 29
0
def setup_args():
    """
    Get standard connection arguments
    """
    parser = cli.build_arg_parser()
    my_args = parser.parse_args()

    return cli.prompt_for_password(my_args)
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n',
                        '--vmname',
                        required=False,
                        help="Name of the VirtualMachine you want to change.")
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
Ejemplo n.º 31
0
def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument('-v',
                        '--vm_uuid',
                        required=False,
                        action='store',
                        help='Virtual machine uuid')

    parser.add_argument('-i',
                        '--ip',
                        required=False,
                        action='store',
                        help='IP address of the VM to search for')

    parser.add_argument('-r',
                        '--vm_user',
                        required=False,
                        action='store',
                        help='virtual machine user name')

    parser.add_argument('-w',
                        '--vm_pwd',
                        required=False,
                        action='store',
                        help='virtual machine password')

    parser.add_argument('-l',
                        '--path_to_program',
                        required=False,
                        action='store',
                        help='Path inside VM to the program')

    parser.add_argument('-f',
                        '--program_arguments',
                        required=False,
                        action='store',
                        help='Program command line options')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
def setup_args():

    """
    Get standard connection arguments
    """
    parser = cli.build_arg_parser()
    my_args = parser.parse_args()

    return cli.prompt_for_password(my_args)
Ejemplo n.º 33
0
def setup_args():
    """
    Adds additional args to allow the vm uuid to
    be set.
    """
    parser = cli.build_arg_parser()
    parser.add_argument('--vm-name', help="Name of the virtual machine.")
    parser.add_argument('--ignition-config', help="Path to ignition config.")
    return cli.prompt_for_password(parser.parse_args())
Ejemplo n.º 34
0
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-f', '--find',
                        required=False,
                        action='store',
                        help='String to match VM names')
    args = parser.parse_args()

    return cli.prompt_for_password(args)
def get_args():
    """
    Use the tools.cli methods and then add a few more arguments.
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-c', '--count',
                        type=int,
                        required=True,
                        action='store',
                        help='Number of VMs to create')

    parser.add_argument('-d', '--datastore',
                        required=True,
                        action='store',
                        help='Name of Datastore to create VM in')

    parser.add_argument('--datacenter',
                        required=True,
                        help='Name of the datacenter to create VM in.')

    parser.add_argument('--folder',
                        required=True,
                        help='Name of the vm folder to create VM in.')

    parser.add_argument('--resource-pool',
                        required=True,
                        help='Name of resource pool to create VM in.')

    parser.add_argument('--opaque-network',
                        help='Name of the opaque network to add to the new VM')

    # NOTE (hartsock): as a matter of good security practice, never ever
    # save a credential of any kind in the source code of a file. As a
    # matter of policy we want to show people good programming practice in
    # these samples so that we don't encourage security audit problems for
    # people in the future.

    parser.add_argument('-k', '--public_key_file',
                        required=False,
                        action='store',
                        help='Name of the file holding your marvel public key,'
                             ' the key should be the first only of the file. '
                             'Set one up at developer.marvel.com/account')

    parser.add_argument('-e', '--private_key_file',
                        required=False,
                        action='store',
                        help='Name of the file holding your marvel private '
                             'key, the key should be the only line of the '
                             'file. '
                             'Set one up at developer.marvel.com/account')

    args = parser.parse_args()

    return cli.prompt_for_password(args)
Ejemplo n.º 36
0
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--vmname', required=True,
                        help="Name of the VirtualMachine you want to change.")
    parser.add_argument('-m', '--unitnumber', required=True,
                        help='HDD number to delete.', type=int)
    parser.add_argument('-y', '--yes',
                        help='Confirm disk deletion.', action='store_true')
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    """Get command line args from the user.
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-v', '--vm_name',
                        required=True,
                        action='store',
                        help='Virtual machine name')

    parser.add_argument('-n', '--network_name',
                        required=True,
                        action='store',
                        help='Name of the portgroup or NSX-T Logical Switch')

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--vmname', required=True,
                        help="Name of the VirtualMachine you want to change.")
    parser.add_argument('-m', '--unitnumber', required=True,
                        help='NIC number.', type=int)
    parser.add_argument('-t', '--state', required=True,
                        choices=['delete', 'disconnect', 'connect'])
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--vmname', required=True,
                        help="Name of the VirtualMachine you want to change.")
    parser.add_argument('-m', '--unitnumber', required=True,
                        help='HDD number to delete.', type=int)
    parser.add_argument('-y', '--yes',
                        help='Confirm disk deletion.', action='store_true')
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--vmname', required=True,
                        help="Name of the VirtualMachine you want to change.")
    parser.add_argument('-m', '--unitnumber', required=True,
                        help='NIC number.', type=int)
    parser.add_argument('-t', '--state', required=True,
                        choices=['delete', 'disconnect', 'connect'])
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
Ejemplo n.º 41
0
def setup_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--name',
                        help='Name of the VM to test CD-rom on')
    parser.add_argument('-i', '--iso',
                        help='ISO to use in test. Use datastore path format. '
                              'E.g. [datastore1] path/to/file.iso')
    parser.add_argument('-d', '--datacenter',
                        help='Name of datacenter to search on. '
                             'Defaults to first.')
    return cli.prompt_for_password(parser.parse_args())
def setup_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--name',
                        help='Name of the VM for relocate events')
    parser.add_argument('-d', '--datacenter',
                        help='Name of datacenter to search on. '
                             'Defaults to first.')
    parser.add_argument('--filterUsers',
                        help="Comma-separated list of users to filter on")
    parser.add_argument('--filterSystemUser', action='store_true',
                        help="Filter system user, defaults to false.")
    return cli.prompt_for_password(parser.parse_args())
def get_args():
    parser = cli.build_arg_parser()

    parser.add_argument('-v',
                        '--vswitch',
                        type=str,
                        action='store',
                        help='standard vSwitch name for creation',
                        required=True)
    args = parser.parse_args()

    return cli.prompt_for_password(args)
Ejemplo n.º 44
0
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--vmname', required=True,
                        help="Name of the VirtualMachine you want to change.")
    parser.add_argument('-m', '--unitnumber', required=True,
                        help='CD/DVD unit number.', type=int)
    parser.add_argument('-i', '--iso', required=False,
                        help='Full path to iso. i.e. "[ds1] folder/Ubuntu.iso"'
                             ' If not provided, backend will'
                             ' set to RemotePassThrough')
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    """
    Adds additional args for creating a fcd from a snapshot

    -d source_datastore
    -v source_vdisk
    -n snapshot
    -D dest_datastore
    -V dest_vdisk
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-d',
                        '--source_datastore',
                        required=True,
                        action='store',
                        help='Datastore name where source disk is located')

    parser.add_argument('-v',
                        '--source_vdisk',
                        required=True,
                        action='store',
                        help='First Class Disk name with specified snapshot')

    # because -s is reserved for 'service', we use -n for snapshot name
    parser.add_argument('-n',
                        '--snapshot',
                        required=True,
                        action='store',
                        help='Snapshot name to be cloned')

    parser.add_argument('-D',
                        '--dest_datastore',
                        required=True,
                        action='store',
                        help='Datastore name where new disk is located')

    parser.add_argument('-V',
                        '--dest_vdisk',
                        required=True,
                        action='store',
                        help='First Class Disk name to be created')

    # because -s is reserved for 'service' and -p is reserved for 'password'
    parser.add_argument('-e',
                        '--policy',
                        action='store',
                        help='Storage Policy name for new disk. If unset, '
                        'the default policy of the datastore specified '
                        'will apply.')

    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def setup_args():
    """
    Adds additional args to allow the vm uuid to
    be set.
    """
    parser = cli.build_arg_parser()
    # using j here because -u is used for user
    parser.add_argument('-j', '--uuid',
                        required=True,
                        help='UUID of the VirtualMachine you want to reboot.')
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-n', '--vmname', required=True,
                        help="Name of the VirtualMachine you want to change.")
    parser.add_argument('-m', '--unitnumber', required=True,
                        help='CD/DVD unit number.', type=int)
    parser.add_argument('-i', '--iso', required=False,
                        help='Full path to iso. i.e. "[ds1] folder/Ubuntu.iso"'
                             ' If not provided, backend will'
                             ' set to RemotePassThrough')
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def main():
    """
    Simple command-line program for listing all ESXi datastores and their
    associated devices
    """

    args = get_args()

    cli.prompt_for_password(args)

    try:
        service_instance = connect.SmartConnect(host=args.host,
                                                user=args.user,
                                                pwd=args.password,
                                                port=int(args.port))
        if not service_instance:
            print("Could not connect to the specified host using specified "
                  "username and password")
            return -1

        atexit.register(connect.Disconnect, service_instance)

        content = service_instance.RetrieveContent()
        # Search for all ESXi hosts
        objview = content.viewManager.CreateContainerView(content.rootFolder,
                                                          [vim.VirtualMachine],
                                                          True)
        vms = objview.view
        objview.Destroy()

        for vm in vms:
            if vm.name == args.vm_name:
                print "VM {} is {}".format(vm.name, vm.runtime.powerState)
                break

    except vmodl.MethodFault as error:
        print "Caught vmodl fault : " + error.msg
        return -1

    return 0
def get_args():
    """Get command line args from the user.
    """

    parser = cli.build_arg_parser()

    parser.add_argument("-v", "--vm_uuid", required=False, action="store", help="Virtual machine uuid")

    parser.add_argument("-r", "--vm_user", required=False, action="store", help="virtual machine user name")

    parser.add_argument("-w", "--vm_pwd", required=False, action="store", help="virtual machine password")

    parser.add_argument("-l", "--path_inside_vm", required=False, action="store", help="Path inside VM for upload")

    parser.add_argument(
        "-f", "--upload_file", required=False, action="store", help="Path of the file to be uploaded from host"
    )

    args = parser.parse_args()

    cli.prompt_for_password(args)
    return args
def get_args():
    """
    Add VM name to args
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-n', '--name',
                        required=True,
                        help='Name of Virtual Machine.')

    args = parser.parse_args()

    return cli.prompt_for_password(args)
def setup_args():
    """
    Adds additional ARG to allow the uuid to be set.
    """
    parser = cli.build_arg_parser()
    # using j here because -u is used for user
    parser.add_argument('-j', '--uuid',
                        help='UUID of the HostSystem you want to find'
                             ' duplicate of if not looking for the default'
                             ' Dell UUID: 44454C4C-0000-1020-8020-80C04F202020')

    my_args = parser.parse_args()

    return cli.prompt_for_password(my_args)
def get_args():
    """ Get commandline arguments from the user. """
    parser = cli.build_arg_parser()

    parser.add_argument('-v', '--version',
                        required=False,
                        action='store',
                        default=None,
                        help='Virtual machine hardware version')
    parser.add_argument('-n', '--name',
                        required=True,
                        action='store',
                        help='Name of the virtual machine to upgrade '
                             '(case sensitive!)')
    parser.add_argument('-S', '--use-ssl',
                        required=False,
                        action='store_true',
                        default=False,  # Test setups are usually self-signed
                        help='Enable SSL host certificate verification')

    args = parser.parse_args()
    cli.prompt_for_password(args)
    return args
def setup_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-j', '--uuid', required=True,
                        help="UUID of the VirtualMachine you want to find."
                             " If -i is not used BIOS UUID assumed.")
    parser.add_argument('-i', '--instance', required=False,
                        action='store_true',
                        help="Flag to indicate the UUID is an instance UUID")
    parser.add_argument('-d', '--description', required=False,
                        help="Description for the snapshot")
    parser.add_argument('-n', '--name', required=True,
                        help="Name for the Snapshot")
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def setup_args():
    parser = cli.build_arg_parser()
    # parser.add_argument('-j', '--uuid', required=False,
    #                     help="UUID of the VirtualMachine you want to find."
    #                          " If -i is not used BIOS UUID assumed.")
    # parser.add_argument('-i', '--instance', required=False,
    #                     action='store_true',
    #                     help="Flag to indicate the UUID is an instance UUID")
    parser.add_argument('-n', '--name', 
                        required=False,
                        action='store',
                        help="name of VirtualMachine")
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    """
    Adds additional args for the Dvs portgroup configuration
    """
    parser = cli.build_arg_parser()

    parser.add_argument('-ds', '--dvs-name',
                        required=True,
                        help=' Name of the distributed virtual switch')

    parser.add_argument('-pg', '--dvs-pg-name',
                        required=True,
                        help="Name of the distributed port group")
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-d', '--uuid',
                        required=True,
                        action='store',
                        help='Instance UUID of the VM to look for.')
    parser.add_argument('-n', '--name',
                        required=False,
                        action='store',
                        help='The ovf:id to use for the top-level OVF Entity.')
    parser.add_argument('-w', '--workdir',
                        required=True,
                        action='store',
                        help='Working directory. Must have write permission.')
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument('-d', '--datastore',
                        required=True,
                        action='store',
                        help='Datastore name')
    parser.add_argument('-l', '--local_file',
                        required=True,
                        action='store',
                        help='Local disk path to file')
    parser.add_argument('-r', '--remote_file',
                        required=True,
                        action='store',
                        help='Path on datastore to place file')
    args = parser.parse_args()

    return cli.prompt_for_password(args)
Ejemplo n.º 58
0
def setup_args():
    """Adds additional ARGS to allow the vm name or uuid to
    be set.
    """
    parser = cli.build_arg_parser()
    # using j here because -u is used for user
    parser.add_argument('-j', '--uuid',
                        help='UUID of the VirtualMachine you want to reboot.')
    parser.add_argument('-n', '--name',
                        help='DNS Name of the VirtualMachine you want to '
                             'reboot.')
    parser.add_argument('-i', '--ip',
                        help='IP Address of the VirtualMachine you want to '
                             'reboot')

    my_args = parser.parse_args()

    return cli.prompt_for_password(my_args)
def get_args():
    parser = cli.build_arg_parser()
    parser.add_argument("-v", "--vmname", required=True, help="Name of the VirtualMachine you want to change.")
    parser.add_argument("-d", "--disk-number", required=True, help="Disk number to change mode.")
    parser.add_argument(
        "-m",
        "--mode",
        required=True,
        choices=[
            "independent_persistent",
            "persistent",
            "independent_nonpersistent",
            "nonpersistent",
            "undoable",
            "append",
        ],
    )
    my_args = parser.parse_args()
    return cli.prompt_for_password(my_args)