]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/header-zone
zone: Allow creating configs which do not require arguments
[people/stevee/network.git] / src / header-zone
index 3241eb5a4f99110a81f9190d5d0c58dd254b2c0a..9a25c0ebab4a854cb16b58d70a74b9da7b2f3fe8 100644 (file)
@@ -29,22 +29,22 @@ function hook_hotplug() {
        exit ${EXIT_NOT_HANDLED}
 }
 
-function hook_create() {
+function hook_new() {
        local zone="${1}"
        assert isset zone
        shift
 
-       settings_read $(zone_dir ${zone})/settings
+       zone_settings_read "${zone}"
 
        hook_parse_cmdline $@
 
-       settings_write $(zone_dir ${zone})/settings ${HOOK_SETTINGS}
+       zone_settings_write "${zone}"
 
        exit ${EXIT_OK}
 }
 
 function hook_edit() {
-       hook_create $@
+       hook_new $@
 }
 
 function hook_remove() {
@@ -102,7 +102,11 @@ function hook_port() {
        exit ${ret}
 }
 
-function hook_port_add() {
+function hook_port_attach() {
+       return ${EXIT_NOT_SUPPORTED}
+}
+
+function hook_port_detach() {
        return ${EXIT_NOT_SUPPORTED}
 }
 
@@ -110,16 +114,34 @@ function hook_port_edit() {
        return ${EXIT_NOT_SUPPORTED}
 }
 
-function hook_port_remove() {
+function hook_port_status() {
        return ${EXIT_NOT_SUPPORTED}
 }
 
-function hook_port_show() {
-       cmd_not_implemented
+function hook_default_port_create() {
+       assert [ $# -ge 2 ]
+
+       local zone="${1}"
+       local port="${2}"
+
+       port_create "${port}"
 }
 
-function hook_port_status() {
-       return ${EXIT_NOT_SUPPORTED}
+function hook_port_create() {
+       hook_default_port_create $@
+}
+
+function hook_default_port_remove() {
+       assert [ $# -ge 2 ]
+
+       local zone="${1}"
+       local port="${2}"
+
+       port_remove "${port}"
+}
+
+function hook_port_remove() {
+       hook_default_port_remove $@
 }
 
 function hook_port_up() {
@@ -178,7 +200,7 @@ function hook_config_cmd() {
 }
 
 function hook_config_create() {
-       assert [ $# -gt 2 ]
+       assert [ $# -ge 2 ]
 
        hook_config_cmd "create" "$@"
 }