| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- # encoding: utf-8
- from __future__ import unicode_literals
- import os
- from . import consts
- def inject_ssh_options(parser):
- # optional options
- help_d = lambda help: help + " (default: %(default)s)"
- parser.add_argument("--user", "-u",
- dest="ssh_user",
- default="root",
- help=help_d("target host ssh user"))
- parser.add_argument("--key-file", "-k",
- dest="ssh_private_file",
- default=os.path.expanduser("~/.ssh/id_rsa"),
- help=help_d("target host ssh private key file"))
- parser.add_argument("--port", "-p",
- dest="ssh_port",
- type=int,
- default="22",
- help=help_d("target host host ssh port"))
- return parser
- def inject_ssh_hosts_options(parser):
- parser.add_argument("target_node_hosts",
- nargs='+',
- default=[],
- metavar="TARGET_NODE_HOSTS",
- help="target nodes")
- inject_ssh_options(parser)
- return parser
- def help_d(help):
- return help + " (default: %(default)s)"
- def inject_primary_node_options(parser):
- parser.add_argument("primary_master_host",
- metavar="FIRST_MASTER_HOST",
- help="onecloud cluster primary master host, \
- e.g., 10.1.2.56")
- def inject_add_nodes_options(parser):
- inject_primary_node_options(parser)
- inject_ssh_options(parser)
- parser.add_argument("target_node_hosts",
- nargs='+',
- default=[],
- metavar="TARGET_NODE_HOSTS",
- help="target nodes ip added into cluster")
- # optional options
- parser.add_argument("--node-port", "-n",
- dest="ssh_node_port",
- type=int,
- default="22",
- help=help_d("worker node host ssh port"))
- parser.add_argument("--offline-data-path",
- dest="offline_data_path",
- default="",
- help="offline rpm repo path for upgrade mode")
- parser.add_argument("--ip-type",
- dest="ip_type",
- default="",
- choices=[consts.IP_TYPE_IPV4, consts.IP_TYPE_IPV6, consts.IP_TYPE_DUAL_STACK],
- help="ip type of target nodes")
- # 双栈支持
- parser.add_argument('--ip-dual-conf', type=str, dest='ip_dual_conf',
- help="Input the second IP address for dual-stack configuration (IPv6 if TARGET_NODE_HOSTS is IPv4, or IPv4 if TARGET_NODE_HOSTS is IPv6)")
- def inject_add_hostagent_options(parser):
- parser.add_argument("--enable-host-on-vm",
- dest="enable_host_on_vm",
- action="store_true", default=False,
- help="enable kvm host service inside virtual machine")
- parser.add_argument("--host-network",
- nargs="*",
- action="extend",
- dest="host_networks",
- help="networks option of /etc/yunion/host.conf")
- parser.add_argument("--disk-path",
- nargs="*",
- action="extend",
- dest="disk_paths",
- help="local_image_path of /etc/yunion/host.conf")
- def inject_add_nodes_runtime_options(parser):
- parser.add_argument("--runtime",
- dest="runtime",
- default=None,
- choices=[consts.RUNTIME_QEMU, consts.RUNTIME_CONTAINERD],
- help="select runtime type when adding node. default: qemu")
- def inject_ai_nvidia_options(parser):
- """添加 ai 相关的 NVIDIA 参数(run.py ai 与 add-node --enable-ai-env 共用)"""
- parser.add_argument("--nvidia-driver-installer-path",
- dest="nvidia_driver_installer_path",
- required=False,
- help="Full path to NVIDIA driver installer (e.g., /root/nvidia/NVIDIA-Linux-x86_64-570.133.07.run). If not provided, assumes NVIDIA driver is already installed")
- parser.add_argument("--cuda-installer-path",
- dest="cuda_installer_path",
- required=False,
- help="Full path to CUDA installer (e.g., /root/nvidia/cuda_12.8.1_570.124.06_linux.run). If not provided, assumes CUDA is already installed")
- parser.add_argument("--gpu-device-virtual-number",
- dest="gpu_device_virtual_number",
- type=int,
- default=2,
- help=help_d("Virtual number for NVIDIA GPU share device (default: 2)"))
- def inject_auto_backup_options(parser):
- parser.add_argument(
- '--backup-path', help="backup path, default: /opt/yunion/backup", default="/opt/yunion/backup")
- parser.add_argument('--light', action='store_true', default=True,
- help="ignore yunionmeter and yunionlogger database; ignore tables start with 'opslog' and 'task'.")
- parser.add_argument('--max-backups', default=10, type=int,
- help="how many backups to keep. default: 10")
- parser.add_argument('--max-disk-percentage', default=75, type=int,
- help="the max usage percentage of the disk on which the backup will be done allowed to perform backup. the backup job will not work when the disk's usage is above the threshold. default: 75(%%).")
|