]> git.ipfire.org Git - people/arne_f/network.git/commitdiff
Fix weird device CLI command. master
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Mar 2011 11:07:32 +0000 (11:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 12 Mar 2011 11:07:32 +0000 (11:07 +0000)
For now, discover and show are supported.

functions.cli

index aa0bddf679c7af04ede1939df0b971e838d8fd6f..a2ceb99e42df525c881fd3af9fcaeff95d69a550 100644 (file)
@@ -33,44 +33,32 @@ function cli_config() {
 }
 
 function cli_device() {
-       if device_config_exists ${1}; then
-               local device=${1}
-               local action=${2}
-               shift 2
+       local device=${1}
+       local action=${2}
+       shift 2
 
-               case "${action}" in
-                       down|up)
-                               device_${action} ${device} $@
-                               ;;
-               esac
-       else
-               local action=${1}
-               shift
+       assert device_exists ${device}
 
-               case "${action}" in
-                       create)
-                               device_${action} $@
-                               ;;
+       if zone_exists ${device} || port_exists ${device}; then
+               error "The device '${device}' has already been configured."
+               error "You cannot do a device action."
+               return ${EXIT_ERROR}
+       fi
 
-                       discover)
-                               echo "# XXX need to implement --raw here"
-                               local device
-                               for device in ${devices}; do
-                                       cli_device_discover ${device} $@
-                               done
-                               ;;
+       case "${action}" in
+               discover)
+                       echo "# XXX need to implement --raw here"
+                       cli_device_discover ${device} $@
+                       ;;
 
-                       show|"")
-                               local device
-                               for device in $(device_get $@); do
-                                       device_print ${device}
-                               done
-                               ;;
-                       *)
-                               cli_usage device
-                               ;;                              
-               esac
-       fi
+               show|"")
+                       # XXX device_show needs to be implemented
+                       device_show ${device}
+                       ;;
+               *)
+                       cli_usage device
+                       ;;
+       esac
 }
 
 function cli_device_discover() {