def add_subparser(subparsers): description = """Add a new VM.""" epilog = """Configuration items should be specified in DAEMON:KEY:VALUE format, either as a series of --config arguments, or using the --config-file argument with a file containing one configuration item per line.""" parser = subparsers.add_parser("add-vm", help="add new VM", description=description, epilog=epilog) arguments.add_output_args(parser, field="vm_uuid") _add_config_args(parser) parser.add_argument("-d", "--disk", metavar="DISK_UUID", action=arguments.AppendNonEmptyValue, default=[], help="disk uuid (can be specified multiple times)") parser.add_argument("name", metavar="VM_NAME", action=arguments.StoreSingleNonEmptyValue, help="VM name") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Add a new device.""" epilog = """Configuration items should be specified in DAEMON:KEY:VALUE format, either as a series of --config arguments, or using the --config-file argument with a file containing one configuration item per line.""" parser = subparsers.add_parser("add-device", help="add new device", description=description, epilog=epilog) arguments.add_output_args(parser, field="device_uuid") _add_config_args(parser) parser.add_argument("-r", "--repo", metavar="REPO_UUID", action=arguments.StoreSingleNonEmptyValue, help="repository uuid") parser.add_argument("name", metavar="DEVICE_NAME", action=arguments.StoreSingleNonEmptyValue, help="device name") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Add a new device.""" epilog = """Configuration items should be specified in DAEMON:KEY:VALUE format, either as a series of --config arguments, or using the --config-file argument with a file containing one configuration item per line.""" parser = subparsers.add_parser("add-device", help="add new device", description=description, epilog=epilog) arguments.add_output_args(parser, field="device_uuid") _add_config_args(parser) parser.add_argument("-r", "--repo", metavar="REPO_UUID", action=arguments.StoreSingleNonEmptyValue, help="repository uuid") parser.add_argument("name", metavar="DEVICE_NAME", action=arguments.StoreSingleNonEmptyValue, help="device name") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Remove a VM instance from a device. Information about the VM instance is retained, but can be permanently removed with the purge-vm-instance command.""" epilog = """By default, the device will wait until the VM instance is no longer running before removing it. With the --hard argument, the device will force the VM instance to shut down and remove it.""" parser = subparsers.add_parser("remove-vm-instance", help="remove VM instance", description=description, epilog=epilog) arguments.add_output_args(parser, suppress=True) parser.add_argument("--hard", action="store_true", help="don't wait until VM instance is shut down") parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Remove a VM instance from a device. Information about the VM instance is retained, but can be permanently removed with the purge-vm-instance command.""" epilog = """By default, the device will wait until the VM instance is no longer running before removing it. With the --hard argument, the device will force the VM instance to shut down and remove it.""" parser = subparsers.add_parser("remove-vm-instance", help="remove VM instance", description=description, epilog=epilog) arguments.add_output_args(parser, suppress=True) parser.add_argument("--hard", action="store_true", help="don't wait until VM instance is shut down") parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Add a new repository.""" parser = subparsers.add_parser("add-repo", help="add new repository", description=description) arguments.add_output_args(parser, field="repo_uuid") parser.add_argument("file_path", metavar="FILE_PATH", action=arguments.StoreSingleNonEmptyValue, help="path to file") parser.add_argument("--release", metavar="RELEASE", action=arguments.StoreSingleNonEmptyValue, help="assume release is RELEASE rather than extract " "it from file") parser.add_argument("--build", metavar="BUILD", action=arguments.StoreSingleNonEmptyValue, help="assume build is BUILD rather than extract it " "from file") parser.add_argument("--hash", metavar="FILE_HASH", action=arguments.StoreSingleValue, help="assume SHA-256 checksum of file is FILE_HASH " "rather than compute it") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Add a new VM instance to a device.""" parser = subparsers.add_parser("add-vm-instance", help="add new VM instance", description=description) arguments.add_output_args(parser, field="vm_instance_uuid") parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.add_argument("vm", metavar="VM_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM uuid") parser.add_argument("name", metavar="VM_INSTANCE_NAME", action=arguments.StoreSingleNonEmptyValue, help="VM instance name") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Verify the integrity of the database.""" parser = subparsers.add_parser("verify-database", help="verify database", description=description) arguments.add_output_args(parser, suppress=True) parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show licensing information.""" parser = subparsers.add_parser("show-licensing", help="show licensing information", description=description) arguments.add_output_args(parser) parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """List devices.""" parser = subparsers.add_parser("list-devices", help="list devices", description=description) arguments.add_output_args(parser, field="device_uuid") _add_filter_args(parser) parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """List repositories.""" parser = subparsers.add_parser("list-repos", help="list repositories", description=description) arguments.add_output_args(parser, field="repo_uuid") _add_filter_args(parser) parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show current state reported by a device.""" parser = subparsers.add_parser("show-report", help="show state reported by device", description=description) arguments.add_output_args(parser) parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show the configuration for a VM.""" parser = subparsers.add_parser("show-vm-config", help="show VM configuration", description=description) arguments.add_output_args(parser) parser.add_argument("vm", metavar="VM_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """List VM instances.""" parser = subparsers.add_parser("list-vm-instances", help="list VM instances", description=description) arguments.add_output_args(parser, field="vm_instance_uuid") _add_filter_args(parser) parser.add_argument("--removed", action="store_true", help="list VM instances which have been removed") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show the configuration for a device.""" parser = subparsers.add_parser("show-device-config", help="show device configuration", description=description) arguments.add_output_args(parser) parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show information about a repository.""" parser = subparsers.add_parser("show-repo", help="show repository", description=description) arguments.add_output_args(parser) parser.add_argument("repo", metavar="REPO_UUID", action=arguments.StoreSingleNonEmptyValue, help="repo uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show current state reported by a device.""" parser = subparsers.add_parser("show-report", help="show state reported by device", description=description) arguments.add_output_args(parser) parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """List VM instances.""" parser = subparsers.add_parser("list-vm-instances", help="list VM instances", description=description) arguments.add_output_args(parser, field="vm_instance_uuid") _add_filter_args(parser) parser.add_argument("--removed", action="store_true", help="list VM instances which have been removed") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show information about a disk.""" parser = subparsers.add_parser("show-disk", help="show disk", description=description) arguments.add_output_args(parser) parser.add_argument("disk", metavar="DISK_UUID", action=arguments.StoreSingleNonEmptyValue, help="disk uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Remove a VM.""" parser = subparsers.add_parser("remove-vm", help="remove VM", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("vm", metavar="VM_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Unlock a previously-locked VM instance on a device.""" parser = subparsers.add_parser("unlock-vm-instance", help="unlock VM instance", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show the configuration for a VM.""" parser = subparsers.add_parser("show-vm-config", help="show VM configuration", description=description) arguments.add_output_args(parser) parser.add_argument("vm", metavar="VM_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show the shared secret for a device.""" parser = subparsers.add_parser("show-device-secret", help="show shared secret for device", description=description) arguments.add_output_args(parser, field="shared_secret") parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show information about a repository.""" parser = subparsers.add_parser("show-repo", help="show repository", description=description) arguments.add_output_args(parser) parser.add_argument("repo", metavar="REPO_UUID", action=arguments.StoreSingleNonEmptyValue, help="repo uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show information about a VM instance.""" parser = subparsers.add_parser("show-vm-instance", help="show VM instance", description=description) arguments.add_output_args(parser) parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Unlock a previously-locked VM instance on a device.""" parser = subparsers.add_parser("unlock-vm-instance", help="unlock VM instance", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Generate a new shared secret for a device.""" parser = subparsers.add_parser("reset-device-secret", help="generate new shared secret for device", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show information about a device.""" parser = subparsers.add_parser("show-device", help="show device", description=description) arguments.add_output_args(parser) parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Generate a new shared secret for a device.""" parser = subparsers.add_parser( "reset-device-secret", help="generate new shared secret for device", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Verify all disk files and repository files. For each file, check that it exists and has the correct size and hash.""" parser = subparsers.add_parser("verify-files", help="verify all disk files and repository " "files", description=description) parser.add_argument("-s", "--short", action="store_true", help="short verification: skip file hash check") arguments.add_output_args(parser, suppress=True) parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Re-add a VM instance which has previously been removed from a device.""" parser = subparsers.add_parser("readd-vm-instance", help="re-add removed VM instance", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.set_defaults(func=_run) parser.set_defaults(completion_hints={"VM_INSTANCE_UUID": "--removed"})
def add_subparser(subparsers): description = """Verify all disk files and repository files. For each file, check that it exists and has the correct size and hash.""" parser = subparsers.add_parser("verify-files", help="verify all disk files and repository " "files", description=description) parser.add_argument("-s", "--short", action="store_true", help="short verification: skip file hash check") arguments.add_output_args(parser, suppress=True) parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Add a new disk.""" parser = subparsers.add_parser("add-disk", help="add new disk", description=description) arguments.add_output_args(parser, field="disk_uuid") _add_key_args(parser) parser.add_argument("name", metavar="DISK_NAME", action=arguments.StoreSingleNonEmptyValue, help="disk name") parser.add_argument("file_path", metavar="FILE_PATH", action=arguments.StoreSingleNonEmptyValue, help="path to file") parser.add_argument("-r", "--read-only", action="store_true", help="read-only") parser.add_argument("-s", "--shared", action="store_true", help="share disk between VMs") # TODO: improve help parser.add_argument("--hash", metavar="FILE_HASH", action=arguments.StoreSingleValue, help="assume SHA-256 checksum of file is FILE_HASH " "rather than compute it") parser.add_argument("-t", "--type", metavar="DISK_TYPE", action=arguments.StoreSingleValue, choices=DISK_TYPES, help="disk type ('iso' or 'vhd'); if not specified, " "deduce from file name") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Remove a VM instance from a device (forcing it to shut down if necessary) and permanently remove all information related to the VM instance.""" parser = subparsers.add_parser("purge-vm-instance", help="completely remove VM instance", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.set_defaults(func=_run) parser.set_defaults(completion_hints={"VM_INSTANCE_UUID": "--all"})
def add_subparser(subparsers): description = """Remove a VM instance from a device (forcing it to shut down if necessary) and permanently remove all information related to the VM instance.""" parser = subparsers.add_parser("purge-vm-instance", help="completely remove VM instance", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.set_defaults(func=_run) parser.set_defaults(completion_hints={"VM_INSTANCE_UUID": "--all"})
def add_subparser(subparsers): description = """Add a new disk.""" parser = subparsers.add_parser("add-disk", help="add new disk", description=description) arguments.add_output_args(parser, field="disk_uuid") _add_key_args(parser) parser.add_argument("name", metavar="DISK_NAME", action=arguments.StoreSingleNonEmptyValue, help="disk name") parser.add_argument("file_path", metavar="FILE_PATH", action=arguments.StoreSingleNonEmptyValue, help="path to file") parser.add_argument("-r", "--read-only", action="store_true", help="read-only") parser.add_argument("-s", "--shared", action="store_true", help="share disk between VMs") # TODO: improve help parser.add_argument("--hash", metavar="FILE_HASH", action=arguments.StoreSingleValue, help="assume SHA-256 checksum of file is FILE_HASH " "rather than compute it") parser.add_argument("-t", "--type", metavar="DISK_TYPE", action=arguments.StoreSingleValue, choices=DISK_TYPES, help="disk type ('iso' or 'vhd'); if not specified, " "deduce from file name") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Modify the name of a VM instance.""" parser = subparsers.add_parser("modify-vm-instance-name", help="modify VM instance name", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("vm_instance", metavar="VM_INSTANCE_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM instance uuid") parser.add_argument("name", metavar="VM_INSTANCE_NAME", action=arguments.StoreSingleNonEmptyValue, help="VM instance name") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Permanently remove all information about a device and prevent it from contacting Synchronizer.""" parser = subparsers.add_parser("remove-device", help="remove device", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("-c", "--cascade", action="store_true", help="purge any VM instances for device") parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show the encryption key for a disk.""" parser = subparsers.add_parser("show-disk-key", help="show encryption key for disk", description=description) arguments.add_output_args(parser, field="encryption_key") parser.add_argument("disk", metavar="DISK_UUID", action=arguments.StoreSingleNonEmptyValue, help="disk uuid") parser.add_argument("-f", "--file", metavar="KEY_FILE", action=arguments.StoreSingleValue, help="write raw disk encryption key to file") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Modify the repository for a device.""" parser = subparsers.add_parser("modify-device-repo", help="modify device repository", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.add_argument("-r", "--repo", metavar="REPO_UUID", action=arguments.StoreSingleNonEmptyValue, help="repository uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Permanently remove all information about a device and prevent it from contacting Synchronizer.""" parser = subparsers.add_parser("remove-device", help="remove device", description=description) arguments.add_output_args(parser, suppress=True) parser.add_argument("-c", "--cascade", action="store_true", help="purge any VM instances for device") parser.add_argument("device", metavar="DEVICE_UUID", action=arguments.StoreSingleNonEmptyValue, help="device uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Show the encryption key for a disk.""" parser = subparsers.add_parser("show-disk-key", help="show encryption key for disk", description=description) arguments.add_output_args(parser, field="encryption_key") parser.add_argument("disk", metavar="DISK_UUID", action=arguments.StoreSingleNonEmptyValue, help="disk uuid") parser.add_argument("-f", "--file", metavar="KEY_FILE", action=arguments.StoreSingleValue, help="write raw disk encryption key to file") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Modify the configuration for a VM.""" epilog = """Configuration items should be specified in DAEMON:KEY:VALUE format, either as a series of --config arguments, or using the --config-file argument with a file containing one configuration item per line. Leaving VALUE empty removes the configuration item.""" parser = subparsers.add_parser("modify-vm-config", help="modify VM configuration", description=description, epilog=epilog) arguments.add_output_args(parser, suppress=True) _add_config_args(parser) parser.add_argument("vm", metavar="VM_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM uuid") parser.set_defaults(func=_run)
def add_subparser(subparsers): description = """Modify the configuration for a VM.""" epilog = """Configuration items should be specified in DAEMON:KEY:VALUE format, either as a series of --config arguments, or using the --config-file argument with a file containing one configuration item per line. Leaving VALUE empty removes the configuration item.""" parser = subparsers.add_parser("modify-vm-config", help="modify VM configuration", description=description, epilog=epilog) arguments.add_output_args(parser, suppress=True) _add_config_args(parser) parser.add_argument("vm", metavar="VM_UUID", action=arguments.StoreSingleNonEmptyValue, help="VM uuid") parser.set_defaults(func=_run)