Author: sandervanderburg
Date: Mon Nov 22 15:35:44 2010
New Revision: 24814
URL: https://svn.nixos.org/websvn/nix/?rev=24814&sc=1

Log:
Added dydisnix-env and dydisnix-self-adapt commands

Added:
   disnix/dydisnix/trunk/scripts/dydisnix-env.in
   disnix/dydisnix/trunk/scripts/dydisnix-self-adapt.in
Modified:
   disnix/dydisnix/trunk/configure.ac
   disnix/dydisnix/trunk/scripts/Makefile.am

Modified: disnix/dydisnix/trunk/configure.ac
==============================================================================
--- disnix/dydisnix/trunk/configure.ac  Mon Nov 22 15:19:23 2010        (r24813)
+++ disnix/dydisnix/trunk/configure.ac  Mon Nov 22 15:35:44 2010        (r24814)
@@ -50,7 +50,9 @@
 # Output
 AC_CONFIG_FILES([
 Makefile
+scripts/dydisnix-env
 scripts/dydisnix-gendist
+scripts/dydisnix-self-adapt
 scripts/Makefile
 src/Makefile
 src/filter-buildable/Makefile

Modified: disnix/dydisnix/trunk/scripts/Makefile.am
==============================================================================
--- disnix/dydisnix/trunk/scripts/Makefile.am   Mon Nov 22 15:19:23 2010        
(r24813)
+++ disnix/dydisnix/trunk/scripts/Makefile.am   Mon Nov 22 15:35:44 2010        
(r24814)
@@ -1,3 +1,3 @@
-bin_SCRIPTS = dydisnix-gendist
+bin_SCRIPTS = dydisnix-gendist dydisnix-env dydisnix-self-adapt
 
-EXTRA_DIST = dydisnix-gendist.in
+EXTRA_DIST = dydisnix-gendist.in dydisnix-env.in dydisnix-self-adapt.in

Added: disnix/dydisnix/trunk/scripts/dydisnix-env.in
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ disnix/dydisnix/trunk/scripts/dydisnix-env.in       Mon Nov 22 15:35:44 
2010        (r24814)
@@ -0,0 +1,94 @@
+#!/bin/bash -e
+
+# Shows the usage of this command to the user
+
+showUsage()
+{
+    echo "Usage: $0 -s services_expr -q qos_expr [-i infrastructure_expr] 
[options]"
+    echo "Options:"
+    echo
+    echo "-s,--services       Services Nix expression which describes all 
components of the distributed system"
+    echo "-q,--qos            Quality of service Nix expression which 
describes how to devide services onto targets based on quality of service 
attributes"
+    echo "-i,--infrastructure Infrastructure Nix expression which captures 
properties of machines in the network"
+    echo "--infragen          Path to the infrastructure generator"
+    echo "-h,--help           Shows the usage of this command"
+}
+
+# Import checks
+
+source @DISNIX_PREFIX@/share/disnix/checks
+
+# Parse valid argument options
+
+PARAMS=`getopt -n $0 -o s:i:q:h -l 
services:,infrastructure:,qos:,infragen:,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`
+           ;;
+       -q|--qos)
+           qosFile=`readlink -f $2`
+           ;;
+       -i|--infrastructure)
+           infrastructureFile=`readlink -f $2`
+           ;;
+       --interval)
+           interval=$2
+           ;;
+       --infragen)
+           infragen=$2
+           ;;
+       -h|--help)
+           showUsage
+           exit 0
+           ;;
+    esac
+    
+    shift
+done
+
+# Validate the given options
+
+checkServicesFile
+
+if [ "$qosFile" = "" ]
+then
+    echo "ERROR: A quality of service model must be specified!" >&2
+    exit 1
+fi
+
+if [ "$infragen" = "" ]
+then
+    if [ "$DYDISNIX_INFRAGEN" = "" ] && [ "$infrastructureFile" = "" ]
+    then
+       echo "ERROR: Either an infrastructure generator or an infrastructure 
expression must be specified!" >&2
+       exit 1
+    else
+       infragen=$DYDISNIX_INFRAGEN
+    fi
+fi
+
+checkTmpDir
+
+# Execute operation
+
+if [ "$infrastructureFile" = "" ]
+then
+    $infragen > $TMPDIR/infrastructure.nix
+    infrastructureFile=$TMPDIR/infrastructure.nix
+fi
+
+distribution=`dydisnix-gendist --services $servicesFile --infrastructure 
$infrastructureFile --qos $qosFile`
+disnix-env --services $servicesFile --infrastructure $infrastructureFile 
--distribution $distribution

Added: disnix/dydisnix/trunk/scripts/dydisnix-self-adapt.in
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ disnix/dydisnix/trunk/scripts/dydisnix-self-adapt.in        Mon Nov 22 
15:35:44 2010        (r24814)
@@ -0,0 +1,101 @@
+#!/bin/bash -e
+
+# Shows the usage of this command to the user
+
+showUsage()
+{
+    echo "Usage: $0 -s services_expr -q qos_expr [options]"
+    echo "Options:"
+    echo
+    echo "-s,--services  Services Nix expression which describes all 
components of the distributed system"
+    echo "-q,--qos       Quality of service Nix expression which describes how 
to devide services onto targets based on quality of service attributes"
+    echo "--interval     Sleep interval (defaults to 1)"
+    echo "--infragen     Path to the infrastructure generator"
+    echo "-h,--help      Shows the usage of this command"
+}
+
+# Import checks
+
+source @DISNIX_PREFIX@/share/disnix/checks
+
+# Parse valid argument options
+
+PARAMS=`getopt -n $0 -o s:q:h -l services:,qos:,interval:,infragen:,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`
+           ;;
+       -q|--qos)
+           qosFile=`readlink -f $2`
+           ;;
+       --interval)
+           interval=$2
+           ;;
+       --infragen)
+           infragen=$2
+           ;;
+       -h|--help)
+           showUsage
+           exit 0
+           ;;
+    esac
+    
+    shift
+done
+
+# Validate the given options
+
+checkServicesFile
+
+if [ "$qosFile" = "" ]
+then
+    echo "ERROR: A quality of service model must be specified!" >&2
+    exit 1
+fi
+
+if [ "$interval" = ""]
+then
+    interval=1
+fi
+
+if [ "$infragen" = "" ]
+then
+    if [ "$DYDISNIX_INFRAGEN" = "" ]
+    then
+       echo "ERROR: An infrastructure generator must be specified!" >&2
+       exit 1
+    else
+       infragen=$DYDISNIX_INFRAGEN
+    fi
+fi
+
+checkTmpDir
+
+# Execute operation
+
+while true
+do
+    $infragen > $TMPDIR/infrastructure.nix
+    
+    if [ ! -f $TMPDIR/previous_infrastructure.nix ] || [ "$(cat 
$TMPDIR/previous_infrastructure.nix | sha256sum -)" != "$(cat 
$TMPDIR/infrastructure.nix | sha256sum -)" ]
+    then
+       distribution=`dydisnix-gendist --services $servicesFile 
--infrastructure $TMPDIR/infrastructure.nix --qos $qosFile`
+       disnix-env --services $servicesFile --infrastructure 
$TMPDIR/infrastructure.nix --distribution $distribution
+       mv $TMPDIR/infrastructure.nix $TMPDIR/previous_infrastructure.nix
+    fi
+        
+    sleep $interval
+done
_______________________________________________
nix-commits mailing list
nix-comm...@cs.uu.nl
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to