Author: sandervanderburg
Date: Mon Aug  2 17:32:26 2010
New Revision: 22899
URL: https://svn.nixos.org/websvn/nix/?rev=22899&sc=1

Log:
Implemented --coordinator-profile-path option, so that the virtualization 
extension cannot mess up the user profile

Modified:
   disnix/disnix/trunk/man/disnix-activate.8
   disnix/disnix/trunk/man/disnix-env.8
   disnix/disnix/trunk/scripts/disnix-env
   disnix/disnix/trunk/src/activate/main.c

Modified: disnix/disnix/trunk/man/disnix-activate.8
==============================================================================
--- disnix/disnix/trunk/man/disnix-activate.8   Mon Aug  2 17:20:40 2010        
(r22898)
+++ disnix/disnix/trunk/man/disnix-activate.8   Mon Aug  2 17:32:26 2010        
(r22899)
@@ -37,6 +37,12 @@
 stored in the disnix-coordinator profile instead of the specified one, which 
is usually sufficient
 in most cases.
 .TP
+\fB\-\-coordinator\-profile\-path\fR
+Nix profile path where the manifest should be stored, so that Disnix knows the 
current configuration
+of a distributed system. By default it is stored in the profile directory of 
the user.
+Most users do not want to use this option directly, but it is used by e.g. the 
virtualization
+extension to store virtual machine profile in a separate directory.
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Shows the usage of this command to the user
 .SH ENVIRONMENT VARIABLES

Modified: disnix/disnix/trunk/man/disnix-env.8
==============================================================================
--- disnix/disnix/trunk/man/disnix-env.8        Mon Aug  2 17:20:40 2010        
(r22898)
+++ disnix/disnix/trunk/man/disnix-env.8        Mon Aug  2 17:32:26 2010        
(r22899)
@@ -53,6 +53,12 @@
 \fB\-\-build\-on\-targets\fR
 Build the services on the target machines in the network instead of managing 
the build by the coordinator.
 .TP
+\fB\-\-coordinator\-profile\-path\fR
+Nix profile path where the manifest should be stored, so that Disnix knows the 
current configuration
+of a distributed system. By default it is stored in the profile directory of 
the user.
+Most users do not want to use this option directly, but it is used by e.g. the 
virtualization
+extension to store virtual machine profile in a separate directory.
+.TP
 \fB\-\-show-trace\fR
 Shows a trace of the output.
 .TP

Modified: disnix/disnix/trunk/scripts/disnix-env
==============================================================================
--- disnix/disnix/trunk/scripts/disnix-env      Mon Aug  2 17:20:40 2010        
(r22898)
+++ disnix/disnix/trunk/scripts/disnix-env      Mon Aug  2 17:32:26 2010        
(r22899)
@@ -23,21 +23,22 @@
     echo "Usage: $0 -s services_expr -i infrastructure_expr -d 
distribution_expr [options]"
     echo "Options:"
     echo
-    echo "-s,--services       Services Nix expression which describes all 
components of the distributed system"
-    echo "-i,--infrastructure Infrastructure Nix expression which captures 
properties of machines 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-client"
-    echo "-p,--profile        Name of the profile that is used for this 
system. Defaults to: default"
-    echo "--build-on-targets  Build the services on the target machines in the 
network instead of managing the build by the coordinator"
-    echo "--show-trace        Shows a trace of the output"
-    echo "-h,--help           Shows the usage of this command"
+    echo "-s,--services               Services Nix expression which describes 
all components of the distributed system"
+    echo "-i,--infrastructure         Infrastructure Nix expression which 
captures properties of machines 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-client"
+    echo "-p,--profile                Name of the profile that is used for 
this system. Defaults to: default"
+    echo "--build-on-targets          Build the services on the target 
machines in the network instead of managing the build by the coordinator"
+    echo "--coordinator-profile-path  Path where to store the coordinator 
profile generations"
+    echo "--show-trace                Shows a trace of the output"
+    echo "-h,--help                   Shows the usage of this command"
 }
 
 # Parse valid argument options
 
-PARAMS=`getopt -n $0 -o s:i:d:p:h -l 
services:,infrastructure:,distribution:,interface:,target-property:,profile:,build-on-targets,show-trace,help
 -- "$@"`
+PARAMS=`getopt -n $0 -o s:i:d:p:h -l 
services:,infrastructure:,distribution:,interface:,target-property:,profile:,build-on-targets,coordinator-profile-path:,show-trace,help
 -- "$@"`
 
 if [ $? != 0 ]
 then
@@ -73,6 +74,9 @@
        -p|--profile)
            profileArg="--profile $2"
            ;;
+       --coordinator-profile-path)
+           coordinatorProfilePathArg="--coordinator-profile-path $2"
+           ;;
        --target-property)
            targetProperty=$2
            ;;
@@ -138,4 +142,4 @@
 
 distributionExport=`disnix-manifest -s $servicesFile -i $infrastructureFile -d 
$distributionFile $targetPropertyArg $showTraceArg`
 disnix-distribute --interface $interface $distributionExport
-disnix-activate --interface $interface $profileArg $distributionExport
+disnix-activate --interface $interface $profileArg $coordinatorProfilePathArg 
$distributionExport

Modified: disnix/disnix/trunk/src/activate/main.c
==============================================================================
--- disnix/disnix/trunk/src/activate/main.c     Mon Aug  2 17:20:40 2010        
(r22898)
+++ disnix/disnix/trunk/src/activate/main.c     Mon Aug  2 17:32:26 2010        
(r22899)
@@ -33,7 +33,7 @@
 static void print_usage()
 {
     fprintf(stderr, "Usage:\n");
-    fprintf(stderr, "disnix-activate [--interface interface] [{-p|--profile} 
profile] [{-o|--old-manifest} manifest] manifest\n");
+    fprintf(stderr, "disnix-activate [--interface interface] [{-p|--profile} 
profile] [--coordinator-profile-path path] [{-o|--old-manifest} manifest] 
manifest\n");
     fprintf(stderr, "disnix-activate {-h | --help}\n");
 }
 
@@ -343,14 +343,18 @@
     return TRUE;
 }
 
-static int set_coordinator_profile(char *distribution_manifest, char *profile, 
char *username)
+static int set_coordinator_profile(char *coordinator_profile_path, char 
*distribution_manifest, char *profile, char *username)
 {
     gchar *profile_path, *distribution_manifest_path;
     int status;
            
     printf("Setting the coordinator profile:\n");
-           
-    profile_path = g_strconcat(LOCALSTATEDIR, "/nix/profiles/per-user/", 
username, "/disnix-coordinator", NULL);
+
+    if(coordinator_profile_path == NULL)
+       profile_path = g_strconcat(LOCALSTATEDIR, "/nix/profiles/per-user/", 
username, "/disnix-coordinator", NULL);
+    else
+       profile_path = g_strdup(coordinator_profile_path);
+    
     mkdir(profile_path, 0755);
     g_free(profile_path);
     
@@ -360,7 +364,10 @@
     else
        distribution_manifest_path = g_strconcat("./", NULL);
     
-    profile_path = g_strconcat(LOCALSTATEDIR "/nix/profiles/per-user/", 
username, "/disnix-coordinator/", profile, NULL);
+    if(coordinator_profile_path == NULL)
+       profile_path = g_strconcat(LOCALSTATEDIR "/nix/profiles/per-user/", 
username, "/disnix-coordinator/", profile, NULL);
+    else
+       profile_path = g_strconcat(coordinator_profile_path, "/", profile, 
NULL);
     
     status = fork();
     
@@ -493,6 +500,7 @@
     {
        {"interface", required_argument, 0, 'i'},
        {"old-manifest", required_argument, 0, 'o'},
+       {"coordinator-profile-path", required_argument, 0, 'P'},
        {"profile", required_argument, 0, 'p'},
        {"help", no_argument, 0, 'h'},
        {0, 0, 0, 0}
@@ -500,6 +508,7 @@
     char *interface = NULL;
     char *old_manifest = NULL;
     char *profile = "default";
+    char *coordinator_profile_path = NULL;
     
     /* Parse command-line options */
     while((c = getopt_long(argc, argv, "o:p:h", long_options, &option_index)) 
!= -1)
@@ -515,6 +524,9 @@
            case 'p':
                profile = optarg;
                break;
+           case 'P':
+               coordinator_profile_path = optarg;
+               break;
            case 'h':
                print_usage();
                return 0;
@@ -551,8 +563,13 @@
         {
            FILE *file;
            
-           /* If no old manifest file is given, try to to open the manifest 
file in the Nix profile */     
-           old_manifest_file = g_strconcat(LOCALSTATEDIR 
"/nix/profiles/per-user/", username, "/disnix-coordinator/", profile, NULL);    
  
+           /* If no old manifest file is given, try to to open the manifest 
file in the Nix profile */
+           
+           if(coordinator_profile_path == NULL)
+               old_manifest_file = g_strconcat(LOCALSTATEDIR 
"/nix/profiles/per-user/", username, "/disnix-coordinator/", profile, NULL);    
      
+           else
+               old_manifest_file = g_strconcat(coordinator_profile_path, "/", 
profile, NULL);
+           
            file = fopen(old_manifest_file, "r");
            
            if(file == NULL)
@@ -610,7 +627,7 @@
        }
        
        /* Store the activated manifest in the profile of the current user */
-       if(!set_coordinator_profile(argv[optind], profile, username))
+       if(!set_coordinator_profile(coordinator_profile_path, argv[optind], 
profile, username))
        {
            delete_distribution_array(distribution_array);
            return 1;
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to