return 0
fi
+
local args="${words[@]:1}"
case "${cmd}" in
new)
- # TODO
- return 0
+ _network_zone_new ${args}
;;
destroy)
_network_complete_zones
esac
}
+_network_zone_new() {
+ local words=( $@ )
+ local cmd=${words[@]:0:1}
+
+ # Suggest useful zone names
+ if [[ -z "${cmd}" ]]; then
+ local commands="$(network raw list-next-free-zones)"
+ COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
+
+ # If a valid zone name was entered, we can move on
+ elif network raw zone-name-is-valid ${cmd}; then
+ local args="${words[@]:1}"
+ _network_complete_hooks zone ${args}
+ fi
+
+ return 0
+}
+
_network_zone_subcommand() {
local zone="${1}"
shift
done
}
+zones_get_next_free() {
+ # This function return the next free zones.
+ # Example net0 upl0 upl1 are configured so the next free zones are:
+ # net1 upl2
+ local i
+ local zone_name
+ for zone_name in ${VALID_ZONES}; do
+ i=0
+
+ while true; do
+ local zone="${zone_name}${i}"
+ if ! zone_exists ${zone}; then
+ echo "${zone}"
+ break
+ fi
+ i=$(( i + 1 ))
+ done
+ done
+}
+
zones_get_local() {
local zone
for zone in $(zones_get_all); do