/usr/share/bash-completion/completions/lxc is in lxd-client 3.0.0-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 | _have lxc && {
_lxd_complete()
{
_lxd_names()
{
local state=$1
local keys=$2
local cmd="lxc list --format=csv --columns=ns"
[ -n "$state" ] && cmd="$cmd | grep -E '$state$'"
COMPREPLY=( $( compgen -W \
"$( eval $cmd | cut -d, -f1 ) $keys" "$cur" )
)
}
_lxd_images()
{
COMPREPLY=( $( compgen -W \
"$( lxc image list | tail -n +4 | awk '{print $2}' | egrep -v '^(\||^$)' )" "$cur" )
)
}
_lxd_remotes()
{
COMPREPLY=( $( compgen -W \
"$( lxc remote list | tail -n +4 | awk '{print $2}' | egrep -v '^(\||^$)' )" "$cur" )
)
}
_lxd_profiles()
{
COMPREPLY=( $( compgen -W "$( lxc profile list | tail -n +4 | awk '{print $2}' | egrep -v '^(\||^$)' )" "$cur" ) )
}
_lxd_networks()
{
COMPREPLY=( $( compgen -W \
"$( lxc network list | tail -n +4 | awk '{print $2}' | egrep -v '^(\||^$)' )" "$cur" )
)
}
_lxd_storage_pools()
{
COMPREPLY=( $( compgen -W \
"$( lxc storage list | tail -n +4 | awk '{print $2}' | egrep -v '^(\||^$)' )" "$cur" )
)
}
_lxd_storage_volumes()
{
COMPREPLY=( $( compgen -W \
"$( lxc storage volume list | tail -n +4 | awk '{print $2}' | egrep -v '^(\||^$)' )" "$cur" )
)
}
COMPREPLY=()
# ignore special --foo args
if [[ ${COMP_WORDS[COMP_CWORD]} == -* ]]; then
return 0
fi
lxc_cmds="config copy delete exec file finger help image info init launch \
list manpage monitor move network profile publish query remote rename \
restart restore shell snapshot start stop storage version"
global_keys="core.https_address core.https_allowed_credentials \
core.https_allowed_headers core.https_allowed_methods \
core.https_allowed_origin core.macaroon.endpoint core.proxy_https \
core.proxy_http core.proxy_ignore_hosts core.trust_password \
cluster.offline_threshold \
images.auto_update_cached images.auto_update_interval \
images.compression_algorithm images.remote_cache_expiry \
maas.api.url maas.api.key maas.machine"
container_keys="boot.autostart boot.autostart.delay \
boot.autostart.priority boot.stop.priority \
boot.host_shutdown_timeout environment. \
limits.cpu limits.cpu.allowance limits.cpu.priority \
limits.disk.priority limits.memory limits.memory.enforce \
limits.memory.swap limits.memory.swap.priority limits.network.priority \
limits.processes linux.kernel_modules migration.incremental.memory \
migration.incremental.memory.goal nvidia.runtime \
migration.incremental.memory.iterations raw.apparmor raw.idmap raw.lxc \
raw.seccomp security.idmap.base security.idmap.isolated \
security.idmap.size security.devlxd security.nesting security.privileged \
security.syscalls.blacklist security.syscalls.blacklist_compat \
security.syscalls.blacklist_default \
volatile.apply_quota volatile.apply_template volatile.base_image \
volatile.idmap.base volatile.idmap.next volatile.last_state.idmap \
volatile.last_state.power user.meta-data user.network-config \
user.network_mode user.user-data user.vendor-data"
networks_keys="bridge.driver bridge.external_interfaces bridge.mode \
bridge.mtu dns.domain dns.mode fan.overlay_subnet fan.type \
fan.underlay_subnet ipv4.address ipv4.dhcp ipv4.dhcp.expiry ipv4.dhcp.gateway \
ipv4.dhcp.ranges ipv4.firewall ipv4.nat ipv4.routes ipv4.routing \
ipv6.address ipv6.dhcp ipv6.dhcp.expiry ipv6.dhcp.ranges \
ipv6.dhcp.stateful ipv6.firewall ipv6.nat ipv6.routes ipv6.routing \
raw.dnsmasq"
storage_pool_keys="source size btrfs.mount_options ceph.cluster_name \
ceph.osd.force_reuse ceph.osd.pg_num ceph.osd.pool_name \
ceph.rbd.clone_copy ceph.user.name lvm.thinpool_name lvm.use_thinpool \
lvm.vg_name rsync.bwlimit volatile.initial_source \
volatile.pool.pristine volume.block.filesystem \
volume.block.mount_options volume.size volume.zfs.remove_snapshots \
volume.zfs.use_refquota zfs.clone_copy zfs.pool_name"
storage_volume_keys="size block.filesystem block.mount_options \
zfs.remove_snapshots zfs.use_refquota"
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(compgen -W "$lxc_cmds" -- ${COMP_WORDS[COMP_CWORD]}) )
return 0
fi
local no_dashargs
cur=${COMP_WORDS[COMP_CWORD]}
no_dashargs=(${COMP_WORDS[@]// -*})
pos=$((COMP_CWORD - (${#COMP_WORDS[@]} - ${#no_dashargs[@]})))
if [ -z "$cur" ]; then
pos=$(($pos + 1))
fi
case ${no_dashargs[1]} in
"config")
case $pos in
2)
COMPREPLY=( $(compgen -W "get set unset show edit metadata template device trust" -- $cur) )
;;
3)
case ${no_dashargs[2]} in
"trust")
COMPREPLY=( $(compgen -W "list add remove" -- $cur) )
;;
"device")
COMPREPLY=( $(compgen -W "add get set unset list show remove" -- $cur) )
;;
"metadata")
COMPREPLY=( $(compgen -W "show edit" -- $cur) )
;;
"template")
COMPREPLY=( $(compgen -W "list show create edit delete" -- $cur) )
;;
"show"|"edit")
_lxd_names
;;
"get"|"set"|"unset")
_lxd_names "" "$global_keys"
;;
esac
;;
4)
case ${no_dashargs[2]} in
"trust")
_lxd_remotes
;;
"device")
_lxd_names
;;
"get"|"set"|"unset")
COMPREPLY=( $(compgen -W "$container_keys" -- $cur) )
;;
esac
;;
esac
;;
"copy")
if [ $pos -lt 4 ]; then
_lxd_names
fi
;;
"delete")
_lxd_names
;;
"exec")
_lxd_names "RUNNING"
;;
"file")
COMPREPLY=( $(compgen -W "pull push edit delete" -- $cur) )
;;
"help")
COMPREPLY=( $(compgen -W "$lxc_cmds" -- $cur) )
;;
"image")
COMPREPLY=( $(compgen -W "import copy delete refresh export info list show edit alias" -- $cur) )
;;
"info")
_lxd_names
;;
"init")
_lxd_images
;;
"launch")
_lxd_images
;;
"move")
_lxd_names
;;
"network")
case $pos in
2)
COMPREPLY=( $(compgen -W "list show create get set unset delete edit rename attach attach-profile detach detach-profile" -- $cur) )
;;
3)
case ${no_dashargs[2]} in
"show"|"get"|"set"|"unset"|"delete"|"edit"|"rename"|"attach"|"attach-profile"|"detach"|"detach-profile")
_lxd_networks
;;
esac
;;
4)
case ${no_dashargs[2]} in
"get"|"set"|"unset")
COMPREPLY=( $(compgen -W "$networks_keys" -- $cur) )
;;
"attach"|"detach"|"detach-profile")
_lxd_names
;;
"attach-profile")
_lxd_profiles
;;
esac
esac
;;
"profile")
case $pos in
2)
COMPREPLY=( $(compgen -W "list show create copy get set unset delete edit rename assign add remove device " -- $cur) )
;;
3)
case ${no_dashargs[2]} in
"device")
COMPREPLY=( $(compgen -W "list show remove get set unset add" -- $cur) )
;;
"add"|"assign"|"remove")
_lxd_names
;;
*)
_lxd_profiles
;;
esac
;;
4)
case ${no_dashargs[2]} in
"device"|"add"|"assign"|"remove")
_lxd_profiles
;;
*)
COMPREPLY=( $(compgen -W "$container_keys" -- $cur) )
;;
esac
;;
esac
;;
"publish")
_lxd_names
;;
"remote")
COMPREPLY=( $(compgen -W \
"add remove list rename set-url set-default get-default" -- $cur) )
;;
"restart")
_lxd_names
;;
"restore")
_lxd_names
;;
"shell")
_lxd_names "RUNNING"
;;
"snapshot")
_lxd_names
;;
"start")
_lxd_names "STOPPED|FROZEN"
;;
"stop")
_lxd_names "RUNNING"
;;
"storage_pools")
case $pos in
2)
COMPREPLY=( $(compgen -W "list show create get set unset delete edit" -- $cur) )
;;
3)
case ${no_dashargs[2]} in
"show"|"get"|"set"|"unset"|"delete"|"edit")
_lxd_storage_pools
;;
esac
;;
4)
case ${no_dashargs[2]} in
"get"|"set"|"unset")
COMPREPLY=( $(compgen -W "$storage_pool_keys" -- $cur) )
;;
esac
esac
;;
"storage_volumes")
case $pos in
2)
COMPREPLY=( $(compgen -W "list show create rename get set unset delete edit attach attach-profile detach detach-profile" -- $cur) )
;;
3)
case ${no_dashargs[2]} in
"show"|"get"|"set"|"unset"|"rename"|"delete"|"edit"|"attach"|"attach-profile"|"detach"|"detach-profile")
_lxd_storage_volumes
;;
esac
;;
4)
case ${no_dashargs[2]} in
"get"|"set"|"unset")
COMPREPLY=( $(compgen -W "$storage_volume_keys" -- $cur) )
;;
"attach"|"detach"|"detach-profile")
_lxd_names
;;
"attach-profile")
_lxd_profiles
;;
esac
esac
;;
*)
;;
esac
return 0
}
complete -o default -F _lxd_complete lxc lxd.lxc
}
|