From bd19a03f92065211ba3ed7cf23082d4aeacc6e8c Mon Sep 17 00:00:00 2001
From: Alexander Gordeev <agordeev@mirantis.com>
Date: Mon, 14 Apr 2014 15:36:59 +0400
Subject: [PATCH] Add self to validator method

This patchset allows access to extension class instance for more
advanced command validation.

Change-Id: I9d6df1ab44ab06ef2e663ad777ad3560d9ab7565
---
 ironic_python_agent/decorators.py    | 2 +-
 ironic_python_agent/standby.py       | 2 +-
 ironic_python_agent/tests/standby.py | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ironic_python_agent/decorators.py b/ironic_python_agent/decorators.py
index 5f03b6e8e..30f7cf7c6 100644
--- a/ironic_python_agent/decorators.py
+++ b/ironic_python_agent/decorators.py
@@ -28,7 +28,7 @@ def async_command(validator=None):
             # Run a validator before passing everything off to async.
             # validators should raise exceptions or return silently.
             if validator:
-                validator(**command_params)
+                validator(self, **command_params)
 
             # bind self to func so that AsyncCommandResult doesn't need to
             # know about the mode
diff --git a/ironic_python_agent/standby.py b/ironic_python_agent/standby.py
index 584869592..133bcf718 100644
--- a/ironic_python_agent/standby.py
+++ b/ironic_python_agent/standby.py
@@ -133,7 +133,7 @@ def _verify_image(image_info, image_location):
     return False
 
 
-def _validate_image_info(image_info=None, **kwargs):
+def _validate_image_info(ext, image_info=None, **kwargs):
     image_info = image_info or {}
 
     for field in ['id', 'urls', 'hashes']:
diff --git a/ironic_python_agent/tests/standby.py b/ironic_python_agent/tests/standby.py
index 40d72fdd8..b8911ba01 100644
--- a/ironic_python_agent/tests/standby.py
+++ b/ironic_python_agent/tests/standby.py
@@ -45,7 +45,7 @@ class TestStandbyExtension(test_base.BaseTestCase):
         }
 
     def test_validate_image_info_success(self):
-        standby._validate_image_info(self._build_fake_image_info())
+        standby._validate_image_info(None, self._build_fake_image_info())
 
     def test_validate_image_info_missing_field(self):
         for field in ['id', 'urls', 'hashes']: