Author: eelco
Date: Tue Jun 21 17:14:30 2011
New Revision: 27514
URL: https://svn.nixos.org/websvn/nix/?rev=27514&sc=1

Log:
* Handle Nova instance termination (the result seems to be slightly
  different from EC2).

Modified:
   cloud/trunk/src/nixos-deploy-network.pl

Modified: cloud/trunk/src/nixos-deploy-network.pl
==============================================================================
--- cloud/trunk/src/nixos-deploy-network.pl     Tue Jun 21 16:46:18 2011        
(r27513)
+++ cloud/trunk/src/nixos-deploy-network.pl     Tue Jun 21 17:14:30 2011        
(r27514)
@@ -284,8 +284,14 @@
         print STDERR "killing VM ‘$name’ (EC2 instance 
‘$machine->{vmId}’)...\n";
         my $ec2 = openEC2($name, $machine);
         my $res = $ec2->terminate_instances(InstanceId => $machine->{vmId});
-        die "could not terminate EC2 instance: “" . 
@{$res->errors}[0]->message . "”\n"
-            unless ref $res eq "ARRAY";
+        unless (!defined $res || ref $res eq "ARRAY") {
+            my $error = @{$res->errors}[0];
+            if ($error->code eq "InstanceNotFound") {
+                warn "EC2 instance “$machine->{vmId}” no longer exists, 
removing\n";
+            } else {
+                die "could not terminate EC2 instance: “" . $error->message . 
"”\n";
+            }
+        }
         # !!! Check the state change? Wait until the machine has shut down?
     }
 
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to