Author: sandervanderburg
Date: Wed Jan 19 10:50:52 2011
New Revision: 25623
URL: https://svn.nixos.org/websvn/nix/?rev=25623&sc=1

Log:
- Added disnixos-env
- Moved network file checks into a separate file

Added:
   disnix/disnixos/trunk/scripts/checks
   disnix/disnixos/trunk/scripts/disnixos-env.in
Modified:
   disnix/disnixos/trunk/configure.ac
   disnix/disnixos/trunk/scripts/Makefile.am
   disnix/disnixos/trunk/scripts/disnixos-gentests.in
   disnix/disnixos/trunk/scripts/disnixos-vm-env.in

Modified: disnix/disnixos/trunk/configure.ac
==============================================================================
--- disnix/disnixos/trunk/configure.ac  Wed Jan 19 09:06:12 2011        (r25622)
+++ disnix/disnixos/trunk/configure.ac  Wed Jan 19 10:50:52 2011        (r25623)
@@ -34,6 +34,7 @@
 data/testing.nix
 scripts/disnix-backdoor-client
 scripts/disnixos-deploy-network
+scripts/disnixos-env
 scripts/disnixos-geninfra
 scripts/disnixos-genservices
 scripts/disnixos-gentests

Modified: disnix/disnixos/trunk/scripts/Makefile.am
==============================================================================
--- disnix/disnixos/trunk/scripts/Makefile.am   Wed Jan 19 09:06:12 2011        
(r25622)
+++ disnix/disnixos/trunk/scripts/Makefile.am   Wed Jan 19 10:50:52 2011        
(r25623)
@@ -1,3 +1,3 @@
-bin_SCRIPTS = disnix-backdoor-client disnixos-geninfra disnixos-genservices 
disnixos-gentests disnixos-vm-env disnixos-deploy-network
+bin_SCRIPTS = disnix-backdoor-client disnixos-geninfra disnixos-genservices 
disnixos-gentests disnixos-env disnixos-vm-env disnixos-deploy-network
 
-EXTRA_DIST = disnix-backdoor-client.in disnixos-geninfra.in 
disnixos-genservices.in disnixos-gentests.in disnixos-vm-env.in 
disnixos-deploy-network.in
+EXTRA_DIST = disnix-backdoor-client.in disnixos-geninfra.in 
disnixos-genservices.in disnixos-gentests.in disnixos-env.in disnixos-vm-env.in 
disnixos-deploy-network.in

Added: disnix/disnixos/trunk/scripts/checks
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ disnix/disnixos/trunk/scripts/checks        Wed Jan 19 10:50:52 2011        
(r25623)
@@ -0,0 +1,28 @@
+#!/bin/bash -e
+# Disnix - A distributed application layer for Nix
+# Copyright (C) 2008-2010  Sander van der Burg
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+
+# Checks whether a network expression is given. Exits with status 1 if not set.
+
+checkNetworkFile()
+{
+    if [ "$networkFile" = "" ]
+    then
+       echo "ERROR: A network expression must be specified!" >&2
+       exit 1
+    fi
+}

Added: disnix/disnixos/trunk/scripts/disnixos-env.in
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ disnix/disnixos/trunk/scripts/disnixos-env.in       Wed Jan 19 10:50:52 
2011        (r25623)
@@ -0,0 +1,109 @@
+#!/bin/bash -e
+# Disnix - A distributed application layer for Nix
+# Copyright (C) 2008-2010  Sander van der Burg
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+
+# Shows the usage of this command to the user
+
+showUsage()
+{
+    echo "Usage: $0 -s services.nix -n network.nix -d distribution.nix 
[options]"
+    echo "Options:"
+    echo
+    echo "-s,--services       Services Nix expression which describes all 
components of the distributed system"
+    echo "-n,--network        Network Nix expression which declares a NixOS 
configuration for each machine in the network"
+    echo "-d,--distribution   Distribution Nix expression which maps services 
to machines in the network"
+    echo "--target-property   The target property of an infrastructure model, 
that specifies how to "
+    echo "                    connect to the remote Disnix interface. 
(Defaults to hostname)"
+    echo "--interface         Process that communicates with the remote disnix 
service. Defaults to disnix-ssh-client"
+    echo "-p,--profile        Name of the profile that is used for this 
system. Defaults to: default"
+    echo "--show-trace        Shows a trace of the output"
+    echo "-h,--help           Shows the usage of this command"
+}
+
+# Autoconf settings
+export prefix=@prefix@
+
+# Import checks
+source @datadir@/@PACKAGE@/checks
+
+# Import Disnix checks
+source @DISNIX_PREFIX@/share/disnix/checks
+
+# Parse valid argument options
+
+PARAMS=`getopt -n $0 -o s:n:d:p:h -l 
services:,network:,distribution:,profile:,target-property:,interface:,show-trace,help
 -- "$@"`
+
+if [ $? != 0 ]
+then
+    showUsage
+    exit 1
+fi
+
+eval set -- "$PARAMS"
+
+# Evaluate valid options
+
+while [ "$1" != "--" ]
+do
+    case "$1" in
+        -s|--services)     
+           servicesFile=`readlink -f $2`
+           ;;
+       -n|--network)
+           networkFile=`readlink -f $2`
+           ;;
+       -d|--distribution)
+           distributionFile=`readlink -f $2`
+           ;;
+       -p|--profile)
+           profileArg="--profile $2"
+           ;;
+        --target-property)
+           targetProperty=$2
+           ;;
+       --interface)
+           interface=$2
+           ;;
+       --show-trace)
+           showTrace=1
+           ;;
+       -h|--help)
+           showUsage
+           exit 0
+           ;;
+    esac
+    
+    shift
+done
+
+# Validate the given options
+
+checkServicesFile
+checkNetworkFile
+checkDistributionFile
+checkClientInterface
+checkTargetProperty
+checkShowTrace
+
+# Generate infrastructure model from network model
+infrastructureFile=`disnixos-geninfra network.nix`
+
+# Upgrade the NixOS configurations
+disnixos-deploy-network --target-property $targetProperty --interface 
$interface $profileArg $showTraceArg $networkFile
+
+# Upgrade the services
+disnix-env -s $servicesFile -i $infrastructureFile -d $distributionFile 
--target-property $targetProperty --interface $interface $profileArg 
$showTraceArg

Modified: disnix/disnixos/trunk/scripts/disnixos-gentests.in
==============================================================================
--- disnix/disnixos/trunk/scripts/disnixos-gentests.in  Wed Jan 19 09:06:12 
2011        (r25622)
+++ disnix/disnixos/trunk/scripts/disnixos-gentests.in  Wed Jan 19 10:50:52 
2011        (r25623)
@@ -33,6 +33,9 @@
 export prefix=@prefix@
 
 # Import checks
+source @datadir@/@PACKAGE@/checks
+
+# Import Disnix checks
 source @DISNIX_PREFIX@/share/disnix/checks
 
 # Parse valid argument options
@@ -74,12 +77,7 @@
 
 # Validate options
 
-if [ "$networkFile" = "" ]
-then
-    echo "ERROR: A network expression must be specified!" >&2
-    exit 1
-fi
-
+checkNetworkFile
 checkShowTrace
 checkNoOutLink
 

Modified: disnix/disnixos/trunk/scripts/disnixos-vm-env.in
==============================================================================
--- disnix/disnixos/trunk/scripts/disnixos-vm-env.in    Wed Jan 19 09:06:12 
2011        (r25622)
+++ disnix/disnixos/trunk/scripts/disnixos-vm-env.in    Wed Jan 19 10:50:52 
2011        (r25623)
@@ -30,8 +30,16 @@
     echo "-h,--help           Shows the usage of this command"
 }
 
+# Autoconf settings
+
+export prefix=@prefix@
+
 # Import checks
 
+source @datadir@/@PACKAGE@/checks
+
+# Import Disnix checks
+
 source @DISNIX_PREFIX@/share/disnix/checks
 
 # Parse valid argument options
@@ -78,13 +86,7 @@
 # Validate the given options
 
 checkServicesFile
-
-if [ "$networkFile" = "" ]
-then
-    echo "ERROR: A network expression must be specified!" >&2
-    exit 1
-fi
-
+checkNetworkFile
 checkDistributionFile
 checkShowTrace
 
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to