Fix for maas.machines.storage state

- Skip machines which are marked deployed.
  This increases ensure step for huge environments

Prod-Related: PROD-34791
Change-Id: Iaf0f3b3151c7ed3e5c2bc6c5e3ded2ad9aec2c51
diff --git a/maas/machines/storage.sls b/maas/machines/storage.sls
index e658f06..d632c90 100644
--- a/maas/machines/storage.sls
+++ b/maas/machines/storage.sls
@@ -5,9 +5,17 @@
   cmd.run:
   - name: "maas-region apikey --username {{ region.admin.username }} > /var/lib/maas/.maas_credentials"
 
+{%- set maas_undeployed_machines = [] %}
+{%- for maas_machine_name, maas_machine in salt['maasng.list_machines']().iteritems() %}
+{%- if maas_machine['status_name'] not in ['Deployed'] %}
+{%- do maas_undeployed_machines.append(maas_machine_name) %}
+{%- endif %}
+{%- endfor %}
 
 {%- for machine_name, machine in region.machines.iteritems() %}
 
+{%- if machine_name in maas_undeployed_machines %}
+
 {%- if machine.disk_layout is defined %}
 
 {%- if machine.disk_layout.type is defined %}
@@ -147,5 +155,6 @@
 
 {%- endif %}
 
-{%- endfor %}
+{%- endif %}
 
+{%- endfor %}