# #
###############################################################################
-function zone_dir() {
+zone_dir() {
local zone=${1}
echo "${NETWORK_ZONE_DIR}/zones/${zone}"
}
-function zone_exists() {
+zone_exists() {
local zone=${1}
assert isset zone
[ -d "$(zone_dir ${zone})" ]
}
-function zone_match() {
+zone_match() {
local match
local i
echo "${match:1:${#match}}"
}
-function zone_name_is_valid() {
+zone_name_is_valid() {
local zone=${1}
# Don't accept empty strings.
[[ ${zone} =~ $(zone_match) ]]
}
-function zone_is_local() {
+zone_is_local() {
local zone=${1}
[[ "${zone:0:${#ZONE_LOCAL}}" = "${ZONE_LOCAL}" ]]
}
-function zone_is_nonlocal() {
+zone_is_nonlocal() {
local zone=${1}
[[ "${zone:0:${#ZONE_NONLOCAL}}" = "${ZONE_NONLOCAL}" ]]
}
-function zone_get_hook() {
+zone_get_hook() {
local zone=${1}
assert isset zone
config_get_hook $(zone_dir ${zone})/settings
}
-function zone_start() {
+zone_start() {
# This function will bring up the zone
# 'asynchronously' with help of systemd.
service_start "network@${zone}.service"
}
-function zone_start_auto() {
+zone_start_auto() {
local zone="${1}"
assert zone_exists "${zone}"
return ${EXIT_OK}
}
-function zone_stop() {
+zone_stop() {
# This function will bring down the zone
# 'asynchronously' with help of systemd.
service_stop "network@${zone}.service"
}
-function zone_reload() {
+zone_reload() {
local zone="${1}"
assert zone_exists "${zone}"
service_reload "network@${zone}.service"
}
-function zone_hotplug_event() {
+zone_hotplug_event() {
local zone="${1}"
assert isset zone
zone_cmd "hotplug" "${zone}"
}
-function zone_enable() {
+zone_enable() {
# This function will enable the zone
# with help of systemd.
return ${ret}
}
-function zone_disable() {
+zone_disable() {
# This function will disable the zone
# with help of systemd.
return ${ret}
}
-function zone_is_enabled() {
+zone_is_enabled() {
local zone="${1}"
assert isset zone
return ${EXIT_FALSE}
}
-function zone_is_active() {
+zone_is_active() {
local zone="${1}"
assert isset zone
return ${EXIT_FALSE}
}
-function zone_is_enabled_or_active() {
+zone_is_enabled_or_active() {
local zone="${1}"
assert isset zone
zone_is_enabled "${zone}" || zone_is_active "${zone}"
}
-function zone_cmd() {
+zone_cmd() {
local cmd="${1}"
local port="${2}"
shift 2
hook_exec zone "${hook}" "${cmd}" "${zone}" $@
}
-function zone_new() {
+zone_new() {
local zone=${1}
local hook=${2}
shift 2
zone_start "${zone}"
}
-function zone_edit() {
+zone_edit() {
local zone=${1}
shift
}
-function zone_destroy() {
+zone_destroy() {
local zone="${1}"
assert zone_exists "${zone}"
log INFO "Zone '${zone}' has been tagged for removal."
}
-function zone_has_destroy_tag() {
+zone_has_destroy_tag() {
local zone="${1}"
assert zone_exists "${zone}"
# This function will remove the given zone
# RIGHT NOW. Use zone_destroy to remove it
# at the next status change.
-function zone_destroy_now() {
+zone_destroy_now() {
local zone="${1}"
assert zone_exists "${zone}"
rm -rf "$(zone_dir "${zone}")"
}
-function zone_up() {
+zone_up() {
local zone=${1}
shift
zone_db ${zone} started
}
-function zone_down() {
+zone_down() {
local zone=${1}
shift
fi
}
-function zone_status() {
+zone_status() {
local zone="${1}"
assert isset zone
shift
fi
}
-function zone_get_ports() {
+zone_get_ports() {
local zone=${1}
assert isset zone
done
}
-function zone_get_ports_num() {
+zone_get_ports_num() {
local zone="${1}"
assert isset zone
return ${EXIT_OK}
}
-function zone_has_port() {
+zone_has_port() {
# Check, if the given port is configured
# in this zone.
[ -e "$(zone_dir ${zone})/ports/${port}" ]
}
-function zone_config() {
+zone_config() {
local zone="${1}"
local cmd="${2}"
shift 2
esac
}
-function zone_config_cmd() {
+zone_config_cmd() {
assert [ $# -gt 2 ]
local cmd="${1}"
hook_zone_exec "${hook}" "config_${cmd}" "${zone}" "$@"
}
-function zone_config_create() {
+zone_config_create() {
zone_config_cmd "create" "$@"
}
-function zone_config_edit() {
+zone_config_edit() {
zone_config_cmd "edit" "$@"
}
-function zone_config_remove() {
+zone_config_remove() {
zone_config_cmd "remove" "$@"
}
-function zone_config_show() {
+zone_config_show() {
zone_config_cmd "show" "$@"
}
-function zone_show() {
+zone_show() {
local zone=${1}
echo "${zone}"
echo
}
-function zones_show() {
+zones_show() {
local zone
for zone in $(zones_get $@); do
done
}
-function zones_get_all() {
+zones_get_all() {
local zone
for zone in $(zone_dir)/*; do
zone=$(basename ${zone})
done
}
-function zones_get_local() {
+zones_get_local() {
local zone
for zone in $(zones_get_all); do
zone_is_local ${zone} && echo "${zone}"
done
}
-function zones_get_nonlocal() {
+zones_get_nonlocal() {
local zone
for zone in $(zones_get_all); do
zone_is_nonlocal ${zone} && echo "${zone}"
done
}
-function zones_get() {
+zones_get() {
local local=1
local remote=1
fi
}
-function zone_ports_list() {
+zone_ports_list() {
local zone=${1}
local port
done
}
-function zone_port_attach() {
+zone_port_attach() {
local zone="${1}"
assert isset zone
return ${ret}
}
-function zone_port_edit() {
+zone_port_edit() {
local zone="${1}"
assert isset zone
hook_zone_exec "${hook}" "port_edit" "${zone}" "${port}" "$@"
}
-function zone_port_detach() {
+zone_port_detach() {
local zone="${1}"
assert isset zone
return ${ret}
}
-function zone_port_cmd() {
+zone_port_cmd() {
local cmd="${1}"
assert isset cmd
hook_zone_exec "${hook}" "${cmd}" "${zone}" "${port}" $@
}
-function zone_port_create() {
+zone_port_create() {
zone_port_cmd "port_create" $@
}
-function zone_port_remove() {
+zone_port_remove() {
zone_port_cmd "port_remove" $@
}
-function zone_port_up() {
+zone_port_up() {
zone_port_cmd "port_up" $@
}
-function zone_port_down() {
+zone_port_down() {
zone_port_cmd "port_down" $@
}
# and therefore do not dispatch a hotplug event when
# port_create is called.
-function zone_port_start() {
+zone_port_start() {
local zone="${1}"
local port="${2}"
return ${EXIT_OK}
}
-function zone_port_stop() {
+zone_port_stop() {
local zone="${1}"
local port="${2}"
zone_port_remove "${zone}" "${port}"
}
-function zone_port_status() {
+zone_port_status() {
zone_port_cmd "port_status" $@
}
-function zone_ports_cmd() {
+zone_ports_cmd() {
local cmd="${1}"
assert isset cmd
done
}
-function zone_ports_create() {
+zone_ports_create() {
zone_ports_cmd "port_create" $@
}
-function zone_ports_remove() {
+zone_ports_remove() {
zone_ports_cmd "port_remove" $@
}
-function zone_ports_up() {
+zone_ports_up() {
zone_ports_cmd "port_up" $@
}
-function zone_ports_down() {
+zone_ports_down() {
zone_ports_cmd "port_down" $@
}
-function zone_ports_status() {
+zone_ports_status() {
zone_ports_cmd "port_status" $@
}
-function zone_configs_cmd() {
+zone_configs_cmd() {
assert [ $# -ge 2 ]
local cmd="${1}"
done
}
-function zone_configs_up() {
+zone_configs_up() {
zone_configs_cmd "up" $@
}
-function zone_configs_down() {
+zone_configs_down() {
zone_configs_cmd "down" $@
}
-function zone_configs_status() {
+zone_configs_status() {
zone_configs_cmd "status" $@
}
-function zone_configs_list() {
+zone_configs_list() {
local zone=${1}
local config
done
}
-function zone_config_get_hook() {
+zone_config_get_hook() {
assert [ $# -eq 2 ]
local zone="${1}"
print "${HOOK}"
}
-function zone_has_ip() {
+zone_has_ip() {
device_has_ip $@
}
-function zone_db() {
+zone_db() {
local zone=${1}
local action=${2}
shift 2
esac
}
-function zone_is_up() {
+zone_is_up() {
local zone=${1}
device_is_up ${zone}
}
-function zone_is_down() {
+zone_is_down() {
! zone_is_up $@
}
-function zone_get_supported_port_hooks() {
+zone_get_supported_port_hooks() {
local zone=${1}
local hook=$(zone_get_hook ${zone})
hook_zone_ports_get_all ${hook}
}
-function zone_get_supported_config_hooks() {
+zone_get_supported_config_hooks() {
hook_config_get_all
}
-function zone_file() {
+zone_file() {
local zone=${1}
assert isset zone
echo "$(zone_dir ${zone})/settings"
}
-function zone_settings_read() {
+zone_settings_read() {
local zone=${1}
assert isset zone
shift
HOOK="${hook}"
}
-function zone_settings_write() {
+zone_settings_write() {
local zone="${1}"
assert isset zone
settings_write "$(zone_file ${zone})" ${args}
}
-function zone_settings_set() {
+zone_settings_set() {
local zone=${1}
shift
local args="$@"
)
}
-function zone_settings_get() {
+zone_settings_get() {
local zone=${1}
local key=${2}
)
}
-function zone_config_settings_read() {
+zone_config_settings_read() {
assert [ $# -ge 2 ]
local zone="${1}"
settings_read "${path}" ${args}
}
-function zone_config_settings_write() {
+zone_config_settings_write() {
assert [ $# -ge 2 ]
local zone="${1}"
settings_write "${path}" ${args}
}
-function zone_port_settings_read() {
+zone_port_settings_read() {
assert [ $# -ge 2 ]
local zone="${1}"
settings_read "${path}" ${args}
}
-function zone_port_settings_write() {
+zone_port_settings_write() {
assert [ $# -ge 2 ]
local zone="${1}"
settings_write "${path}" ${args}
}
-function zone_port_settings_remove() {
+zone_port_settings_remove() {
assert [ $# -eq 2 ]
local zone="${1}"