Branch: refs/heads/master
  Home:   https://github.com/NixOS/charon
  Commit: ae0c654b115e8a40a2ff980484b2bb6728a73219
      
https://github.com/NixOS/charon/commit/ae0c654b115e8a40a2ff980484b2bb6728a73219
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-18 (Wed, 18 Apr 2012)

  Changed paths:
    M nix/options.nix

  Log Message:
  -----------
  Fix EC2 evaluation error due to missing fileSystems option

The underlying problem is that amazon-image.nix isn't included
during the first stage evaluation.


diff --git a/nix/options.nix b/nix/options.nix
index c707eab..d03c845 100644
--- a/nix/options.nix
+++ b/nix/options.nix
@@ -41,6 +41,7 @@ let
   };
 
   isEc2Hvm = (cfg.ec2.instanceType == "cc1.4xlarge" || cfg.ec2.instanceType == 
"cc2.8xlarge");
+  
 in
 
 {
@@ -296,6 +297,9 @@ in
   
     boot.loader.grub.extraPerEntryConfig = mkIf isEc2Hvm "root (hd0)";
 
+    # Workaround: the evaluation of blockDeviceMapping requires fileSystems to 
be defined.
+    fileSystems = [];
+
     deployment.ec2 = mkIf (cfg.ec2.region != "") {
     
       controller = mkDefault "https://ec2.${cfg.ec2.region}.amazonaws.com/";;


================================================================
  Commit: 24b4de55bdf17d14e7a7e0684864e38339fb4cdc
      
https://github.com/NixOS/charon/commit/24b4de55bdf17d14e7a7e0684864e38339fb4cdc
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-18 (Wed, 18 Apr 2012)

  Changed paths:
    M charon/backends/ec2.py

  Log Message:
  -----------
  Make sure that an AMI is defined


diff --git a/charon/backends/ec2.py b/charon/backends/ec2.py
index 66b8957..698c053 100644
--- a/charon/backends/ec2.py
+++ b/charon/backends/ec2.py
@@ -27,6 +27,7 @@ def __init__(self, xml):
         self.region = x.find("attr[@name='region']/string").get("value")
         self.controller = 
x.find("attr[@name='controller']/string").get("value")
         self.ami = x.find("attr[@name='ami']/string").get("value")
+        if self.ami == "": raise Exception("no AMI defined for EC2 machine 
‘{0}’".format(self.name))
         self.instance_type = 
x.find("attr[@name='instanceType']/string").get("value")
         self.key_pair = x.find("attr[@name='keyPair']/string").get("value")
         self.security_groups = [e.get("value") for e in 
x.findall("attr[@name='securityGroups']/list/string")]


================================================================
  Commit: c70c624fed20158390fa6e0a5c3496ad5c83d991
      
https://github.com/NixOS/charon/commit/c70c624fed20158390fa6e0a5c3496ad5c83d991
  Author: Eelco Dolstra <[email protected]>
  Date:   2012-04-18 (Wed, 18 Apr 2012)

  Changed paths:
    M charon/backends/ec2.py
    M nix/options.nix

  Log Message:
  -----------
  Add a deleteOnTermination option

Fixes #13.


diff --git a/charon/backends/ec2.py b/charon/backends/ec2.py
index 698c053..bfaed0c 100644
--- a/charon/backends/ec2.py
+++ b/charon/backends/ec2.py
@@ -35,7 +35,8 @@ def __init__(self, xml):
         def f(xml):
             return {'disk': 
xml.find("attrs/attr[@name='disk']/string").get("value"),
                     'size': 
int(xml.find("attrs/attr[@name='size']/int").get("value")),
-                    'fsType': 
xml.find("attrs/attr[@name='fsType']/string").get("value")}
+                    'fsType': 
xml.find("attrs/attr[@name='fsType']/string").get("value"),
+                    'deleteOnTermination': 
xml.find("attrs/attr[@name='deleteOnTermination']/bool").get("value") == "true"}
         self.block_device_mapping = {_xvd_to_sd(k.get("name")): f(k) for k in 
x.findall("attr[@name='blockDeviceMapping']/attrs/attr")}
 
     def make_state():
@@ -275,7 +276,8 @@ def create(self, defn, check):
                     raise Exception("non-ephemeral disk not allowed on device 
‘{0}’; use /dev/xvdf or higher".format(_sd_to_xvd(k)))
                 if v['disk'] == '':
                     if ami.root_device_type == "ebs":
-                        devmap[k] = 
boto.ec2.blockdevicemapping.BlockDeviceType(size=v['size'], 
delete_on_termination=True)
+                        devmap[k] = 
boto.ec2.blockdevicemapping.BlockDeviceType(
+                            size=v['size'], 
delete_on_termination=v['deleteOnTermination'])
                         v['needsInit'] = True
                         self._block_device_mapping[k] = v
                     # Otherwise, it's instance store backed, and we'll create 
the volume later.
@@ -367,7 +369,11 @@ def create(self, defn, check):
                 self.connect()
                 volume = self._conn.create_volume(size=v['size'], 
zone=self._zone)
                 v['needsInit'] = True
-                v['deleteOnTermination'] = True
+                # The flag charonDeleteOnTermination denotes that on
+                # instance termination, we have to delete the volume
+                # ourselves.  For volumes created at instance creation
+                # time, EC2 will do it for us.
+                v['charonDeleteOnTermination'] = v['deleteOnTermination']
                 v['needsAttach'] = True
                 v['volumeId'] = volume.id
                 self._block_device_mapping[k] = v
@@ -404,6 +410,8 @@ def check_dev():
                 charon.util.check_wait(check_dev)
                 del v['needsAttach']
                 self.write()
+
+        # FIXME: process changes to the deleteOnTermination flag.
                 
         # Detach volumes that are no longer in the deployment spec.
         for k, v in self._block_device_mapping.items():
@@ -418,7 +426,7 @@ def check_dev():
                         raise Exception("unable to detach device ‘{0}’ from 
EC2 machine ‘{1}’".format(v['disk'], self.name))
                     # FIXME: Wait until the volume is actually detached.
                     
-                if v.get('deleteOnTermination', False):
+                if v.get('charonDeleteOnTermination', False):
                     self._delete_volume(v['volumeId'])
                 
                 del self._block_device_mapping[k]
@@ -478,7 +486,7 @@ def destroy(self):
 
         # Destroy volumes created for this instance.
         for k, v in self._block_device_mapping.items():
-            if v.get('deleteOnTermination', False):
+            if v.get('charonDeleteOnTermination', False):
                 self._delete_volume(v['volumeId'])
 
 
diff --git a/nix/options.nix b/nix/options.nix
index d03c845..57caf67 100644
--- a/nix/options.nix
+++ b/nix/options.nix
@@ -6,36 +6,52 @@ let
 
   cfg = config.deployment;
 
-  ec2DiskOptions = {
+  ec2DiskOptions = { config, ... }: {
+  
+    options = {
       
-    disk = mkOption {
-      default = "";
-      example = "vol-d04895b8";
-      type = types.uniq types.string;
-      description = ''
-        EC2 identifier of the disk to be mounted.  This can be an
-        ephemeral disk (e.g. <literal>ephemeral0</literal>), a
-        snapshot ID (e.g. <literal>snap-1cbda474</literal>) or a
-        volume ID (e.g. <literal>vol-d04895b8</literal>).  Leave
-        empty to create an EBS volume automatically.
-      '';
-    };
+      disk = mkOption {
+        default = "";
+        example = "vol-d04895b8";
+        type = types.uniq types.string;
+        description = ''
+          EC2 identifier of the disk to be mounted.  This can be an
+          ephemeral disk (e.g. <literal>ephemeral0</literal>), a
+          snapshot ID (e.g. <literal>snap-1cbda474</literal>) or a
+          volume ID (e.g. <literal>vol-d04895b8</literal>).  Leave
+          empty to create an EBS volume automatically.
+        '';
+      };
+
+      size = mkOption {
+        default = 0;
+        type = types.uniq types.int;
+        description = ''
+          Filesystem size (in gigabytes) for automatically created
+          EBS volumes.
+        '';
+      };
+
+      fsType = mkOption {
+        default = "ext4";
+        type = types.uniq types.string;
+        description = ''
+          Filesystem type for automatically created EBS volumes.
+        '';
+      };
+
+      deleteOnTermination = mkOption {
+        type = types.bool;
+        description = ''
+          For automatically created EBS volumes, determines whether the
+          volume should be deleted on instance termination.
+        '';
+      };
 
-    size = mkOption {
-      default = 0;
-      type = types.uniq types.int;
-      description = ''
-        Filesystem size (in gigabytes) for automatically created
-        EBS volumes.
-      '';
     };
 
-    fsType = mkOption {
-      default = "ext4";
-      type = types.uniq types.string;
-      description = ''
-        Filesystem type for automatically created EBS volumes.
-      '';
+    config = {
+      deleteOnTermination = mkDefault (config.disk == "");
     };
 
   };


================================================================
Compare: https://github.com/NixOS/charon/compare/5170272...c70c624
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits

Reply via email to