<refsynopsisdiv>
<cmdsynopsis>
- <command>network zone <arg choice="plain">[create|remove]</arg> <replaceable>ZONE</replaceable> ...</command>
+ <command>network zone <arg choice="plain">[new|destroy]</arg> <replaceable>ZONE</replaceable> ...</command>
</cmdsynopsis>
<cmdsynopsis>
<variablelist>
<varlistentry>
<term>
- <command>create <replaceable>ZONE</replaceable> <replaceable>HOOK</replaceable> <arg choice="opt" rep="repeat">OPTIONS</arg></command>
+ <command>new <replaceable>ZONE</replaceable> <replaceable>HOOK</replaceable> <arg choice="opt" rep="repeat">OPTIONS</arg></command>
</term>
<listitem>
<varlistentry>
<term>
- <command>remove <replaceable>ZONE</replaceable></command>
+ <command>destroy <replaceable>ZONE</replaceable></command>
</term>
<listitem>
<para>
- A zone can be simple removed with this command.
+ A zone can be destroyed with this command.
</para>
<para>
There are two possible ways to remove a zone. The case
hook_exec zone "${hook}" "${cmd}" "${zone}" $@
}
-function zone_create() {
+function zone_new() {
local zone=${1}
local hook=${2}
shift 2
# Create directories for configs and ports
mkdir -p $(zone_dir ${zone})/{configs,ports}
- hook_zone_exec ${hook} create ${zone} $@
+ hook_zone_exec "${hook}" "new" "${zone}" $@
local ret=$?
- # Maybe the zone create hook did not exit correctly.
+ # Maybe the zone new hook did not exit correctly.
# If this is the case we remove the created zone immediately.
if [ "${ret}" = "${EXIT_ERROR}" ]; then
- zone_remove_now ${zone}
+ zone_destroy_now "${zone}"
return ${EXIT_ERROR}
fi
fi
# Check if the zone is tagged for removal.
- if zone_has_remove_tag ${zone}; then
+ if zone_has_destroy_tag ${zone}; then
error "You cannot edit a zone that is tagged for removal."
return ${EXIT_ERROR}
fi
}
-function zone_remove() {
- local zone=${1}
- assert zone_exists ${zone}
+function zone_destroy() {
+ local zone="${1}"
+ assert zone_exists "${zone}"
# Make the zone for removal.
- touch $(zone_dir ${zone})/.remove
+ touch "$(zone_dir "${zone}")/.destroy"
log INFO "Zone '${zone}' has been tagged for removal."
}
-function zone_has_remove_tag() {
- local zone=${1}
- assert zone_exists ${zone}
+function zone_has_destroy_tag() {
+ local zone="${1}"
+ assert zone_exists "${zone}"
- [ -e "$(zone_dir ${zone})/.remove" ]
+ [ -e "$(zone_dir "${zone}")/.destroy" ]
}
# This function will remove the given zone
-# RIGHT NOW. Use zone_remove to remove it
+# RIGHT NOW. Use zone_destroy to remove it
# at the next status change.
-function zone_remove_now() {
- local zone=${1}
- assert zone_exists ${zone}
+function zone_destroy_now() {
+ local zone="${1}"
+ assert zone_exists "${zone}"
log INFO "Removing zone '${zone}' right now."
# Force the zone down.
- zone_is_up ${zone} && zone_set_down ${zone}
+ zone_is_up "${zone}" && zone_set_down "${zone}"
# Disable zone.
zone_disable "${zone}"
- rm -rf $(zone_dir ${zone})
+ rm -rf "$(zone_dir "${zone}")"
}
function zone_up() {
zone_db ${zone} stopped
# Remove the zone, if it has got a remove tag.
- if zone_has_remove_tag ${zone}; then
- zone_remove_now ${zone}
+ if zone_has_destroy_tag "${zone}"; then
+ zone_destroy_now "${zone}"
fi
}
shift
case "${action}" in
- create)
- zone_${action} $@
+ new)
+ zone_new $@
;;
- remove)
- cli_zone_remove $@
+ destroy)
+ cli_zone_destroy $@
;;
list-hooks)
cli_list_hooks zone $@
# Removes a zone either immediately, if it is currently down,
# or adds a tag that the removal will be done when the zone
# is brought down the next time.
-function cli_zone_remove() {
+function cli_zone_destroy() {
if cli_help_requested $@; then
cli_show_man network-zone
exit ${EXIT_OK}
fi
- local zone=${1}
- assert zone_exists ${zone}
+ local zone="${1}"
+ assert zone_exists "${zone}"
if zone_is_up ${zone}; then
echo "Zone '${zone}' is up and will be removed when it goes down the next time."
- zone_remove ${zone}
+ zone_destroy "${zone}"
else
echo "Removing zone '${zone}' now..."
- zone_remove_now ${zone}
+ zone_destroy_now "${zone}"
fi
exit ${EXIT_OK}
local zone
for zone in $(zones_get --all); do
- zone_remove ${zone}
+ zone_destroy_now "${zone}"
done
local port