Repository: cloud-custodian/cloud-custodian

Issue:
Azure VM - We are not getting power state
The VM data we are getting back does not tell you if the VM is running or not.

I think perhaps you have to tell the `list_all` api what you want - we want `instanceview`

https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/instanceview

Not sure how this happens via SDK.


Discussion:

Resolving patch:
diff --git a/tools/c7n_azure/c7n_azure/resources/vm.py b/tools/c7n_azure/c7n_azure/resources/vm.py
--- a/tools/c7n_azure/c7n_azure/resources/vm.py
+++ b/tools/c7n_azure/c7n_azure/resources/vm.py
@@ -31,3 +31,15 @@ class resource_type(object):
             'resourceGroup',
             'properties.hardwareProfile.vmSize',
         )
+
+@VirtualMachine.filter_registry.register('instance-view')
+class InstanceViewFilter(ValueFilter):
+    schema = type_schema('instance-view', rinherit=ValueFilter.schema)
+
+    def __call__(self, i):
+        if 'instanceView' not in i:
+            client = self.manager.get_client()
+            instance = client.virtual_machines.get(i['resourceGroup'], i['name'], expand='instanceview').instance_view
+            i['instanceView'] = instance.serialize()
+
+        return super(InstanceViewFilter, self).__call__(i['instanceView'])


Test patch:
diff --git a/tools/c7n_azure/tests/azure_common.py b/tools/c7n_azure/tests/azure_common.py
--- a/tools/c7n_azure/tests/azure_common.py
+++ b/tools/c7n_azure/tests/azure_common.py
@@ -147,10 +147,11 @@ def write(self, b):
 
 def arm_template(template):
     def decorator(func):
-        def wrapper(*args):
+        def wrapper(*args, **kwargs):
             template_file_path = os.path.dirname(__file__) + "/templates/"+template
             if not os.path.isfile(template_file_path):
                 return args[0].fail("ARM template {} is not found".format(template_file_path))
+            return func(*args, **kwargs)
         return wrapper
     return decorator
 
diff --git a/tools/c7n_azure/tests/cassettes/VMTest.test_find_by_name.yaml b/tools/c7n_azure/tests/cassettes/VMTest.test_find_by_name.yaml
--- a/tools/c7n_azure/tests/cassettes/VMTest.test_find_by_name.yaml
+++ b/tools/c7n_azure/tests/cassettes/VMTest.test_find_by_name.yaml
@@ -6,55 +6,54 @@ interactions:
       Accept-Encoding: ['gzip, deflate']
       Connection: [keep-alive]
       Content-Type: [application/json; charset=utf-8]
-      User-Agent: [python/2.7.10 (Darwin-17.5.0-x86_64-i386-64bit) requests/2.18.4
-          msrest/0.4.27 msrest_azure/0.4.24 computemanagementclient/3.0.1 Azure-SDK-For-Python]
+      User-Agent: [python/2.7.13 (Windows-10-10.0.16299) requests/2.18.4 msrest/0.4.27
+          msrest_azure/0.4.25 computemanagementclient/3.1.0rc3 Azure-SDK-For-Python]
       accept-language: [en-US]
     method: GET
-    uri: https://management.azure.com/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/providers/Microsoft.Compute/virtualMachines?api-version=2017-03-30
+    uri: https://management.azure.com/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/providers/Microsoft.Compute/virtualMachines?api-version=2017-12-01
   response:
     body:
       string: !!binary |
         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
-        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
+        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
+        AAA=
     headers:
       cache-control: [no-cache]
       content-encoding: [gzip]
-      content-length: ['1481']
       content-type: [application/json; charset=utf-8]
-      date: ['Thu, 19 Apr 2018 19:26:55 GMT']
+      date: ['Mon, 30 Apr 2018 18:09:28 GMT']
       expires: ['-1']
       pragma: [no-cache]
+      server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
       strict-transport-security: [max-age=31536000; includeSubDomains]
       vary: [Accept-Encoding]
       x-content-type-options: [nosniff]
-      x-ms-correlation-request-id: [637d0d6c-4818-479e-bd51-e5ee231fea7c]
-      x-ms-original-request-ids: [09c4332a-017b-4df3-b927-876238406286, 3138de2d-c88d-4d36-8101-976c2a346ce5]
+      x-ms-correlation-request-id: [5d80d7d5-bc42-4501-9287-2babd1b4d463]
+      x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/HighCostGet3Min;159,Microsoft.Compute/HighCostGet30Min;799']
       x-ms-ratelimit-remaining-subscription-reads: ['14999']
-      x-ms-request-id: [637d0d6c-4818-479e-bd51-e5ee231fea7c]
-      x-ms-routing-request-id: ['WESTUS2:20180419T192656Z:637d0d6c-4818-479e-bd51-e5ee231fea7c']
+      x-ms-request-id: [6233991b-fb8c-4070-ac0a-e653d127ab56]
+      x-ms-routing-request-id: ['WESTUS2:20180430T180929Z:5d80d7d5-bc42-4501-9287-2babd1b4d463']
+      x-ms-served-by: [5bf72e87-b853-4001-bd50-8d9de6e6ce78_131652014115955634]
     status: {code: 200, message: OK}
 version: 1
diff --git a/tools/c7n_azure/tests/cassettes/VMTest.test_find_running.yaml b/tools/c7n_azure/tests/cassettes/VMTest.test_find_running.yaml
new file mode 100644
--- /dev/null
+++ b/tools/c7n_azure/tests/cassettes/VMTest.test_find_running.yaml
@@ -0,0 +1,118 @@
+interactions:
+- request:
+    body: null
+    headers:
+      Accept: [application/json]
+      Accept-Encoding: ['gzip, deflate']
+      Connection: [keep-alive]
+      Content-Type: [application/json; charset=utf-8]
+      User-Agent: [python/2.7.13 (Windows-10-10.0.16299) requests/2.18.4 msrest/0.4.27
+          msrest_azure/0.4.25 computemanagementclient/3.1.0rc3 Azure-SDK-For-Python]
+      accept-language: [en-US]
+    method: GET
+    uri: https://management.azure.com/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/providers/Microsoft.Compute/virtualMachines?api-version=2017-12-01
+  response:
+    body:
+      string: !!binary |
+        H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcpl
+        VmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/In7xb5yk
+        6UeXWbnOP3qUfg9/pSl/iOejVV2t8rot8oa+tR/TF5eLsxl99NHswTSfPbx3b/vhwYPZ9v50d3/7
+        4acH2fbk4e5kcj97uDvL849G3ovzrJ5dZXX+sq7OixKdemDp+8vF6+IH+Pij1222nFHr3//JbvOR
+        a/NLfGhNW9XZxSCwYkFfvsrP8zpfTntfU4PVelIWzTyv6buPTrJltSymWekjjOej6pxAoMlXk/Wy
+        Xb/O60v6u9uqebtGm91Pxzv728/fvO41oJeaolqiUZm1edN6wwoHRo2r5mnRvKW2XZyr5s31CoP5
+        6HmxXL/r9bLMFvxttvxBVVbT+TZ62r5c/P5fMsTff/f3z+/v5Pdmu5MHk/PJ/sHBvcn9vQef5vm9
+        e/nuzuz+/sMeyGmdE75frlrF/lldLc5A237LbDovlhdo9CrPZt+ti7bfaJEt6d0ZsKGGnfHR9zqr
+        x9NpReQ2o31Z54tivfj9n7/qUZbeKZgd7zbrSTOtC8a0uZtlDw8ePtifbN+f7WXb+7OHB9vZA+LO
+        ewd75/ce7N6f7TzI79Z5U63raf55Xa1Xzd3jFz/15fMvT769/eb09Zvtn/ziLsnAZTGjqbv7RTGt
+        q6Y6b8cn1WK1bvO7MxoCdfP1KR2OI2QBGhXgQx4+f0Kju7fjfxu2/WiWtRk6haB+7/vuK78Zsc6Q
+        pExlQPWLAeYJKf5RNlsUy6+avDbMNimzeadNCe48qZbnxcW6zjAh1DDolRrRALNJmb/MmuaqqmfH
+        63aeL1sSQm1/npVN7r/jj4feb3LizXbjoJd5S6DfeiM3H50tacTn2RTa7Xu/mFnom+CgLu2iHPRC
+        ULjbQ6X3+u793Y9+yfeDIc2K7GJZNUSnwQmdVFX71DXrfk8t8iUoT2NO23qde+DxGBn8qi6owUfz
+        tl01j+5a3IDa5QJoPLy/O56U1WQ8rep8fFUsZ9VVM6ZR3Q14+5e4P4KRMGmgFElpkMInZUG9vV5P
+        p3k+I9xMS/fOR62qA0dKI4yXRd2us/ILVkE0p+4dQtkw1Ec0Ve18SkxWZ+Xab4Tp/+FrkA7SlsJm
+        9j0Ejaz1mkgLQyM7zyDuZuv9cP/e7oN7s0+379/PD8h6P5xtT+5PP90+z/b27n96//69g+m5Q4Be
+        vL31fpI1xfT3P95R5PAYBPEY/hoC9HNnucc7/y+w3dMpuvAtycHuPZqNfPbpvfNs/+D+/clBdv/8
+        Xr43ycim7N6b9kCRXiQ8v2Q+BsifE5tNIi0+3M+y0Qa1fv8BTWskjUwN2eqvQdkQ7XCqaRCAC65/
+        Txvtf+MJrXk+KteYtp0AAp4+jwCBvd8/e7jz8EE+m55nn366f36+fzA9yA/ofw9mD/Z2du71ZpQg
+        dVnkdLFqr2PtHIO8qJYxSDdwB7X4OvxBr/1ccgj+vAVdu1iHk44nZJHdnb17YQvPOKbpkBtze9/t
+        crF/f/GLphfZg9Xb5qoI6dp33TDaNf3daffz1n0DPYY4ZdhrW1z/5Bcviun/azy1gAWajGfzcvH/
+        E1etzS46dGIupo/pU/5VMhrmew8ncMk3olDg3P3+7+ncGdXiDcVIof1KvuFJIJH4Jf8PY8Oo+qER
+        AAA=
+    headers:
+      cache-control: [no-cache]
+      content-encoding: [gzip]
+      content-type: [application/json; charset=utf-8]
+      date: ['Mon, 30 Apr 2018 18:11:31 GMT']
+      expires: ['-1']
+      pragma: [no-cache]
+      server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
+      strict-transport-security: [max-age=31536000; includeSubDomains]
+      vary: [Accept-Encoding]
+      x-content-type-options: [nosniff]
+      x-ms-correlation-request-id: [8292f732-bf27-4ee9-937c-4a8e5eb61c4c]
+      x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/HighCostGet3Min;157,Microsoft.Compute/HighCostGet30Min;797']
+      x-ms-ratelimit-remaining-subscription-reads: ['14998']
+      x-ms-request-id: [183e6159-3b3f-4057-9061-b27a90fc42bd]
+      x-ms-routing-request-id: ['WESTUS2:20180430T181132Z:8292f732-bf27-4ee9-937c-4a8e5eb61c4c']
+      x-ms-served-by: [5bf72e87-b853-4001-bd50-8d9de6e6ce78_131652014115955634]
+    status: {code: 200, message: OK}
+- request:
+    body: null
+    headers:
+      Accept: [application/json]
+      Accept-Encoding: ['gzip, deflate']
+      Connection: [keep-alive]
+      Content-Type: [application/json; charset=utf-8]
+      User-Agent: [python/2.7.13 (Windows-10-10.0.16299) requests/2.18.4 msrest/0.4.27
+          msrest_azure/0.4.25 computemanagementclient/3.1.0rc3 Azure-SDK-For-Python]
+      accept-language: [en-US]
+    method: GET
+    uri: https://management.azure.com/subscriptions/ea42f556-5106-4743-99b0-c129bfa71a47/resourceGroups/TEST_VM/providers/Microsoft.Compute/virtualMachines/cctestvm?api-version=2017-12-01&$expand=instanceView
+  response:
+    body:
+      string: !!binary |
+        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
+    headers:
+      cache-control: [no-cache]
+      content-encoding: [gzip]
+      content-type: [application/json; charset=utf-8]
+      date: ['Mon, 30 Apr 2018 18:11:32 GMT']
+      expires: ['-1']
+      pragma: [no-cache]
+      server: [Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0]
+      strict-transport-security: [max-age=31536000; includeSubDomains]
+      vary: [Accept-Encoding]
+      x-content-type-options: [nosniff]
+      x-ms-correlation-request-id: [bca78b37-9f82-4c4c-a299-c6725f63572c]
+      x-ms-ratelimit-remaining-resource: ['Microsoft.Compute/LowCostGet3Min;4198,Microsoft.Compute/LowCostGet30Min;33585']
+      x-ms-ratelimit-remaining-subscription-reads: ['14999']
+      x-ms-request-id: [0da0cb3e-1c9e-4d03-a56d-4ca590f3ab17]
+      x-ms-routing-request-id: ['WESTUS2:20180430T181133Z:bca78b37-9f82-4c4c-a299-c6725f63572c']
+      x-ms-served-by: [5bf72e87-b853-4001-bd50-8d9de6e6ce78_131652014115955634]
+    status: {code: 200, message: OK}
+version: 1
diff --git a/tools/c7n_azure/tests/test_vm.py b/tools/c7n_azure/tests/test_vm.py
--- a/tools/c7n_azure/tests/test_vm.py
+++ b/tools/c7n_azure/tests/test_vm.py
@@ -34,3 +34,24 @@ def test_find_by_name(self):
         resources = p.run()
         self.assertEqual(len(resources), 1)
 
+    @arm_template('vm.json')
+    def test_find_running(self):
+        p = self.load_policy({
+            'name': 'test-azure-vm',
+            'resource': 'azure.vm',
+            'filters': [
+                {'type': 'value',
+                 'key': 'name',
+                 'op': 'eq',
+                 'value_type': 'normalize',
+                 'value': 'cctestvm'},
+                {'type': 'instance-view',
+                 'key': 'statuses[].code',
+                 'op': 'in',
+                 'value_type': 'swap',
+                 'value': 'PowerState/running'}],
+        })
+        resources = p.run()
+        self.assertEqual(len(resources), 1)
+
+