Simplify 'grep | awk' constructs
authorJulien Cristau <julien.cristau@logilab.fr>
Fri, 06 Sep 2013 15:16:40 +0200
changeset 198 b3c538ac138d
parent 197 f84de149155d
child 199 1aad8eabec83
Simplify 'grep | awk' constructs
_modules/aws_client.py
--- a/_modules/aws_client.py	Fri Sep 06 14:34:17 2013 +0200
+++ b/_modules/aws_client.py	Fri Sep 06 15:16:40 2013 +0200
@@ -62,8 +62,8 @@
         - register image using snapshot and specified aki
         - delete volume
     '''
-    availability_zone = __salt__['cmd.run']("ec2metadata|grep availability-zone|awk '{print $2}'")
-    instance_id = __salt__['cmd.run']("ec2metadata|grep instance-id|awk '{print $2}'")
+    availability_zone = __salt__['cmd.run']("ec2metadata | awk '/availability-zone/ {print $2}'")
+    instance_id = __salt__['cmd.run']("ec2metadata | awk '/instance-id/ {print $2}'")
     size = int(ceil(os.path.getsize(filename)/(1024.**3)))
     volume_id = create_ec2_volume(size, availability_zone, region, cert_path, pk_path)
     log.info(__salt__['cmd.run']("ec2-attach-volume " + volume_id + " --instance " +